]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Implement phase one of EXT_ENTITYPARAM (optional entity parameter for engine builtin...
authorMario <mario@smbclan.net>
Thu, 28 May 2020 12:25:54 +0000 (22:25 +1000)
committerMario <mario@smbclan.net>
Thu, 28 May 2020 12:25:54 +0000 (22:25 +1000)
csprogs.c
dpdefs/dpextensions.qc
host.c
host_cmd.c
protocol.c
prvm_edict.c
sv_main.c
sv_phys.c
sv_user.c
svvm_cmds.c

index 4f47741b586ecc27cd2efac6ab5916893067718b..68e7b3c066ed2e43fc08dab563d984fc973eeb04 100644 (file)
--- 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));
index 9cdeb695744219f529aed58e1636d992980b6c8f..1c6ec21e9121c445f4b543f1dd750b286a632352 100644 (file)
@@ -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 03375f69a6b39fcdbf0f6a215f5b64f1b84e22ca..9404ac952bc06c350d75499708d67af5236bbecf 100644 (file)
--- 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;
        }
index b095d181f087f551358a6d8ce3ba3895b8f351cb..6363dc0830639752da7c26a33340dba92ffc2aa2 100644 (file)
@@ -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");
        }
 
index bdeebdd5763cd16426131b3bea446bb372a87d14..f4fcb50c750378e9c359236d1f65df7b65f534ef 100644 (file)
@@ -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;
index 9d81ef048263355bba93ed028b8e64e2bc358130..22f5b9cfcbcada28ee2765c0bd68dad395d272f5 100644 (file)
@@ -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");
                }
 
index b10a67d9f13424b0119993cc0ddc28ac41ae1688..007107c51a6f48125a26a1b07cbbda34dc936553 100644 (file)
--- 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 ; j<NUM_SPAWN_PARMS ; j++)
                        host_client->spawn_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;
                }
index 9964c362f0d0dada04d617f81ed434641eea31eb..82388bbf0ab23b3d4f0c7191bd8865d887dd5246 100644 (file)
--- 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)
index 6c0468e5bcf204f62657ed48de96b17c40d0d544..02d7cb4608f40114e4827b16d0f78f7f7c14c51c 100644 (file)
--- 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");
index 015c6b9da48e3037361106dca32cccdf23712da9..bd58183b46f50c010005397240ab58dd41c48dcd 100644 (file)
@@ -228,6 +228,7 @@ const char *vm_sv_extensions =
 "TW_SV_STEPCONTROL "
 "ZQ_PAUSE "
 "DP_RM_CLIPGROUP "
+"EXT_ENTITYPARAM "
 //"EXT_CSQC " // not ready yet
 ;