src/openttd.cpp
branchnoai
changeset 10294 7798ae816af8
parent 10249 58810805030e
child 10355 ee4b5f7a5bf2
--- a/src/openttd.cpp	Mon Apr 21 20:52:54 2008 +0000
+++ b/src/openttd.cpp	Mon Apr 21 21:15:50 2008 +0000
@@ -59,6 +59,8 @@
 #include "date_func.h"
 #include "vehicle_func.h"
 #include "cheat_func.h"
+#include "animated_tile_func.h"
+#include "functions.h"
 
 #include "newgrf.h"
 #include "newgrf_config.h"
@@ -93,6 +95,8 @@
 void DoPaletteAnimations();
 void MusicLoop();
 void ResetMusic();
+void ResetOldNames();
+void ProcessAsyncSaveFinish();
 
 extern void SetDifficultyLevel(int mode, GameOptions *gm_opt);
 extern Player* DoStartupNewPlayer(bool is_ai);
@@ -654,39 +658,6 @@
 	}
 }
 
-
-/** 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) {
@@ -1104,9 +1075,7 @@
 
 void GameLoop()
 {
-	ThreadMsg message;
-
-	if ((message = OTTD_PollThreadEvent()) != 0) ProcessSentMessage(message);
+	ProcessAsyncSaveFinish();
 
 	/* autosave game? */
 	if (_do_autosave) {
@@ -1400,6 +1369,9 @@
 		}
 	}
 
+	/* From this point the old names array is cleared. */
+	ResetOldNames();
+
 	/* convert road side to my format. */
 	if (_opt.road_side) _opt.road_side = 1;