mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-07 21:56:44 +01:00
emscripten: fix a crash when onvisibilitychange fired during loading
This commit is contained in:
parent
8c7068b48d
commit
871cdf115e
2 changed files with 8 additions and 1 deletions
|
@ -217,6 +217,7 @@ struct Game {
|
||||||
int progress;
|
int progress;
|
||||||
int loaded, to_load;
|
int loaded, to_load;
|
||||||
volatile bool in_progress;
|
volatile bool in_progress;
|
||||||
|
bool lock;
|
||||||
double time;
|
double time;
|
||||||
ALLEGRO_BITMAP* fb;
|
ALLEGRO_BITMAP* fb;
|
||||||
} loading;
|
} loading;
|
||||||
|
|
|
@ -245,6 +245,7 @@ static inline bool MainloopTick(struct Game* game) {
|
||||||
|
|
||||||
game->_priv.loading.to_load = 0;
|
game->_priv.loading.to_load = 0;
|
||||||
game->_priv.loading.loaded = 0;
|
game->_priv.loading.loaded = 0;
|
||||||
|
game->_priv.loading.lock = true;
|
||||||
game->loading.progress = 0;
|
game->loading.progress = 0;
|
||||||
|
|
||||||
// TODO: support gamestate dependences/ordering
|
// TODO: support gamestate dependences/ordering
|
||||||
|
@ -407,6 +408,8 @@ static inline bool MainloopTick(struct Game* game) {
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
game->_priv.loading.lock = false;
|
||||||
|
|
||||||
if (!gameActive) {
|
if (!gameActive) {
|
||||||
PrintConsole(game, "No gamestates left, exiting...");
|
PrintConsole(game, "No gamestates left, exiting...");
|
||||||
return false;
|
return false;
|
||||||
|
@ -438,6 +441,9 @@ static inline bool MainloopTick(struct Game* game) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SYMBOL_EXPORT bool libsuperderpy_mainloop(struct Game* game) {
|
SYMBOL_EXPORT bool libsuperderpy_mainloop(struct Game* game) {
|
||||||
ClearGarbage(game);
|
if (game->_priv.loading.lock) {
|
||||||
return MainloopEvents(game) && MainloopTick(game);
|
return true;
|
||||||
|
}
|
||||||
|
ClearGarbage(game);
|
||||||
|
return MainloopEvents(game) && MainloopTick(game) && MainloopEvents(game);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue