X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=2d6b750dbd19b4307f116b607175a56f13ed5fc8;hb=7a8e465114815815796c2ebbe5f2e018a9265a3f;hp=8c0f26e3ede53fd49e6feccfa6ed995f635d7e54;hpb=1cf0e16ba9bfee0897a02d4a7d9d2eccfb8f04b3;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 8c0f26e3..2d6b750d 100644 --- a/src/init.c +++ b/src/init.c @@ -6330,6 +6330,9 @@ void OpenAll(void) print_timestamp_done("OpenAll"); + if (setup.ask_for_remaining_tapes) + setup.ask_for_uploading_tapes = TRUE; + DrawMainMenu(); #if 0 @@ -6351,8 +6354,44 @@ void OpenAll(void) #endif } +static boolean WaitForApiThreads(void) +{ + unsigned int thread_delay = 0; + unsigned int thread_delay_value = 10000; + + if (program.api_thread_count == 0) + return TRUE; + + // deactivate global animations (not accessible in game state "loading") + setup.toons = FALSE; + + // set game state to "loading" to be able to show busy animation + SetGameStatus(GAME_MODE_LOADING); + + ResetDelayCounter(&thread_delay); + + // wait for threads to finish (and fail on timeout) + while (program.api_thread_count > 0) + { + if (DelayReached(&thread_delay, thread_delay_value)) + { + Error("failed waiting for threads - TIMEOUT"); + + return FALSE; + } + + UPDATE_BUSY_STATE(); + + Delay(20); + } + + return TRUE; +} + void CloseAllAndExit(int exit_value) { + WaitForApiThreads(); + StopSounds(); FreeAllSounds(); FreeAllMusic();