57 #include "group.h" |
57 #include "group.h" |
58 #include "strings_func.h" |
58 #include "strings_func.h" |
59 #include "date_func.h" |
59 #include "date_func.h" |
60 #include "vehicle_func.h" |
60 #include "vehicle_func.h" |
61 #include "cheat_func.h" |
61 #include "cheat_func.h" |
|
62 #include "animated_tile_func.h" |
|
63 #include "functions.h" |
62 |
64 |
63 #include "newgrf.h" |
65 #include "newgrf.h" |
64 #include "newgrf_config.h" |
66 #include "newgrf_config.h" |
65 #include "newgrf_house.h" |
67 #include "newgrf_house.h" |
66 #include "newgrf_commons.h" |
68 #include "newgrf_commons.h" |
91 void CallLandscapeTick(); |
93 void CallLandscapeTick(); |
92 void IncreaseDate(); |
94 void IncreaseDate(); |
93 void DoPaletteAnimations(); |
95 void DoPaletteAnimations(); |
94 void MusicLoop(); |
96 void MusicLoop(); |
95 void ResetMusic(); |
97 void ResetMusic(); |
|
98 void ResetOldNames(); |
|
99 void ProcessAsyncSaveFinish(); |
96 |
100 |
97 extern void SetDifficultyLevel(int mode, GameOptions *gm_opt); |
101 extern void SetDifficultyLevel(int mode, GameOptions *gm_opt); |
98 extern Player* DoStartupNewPlayer(bool is_ai); |
102 extern Player* DoStartupNewPlayer(bool is_ai); |
99 extern void ShowOSErrorBox(const char *buf); |
103 extern void ShowOSErrorBox(const char *buf); |
100 extern void InitializeRailGUI(); |
104 extern void InitializeRailGUI(); |
652 } else { |
656 } else { |
653 AskExitGame(); |
657 AskExitGame(); |
654 } |
658 } |
655 } |
659 } |
656 |
660 |
657 |
|
658 /** Mutex so that only one thread can communicate with the main program |
|
659 * at any given time */ |
|
660 static ThreadMsg _message = MSG_OTTD_NO_MESSAGE; |
|
661 |
|
662 static inline void OTTD_ReleaseMutex() {_message = MSG_OTTD_NO_MESSAGE;} |
|
663 static inline ThreadMsg OTTD_PollThreadEvent() {return _message;} |
|
664 |
|
665 /** Called by running thread to execute some action in the main game. |
|
666 * It will stall as long as the mutex is not freed (handled) by the game */ |
|
667 void OTTD_SendThreadMessage(ThreadMsg msg) |
|
668 { |
|
669 if (_exit_game) return; |
|
670 while (_message != MSG_OTTD_NO_MESSAGE) CSleep(10); |
|
671 |
|
672 _message = msg; |
|
673 } |
|
674 |
|
675 |
|
676 /** Handle the user-messages sent to us |
|
677 * @param message message sent |
|
678 */ |
|
679 static void ProcessSentMessage(ThreadMsg message) |
|
680 { |
|
681 switch (message) { |
|
682 case MSG_OTTD_SAVETHREAD_DONE: SaveFileDone(); break; |
|
683 case MSG_OTTD_SAVETHREAD_ERROR: SaveFileError(); break; |
|
684 default: NOT_REACHED(); |
|
685 } |
|
686 |
|
687 OTTD_ReleaseMutex(); // release mutex so that other threads, messages can be handled |
|
688 } |
|
689 |
|
690 static void ShowScreenshotResult(bool b) |
661 static void ShowScreenshotResult(bool b) |
691 { |
662 { |
692 if (b) { |
663 if (b) { |
693 SetDParamStr(0, _screenshot_name); |
664 SetDParamStr(0, _screenshot_name); |
694 ShowErrorMessage(INVALID_STRING_ID, STR_031B_SCREENSHOT_SUCCESSFULLY, 0, 0); |
665 ShowErrorMessage(INVALID_STRING_ID, STR_031B_SCREENSHOT_SUCCESSFULLY, 0, 0); |
1397 FOR_ALL_WAYPOINTS(wp) { |
1366 FOR_ALL_WAYPOINTS(wp) { |
1398 wp->name = CopyFromOldName(wp->string); |
1367 wp->name = CopyFromOldName(wp->string); |
1399 wp->string = STR_EMPTY; |
1368 wp->string = STR_EMPTY; |
1400 } |
1369 } |
1401 } |
1370 } |
|
1371 |
|
1372 /* From this point the old names array is cleared. */ |
|
1373 ResetOldNames(); |
1402 |
1374 |
1403 /* convert road side to my format. */ |
1375 /* convert road side to my format. */ |
1404 if (_opt.road_side) _opt.road_side = 1; |
1376 if (_opt.road_side) _opt.road_side = 1; |
1405 |
1377 |
1406 /* Check if all NewGRFs are present, we are very strict in MP mode */ |
1378 /* Check if all NewGRFs are present, we are very strict in MP mode */ |