summaryrefslogtreecommitdiff
path: root/src/town_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-10-25 13:51:47 +0000
committerrubidium <rubidium@openttd.org>2008-10-25 13:51:47 +0000
commita14ad77a36c836fd3f6940eadeb8161e7ad02f92 (patch)
treeba7c12966aad60d82c8e03bb0593bce949ec2b86 /src/town_gui.cpp
parent9075a2bbfc7c33a089fe100c42b96b831521d6d8 (diff)
downloadopenttd-a14ad77a36c836fd3f6940eadeb8161e7ad02f92.tar.xz
(svn r14528) -Codechange: cache the closest town for all road tiles instead of only roads owned by tiles. This replaces a O(n) search over all towns from the road's tileloop with a O(1) lookup (PhilSophus)
Diffstat (limited to 'src/town_gui.cpp')
-rw-r--r--src/town_gui.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index aee252892..48f8524b1 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -25,6 +25,7 @@
#include "tilehighlight_func.h"
#include "string_func.h"
#include "sortlist_type.h"
+#include "road_cmd.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -731,6 +732,7 @@ public:
ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
} else {
ScrollMainWindowToTile(t->xy);
+ InvalidateTownForRoadTile();
}
} break;
@@ -738,7 +740,11 @@ public:
this->HandleButtonClick(TSEW_MANYRANDOMTOWNS);
_generating_world = true;
- if (!GenerateTowns()) ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
+ if (!GenerateTowns()) {
+ ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
+ } else {
+ InvalidateTownForRoadTile();
+ }
_generating_world = false;
break;
@@ -783,4 +789,3 @@ void ShowBuildTownWindow()
if (_game_mode != GM_EDITOR && !IsValidCompanyID(_current_company)) return;
AllocateWindowDescFront<ScenarioEditorTownGenerationWindow>(&_scen_edit_town_gen_desc, 0);
}
-