summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-06-05 13:32:42 +0000
committerfrosch <frosch@openttd.org>2010-06-05 13:32:42 +0000
commit9e53f1e004bf8e65f268b8854a6eb08229e3f2ed (patch)
treefa373b8ec4b6089ac9c1e51f168d44434df8c238 /src/window.cpp
parente852bf154f2af40b3cee1f67bef41a78c2056de5 (diff)
downloadopenttd-9e53f1e004bf8e65f268b8854a6eb08229e3f2ed.tar.xz
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 4f147a670..f15293ea3 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1918,16 +1918,9 @@ static bool MaybeBringWindowToFront(Window *w)
*/
void HandleKeypress(uint32 raw_key)
{
- /*
- * During the generation of the world, there might be
- * another thread that is currently building for example
- * a road. To not interfere with those tasks, we should
- * NOT change the _current_company here.
- *
- * This is not necessary either, as the only events that
- * can be handled are the 'close application' events
- */
- if (!IsGeneratingWorld()) _current_company = _local_company;
+ /* World generation is multithreaded and messes with companies.
+ * But there is no company related window open anyway, so _current_company is not used. */
+ assert(IsGeneratingWorld() || _local_company == _current_company);
/* Setup event */
uint16 key = GB(raw_key, 0, 16);
@@ -2083,6 +2076,10 @@ static void HandleKeyScrolling()
static void MouseLoop(MouseClick click, int mousewheel)
{
+ /* World generation is multithreaded and messes with companies.
+ * But there is no company related window open anyway, so _current_company is not used. */
+ assert(IsGeneratingWorld() || _local_company == _current_company);
+
HandlePlacePresize();
UpdateTileSelection();
@@ -2183,21 +2180,14 @@ static void MouseLoop(MouseClick click, int mousewheel)
*/
void HandleMouseEvents()
{
+ /* World generation is multithreaded and messes with companies.
+ * But there is no company related window open anyway, so _current_company is not used. */
+ assert(IsGeneratingWorld() || _local_company == _current_company);
+
static int double_click_time = 0;
static int double_click_x = 0;
static int double_click_y = 0;
- /*
- * During the generation of the world, there might be
- * another thread that is currently building for example
- * a road. To not interfere with those tasks, we should
- * NOT change the _current_company here.
- *
- * This is not necessary either, as the only events that
- * can be handled are the 'close application' events
- */
- if (!IsGeneratingWorld()) _current_company = _local_company;
-
/* Mouse event? */
MouseClick click = MC_NONE;
if (_left_button_down && !_left_button_clicked) {
@@ -2280,6 +2270,10 @@ static void CheckSoftLimit()
*/
void InputLoop()
{
+ /* World generation is multithreaded and messes with companies.
+ * But there is no company related window open anyway, so _current_company is not used. */
+ assert(IsGeneratingWorld() || _local_company == _current_company);
+
CheckSoftLimit();
HandleKeyScrolling();