(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.

This commit is contained in:
frosch
2010-06-05 13:32:42 +00:00
parent 6c1a2a2009
commit 65d058723e
7 changed files with 54 additions and 39 deletions

View File

@@ -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();