From: divverent Date: Thu, 22 Jan 2009 08:20:15 +0000 (+0000) Subject: DP_SV_ONENTITYPREPOSTSPAWNFUNCTION - hooks before and after spawning an entity from... X-Git-Tag: xonotic-v0.1.0preview~1930 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=5d4bcbc38c9782e3ead51ab810233cb9e2b275c6 DP_SV_ONENTITYPREPOSTSPAWNFUNCTION - hooks before and after spawning an entity from a map/ent git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8662 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/progsvm.h b/progsvm.h index f614f8c3..edad32a5 100644 --- a/progsvm.h +++ b/progsvm.h @@ -287,7 +287,9 @@ typedef struct prvm_prog_funcoffsets_s func_t SV_ChangeTeam; // ssqc func_t SV_ParseClientCommand; // ssqc func_t SV_PlayerPhysics; // ssqc + func_t SV_OnEntityPreSpawnFunction; // ssqc func_t SV_OnEntityNoSpawnFunction; // ssqc + func_t SV_OnEntityPostSpawnFunction; // ssqc func_t GameCommand; // any func_t SV_Shutdown; // ssqc func_t URI_Get_Callback; // any diff --git a/prvm_edict.c b/prvm_edict.c index 2a7c222e..c3bbfb8f 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1323,9 +1323,17 @@ void PRVM_ED_LoadFromFile (const char *data) continue; } + if (prog->funcoffsets.SV_OnEntityPreSpawnFunction) + { + // self = ent + PRVM_GLOBALFIELDVALUE(prog->globaloffsets.self)->edict = PRVM_EDICT_TO_PROG(ent); + PRVM_ExecuteProgram (prog->funcoffsets.SV_OnEntityPreSpawnFunction, "QC function SV_OnEntityPreSpawnFunction is missing"); + } + // // immediately call spawn function, but only if there is a self global and a classname // + if(!ent->priv.required->free) if(prog->globaloffsets.self >= 0 && prog->fieldoffsets.classname >= 0) { string_t handle = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.classname)->string; @@ -1361,7 +1369,7 @@ void PRVM_ED_LoadFromFile (const char *data) PRVM_ED_Print(ent, NULL); } PRVM_ED_Free (ent); - continue; + continue; // not included in "inhibited" count } } else @@ -1372,6 +1380,14 @@ void PRVM_ED_LoadFromFile (const char *data) } } + if(!ent->priv.required->free) + if (prog->funcoffsets.SV_OnEntityPostSpawnFunction) + { + // self = ent + PRVM_GLOBALFIELDVALUE(prog->globaloffsets.self)->edict = PRVM_EDICT_TO_PROG(ent); + PRVM_ExecuteProgram (prog->funcoffsets.SV_OnEntityPostSpawnFunction, "QC function SV_OnEntityPostSpawnFunction is missing"); + } + spawned++; if (ent->priv.required->free) died++; @@ -1501,6 +1517,8 @@ void PRVM_FindOffsets(void) prog->funcoffsets.SV_ParseClientCommand = PRVM_ED_FindFunctionOffset("SV_ParseClientCommand"); prog->funcoffsets.SV_PlayerPhysics = PRVM_ED_FindFunctionOffset("SV_PlayerPhysics"); prog->funcoffsets.SV_OnEntityNoSpawnFunction = PRVM_ED_FindFunctionOffset("SV_OnEntityNoSpawnFunction"); + prog->funcoffsets.SV_OnEntityPreSpawnFunction = PRVM_ED_FindFunctionOffset("SV_OnEntityPreSpawnFunction"); + prog->funcoffsets.SV_OnEntityPostSpawnFunction = PRVM_ED_FindFunctionOffset("SV_OnEntityPostSpawnFunction"); prog->funcoffsets.GameCommand = PRVM_ED_FindFunctionOffset("GameCommand"); prog->funcoffsets.SV_Shutdown = PRVM_ED_FindFunctionOffset("SV_Shutdown"); prog->funcoffsets.URI_Get_Callback = PRVM_ED_FindFunctionOffset("URI_Get_Callback"); diff --git a/svvm_cmds.c b/svvm_cmds.c index 9bb99eb8..b16f16a0 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -124,6 +124,7 @@ char *vm_sv_extensions = "DP_SV_NETADDRESS " "DP_SV_NODRAWTOCLIENT " "DP_SV_ONENTITYNOSPAWNFUNCTION " +"DP_SV_ONENTITYPREPOSTSPAWNFUNCTION " "DP_SV_PING " "DP_SV_PLAYERPHYSICS " "DP_SV_POINTPARTICLES "