Bug #1278
closedbug 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 about 2 months 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 about 2 months ago
Yes it needs a comment. Also needed to do things differently to fix the bug.
Updated by Dean Brown about 2 months ago
- File 1278_S3_2.patch added
- File 1278.patch added
1278.patch for S3_3 and Main.
Updated by Marko Lindqvist about 1 month ago
The comment still says "HR #1278" (I assume you fixed commit message instead)
Updated by Dean Brown about 1 month ago
- File 1278_S3_2.patch 1278_S3_2.patch added
- File 1278.patch added
fixed
Updated by Marko Lindqvist 17 days ago
In main and S3_3 you should use MAP_NUM_VALID_DIRS instead of wld.map.num_valid_dirs.
Updated by Marko Lindqvist 13 days ago
- Status changed from New to In Review
- Assignee set to Marko Lindqvist
- Target version set to 3.2.3