diff --git a/binaries/data/mods/public/maps/random/rmgen/constraint.js b/binaries/data/mods/public/maps/random/rmgen/constraint.js index f81186ee85..defdf32f25 100644 --- a/binaries/data/mods/public/maps/random/rmgen/constraint.js +++ b/binaries/data/mods/public/maps/random/rmgen/constraint.js @@ -17,7 +17,12 @@ NullConstraint.prototype.allows = function(x, z) */ function AndConstraint(constraints) { - this.constraints = constraints; + if (constraints instanceof Array) + this.constraints = constraints + else if (!constraints) + this.constraints = []; + else + this.constraints = [constraints]; } AndConstraint.prototype.allows = function(x, z) diff --git a/binaries/data/mods/public/maps/random/rmgen/gaia_terrain.js b/binaries/data/mods/public/maps/random/rmgen/gaia_terrain.js index 48275377b1..6dafdffd4f 100644 --- a/binaries/data/mods/public/maps/random/rmgen/gaia_terrain.js +++ b/binaries/data/mods/public/maps/random/rmgen/gaia_terrain.js @@ -65,10 +65,9 @@ function createMountains(terrain, constraint, tileClass, count, maxHeight, minRa /** * Create a mountain using a technique very similar to ChainPlacer. */ -function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraint, x, z, terrain, tileClass, fcc = 0, q = []) +function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraints, x, z, terrain, tileClass, fcc = 0, q = []) { - if (constraint instanceof Array) - constraint = new AndConstraint(constraint); + let constraint = new AndConstraint(constraints); if (!g_Map.inMapBounds(x, z) || !constraint.allows(x, z)) return; diff --git a/binaries/data/mods/public/maps/random/rmgen/library.js b/binaries/data/mods/public/maps/random/rmgen/library.js index 6b1eda2ae6..8a047bb72c 100644 --- a/binaries/data/mods/public/maps/random/rmgen/library.js +++ b/binaries/data/mods/public/maps/random/rmgen/library.js @@ -247,17 +247,12 @@ function getTileClass(id) } /** - * Constructs a new Area shaped by the Placer meeting the Constraint and calls the Painters there. + * Constructs a new Area shaped by the Placer meeting the Constraints and calls the Painters there. * Supports both Centered and Non-Centered Placers. */ -function createArea(placer, painter, constraint) +function createArea(placer, painter, constraints) { - if (!constraint) - constraint = new NullConstraint(); - else if (constraint instanceof Array) - constraint = new AndConstraint(constraint); - - let points = placer.place(constraint); + let points = placer.place(new AndConstraint(constraints)); if (!points) return undefined; @@ -296,17 +291,12 @@ function unPaintTileClassBasedOnHeight(minHeight, maxHeight, mode, tileClass) } /** - * Places the Entities of the given Group if they meet the Constraint + * Places the Entities of the given Group if they meet the Constraints * and sets the given player as the owner. */ -function createObjectGroup(group, player, constraint) +function createObjectGroup(group, player, constraints) { - if (!constraint) - constraint = new NullConstraint(); - else if (constraint instanceof Array) - constraint = new AndConstraint(constraint); - - return group.place(player, constraint); + return group.place(player, new AndConstraint(constraints)); } function getMapSize()