gmaestate: automatically load unloaded gamestate when trying to start it

This commit is contained in:
Sebastian Krzyszkowiak 2018-07-18 19:50:35 +02:00
parent 91a3bd1efa
commit f4ca431238

View file

@ -95,6 +95,7 @@ SYMBOL_EXPORT void UnloadGamestate(struct Game* game, const char* name) {
PrintConsole(game, "Gamestate \"%s\" marked to be UNLOADED.", name);
} else {
PrintConsole(game, "Tried to unload nonexisitent gamestate \"%s\"", name);
return;
}
game->_priv.gamestate_scheduled = true;
}
@ -106,10 +107,15 @@ SYMBOL_EXPORT void StartGamestate(struct Game* game, const char* name) {
PrintConsole(game, "Gamestate \"%s\" already started.", name);
return;
}
if (!gs->loaded) {
LoadGamestate(game, name);
}
gs->pending_start = true;
PrintConsole(game, "Gamestate \"%s\" marked to be STARTED.", name);
} else {
PrintConsole(game, "Tried to start nonexisitent gamestate \"%s\"", name);
// trying to start a gamestate that's not registered yet
LoadGamestate(game, name);
return StartGamestate(game, name);
}
game->_priv.gamestate_scheduled = true;
}
@ -130,6 +136,7 @@ SYMBOL_EXPORT void StopGamestate(struct Game* game, const char* name) {
PrintConsole(game, "Gamestate \"%s\" marked to be STOPPED.", name);
} else {
PrintConsole(game, "Tried to stop nonexisitent gamestate \"%s\"", name);
return;
}
game->_priv.gamestate_scheduled = true;
}