From: Mario Date: Thu, 28 May 2020 12:25:54 +0000 (+1000) Subject: Implement phase one of EXT_ENTITYPARAM (optional entity parameter for engine builtin... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8d4365ffce6a653810d5758f780bc90586d7c503;p=xonotic%2Fdarkplaces.git Implement phase one of EXT_ENTITYPARAM (optional entity parameter for engine builtin functions), most engine to VM functions ported, builtins untouched --- diff --git a/csprogs.c b/csprogs.c index 4f47741b..68e7b3c0 100644 --- a/csprogs.c +++ b/csprogs.c @@ -266,6 +266,8 @@ void CSQC_Predraw (prvm_edict_t *ed) return; b = PRVM_clientglobaledict(self); PRVM_clientglobaledict(self) = PRVM_EDICT_TO_PROG(ed); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ed); prog->ExecuteProgram(prog, PRVM_clientedictfunction(ed, predraw), "CSQC_Predraw: NULL function\n"); PRVM_clientglobaledict(self) = b; } @@ -280,6 +282,8 @@ void CSQC_Think (prvm_edict_t *ed) PRVM_clientedictfloat(ed, nextthink) = 0; b = PRVM_clientglobaledict(self); PRVM_clientglobaledict(self) = PRVM_EDICT_TO_PROG(ed); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ed); prog->ExecuteProgram(prog, PRVM_clientedictfunction(ed, think), "CSQC_Think: NULL function\n"); PRVM_clientglobaledict(self) = b; } @@ -490,6 +494,7 @@ qboolean CL_VM_UpdateView (double frametime) // pass in width and height as parameters (EXT_CSQC_1) PRVM_G_FLOAT(OFS_PARM0) = vid.width; PRVM_G_FLOAT(OFS_PARM1) = vid.height; + PRVM_G_INT(OFS_PARM2) = cl.csqc_server2csqcentitynumber[cl.playerentity]; prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_UpdateView), "QC function CSQC_UpdateView is missing"); //VectorCopy(oldangles, cl.viewangles); // Dresk : Reset Dmg Globals Here @@ -516,6 +521,8 @@ qboolean CL_VM_ConsoleCommand (const char *cmd) PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity]; restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize; PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, cmd); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = cl.csqc_server2csqcentitynumber[cl.playerentity]; prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_ConsoleCommand), "QC function CSQC_ConsoleCommand is missing"); prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize; r = CSQC_RETURNVAL != 0; @@ -537,6 +544,8 @@ qboolean CL_VM_Parse_TempEntity (void) t = cl_message.readcount; PRVM_clientglobalfloat(time) = cl.time; PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity]; + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = cl.csqc_server2csqcentitynumber[cl.playerentity]; prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Parse_TempEntity), "QC function CSQC_Parse_TempEntity is missing"); r = CSQC_RETURNVAL != 0; if(!r) @@ -622,6 +631,8 @@ void CL_VM_Parse_StuffCmd (const char *msg) PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity]; restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize; PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, msg); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = cl.csqc_server2csqcentitynumber[cl.playerentity]; prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Parse_StuffCmd), "QC function CSQC_Parse_StuffCmd is missing"); prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize; } @@ -638,6 +649,8 @@ static void CL_VM_Parse_Print (const char *msg) PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity]; restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize; PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, msg); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = cl.csqc_server2csqcentitynumber[cl.playerentity]; prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Parse_Print), "QC function CSQC_Parse_Print is missing"); prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize; } @@ -692,6 +705,8 @@ void CL_VM_Parse_CenterPrint (const char *msg) PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity]; restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize; PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, msg); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = cl.csqc_server2csqcentitynumber[cl.playerentity]; prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Parse_CenterPrint), "QC function CSQC_Parse_CenterPrint is missing"); prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize; } @@ -739,6 +754,7 @@ qboolean CL_VM_Event_Sound(int sound_num, float fvolume, int channel, float atte VectorCopy(pos, PRVM_G_VECTOR(OFS_PARM5) ); PRVM_G_FLOAT(OFS_PARM6) = speed * 100.0f; PRVM_G_FLOAT(OFS_PARM7) = flags; // flags + // NOTE: entity parameter can't be used here, as there are not enough offsets available prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Event_Sound), "QC function CSQC_Event_Sound is missing"); r = CSQC_RETURNVAL != 0; } @@ -825,6 +841,8 @@ void CSQC_ReadEntities (void) { if(PRVM_clientglobaledict(self)) { + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = cl.csqc_server2csqcentitynumber[realentnum]; prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Ent_Remove), "QC function CSQC_Ent_Remove is missing"); cl.csqc_server2csqcentitynumber[realentnum] = 0; } @@ -859,10 +877,14 @@ void CSQC_ReadEntities (void) PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[realentnum] = PRVM_EDICT( PRVM_G_INT( OFS_RETURN ) ); } PRVM_G_FLOAT(OFS_PARM0) = 1; + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = cl.csqc_server2csqcentitynumber[realentnum]; prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Ent_Update), "QC function CSQC_Ent_Update is missing"); } else { PRVM_G_FLOAT(OFS_PARM0) = 0; + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = cl.csqc_server2csqcentitynumber[realentnum]; prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Ent_Update), "QC function CSQC_Ent_Update is missing"); } } @@ -1233,6 +1255,8 @@ qboolean CL_VM_TransformView(int entnum, matrix4x4_t *viewmatrix, mplane_t *clip PRVM_clientglobaledict(self) = entnum; VectorCopy(origin, PRVM_G_VECTOR(OFS_PARM0)); VectorCopy(ang, PRVM_G_VECTOR(OFS_PARM1)); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM2) = entnum; VectorCopy(forward, PRVM_clientglobalvector(v_forward)); VectorScale(left, -1, PRVM_clientglobalvector(v_right)); VectorCopy(up, PRVM_clientglobalvector(v_up)); diff --git a/dpdefs/dpextensions.qc b/dpdefs/dpextensions.qc index 9cdeb695..1c6ec21e 100644 --- a/dpdefs/dpextensions.qc +++ b/dpdefs/dpextensions.qc @@ -2616,3 +2616,10 @@ float MOVETYPE_USER_LAST = 191; .float clipgroup; //description: //If two entities have this field set to the same non-zero integer value, they won't collide with each other. + +//EXT_ENTITYPARAM +//idea: TimePath +//darkplaces implementation: Mario +//description: +//shows that the engine supports the "entity e" parameter in most builtin functions that make use of the global ("self" or "other" for example) entity +//Note: mods are required to modify progsdefs.qc to include the parameters in the builtin functions they wish to access diff --git a/host.c b/host.c index 03375f69..9404ac95 100644 --- a/host.c +++ b/host.c @@ -501,6 +501,8 @@ void SV_DropClient(qboolean crash) host_client->clientconnectcalled = false; PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(ClientDisconnect), "QC function ClientDisconnect is missing"); PRVM_serverglobaledict(self) = saveSelf; } diff --git a/host_cmd.c b/host_cmd.c index b095d181..6363dc08 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -1603,6 +1603,8 @@ static void Host_Color(cmd_state_t *cmd, int changetop, int changebottom) { Con_DPrint("Calling SV_ChangeTeam\n"); prog->globals.fp[OFS_PARM0] = playercolor; + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = PRVM_EDICT_TO_PROG(host_client->edict); PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(SV_ChangeTeam), "QC function SV_ChangeTeam is missing"); @@ -1744,6 +1746,8 @@ static void Host_Kill_f(cmd_state_t *cmd) PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(ClientKill), "QC function ClientKill is missing"); } @@ -1900,6 +1904,8 @@ static void Host_Spawn_f(cmd_state_t *cmd) Con_DPrint("Calling RestoreGame\n"); PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(RestoreGame), "QC function RestoreGame is missing"); } } @@ -1915,12 +1921,16 @@ static void Host_Spawn_f(cmd_state_t *cmd) host_client->clientconnectcalled = true; PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(ClientConnect), "QC function ClientConnect is missing"); if (cls.state == ca_dedicated) Con_Printf("%s connected\n", host_client->name); PRVM_serverglobalfloat(time) = sv.time; + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(PutClientInServer), "QC function PutClientInServer is missing"); } diff --git a/protocol.c b/protocol.c index bdeebdd5..f4fcb50c 100644 --- a/protocol.c +++ b/protocol.c @@ -545,6 +545,8 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers msg->allowoverflow = true; PRVM_G_INT(OFS_PARM0) = sv.writeentitiestoclient_cliententitynumber; PRVM_G_FLOAT(OFS_PARM1) = sendflags; + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM2) = number; PRVM_serverglobaledict(self) = number; prog->ExecuteProgram(prog, PRVM_serveredictfunction(ed, SendEntity), "Null SendEntity\n"); msg->allowoverflow = false; diff --git a/prvm_edict.c b/prvm_edict.c index 9d81ef04..22f5b9cf 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1421,6 +1421,8 @@ void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data) // self = ent PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serverfunction(SV_OnEntityPreSpawnFunction), "QC function SV_OnEntityPreSpawnFunction is missing"); } @@ -1458,6 +1460,8 @@ void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data) // self = ent PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serverfunction(SV_OnEntityNoSpawnFunction), "QC function SV_OnEntityNoSpawnFunction is missing"); } else @@ -1486,6 +1490,8 @@ void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data) // self = ent PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serverfunction(SV_OnEntityPostSpawnFunction), "QC function SV_OnEntityPostSpawnFunction is missing"); } diff --git a/sv_main.c b/sv_main.c index b10a67d9..007107c5 100644 --- a/sv_main.c +++ b/sv_main.c @@ -1647,6 +1647,10 @@ static void SV_MarkWriteEntityStateToClient(entity_state_t *s) PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = s->number; PRVM_serverglobaledict(other) = sv.writeentitiestoclient_cliententitynumber; + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = s->number; + // optional entity parameter for other (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = sv.writeentitiestoclient_cliententitynumber; prog->ExecuteProgram(prog, s->customizeentityforclient, "customizeentityforclient: NULL function"); if(!PRVM_G_FLOAT(OFS_RETURN) || !SV_PrepareEntityForSending(PRVM_EDICT_NUM(s->number), s, s->number)) return; @@ -1788,6 +1792,8 @@ static void SV_AddCameraEyes(void) VectorCopy(sv.writeentitiestoclient_eyes[0], PRVM_serverglobalvector(trace_endpos)); VectorCopy(sv.writeentitiestoclient_eyes[0], PRVM_G_VECTOR(OFS_PARM0)); VectorClear(PRVM_G_VECTOR(OFS_PARM1)); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM2) = sv.writeentitiestoclient_cliententitynumber; prog->ExecuteProgram(prog, PRVM_serveredictfunction(ed, camera_transform), "QC function e.camera_transform is missing"); if(!VectorCompare(PRVM_serverglobalvector(trace_endpos), sv.writeentitiestoclient_eyes[0])) { @@ -3257,6 +3263,8 @@ void SV_SaveSpawnparms (void) // call the progs to get default spawn parms for the new client PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(SetChangeParms), "QC function SetChangeParms is missing"); for (j=0 ; jspawn_parms[j] = (&PRVM_serverglobalfloat(parm1))[j]; @@ -3564,7 +3572,11 @@ void SV_SpawnServer (const char *server) host_client->clientconnectcalled = true; PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(ClientConnect), "QC function ClientConnect is missing"); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(PutClientInServer), "QC function PutClientInServer is missing"); host_client->begun = true; } diff --git a/sv_phys.c b/sv_phys.c index 9964c362..82388bbf 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -721,6 +721,10 @@ void SV_LinkEdict_TouchAreaGrid_Call(prvm_edict_t *touch, prvm_edict_t *ent) PRVM_serverglobalfloat(trace_dphitcontents) = 0; PRVM_serverglobalfloat(trace_dphitq3surfaceflags) = 0; PRVM_serverglobalstring(trace_dphittexturename) = 0; + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(touch); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serveredictfunction(touch, touch), "QC function self.touch is missing"); } @@ -1095,6 +1099,8 @@ static qboolean SV_RunThink (prvm_edict_t *ent) PRVM_serveredictfloat(ent, nextthink) = 0; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent); PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(prog->edicts); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serveredictfunction(ent, think), "QC function self.think is missing"); // mods often set nextthink to time to cause a think every frame, // we don't want to loop in that case, so exit if the new nextthink is @@ -1131,6 +1137,10 @@ static void SV_Impact (prvm_edict_t *e1, trace_t *trace) PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(e1); PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(e2); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(e1); + // optional entity parameter for other (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = PRVM_EDICT_TO_PROG(e2); prog->ExecuteProgram(prog, PRVM_serveredictfunction(e1, touch), "QC function self.touch is missing"); } @@ -1147,6 +1157,10 @@ static void SV_Impact (prvm_edict_t *e1, trace_t *trace) PRVM_serverglobalfloat(trace_dphitcontents) = 0; PRVM_serverglobalfloat(trace_dphitq3surfaceflags) = 0; PRVM_serverglobalstring(trace_dphittexturename) = 0; + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(e2); + // optional entity parameter for other (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = PRVM_EDICT_TO_PROG(e1); prog->ExecuteProgram(prog, PRVM_serveredictfunction(e2, touch), "QC function self.touch is missing"); } @@ -1964,6 +1978,10 @@ static void SV_PushMove (prvm_edict_t *pusher, float movetime) PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(pusher); PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(check); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(pusher); + // optional entity parameter for other (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = PRVM_EDICT_TO_PROG(check); prog->ExecuteProgram(prog, PRVM_serveredictfunction(pusher, blocked), "QC function self.blocked is missing"); } break; @@ -2007,6 +2025,8 @@ static void SV_Physics_Pusher (prvm_edict_t *ent) PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent); PRVM_serverglobaledict(other) = PRVM_EDICT_TO_PROG(prog->edicts); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serveredictfunction(ent, think), "QC function self.think is missing"); } } @@ -2971,6 +2991,8 @@ void SV_Physics_ClientMove(void) PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobalfloat(frametime) = 0; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serverfunction(PlayerPreThink), "QC function PlayerPreThink is missing"); PRVM_serverglobalfloat(frametime) = sv.frametime; @@ -2985,6 +3007,8 @@ void SV_Physics_ClientMove(void) PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobalfloat(frametime) = 0; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serverfunction(PlayerPostThink), "QC function PlayerPostThink is missing"); PRVM_serverglobalfloat(frametime) = sv.frametime; @@ -3023,6 +3047,8 @@ static void SV_Physics_ClientEntity_PreThink(prvm_edict_t *ent) // call standard client pre-think PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serverfunction(PlayerPreThink), "QC function PlayerPreThink is missing"); // make sure the velocity is still sane (not a NaN) @@ -3042,6 +3068,8 @@ static void SV_Physics_ClientEntity_PostThink(prvm_edict_t *ent) // call standard player post-think PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(ent); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(ent); prog->ExecuteProgram(prog, PRVM_serverfunction(PlayerPostThink), "QC function PlayerPostThink is missing"); // make sure the velocity is still sane (not a NaN) diff --git a/sv_user.c b/sv_user.c index 6c0468e5..02d7cb46 100644 --- a/sv_user.c +++ b/sv_user.c @@ -380,6 +380,8 @@ void SV_ClientThink (void) { PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM0) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(SV_PlayerPhysics), "QC function SV_PlayerPhysics is missing"); SV_CheckVelocity(host_client->edict); return; @@ -875,6 +877,8 @@ void SV_ReadClientMessage(void) int restorevm_tempstringsbuf_cursize; restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize; PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, s); + // optional entity parameter for self (EXT_ENTITYPARAM) + PRVM_G_INT(OFS_PARM1) = PRVM_EDICT_TO_PROG(host_client->edict); PRVM_serverglobalfloat(time) = sv.time; PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(SV_ParseClientCommand), "QC function SV_ParseClientCommand is missing"); diff --git a/svvm_cmds.c b/svvm_cmds.c index 015c6b9d..bd58183b 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -228,6 +228,7 @@ const char *vm_sv_extensions = "TW_SV_STEPCONTROL " "ZQ_PAUSE " "DP_RM_CLIPGROUP " +"EXT_ENTITYPARAM " //"EXT_CSQC " // not ready yet ;