gamestate: move loading time counter to main thread to include PostLoad

This commit is contained in:
Sebastian Krzyszkowiak 2018-07-05 20:59:54 +02:00
parent 521e6bf431
commit c4ceb188f5
2 changed files with 3 additions and 4 deletions

View file

@ -221,9 +221,7 @@ SYMBOL_INTERNAL void* GamestateLoadingThread(void* arg) {
struct GamestateLoadingThreadData* data = arg; struct GamestateLoadingThreadData* data = arg;
data->game->_priv.loading.inProgress = true; data->game->_priv.loading.inProgress = true;
al_set_new_bitmap_flags(data->bitmap_flags); al_set_new_bitmap_flags(data->bitmap_flags);
double time = al_get_time();
data->gamestate->data = (*data->gamestate->api->Gamestate_Load)(data->game, &GamestateProgress); data->gamestate->data = (*data->gamestate->api->Gamestate_Load)(data->game, &GamestateProgress);
PrintConsole(data->game, "[%s] Loading took %f seconds.", data->gamestate->name, al_get_time() - time);
if (data->game->_priv.loading.progress != data->gamestate->progressCount) { if (data->game->_priv.loading.progress != data->gamestate->progressCount) {
PrintConsole(data->game, "[%s] WARNING: Gamestate_ProgressCount does not match the number of progress invokations (%d)!", data->gamestate->name, data->game->_priv.loading.progress); PrintConsole(data->game, "[%s] WARNING: Gamestate_ProgressCount does not match the number of progress invokations (%d)!", data->gamestate->name, data->game->_priv.loading.progress);
if (data->game->config.debug) { if (data->game->config.debug) {

View file

@ -415,7 +415,8 @@ 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(); double time = al_get_time();
game->_priv.loading.time = time;
CalculateProgress(game); CalculateProgress(game);
#ifndef LIBSUPERDERPY_SINGLE_THREAD #ifndef LIBSUPERDERPY_SINGLE_THREAD
@ -451,7 +452,7 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) {
game->_priv.loading.progress++; game->_priv.loading.progress++;
CalculateProgress(game); CalculateProgress(game);
PrintConsole(game, "Gamestate \"%s\" loaded successfully.", tmp->name); PrintConsole(game, "Gamestate \"%s\" loaded successfully in %f seconds.", tmp->name, al_get_time() - time);
game->_priv.loading.loaded++; game->_priv.loading.loaded++;
tmp->loaded = true; tmp->loaded = true;