From: dresk Date: Thu, 16 Aug 2007 06:35:30 +0000 (+0000) Subject: Added SSQC Function "SV_OnEntityNoSpawnFunction" which is called, if available, whene... X-Git-Tag: xonotic-v0.1.0preview~2947 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e868764401ba7f2190e30c7b6aae588c50c67421;p=xonotic%2Fdarkplaces.git Added SSQC Function "SV_OnEntityNoSpawnFunction" which is called, if available, whenever an entity on the server is parsed but has no spawn function. Previously Darkplaces would report this to the console under developer mode and immediately remove the entity. The SSQC may now specify the behavior when such an event occurs (it may also simply call remove(self) to mimic the engine's behavior.) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7525 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/progsvm.h b/progsvm.h index 9d50da70..52dfd03b 100644 --- a/progsvm.h +++ b/progsvm.h @@ -267,6 +267,7 @@ typedef struct prvm_prog_funcoffsets_s func_t SV_ChangeTeam; // ssqc func_t SV_ParseClientCommand; // ssqc func_t SV_PlayerPhysics; // ssqc + func_t SV_OnEntityNoSpawnFunction; // ssqc func_t GameCommand; // any // menu qc only uses some functions, nothing else diff --git a/prvm_edict.c b/prvm_edict.c index 102a40c7..8b269d55 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1284,18 +1284,30 @@ void PRVM_ED_LoadFromFile (const char *data) if (!func) { - if (developer.integer) // don't confuse non-developers with errors + // check for OnEntityNoSpawnFunction + if (prog->funcoffsets.SV_OnEntityNoSpawnFunction) { - Con_Print("No spawn function for:\n"); - PRVM_ED_Print(ent, NULL); + // self = ent + PRVM_GLOBALFIELDVALUE(prog->globaloffsets.self)->edict = PRVM_EDICT_TO_PROG(ent); + PRVM_ExecuteProgram (prog->funcoffsets.SV_OnEntityNoSpawnFunction, "QC function SV_OnEntityNoSpawnFunction is missing"); + } + else + { + if (developer.integer) // don't confuse non-developers with errors + { + Con_Print("No spawn function for:\n"); + PRVM_ED_Print(ent, NULL); + } + PRVM_ED_Free (ent); + continue; } - PRVM_ED_Free (ent); - continue; } - - // self = ent - PRVM_GLOBALFIELDVALUE(prog->globaloffsets.self)->edict = PRVM_EDICT_TO_PROG(ent); - PRVM_ExecuteProgram (func - prog->functions, ""); + else + { + // self = ent + PRVM_GLOBALFIELDVALUE(prog->globaloffsets.self)->edict = PRVM_EDICT_TO_PROG(ent); + PRVM_ExecuteProgram (func - prog->functions, ""); + } } spawned++; @@ -1419,6 +1431,7 @@ void PRVM_FindOffsets(void) prog->funcoffsets.SV_ChangeTeam = PRVM_ED_FindFunctionOffset("SV_ChangeTeam"); 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.GameCommand = PRVM_ED_FindFunctionOffset("GameCommand"); prog->globaloffsets.SV_InitCmd = PRVM_ED_FindGlobalOffset("SV_InitCmd"); prog->globaloffsets.self = PRVM_ED_FindGlobalOffset("self"); diff --git a/svvm_cmds.c b/svvm_cmds.c index 106aebae..b0cfa775 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -98,6 +98,7 @@ char *vm_sv_extensions = "DP_SV_DROPCLIENT " "DP_SV_EFFECT " "DP_SV_ENTITYCONTENTSTRANSITION " +"DP_SV_ONENTITYNOSPAWNFUNCTION " "DP_SV_MODELFLAGS_AS_EFFECTS " "DP_SV_NETADDRESS " "DP_SV_NODRAWTOCLIENT "