(svn r15078) -Fix [NoAI]: AIMap didn't filter its input (Yexo)

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
truebrain 16 years ago
parent e00cf92f47
commit 6fe54a2d1a

@ -6161,8 +6161,8 @@
GetTileIndex(): 123 GetTileIndex(): 123
GetTileIndex(): 31488 GetTileIndex(): 31488
GetTileIndex(): 0 GetTileIndex(): 0
GetTileIndex(): -257 GetTileIndex(): -1
GetTileIndex(): 2570000 GetTileIndex(): -1
IsValidTile(123): true IsValidTile(123): true
GetTileX(124): 124 GetTileX(124): 124
GetTileY(124): 0 GetTileY(124): 0
@ -6225,12 +6225,12 @@
Tile 45469 Tile 45469
Tile 45468 Tile 45468
Tile 45467 Tile 45467
Tile 45466 Tile 45211
Tile 45210 Tile 44955
Tile 44954 Tile 44699
Tile 44698 Tile 44443
Tile 44442 Tile 44187
Tile 44186 Tile 43931
Tile 43930 Tile 43930
Tile 43929 Tile 43929
Tile 43928 Tile 43928
@ -7229,7 +7229,7 @@
GetPopulation(): 180 GetPopulation(): 180
GetLocation(): 14935 GetLocation(): 14935
GetHouseCount(): 13 GetHouseCount(): 13
GetRating(): 5 GetRating(): 0
Town 12 Town 12
IsValidTown(): true IsValidTown(): true
GetName(): Ginborough GetName(): Ginborough
@ -7243,7 +7243,7 @@
GetPopulation(): 310 GetPopulation(): 310
GetLocation(): 9595 GetLocation(): 9595
GetHouseCount(): 14 GetHouseCount(): 14
GetRating(): 5 GetRating(): 0
Town 14 Town 14
IsValidTown(): true IsValidTown(): true
GetName(): Prundinghall GetName(): Prundinghall
@ -7278,7 +7278,7 @@
GetPopulation(): 262 GetPopulation(): 262
GetLocation(): 10574 GetLocation(): 10574
GetHouseCount(): 13 GetHouseCount(): 13
GetRating(): 5 GetRating(): 0
Town 19 Town 19
IsValidTown(): true IsValidTown(): true
GetName(): Mendingston GetName(): Mendingston
@ -7299,7 +7299,7 @@
GetPopulation(): 802 GetPopulation(): 802
GetLocation(): 9634 GetLocation(): 9634
GetHouseCount(): 27 GetHouseCount(): 27
GetRating(): 5 GetRating(): 0
Town 22 Town 22
IsValidTown(): true IsValidTown(): true
GetName(): Naborough GetName(): Naborough
@ -7590,12 +7590,12 @@
GetLocation(): 33417 GetLocation(): 33417
GetEngineType(): 153 GetEngineType(): 153
GetUnitNumber(): 1 GetUnitNumber(): 1
GetAge(): 0 GetAge(): 1
GetMaxAge(): 5490 GetMaxAge(): 5490
GetAgeLeft(): 5490 GetAgeLeft(): 5489
GetCurrentSpeed(): 4 GetCurrentSpeed(): 4
GetRunningCost(): 14 GetRunningCost(): 14
GetProfitThisYear(): 0 GetProfitThisYear(): -1
GetProfitLastYear(): 0 GetProfitLastYear(): 0
GetCurrentValue(): 466 GetCurrentValue(): 466
GetVehicleType(): 1 GetVehicleType(): 1
@ -7605,7 +7605,7 @@
IsInDepot(): false IsInDepot(): false
GetNumWagons(): 1 GetNumWagons(): 1
GetWagonEngineType(): 153 GetWagonEngineType(): 153
GetWagonAge(): 0 GetWagonAge(): 1
GetLength(): 8 GetLength(): 8
GetOwner(): 1 GetOwner(): 1
BuildVehicle(): 14 BuildVehicle(): 14
@ -7663,11 +7663,11 @@
14 => 1 14 => 1
12 => 1 12 => 1
Age ListDump: Age ListDump:
14 => 1
13 => 1
12 => 1
17 => 0 17 => 0
16 => 0 16 => 0
14 => 0
13 => 0
12 => 0
MaxAge ListDump: MaxAge ListDump:
16 => 10980 16 => 10980
14 => 10980 14 => 10980
@ -7676,10 +7676,10 @@
12 => 5490 12 => 5490
AgeLeft ListDump: AgeLeft ListDump:
16 => 10980 16 => 10980
14 => 10980 14 => 10979
17 => 7320 17 => 7320
13 => 5490 13 => 5489
12 => 5490 12 => 5489
CurrentSpeed ListDump: CurrentSpeed ListDump:
12 => 13 12 => 13
17 => 0 17 => 0
@ -7697,7 +7697,7 @@
16 => 0 16 => 0
14 => 0 14 => 0
13 => 0 13 => 0
12 => 0 12 => -1
ProfitLastYear ListDump: ProfitLastYear ListDump:
17 => 0 17 => 0
16 => 0 16 => 0

