Bug #1278
openbug in can_reclaim_ocean()
0%
Description
Found while testing #1277, this is an obscure edge case that has likely never happened.
Repro -
civ2civ3 ruleset
edit terrain.ruleset -> ocean_reclaim_requirement = 67
hex tileset
use editing mode to get tech Fusion
put Engineers on a Transport in the ocean on tile with 4 adjacent land tiles
transform to land is available
67% of 6 is 4.02, so should require 5 adjacent land tiles.
int land_tiles = 100 - count_terrain_class_near_tile(nmap, ptile,
FALSE, TRUE,
TC_OCEAN);
count_terrain_class_near_tile() returns 33%, which should really be 33.3%,
100 - that = 67, should really be 66.7,
and 66.7 >= 67 should fail but 67 >= 67 succeeds.
Obvious fix is
int land_tiles = count_terrain_class_near_tile(nmap, ptile,
FALSE, TRUE, TC_LAND);
But there must have been some reason it was coded like it is,
instead of the obvious way - wish there were a comment.
The way it is has side effect that Inaccessible and "off-the-map" tiles
are counted as land tiles.
Files
Updated by Marko Lindqvist 28 days ago
Dean Brown wrote:
But there must have been some reason it was coded like it is,
...
The way it is has side effect that Inaccessible and "off-the-map" tiles
are counted as land tiles.
I think you got the reason just there. Especially on the polar areas (polar strips) we want the off-map area to count as land and not as ocean. Maybe this ticket should be fixed by adding the comment about that?
Updated by Dean Brown 27 days ago
Yes it needs a comment. Also needed to do things differently to fix the bug.
Updated by Dean Brown 27 days ago
- File 1278_S3_2.patch added
- File 1278.patch added
1278.patch for S3_3 and Main.
Updated by Marko Lindqvist 21 days ago
The comment still says "HR #1278" (I assume you fixed commit message instead)
Updated by Dean Brown 20 days ago
- File 1278_S3_2.patch 1278_S3_2.patch added
- File 1278.patch 1278.patch added
fixed