mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 23:51:55 +00:00
67af4b06ab
> There were 4 separate implementations of getting neighboring coordinates for a given x,y pair, 3 completely unique implementations. These were found in neighbors(), processOcean(), processDistToLand(), and getArea(), with processOcean() and processDistToLand() having essentially identical implementations. Created new function getNeighborCoords() with implementation closely resembling that found in neighbors(). Revised aforementioned functions to utilize the new getNeighborCoords() instead, with revised implementations being much more consistent across the impacted functions. > Revised getArea() to correctly assess the area, was previously likely to overestimate the area as it included all coordinates it check regardless of their terrainType. getArea() now also explicitely implements the Coord[] interface, allowing for standardized implementation syntax in all functions which call getArea(). Also removed the parameter targetType as all calls to getArea() targetted the same TerrainType as was present at the passed x, y position. getArea() will now assess targetType based on the passed x, y values. Reordered the parameters of getArea() so that it conformed with the ordering used elsewhere in the script (x, y, map, visited). Updated all calling locations accordingly. > Revised processOcean() to make use of getArea() instead of using its own reimplementation of area checking. This coupled with the use of the new getNeighborCoords() significantly reduced the size of processOcean and improved comprehensibility. Also removed unnecessary check of waterBody.size that would always return TRUE in that context. > Removed checks against and setting of Terrain.ocean values in the removeSmallIslands() and removeSmallLakes() functions as these functions are called prior to processOcean() making the checking redundant/unncessary, and the setting potentially problematic. Revised Terrain class to default ocean to false, to address compiler warning, and since processOcean() handles setting this property to true explicitly. Reduced total lines from 417 to 372.