]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
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 f614f8c36e69c8410c24ec16eeb14a38bee0f80e..edad32a5c92270889432b4ea0e92452c45794243 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_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_OnEntityNoSpawnFunction; // ssqc
+       func_t SV_OnEntityPostSpawnFunction; // ssqc
        func_t GameCommand; // any
        func_t SV_Shutdown; // ssqc
        func_t URI_Get_Callback; // any
        func_t GameCommand; // any
        func_t SV_Shutdown; // ssqc
        func_t URI_Get_Callback; // any
index 2a7c222e0ba2191729bfbe954f3ecd80e73a69a1..c3bbfb8f7d002157ee49f2f5b64a59bbaa0aa53a 100644 (file)
@@ -1323,9 +1323,17 @@ void PRVM_ED_LoadFromFile (const char *data)
                        continue;
                }
 
                        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
 //
 //
 // 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;
                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);
                                                PRVM_ED_Print(ent, NULL);
                                        }
                                        PRVM_ED_Free (ent);
-                                       continue;
+                                       continue; // not included in "inhibited" count
                                }
                        }
                        else
                                }
                        }
                        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++;
                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_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");
        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 9bb99eb8dd0c1a08a1a784bcad9443bf51a54776..b16f16a01935f1e420e710c004654b791cc3445e 100644 (file)
@@ -124,6 +124,7 @@ char *vm_sv_extensions =
 "DP_SV_NETADDRESS "
 "DP_SV_NODRAWTOCLIENT "
 "DP_SV_ONENTITYNOSPAWNFUNCTION "
 "DP_SV_NETADDRESS "
 "DP_SV_NODRAWTOCLIENT "
 "DP_SV_ONENTITYNOSPAWNFUNCTION "
+"DP_SV_ONENTITYPREPOSTSPAWNFUNCTION "
 "DP_SV_PING "
 "DP_SV_PLAYERPHYSICS "
 "DP_SV_POINTPARTICLES "
 "DP_SV_PING "
 "DP_SV_PLAYERPHYSICS "
 "DP_SV_POINTPARTICLES "