mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +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 loaded, to_load;
|
||||
volatile bool in_progress;
|
||||
bool lock;
|
||||
double time;
|
||||
ALLEGRO_BITMAP* fb;
|
||||
} loading;
|
||||
|
|
|
@ -245,6 +245,7 @@ static inline bool MainloopTick(struct Game* game) {
|
|||
|
||||
game->_priv.loading.to_load = 0;
|
||||
game->_priv.loading.loaded = 0;
|
||||
game->_priv.loading.lock = true;
|
||||
game->loading.progress = 0;
|
||||
|
||||
// TODO: support gamestate dependences/ordering
|
||||
|
@ -407,6 +408,8 @@ static inline bool MainloopTick(struct Game* game) {
|
|||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
game->_priv.loading.lock = false;
|
||||
|
||||
if (!gameActive) {
|
||||
PrintConsole(game, "No gamestates left, exiting...");
|
||||
return false;
|
||||
|
@ -438,6 +441,9 @@ static inline bool MainloopTick(struct Game* game) {
|
|||
}
|
||||
|
||||
SYMBOL_EXPORT bool libsuperderpy_mainloop(struct Game* game) {
|
||||
ClearGarbage(game);
|
||||
return MainloopEvents(game) && MainloopTick(game);
|
||||
if (game->_priv.loading.lock) {
|
||||
return true;
|
||||
}
|
||||
ClearGarbage(game);
|
||||
return MainloopEvents(game) && MainloopTick(game) && MainloopEvents(game);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue