Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/constraint.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/constraint.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/constraint.js @@ -81,8 +81,8 @@ /** * The BorderTileClassConstraint is met if there are - * no tiles marked with the given TileClass within distanceInside of the tile, - * but tiles marked with the given TileClass within distanceOutside of the tile. + * tiles not marked with the given TileClass within distanceInside of the tile and + * tiles marked with the given TileClass within distanceOutside of the tile. */ function BorderTileClassConstraint(tileClassID, distanceInside, distanceOutside) { Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/painter.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/painter.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/painter.js @@ -60,43 +60,6 @@ this.terrain.place(point.x, point.z); }; -// Constants for using SmoothElevationPainter -const ELEVATION_SET = 0; -const ELEVATION_MODIFY = 1; - -///////////////////////////////////////////////////////////////////////////// -// ElevationPainter -// -// Class for painting elevation over an area -// -// elevation: Target elevation/height to be painted -// -///////////////////////////////////////////////////////////////////////////// - -function ElevationPainter(elevation) -{ - this.elevation = elevation; - this.DX = [0, 1, 1, 0]; - this.DZ = [0, 0, 1, 1]; -} - -ElevationPainter.prototype.paint = function(area) -{ - var length = area.points.length; - var elevation = this.elevation; - - for (var i=0; i < length; i++) - { - var pt = area.points[i]; - - for (var j=0; j < 4; j++) - { - if (g_Map.inMapBounds(pt.x + this.DX[j],pt.z + this.DZ[j])) - g_Map.height[pt.x + this.DX[j]][pt.z + this.DZ[j]] = elevation; - } - } -}; - ///////////////////////////////////////////////////////////////////////////// // LayeredPainter // @@ -208,6 +171,37 @@ } }; +/** + * Sets the given height in the given Area. + */ +function ElevationPainter(elevation) +{ + this.elevation = elevation; +} + +ElevationPainter.prototype.paint = function(area) +{ + for (let point of area.points) + for (let [dx, dz] of [[0, 0], [1, 0], [0, 1], [1, 1]]) + { + let x = point.x + dx; + let z = point.z + dz; + + if (g_Map.inMapBounds(x, z)) + g_Map.height[x][z] = this.elevation; + } +}; + +/** + * Absolute height change. + */ +const ELEVATION_SET = 0; + +/** + * Relative height change. + */ +const ELEVATION_MODIFY = 1; + ///////////////////////////////////////////////////////////////////////////// // SmoothElevationPainter //