@ -26,37 +26,44 @@
return ::MapSizeY(); return ::MapSizeY();
} }
/* static */ uint32 AIMap::GetTileX(TileIndex t) /* static */ int32 AIMap::GetTileX(TileIndex t)
{ {
if (!::IsValidTile(t)) return -1;
return ::TileX(t); return ::TileX(t);
} }
/* static */ uint32 AIMap::GetTileY(TileIndex t) /* static */ int32 AIMap::GetTileY(TileIndex t)
{ {
if (!::IsValidTile(t)) return -1;
return ::TileY(t); return ::TileY(t);
} }
/* static */ TileIndex AIMap::GetTileIndex(uint32 x, uint32 y) /* static */ TileIndex AIMap::GetTileIndex(uint32 x, uint32 y)
{ {
if (x >= ::MapSizeX() || y >= MapSizeY()) return INVALID_TILE;
return ::TileXY(x, y); return ::TileXY(x, y);
} }
/* static */ uint32 AIMap::DistanceManhattan(TileIndex t1, TileIndex t2) /* static */ int32 AIMap::DistanceManhattan(TileIndex t1, TileIndex t2)
{ {
if (!::IsValidTile(t1) || !::IsValidTile(t2)) return -1;
return ::DistanceManhattan(t1, t2); return ::DistanceManhattan(t1, t2);
} }
/* static */ uint32 AIMap::DistanceMax(TileIndex t1, TileIndex t2) /* static */ int32 AIMap::DistanceMax(TileIndex t1, TileIndex t2)
{ {
if (!::IsValidTile(t1) || !::IsValidTile(t2)) return -1;
return ::DistanceMax(t1, t2); return ::DistanceMax(t1, t2);
} }
/* static */ uint32 AIMap::DistanceSquare(TileIndex t1, TileIndex t2) /* static */ int32 AIMap::DistanceSquare(TileIndex t1, TileIndex t2)
{ {
if (!::IsValidTile(t1) || !::IsValidTile(t2)) return -1;
return ::DistanceSquare(t1, t2); return ::DistanceSquare(t1, t2);
} }
/* static */ uint32 AIMap::DistanceFromEdge(TileIndex t) /* static */ int32 AIMap::DistanceFromEdge(TileIndex t)
{ {
if (!::IsValidTile(t)) return -1;
return ::DistanceFromEdge(t); return ::DistanceFromEdge(t);
} }

@ -49,7 +49,7 @@ public:
* @return The X-value. * @return The X-value.
* @post Return value is always lower than GetMapSizeX(). * @post Return value is always lower than GetMapSizeX().
*/ */
static uint32 GetTileX(TileIndex tile); static int32 GetTileX(TileIndex tile);
/** /**
* Gets the place along the SE/NW border (Y-value). * Gets the place along the SE/NW border (Y-value).
@ -58,7 +58,7 @@ public:
* @return The Y-value. * @return The Y-value.
* @post Return value is always lower than GetMapSizeY(). * @post Return value is always lower than GetMapSizeY().
*/ */
static uint32 GetTileY(TileIndex tile); static int32 GetTileY(TileIndex tile);
/** /**
* Gets the TileIndex given a x,y-coordinate. * Gets the TileIndex given a x,y-coordinate.
@ -79,7 +79,7 @@ public:
* @pre IsValidTile(tile_to). * @pre IsValidTile(tile_to).
* @return The Manhattan distance between the tiles. * @return The Manhattan distance between the tiles.
*/ */
static uint32 DistanceManhattan(TileIndex tile_from, TileIndex tile_to); static int32 DistanceManhattan(TileIndex tile_from, TileIndex tile_to);
/** /**
* Calculates the distance between two tiles via 1D calculation. * Calculates the distance between two tiles via 1D calculation.
@ -91,7 +91,7 @@ public:
* @pre IsValidTile(tile_to). * @pre IsValidTile(tile_to).
* @return The maximum distance between the tiles. * @return The maximum distance between the tiles.
*/ */
static uint32 DistanceMax(TileIndex tile_from, TileIndex tile_to); static int32 DistanceMax(TileIndex tile_from, TileIndex tile_to);
/** /**
* The squared distance between the two tiles. * The squared distance between the two tiles.
@ -103,7 +103,7 @@ public:
* @pre IsValidTile(tile_to). * @pre IsValidTile(tile_to).
* @return The squared distance between the tiles. * @return The squared distance between the tiles.
*/ */
static uint32 DistanceSquare(TileIndex tile_from, TileIndex tile_to); static int32 DistanceSquare(TileIndex tile_from, TileIndex tile_to);
/** /**
* Calculates the shortest distance to the edge. * Calculates the shortest distance to the edge.
@ -111,7 +111,7 @@ public:
* @pre IsValidTile(tile). * @pre IsValidTile(tile).
* @return The distances to the closest edge. * @return The distances to the closest edge.
*/ */
static uint32 DistanceFromEdge(TileIndex tile); static int32 DistanceFromEdge(TileIndex tile);
}; };
#endif /* AI_MAP_HPP */ #endif /* AI_MAP_HPP */

Loading…
Cancel
Save