]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_edict.c
ZQ_PAUSE extension patch from GreEn`mArine
[xonotic/darkplaces.git] / prvm_edict.c
index 2a7c222e0ba2191729bfbe954f3ecd80e73a69a1..a751a15ecfc7e5b50c57244ffd49822b5adecba9 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++;
@@ -1441,6 +1457,7 @@ void PRVM_FindOffsets(void)
        prog->fieldoffsets.frame1time                     = PRVM_ED_FindFieldOffset("frame1time");
        prog->fieldoffsets.frame2                         = PRVM_ED_FindFieldOffset("frame2");
        prog->fieldoffsets.frame2time                     = PRVM_ED_FindFieldOffset("frame2time");
+       prog->fieldoffsets.shadertime                     = PRVM_ED_FindFieldOffset("shadertime");
        prog->fieldoffsets.fullbright                     = PRVM_ED_FindFieldOffset("fullbright");
        prog->fieldoffsets.glow_color                     = PRVM_ED_FindFieldOffset("glow_color");
        prog->fieldoffsets.glow_size                      = PRVM_ED_FindFieldOffset("glow_size");
@@ -1501,9 +1518,12 @@ 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");
+       prog->funcoffsets.SV_PausedTic                    = PRVM_ED_FindFunctionOffset("SV_PausedTic");
        prog->globaloffsets.SV_InitCmd                    = PRVM_ED_FindGlobalOffset("SV_InitCmd");
        prog->globaloffsets.self                          = PRVM_ED_FindGlobalOffset("self");
        prog->globaloffsets.time                          = PRVM_ED_FindGlobalOffset("time");
@@ -1535,6 +1555,15 @@ void PRVM_FindOffsets(void)
        prog->globaloffsets.drawfont                      = PRVM_ED_FindGlobalOffset("drawfont");
        prog->globaloffsets.require_spawnfunc_prefix      = PRVM_ED_FindGlobalOffset("require_spawnfunc_prefix");
        prog->globaloffsets.worldstatus                   = PRVM_ED_FindGlobalOffset("worldstatus");
+       prog->globaloffsets.servertime                    = PRVM_ED_FindGlobalOffset("servertime");
+       prog->globaloffsets.serverprevtime                = PRVM_ED_FindGlobalOffset("serverprevtime");
+       prog->globaloffsets.serverdeltatime               = PRVM_ED_FindGlobalOffset("serverdeltatime");
+       prog->globaloffsets.gettaginfo_name               = PRVM_ED_FindGlobalOffset("gettaginfo_name");
+       prog->globaloffsets.gettaginfo_parent             = PRVM_ED_FindGlobalOffset("gettaginfo_parent");
+       prog->globaloffsets.gettaginfo_offset             = PRVM_ED_FindGlobalOffset("gettaginfo_offset");
+       prog->globaloffsets.gettaginfo_forward            = PRVM_ED_FindGlobalOffset("gettaginfo_forward");
+       prog->globaloffsets.gettaginfo_right              = PRVM_ED_FindGlobalOffset("gettaginfo_right");
+       prog->globaloffsets.gettaginfo_up                 = PRVM_ED_FindGlobalOffset("gettaginfo_up");
 
        // menu qc only uses some functions, nothing else
        prog->funcoffsets.m_draw                          = PRVM_ED_FindFunctionOffset("m_draw");
@@ -2371,7 +2400,7 @@ int PRVM_SetTempString(const char *s)
                {
                        if (developer.integer >= 100)
                                Con_Printf("PRVM_SetTempString: enlarging tempstrings buffer (%iKB -> %iKB)\n", old.maxsize/1024, vm_tempstringsbuf.maxsize/1024);
-                       vm_tempstringsbuf.data = Mem_Alloc(sv_mempool, vm_tempstringsbuf.maxsize);
+                       vm_tempstringsbuf.data = (unsigned char *) Mem_Alloc(sv_mempool, vm_tempstringsbuf.maxsize);
                        if (old.cursize)
                                memcpy(vm_tempstringsbuf.data, old.data, old.cursize);
                        if (old.data)
@@ -2665,7 +2694,7 @@ void PRVM_LeakTest()
 
        for (i = 0; i < (int)Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray); ++i)
        {
-               prvm_stringbuffer_t *stringbuffer = Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, i);
+               prvm_stringbuffer_t *stringbuffer = (prvm_stringbuffer_t*) Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, i);
                if(stringbuffer)
                if(stringbuffer->origin)
                {