don't live-reload gamestates that don't come from dynamic libraries

This commit is contained in:
Sebastian Krzyszkowiak 2018-07-18 19:58:34 +02:00
parent f4ca431238
commit 31f6b8454d
3 changed files with 14 additions and 9 deletions

View file

@ -58,6 +58,7 @@ SYMBOL_EXPORT void RegisterGamestate(struct Game* game, const char* name, struct
return; return;
} }
gs->api = api; gs->api = api;
gs->fromlib = false;
PrintConsole(game, "Gamestate \"%s\" registered.", name); PrintConsole(game, "Gamestate \"%s\" registered.", name);
} }

View file

@ -49,6 +49,7 @@ struct Gamestate {
bool frozen; bool frozen;
bool showLoading; bool showLoading;
bool paused; bool paused;
bool fromlib;
struct Gamestate* next; struct Gamestate* next;
struct Gamestate_API* api; struct Gamestate_API* api;
ALLEGRO_BITMAP* fb; ALLEGRO_BITMAP* fb;

View file

@ -340,6 +340,7 @@ SYMBOL_INTERNAL struct Gamestate* AllocateGamestate(struct Game* game, const cha
tmp->pending_unload = false; tmp->pending_unload = false;
tmp->next = NULL; tmp->next = NULL;
tmp->api = NULL; tmp->api = NULL;
tmp->fromlib = true;
tmp->progressCount = 0; tmp->progressCount = 0;
return tmp; return tmp;
} }
@ -543,6 +544,7 @@ SYMBOL_INTERNAL void ResumeExecution(struct Game* game) {
PrintConsole(game, "DEBUG: reloading the gamestates..."); PrintConsole(game, "DEBUG: reloading the gamestates...");
struct Gamestate* tmp = game->_priv.gamestates; struct Gamestate* tmp = game->_priv.gamestates;
while (tmp) { while (tmp) {
if (tmp->fromlib) {
char* name = strdup(tmp->name); char* name = strdup(tmp->name);
CloseGamestate(game, tmp); CloseGamestate(game, tmp);
tmp->name = name; tmp->name = name;
@ -550,10 +552,11 @@ SYMBOL_INTERNAL void ResumeExecution(struct Game* game) {
if (tmp->api->Gamestate_Reload) { if (tmp->api->Gamestate_Reload) {
tmp->api->Gamestate_Reload(game, tmp->data); tmp->api->Gamestate_Reload(game, tmp->data);
} }
if (!tmp->paused && tmp->api->Gamestate_Resume) {
tmp->api->Gamestate_Resume(game, tmp->data);
} }
} }
if (!tmp->paused && tmp->loaded && tmp->api->Gamestate_Resume) {
tmp->api->Gamestate_Resume(game, tmp->data);
}
tmp = tmp->next; tmp = tmp->next;
} }
game->_priv.paused = false; game->_priv.paused = false;