(svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation

-Codechange: rewrite parts of code responsible for caching index of nearest town
This commit is contained in:
smatz
2008-11-18 22:43:59 +00:00
parent 6386deb708
commit 698f05e756
7 changed files with 70 additions and 41 deletions

View File

@@ -725,14 +725,15 @@ public:
this->HandleButtonClick(TSEW_RANDOMTOWN);
_generating_world = true;
UpdateNearestTownForRoadTiles(true);
t = CreateRandomTown(20, mode, size);
UpdateNearestTownForRoadTiles(false);
_generating_world = false;
if (t == NULL) {
ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
} else {
ScrollMainWindowToTile(t->xy);
InvalidateTownForRoadTile();
}
} break;
@@ -740,11 +741,11 @@ public:
this->HandleButtonClick(TSEW_MANYRANDOMTOWNS);
_generating_world = true;
UpdateNearestTownForRoadTiles(true);
if (!GenerateTowns()) {
ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
} else {
InvalidateTownForRoadTile();
}
UpdateNearestTownForRoadTiles(false);
_generating_world = false;
break;