DP_SV_ONENTITYPREPOSTSPAWNFUNCTION - hooks before and after spawning an entity from...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 22 Jan 2009 08:20:15 +0000 (08:20 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 22 Jan 2009 08:20:15 +0000 (08:20 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8662 d7cf8633-e32d-0410-b094-e92efae38249

progsvm.h
prvm_edict.c
svvm_cmds.c

index f614f8c..edad32a 100644 (file)
--- 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
index 2a7c222..c3bbfb8 100644 (file)
@@ -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");
index 9bb99eb..b16f16a 100644 (file)
@@ -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 "