mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-31 00:30:57 +00:00
Interpret func fields as selectors for entities with objects.
This commit is contained in:
parent
8e18c76bde
commit
2bacfdabf2
3 changed files with 48 additions and 8 deletions
|
@ -32,10 +32,13 @@
|
||||||
#ifndef __QF_ruamoko_h
|
#ifndef __QF_ruamoko_h
|
||||||
#define __QF_ruamoko_h
|
#define __QF_ruamoko_h
|
||||||
|
|
||||||
|
#include "QF/pr_comp.h"
|
||||||
|
|
||||||
struct progs_s;
|
struct progs_s;
|
||||||
struct cbuf_s;
|
struct cbuf_s;
|
||||||
|
|
||||||
void RUA_Init (struct progs_s *pr, int secure);
|
void RUA_Init (struct progs_s *pr, int secure);
|
||||||
void RUA_Cbuf_SetCbuf (struct progs_s *pr, struct cbuf_s *cbuf);
|
void RUA_Cbuf_SetCbuf (struct progs_s *pr, struct cbuf_s *cbuf);
|
||||||
|
func_t RUA_Obj_msg_lookup (struct progs_s *pr, pointer_t _self, pointer_t __cmd);
|
||||||
|
|
||||||
#endif//__QF_ruamoko_h
|
#endif//__QF_ruamoko_h
|
||||||
|
|
|
@ -50,6 +50,7 @@ static __attribute__ ((used)) const char rcsid[] =
|
||||||
#include "QF/hash.h"
|
#include "QF/hash.h"
|
||||||
#include "QF/pr_obj.h"
|
#include "QF/pr_obj.h"
|
||||||
#include "QF/progs.h"
|
#include "QF/progs.h"
|
||||||
|
#include "QF/ruamoko.h"
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
@ -1650,3 +1651,23 @@ RUA_Obj_Init (progs_t *pr, int secure)
|
||||||
|
|
||||||
PR_AddLoadFunc (pr, rua_init_runtime);
|
PR_AddLoadFunc (pr, rua_init_runtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func_t
|
||||||
|
RUA_Obj_msg_lookup (progs_t *pr, pointer_t _self, pointer_t __cmd)
|
||||||
|
{
|
||||||
|
pr_id_t *self = &G_STRUCT (pr, pr_id_t, _self);
|
||||||
|
pr_sel_t *_cmd = &G_STRUCT (pr, pr_sel_t, __cmd);
|
||||||
|
func_t imp;
|
||||||
|
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
if (!_cmd)
|
||||||
|
PR_RunError (pr, "null selector");
|
||||||
|
imp = obj_msg_lookup (pr, self, _cmd);
|
||||||
|
if (!imp)
|
||||||
|
PR_RunError (pr, "%s does not respond to %s",
|
||||||
|
PR_GetString (pr, object_get_class_name (pr, self)),
|
||||||
|
PR_GetString (pr, pr->selector_names[_cmd->sel_id]));
|
||||||
|
|
||||||
|
return imp;
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include "QF/link.h"
|
#include "QF/link.h"
|
||||||
#include "QF/progs.h"
|
#include "QF/progs.h"
|
||||||
|
#include "QF/ruamoko.h"
|
||||||
|
|
||||||
#include "qw/protocol.h"
|
#include "qw/protocol.h"
|
||||||
#include "sv_pr_cmds.h"
|
#include "sv_pr_cmds.h"
|
||||||
|
@ -216,16 +217,21 @@ static inline void
|
||||||
sv_pr_touch (edict_t *self, edict_t *other)
|
sv_pr_touch (edict_t *self, edict_t *other)
|
||||||
{
|
{
|
||||||
pr_int_t this;
|
pr_int_t this;
|
||||||
|
func_t touch;
|
||||||
|
|
||||||
|
touch = SVfunc (self, touch);
|
||||||
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
|
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
|
||||||
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, other);
|
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, other);
|
||||||
if ((this = sv_pr_state.fields.this) != -1) {
|
if ((this = sv_pr_state.fields.this) != -1
|
||||||
|
&& E_POINTER (self, this)) {
|
||||||
PR_RESET_PARAMS (&sv_pr_state);
|
PR_RESET_PARAMS (&sv_pr_state);
|
||||||
P_INT (&sv_pr_state, 0) = E_POINTER (self, this);
|
P_INT (&sv_pr_state, 0) = E_POINTER (self, this);
|
||||||
P_INT (&sv_pr_state, 1) = 0;
|
P_INT (&sv_pr_state, 1) = touch;
|
||||||
P_INT (&sv_pr_state, 2) = E_POINTER (other, this);
|
P_INT (&sv_pr_state, 2) = E_POINTER (other, this);
|
||||||
|
touch = RUA_Obj_msg_lookup (&sv_pr_state, E_POINTER (self, this),
|
||||||
|
touch);
|
||||||
}
|
}
|
||||||
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, touch));
|
PR_ExecuteProgram (&sv_pr_state, touch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -237,30 +243,40 @@ static inline void
|
||||||
sv_pr_think (edict_t *self)
|
sv_pr_think (edict_t *self)
|
||||||
{
|
{
|
||||||
pr_int_t this;
|
pr_int_t this;
|
||||||
|
func_t think;
|
||||||
|
|
||||||
|
think = SVfunc (self, think);
|
||||||
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
|
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
|
||||||
*sv_globals.other = 0;
|
*sv_globals.other = 0;
|
||||||
if ((this = sv_pr_state.fields.this) != -1) {
|
if ((this = sv_pr_state.fields.this) != -1
|
||||||
|
&& E_POINTER (self, this)) {
|
||||||
PR_RESET_PARAMS (&sv_pr_state);
|
PR_RESET_PARAMS (&sv_pr_state);
|
||||||
P_INT (&sv_pr_state, 0) = E_POINTER (self, this);
|
P_INT (&sv_pr_state, 0) = E_POINTER (self, this);
|
||||||
P_INT (&sv_pr_state, 1) = 0;
|
P_INT (&sv_pr_state, 1) = think;
|
||||||
P_INT (&sv_pr_state, 2) = 0;
|
P_INT (&sv_pr_state, 2) = 0;
|
||||||
|
think = RUA_Obj_msg_lookup (&sv_pr_state, E_POINTER (self, this),
|
||||||
|
think);
|
||||||
}
|
}
|
||||||
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, think));
|
PR_ExecuteProgram (&sv_pr_state, think);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
sv_pr_blocked (edict_t *self, edict_t *other)
|
sv_pr_blocked (edict_t *self, edict_t *other)
|
||||||
{
|
{
|
||||||
pr_int_t this;
|
pr_int_t this;
|
||||||
|
func_t blocked;
|
||||||
|
|
||||||
|
blocked = SVfunc (self, blocked);
|
||||||
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
|
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, self);
|
||||||
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, other);
|
*sv_globals.other = EDICT_TO_PROG (&sv_pr_state, other);
|
||||||
if ((this = sv_pr_state.fields.this) != -1) {
|
if ((this = sv_pr_state.fields.this) != -1
|
||||||
|
&& E_POINTER (self, this)) {
|
||||||
PR_RESET_PARAMS (&sv_pr_state);
|
PR_RESET_PARAMS (&sv_pr_state);
|
||||||
P_INT (&sv_pr_state, 0) = E_POINTER (self, this);
|
P_INT (&sv_pr_state, 0) = E_POINTER (self, this);
|
||||||
P_INT (&sv_pr_state, 1) = 0;
|
P_INT (&sv_pr_state, 1) = blocked;
|
||||||
P_INT (&sv_pr_state, 2) = E_POINTER (other, this);
|
P_INT (&sv_pr_state, 2) = E_POINTER (other, this);
|
||||||
|
blocked = RUA_Obj_msg_lookup (&sv_pr_state, E_POINTER (self, this),
|
||||||
|
blocked);
|
||||||
}
|
}
|
||||||
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, blocked));
|
PR_ExecuteProgram (&sv_pr_state, SVfunc (self, blocked));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue