mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +01:00
don't live-reload gamestates that don't come from dynamic libraries
This commit is contained in:
parent
f4ca431238
commit
31f6b8454d
3 changed files with 14 additions and 9 deletions
|
@ -58,6 +58,7 @@ SYMBOL_EXPORT void RegisterGamestate(struct Game* game, const char* name, struct
|
|||
return;
|
||||
}
|
||||
gs->api = api;
|
||||
gs->fromlib = false;
|
||||
PrintConsole(game, "Gamestate \"%s\" registered.", name);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ struct Gamestate {
|
|||
bool frozen;
|
||||
bool showLoading;
|
||||
bool paused;
|
||||
bool fromlib;
|
||||
struct Gamestate* next;
|
||||
struct Gamestate_API* api;
|
||||
ALLEGRO_BITMAP* fb;
|
||||
|
|
|
@ -340,6 +340,7 @@ SYMBOL_INTERNAL struct Gamestate* AllocateGamestate(struct Game* game, const cha
|
|||
tmp->pending_unload = false;
|
||||
tmp->next = NULL;
|
||||
tmp->api = NULL;
|
||||
tmp->fromlib = true;
|
||||
tmp->progressCount = 0;
|
||||
return tmp;
|
||||
}
|
||||
|
@ -543,17 +544,19 @@ SYMBOL_INTERNAL void ResumeExecution(struct Game* game) {
|
|||
PrintConsole(game, "DEBUG: reloading the gamestates...");
|
||||
struct Gamestate* tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
char* name = strdup(tmp->name);
|
||||
CloseGamestate(game, tmp);
|
||||
tmp->name = name;
|
||||
if (OpenGamestate(game, tmp) && LinkGamestate(game, tmp) && tmp->loaded) {
|
||||
if (tmp->api->Gamestate_Reload) {
|
||||
tmp->api->Gamestate_Reload(game, tmp->data);
|
||||
}
|
||||
if (!tmp->paused && tmp->api->Gamestate_Resume) {
|
||||
tmp->api->Gamestate_Resume(game, tmp->data);
|
||||
if (tmp->fromlib) {
|
||||
char* name = strdup(tmp->name);
|
||||
CloseGamestate(game, tmp);
|
||||
tmp->name = name;
|
||||
if (OpenGamestate(game, tmp) && LinkGamestate(game, tmp) && tmp->loaded) {
|
||||
if (tmp->api->Gamestate_Reload) {
|
||||
tmp->api->Gamestate_Reload(game, tmp->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tmp->paused && tmp->loaded && tmp->api->Gamestate_Resume) {
|
||||
tmp->api->Gamestate_Resume(game, tmp->data);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
game->_priv.paused = false;
|
||||
|
|
Loading…
Reference in a new issue