mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-03-04 17:21:27 +01:00
loading: call Gamestate_Logic in single thread mode as well
This commit is contained in:
parent
a9c318dd78
commit
01ae741558
3 changed files with 7 additions and 3 deletions
|
@ -250,9 +250,12 @@ SYMBOL_INTERNAL void GamestateProgress(struct Game* game) {
|
||||||
}
|
}
|
||||||
#ifdef LIBSUPERDERPY_SINGLE_THREAD
|
#ifdef LIBSUPERDERPY_SINGLE_THREAD
|
||||||
DrawGamestates(game);
|
DrawGamestates(game);
|
||||||
|
double delta = al_get_time() - game->_priv.loading.time;
|
||||||
if (tmp->showLoading) {
|
if (tmp->showLoading) {
|
||||||
|
(*game->_priv.loading.gamestate->api->Gamestate_Logic)(game, game->_priv.loading.gamestate->data, delta);
|
||||||
(*game->_priv.loading.gamestate->api->Gamestate_Draw)(game, game->_priv.loading.gamestate->data);
|
(*game->_priv.loading.gamestate->api->Gamestate_Draw)(game, game->_priv.loading.gamestate->data);
|
||||||
}
|
}
|
||||||
|
game->_priv.loading.time += delta;
|
||||||
DrawConsole(game);
|
DrawConsole(game);
|
||||||
al_flip_display();
|
al_flip_display();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -398,19 +398,19 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) {
|
||||||
|
|
||||||
struct GamestateLoadingThreadData data = {.game = game, .gamestate = tmp, .bitmap_flags = al_get_new_bitmap_flags()};
|
struct GamestateLoadingThreadData data = {.game = game, .gamestate = tmp, .bitmap_flags = al_get_new_bitmap_flags()};
|
||||||
game->_priv.loading.inProgress = true;
|
game->_priv.loading.inProgress = true;
|
||||||
|
game->_priv.loading.time = al_get_time();
|
||||||
|
|
||||||
#ifndef LIBSUPERDERPY_SINGLE_THREAD
|
#ifndef LIBSUPERDERPY_SINGLE_THREAD
|
||||||
al_run_detached_thread(GamestateLoadingThread, &data);
|
al_run_detached_thread(GamestateLoadingThread, &data);
|
||||||
double time = al_get_time();
|
|
||||||
while (game->_priv.loading.inProgress) {
|
while (game->_priv.loading.inProgress) {
|
||||||
DrawGamestates(game);
|
DrawGamestates(game);
|
||||||
al_set_target_backbuffer(game->display);
|
al_set_target_backbuffer(game->display);
|
||||||
double delta = al_get_time() - time;
|
double delta = al_get_time() - game->_priv.loading.time;
|
||||||
if (tmp->showLoading) {
|
if (tmp->showLoading) {
|
||||||
(*game->_priv.loading.gamestate->api->Gamestate_Logic)(game, game->_priv.loading.gamestate->data, delta);
|
(*game->_priv.loading.gamestate->api->Gamestate_Logic)(game, game->_priv.loading.gamestate->data, delta);
|
||||||
(*game->_priv.loading.gamestate->api->Gamestate_Draw)(game, game->_priv.loading.gamestate->data);
|
(*game->_priv.loading.gamestate->api->Gamestate_Draw)(game, game->_priv.loading.gamestate->data);
|
||||||
}
|
}
|
||||||
time += delta;
|
game->_priv.loading.time += delta;
|
||||||
DrawConsole(game);
|
DrawConsole(game);
|
||||||
al_flip_display();
|
al_flip_display();
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@ struct Game {
|
||||||
int progress;
|
int progress;
|
||||||
int loaded, toLoad;
|
int loaded, toLoad;
|
||||||
bool inProgress;
|
bool inProgress;
|
||||||
|
double time;
|
||||||
} loading;
|
} loading;
|
||||||
|
|
||||||
struct Gamestate* current_gamestate;
|
struct Gamestate* current_gamestate;
|
||||||
|
|
Loading…
Add table
Reference in a new issue