RuleC: dedicated precache callback which will be called at a specific time.

This commit is contained in:
Marco Cawthorne 2025-02-09 01:16:39 -08:00
parent 3e421aab57
commit e60556e124
2 changed files with 16 additions and 1 deletions

View file

@ -436,6 +436,7 @@ initents(void)
* let's add our own that we can actually trust. */ * let's add our own that we can actually trust. */
serverinfo.SetInteger("sv_playerslots", cvars.GetInteger("sv_playerslots")); serverinfo.SetInteger("sv_playerslots", cvars.GetInteger("sv_playerslots"));
RuleC_Precache();
MapC_CallMainFunction(); MapC_CallMainFunction();
Plugin_InitEnts(); Plugin_InitEnts();
Mapcycle_Init(); Mapcycle_Init();

View file

@ -84,13 +84,27 @@ RuleC_Init(void)
if (mainFunction) { if (mainFunction) {
externset(g_ruleCProgs, world, "self"); externset(g_ruleCProgs, world, "self");
thread(mainFunction()) mainFunction();
} else { } else {
error(sprintf("RuleC %S does not have a main function.", pathToProgs)); error(sprintf("RuleC %S does not have a main function.", pathToProgs));
} }
} }
} }
void
RuleC_Precache(void)
{
void(void) mainFunction;
mainFunction = externvalue(g_ruleCProgs, "CodeCallback_Precache");
if (mainFunction) {
externset(g_ruleCProgs, world, "self");
mainFunction();
} else {
NSError("%s does not have a Precache function.", mapname);
}
}
void void
MapC_CallMainFunction(void) MapC_CallMainFunction(void)
{ {