cvar_set("slowmo", cvar_defstring("slowmo")); // reset it back to 'default'
+ // if _cl_hook_gamestart wasn't called with an actual gamemode
+ // before CSQC VM shutdown then call it with nop fallback here
+ if (!(calledhooks & HOOK_START) && !isdemo())
+ localcmd("\n_cl_hook_gamestart nop\n");
+
// fire game or demo end hooks when CSQC VM shuts down
- if (!isdemo())
+ if (!(calledhooks & HOOK_END))
{
- // if _cl_hook_gamestart wasn't called with an actual gamemode
- // before CSQC VM shutdown then call it with nop fallback here
- if (!(calledhooks & HOOK_START))
- localcmd("\n_cl_hook_gamestart nop\n");
-
// call gameend hook if it hasn't somehow yet fired by intermission starting
- if (!(calledhooks & HOOK_END))
+ if (!isdemo())
{
localcmd("\ncl_hook_gameend\n");
int gamecount = cvar("cl_matchcount");
localcmd(strcat("cl_matchcount ", itos(gamecount + 1), "\n"));
//cvar_set("cl_matchcount", itos(gamecount + 1));
- calledhooks |= HOOK_END;
}
- }
- else
- {
- // call demo end hook
- if (!(calledhooks & HOOK_END))
- {
+ else
localcmd("\ncl_hook_demoend\n");
- calledhooks |= HOOK_END; // mark the hook as having fired
- }
+
+ calledhooks |= HOOK_END; // mark the hook as having fired
}
localcmd("\ncl_hook_shutdown\n");
void Gamemode_Init()
{
// fire game or demo start hooks here
- if (!isdemo())
+ if (!(calledhooks & HOOK_START))
{
- if(!(calledhooks & HOOK_START))
- {
+ if (!isdemo())
localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
- calledhooks |= HOOK_START; // mark start hook as fired
- }
- }
- else
- {
- if (!(calledhooks & HOOK_START))
- {
+ else
localcmd("\ncl_hook_demostart\n");
- calledhooks |= HOOK_START; // mark start hook as fired
- }
+
+ calledhooks |= HOOK_START; // mark start hook as fired
}
}
+
// CSQC_Parse_StuffCmd : Provides the stuffcmd string in the first parameter that the server provided. To execute standard behavior, simply execute localcmd with the string.
void CSQC_Parse_StuffCmd(string strMessage)
{
if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")", strMessage);
localcmd(strMessage);
}
+
// CSQC_Parse_Print : Provides the print string in the first parameter that the server provided. To execute standard behavior, simply execute print with the string.
void CSQC_Parse_Print(string strMessage)
{
else if(game_stopped_time && !STAT(GAME_STOPPED))
game_stopped_time = 0;
- // fire intermission hooks here
- // game/demo end hooks are executed on CSQC VM shutdown
- if(intermission && !(calledhooks & HOOK_INTERMISSION))
+ // fire intermission hooks and gameend hook here
+ // gameend hook is executed on CSQC VM shutdown if
+ // the shutdown happens before intermission start
+ if(intermission
+ && (calledhooks & HOOK_START) // ensure that we have initiated a gamemode
+ && !(calledhooks & HOOK_END)) // fire only once
+ && !(calledhooks & HOOK_INTERMISSION)
{
if(!isdemo())
{
- // ensure that we have properly initiated a gamemode
- // before firing this hook. gamestart -> intermission
- if(calledhooks & HOOK_START)
- {
- localcmd("\ncl_hook_intermission\n");
- calledhooks |= HOOK_INTERMISSION;
- }
+ int gamecount = cvar("cl_matchcount");
+ localcmd("\ncl_hook_gameend\n");
+ // NOTE: using localcmd here to ensure it's executed AFTER cl_hook_gameend
+ // earlier versions of the game abuse the hook to set this cvar
+ localcmd(strcat("cl_matchcount ", itos(gamecount + 1), "\n"));
+ //cvar_set("cl_matchcount", itos(gamecount + 1));
+ calledhooks |= HOOK_END;
+
+ localcmd("\ncl_hook_intermission\n");
+ calledhooks |= HOOK_INTERMISSION;
}
else
{
- // ensure that we have properly initiated a gamemode
- // before firing this hook. demostart -> intermission
- if(calledhooks & HOOK_START)
- {
- localcmd("\ncl_hook_demointermission\n");
- calledhooks |= HOOK_INTERMISSION;
- }
+ localcmd("\ncl_hook_demointermission\n");
+ calledhooks |= HOOK_INTERMISSION;
}
}