summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-19 10:18:38 +0000
committerrubidium <rubidium@openttd.org>2008-04-19 10:18:38 +0000
commit161b58863144b9677ce8d8cdce0f23be33ddab49 (patch)
tree4be252134284abf1ac2d62c17a3d71b160a34a2d /src/openttd.cpp
parente0722751c6515dadfba4944ed35f3fa6f6bcd751 (diff)
downloadopenttd-161b58863144b9677ce8d8cdce0f23be33ddab49.tar.xz
(svn r12784) -Codechange: handle the asynchronious save 'handlers' in saveload.cpp instead of openttd.cpp.
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp38
1 files changed, 2 insertions, 36 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index ae7b0ced5..bc12123df 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -92,6 +92,7 @@ void DoPaletteAnimations();
void MusicLoop();
void ResetMusic();
void ResetOldNames();
+void ProcessAsyncSaveFinish();
extern void SetDifficultyLevel(int mode, GameOptions *gm_opt);
extern Player* DoStartupNewPlayer(bool is_ai);
@@ -645,39 +646,6 @@ void HandleExitGameRequest()
}
}
-
-/** Mutex so that only one thread can communicate with the main program
- * at any given time */
-static ThreadMsg _message = MSG_OTTD_NO_MESSAGE;
-
-static inline void OTTD_ReleaseMutex() {_message = MSG_OTTD_NO_MESSAGE;}
-static inline ThreadMsg OTTD_PollThreadEvent() {return _message;}
-
-/** Called by running thread to execute some action in the main game.
- * It will stall as long as the mutex is not freed (handled) by the game */
-void OTTD_SendThreadMessage(ThreadMsg msg)
-{
- if (_exit_game) return;
- while (_message != MSG_OTTD_NO_MESSAGE) CSleep(10);
-
- _message = msg;
-}
-
-
-/** Handle the user-messages sent to us
- * @param message message sent
- */
-static void ProcessSentMessage(ThreadMsg message)
-{
- switch (message) {
- case MSG_OTTD_SAVETHREAD_DONE: SaveFileDone(); break;
- case MSG_OTTD_SAVETHREAD_ERROR: SaveFileError(); break;
- default: NOT_REACHED();
- }
-
- OTTD_ReleaseMutex(); // release mutex so that other threads, messages can be handled
-}
-
static void ShowScreenshotResult(bool b)
{
if (b) {
@@ -1095,9 +1063,7 @@ static void HandleKeyScrolling()
void GameLoop()
{
- ThreadMsg message;
-
- if ((message = OTTD_PollThreadEvent()) != 0) ProcessSentMessage(message);
+ ProcessAsyncSaveFinish();
/* autosave game? */
if (_do_autosave) {