Skip to content

Commit 065fa21

Browse files
committed
Skip executing FrameDispather on game startup
FrameDispatcher is responsible for frame hooks and methods, that are scheduled via minqlx.delay and minqlx.next_frame decorators. Before this patch, there could be unwanted situations, where self.game is None inside those methods. After this patch self.game is always non-None.
1 parent 5ff4abe commit 065fa21

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

hooks.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
void* qagame;
2121
void* qagame_dllentry;
2222

23+
qboolean skipFrameDispatcher;
2324
static void SetTag(void);
2425

2526
void __cdecl My_Cmd_AddCommand(char* cmd, void* func) {
@@ -156,7 +157,9 @@ void __cdecl My_Com_Printf(char* fmt, ...) {
156157
}
157158

158159
void __cdecl My_SV_SpawnServer(char* server, qboolean killBots) {
160+
skipFrameDispatcher = qtrue;
159161
SV_SpawnServer(server, killBots);
162+
skipFrameDispatcher = qfalse;
160163

161164
// We call NewGameDispatcher here instead of G_InitGame when it's not just a map_restart,
162165
// otherwise configstring 0 and such won't be initialized and we can't instantiate minqlx.Game.
@@ -165,7 +168,11 @@ void __cdecl My_SV_SpawnServer(char* server, qboolean killBots) {
165168

166169
void __cdecl My_G_RunFrame(int time) {
167170
// Dropping frames is probably not a good idea, so we don't allow cancelling.
168-
FrameDispatcher();
171+
172+
if (!skipFrameDispatcher) {
173+
// Skip running frame hooks while game is not initialized
174+
FrameDispatcher();
175+
}
169176

170177
G_RunFrame(time);
171178
}

0 commit comments

Comments
 (0)