From a8960f64be1a7796e90e2634fc2a5419e369f0b5 Mon Sep 17 00:00:00 2001 From: truebrain Date: Sat, 10 Dec 2011 21:07:04 +0000 Subject: [PATCH] (svn r23486) -Fix (r22764): 3 for the price of 1: fix up ScriptTile::GetTownAuthority() (tnx to Torrasque for reporting) --- bin/ai/regression/regression.nut | 8 + bin/ai/regression/regression.txt | 335 ++++++++++++++++++++++++++++++- src/script/api/script_tile.cpp | 12 +- 3 files changed, 351 insertions(+), 4 deletions(-) diff --git a/bin/ai/regression/regression.nut b/bin/ai/regression/regression.nut index b1a0da6a9a..107ff49491 100644 --- a/bin/ai/regression/regression.nut +++ b/bin/ai/regression/regression.nut @@ -1391,11 +1391,19 @@ function Regression::TileList() for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { print(" " + i + " => " + list.GetValue(i)); } + + list.AddRectangle(31895 - 256 * 5, 256 * 5 + 31895 + 8); + list.Valuate(AITile.GetOwner); print(" GetOwner() ListDump:"); for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { print(" " + i + " => " + list.GetValue(i)); } + list.Valuate(AITile.GetTownAuthority); + print(" GetTownAuthority() ListDump:"); + for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { + print(" " + i + " => " + list.GetValue(i)); + } list.Valuate(AITile.GetClosestTown); print(" GetClosestTown() ListDump:"); for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { diff --git a/bin/ai/regression/regression.txt b/bin/ai/regression/regression.txt index 41c855814f..e01a4b2419 100644 --- a/bin/ai/regression/regression.txt +++ b/bin/ai/regression/regression.txt @@ -7863,7 +7863,247 @@ ERROR: IsEnd() is invalid as Begin() is never called 41386 => -1 41385 => -1 41384 => -1 + 33183 => -1 + 33182 => -1 + 33181 => -1 + 33180 => -1 + 33179 => -1 + 33178 => -1 + 33177 => -1 + 33176 => -1 + 33175 => -1 + 32927 => -1 + 32926 => -1 + 32925 => -1 + 32924 => -1 + 32923 => -1 + 32922 => -1 + 32921 => -1 + 32920 => -1 + 32919 => -1 + 32671 => -1 + 32670 => -1 + 32669 => -1 + 32668 => -1 + 32667 => -1 + 32666 => -1 + 32665 => -1 + 32664 => -1 + 32663 => -1 + 32415 => -1 + 32414 => -1 + 32413 => -1 + 32412 => -1 + 32411 => -1 + 32410 => -1 + 32409 => -1 + 32408 => -1 + 32407 => -1 + 32159 => -1 + 32158 => -1 + 32157 => -1 + 32156 => -1 + 32155 => -1 + 32154 => -1 + 32153 => -1 + 32152 => -1 + 32151 => -1 + 31903 => -1 + 31902 => -1 + 31901 => -1 + 31900 => -1 + 31899 => -1 + 31898 => -1 + 31897 => -1 + 31896 => -1 + 31895 => -1 + 31647 => -1 + 31646 => -1 + 31645 => -1 + 31644 => -1 + 31643 => -1 + 31642 => -1 + 31641 => -1 + 31640 => -1 + 31639 => -1 + 31391 => -1 + 31390 => -1 + 31389 => -1 + 31388 => -1 + 31387 => -1 + 31386 => -1 + 31385 => -1 + 31384 => -1 + 31383 => -1 + 31135 => -1 + 31134 => -1 + 31133 => -1 + 31132 => -1 + 31131 => -1 + 31130 => -1 + 31129 => -1 + 31128 => -1 + 31127 => -1 + 30879 => -1 + 30878 => -1 + 30877 => -1 + 30876 => -1 + 30875 => -1 + 30874 => -1 + 30873 => -1 + 30872 => -1 + 30871 => -1 + 30623 => -1 + 30622 => -1 + 30621 => -1 + 30620 => -1 + 30619 => -1 + 30618 => -1 + 30617 => -1 + 30616 => -1 + 30615 => -1 + GetTownAuthority() ListDump: + 33183 => 65535 + 33182 => 65535 + 33181 => 65535 + 33180 => 65535 + 33179 => 65535 + 33178 => 65535 + 33177 => 65535 + 33176 => 65535 + 33175 => 65535 + 32927 => 65535 + 32926 => 65535 + 32925 => 65535 + 32924 => 65535 + 32923 => 65535 + 32922 => 65535 + 32921 => 65535 + 32920 => 65535 + 32919 => 65535 + 32671 => 65535 + 32670 => 65535 + 32669 => 65535 + 32668 => 65535 + 32667 => 65535 + 32666 => 65535 + 32665 => 65535 + 32664 => 65535 + 32663 => 65535 + 32415 => 65535 + 32414 => 65535 + 32413 => 65535 + 32412 => 65535 + 32411 => 65535 + 32410 => 65535 + 32409 => 65535 + 32408 => 65535 + 32407 => 65535 + 32159 => 65535 + 32158 => 65535 + 32157 => 65535 + 32156 => 65535 + 32155 => 65535 + 32154 => 65535 + 32153 => 65535 + 32152 => 65535 + 32151 => 65535 + 31903 => 65535 + 31902 => 65535 + 31901 => 65535 + 31900 => 65535 + 31899 => 65535 + 31898 => 65535 + 31897 => 65535 + 31896 => 65535 + 31895 => 65535 + 31647 => 65535 + 31646 => 65535 + 31645 => 65535 + 31644 => 65535 + 31643 => 65535 + 31642 => 65535 + 31641 => 65535 + 31640 => 65535 + 31639 => 65535 + 31391 => 65535 + 31390 => 65535 + 31389 => 65535 + 31388 => 65535 + 31387 => 65535 + 31386 => 65535 + 31385 => 65535 + 31384 => 65535 + 31383 => 65535 + 31135 => 65535 + 31134 => 65535 + 31133 => 65535 + 31132 => 65535 + 31131 => 65535 + 31130 => 65535 + 31129 => 65535 + 31128 => 65535 + 31127 => 65535 + 30879 => 65535 + 30878 => 65535 + 30877 => 65535 + 30876 => 65535 + 30875 => 65535 + 30874 => 65535 + 30873 => 65535 + 30872 => 65535 + 30871 => 65535 + 30623 => 65535 + 30622 => 65535 + 30621 => 65535 + 30620 => 65535 + 30619 => 65535 + 30618 => 65535 + 30617 => 65535 + 30616 => 65535 + 30615 => 65535 + 42415 => 3 + 42414 => 3 + 42413 => 3 + 42412 => 3 + 42411 => 3 + 42410 => 3 + 42159 => 3 + 42158 => 3 + 42157 => 3 + 42156 => 3 + 42155 => 3 + 42154 => 3 + 42153 => 3 + 41903 => 3 + 41902 => 3 + 41901 => 3 + 41900 => 3 + 41899 => 3 + 41898 => 3 + 41897 => 3 + 41647 => 3 + 41646 => 3 + 41645 => 3 + 41644 => 3 + 41643 => 3 + 41642 => 3 + 41641 => 3 + 41391 => 3 + 41390 => 3 + 41389 => 3 + 41388 => 3 + 41387 => 3 + 41386 => 3 + 41385 => 3 + 41384 => 3 GetClosestTown() ListDump: + 31127 => 24 + 30872 => 24 + 30871 => 24 + 30617 => 24 + 30616 => 24 + 30615 => 24 42415 => 3 42414 => 3 42413 => 3 @@ -7899,6 +8139,99 @@ ERROR: IsEnd() is invalid as Begin() is never called 41386 => 3 41385 => 3 41384 => 3 + 33183 => 3 + 33182 => 3 + 33181 => 3 + 33180 => 3 + 33179 => 3 + 33178 => 3 + 33177 => 3 + 33176 => 3 + 33175 => 3 + 32927 => 3 + 32926 => 3 + 32925 => 3 + 32924 => 3 + 32923 => 3 + 32922 => 3 + 32921 => 3 + 32920 => 3 + 32919 => 3 + 32671 => 3 + 32670 => 3 + 32669 => 3 + 32668 => 3 + 32667 => 3 + 32666 => 3 + 32665 => 3 + 32664 => 3 + 32663 => 3 + 32415 => 3 + 32414 => 3 + 32413 => 3 + 32412 => 3 + 32411 => 3 + 32410 => 3 + 32409 => 3 + 32408 => 3 + 32407 => 3 + 32159 => 3 + 32158 => 3 + 32157 => 3 + 32156 => 3 + 32155 => 3 + 32154 => 3 + 32153 => 3 + 32152 => 3 + 32151 => 3 + 31903 => 3 + 31902 => 3 + 31901 => 3 + 31900 => 3 + 31899 => 3 + 31898 => 3 + 31897 => 3 + 31896 => 3 + 31895 => 3 + 31647 => 3 + 31646 => 3 + 31645 => 3 + 31644 => 3 + 31643 => 3 + 31642 => 3 + 31641 => 3 + 31640 => 3 + 31639 => 3 + 31391 => 3 + 31390 => 3 + 31389 => 3 + 31388 => 3 + 31387 => 3 + 31386 => 3 + 31385 => 3 + 31384 => 3 + 31383 => 3 + 31135 => 3 + 31134 => 3 + 31133 => 3 + 31132 => 3 + 31131 => 3 + 31130 => 3 + 31129 => 3 + 31128 => 3 + 30879 => 3 + 30878 => 3 + 30877 => 3 + 30876 => 3 + 30875 => 3 + 30874 => 3 + 30873 => 3 + 30623 => 3 + 30622 => 3 + 30621 => 3 + 30620 => 3 + 30619 => 3 + 30618 => 3 CargoAcceptance(): done KeepAboveValue(10): done Count(): 15 @@ -8618,7 +8951,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetWagonEngineType(): 27 GetWagonAge(): 1 GetWagonEngineType(): 27 - GetWagonAge(): 0 + GetWagonAge(): 1 GetWagonEngineType(): 65535 GetWagonAge(): -1 --Errors-- diff --git a/src/script/api/script_tile.cpp b/src/script/api/script_tile.cpp index b898b9c153..c0855b902f 100644 --- a/src/script/api/script_tile.cpp +++ b/src/script/api/script_tile.cpp @@ -270,16 +270,22 @@ /* static */ TownID ScriptTile::GetTownAuthority(TileIndex tile) { - if (!::IsValidTile(tile)) return false; + if (!::IsValidTile(tile)) return INVALID_TOWN; - return ::ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority)->index; + Town *town = ::ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); + if (town == NULL) return INVALID_TOWN; + + return town->index; } /* static */ TownID ScriptTile::GetClosestTown(TileIndex tile) { if (!::IsValidTile(tile)) return INVALID_TOWN; - return ::ClosestTownFromTile(tile, UINT_MAX)->index; + Town *town = ::ClosestTownFromTile(tile, UINT_MAX); + if (town == NULL) return INVALID_TOWN; + + return town->index; } /* static */ Money ScriptTile::GetBuildCost(BuildType build_type)