From f52fef5bc209083cbdbbfc37f2c2a8360327ebf5 Mon Sep 17 00:00:00 2001 From: elexis Date: Mon, 5 Mar 2018 14:35:46 +0000 Subject: [PATCH] Rename some constraint arguments to constraints to reflect that one can pass an array too. git-svn-id: https://svn.wildfiregames.com/public/ps/trunk@21439 3db68df2-c116-0410-a063-a993310a9797 --- .../maps/random/rmgen-common/gaia_terrain.js | 20 +++++++++--------- .../data/mods/public/maps/random/rmgen/library.js | 24 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/binaries/data/mods/public/maps/random/rmgen-common/gaia_terrain.js b/binaries/data/mods/public/maps/random/rmgen-common/gaia_terrain.js index e51be8f131..806613ca29 100644 --- a/binaries/data/mods/public/maps/random/rmgen-common/gaia_terrain.js +++ b/binaries/data/mods/public/maps/random/rmgen-common/gaia_terrain.js @@ -5,7 +5,7 @@ /** * Bumps add slight, diverse elevation differences to otherwise completely level terrain. */ -function createBumps(constraint, count, minSize, maxSize, spread, failFraction = 0, elevation = 2) +function createBumps(constraints, count, minSize, maxSize, spread, failFraction = 0, elevation = 2) { g_Map.log("Creating bumps"); createAreas( @@ -15,14 +15,14 @@ function createBumps(constraint, count, minSize, maxSize, spread, failFraction = spread || Math.floor(scaleByMapSize(2, 5)), failFraction), new SmoothElevationPainter(ELEVATION_MODIFY, elevation, 2), - constraint, + constraints, count || scaleByMapSize(100, 200)); } /** * Hills are elevated, planar, impassable terrain areas. */ -function createHills(terrainset, constraint, tileClass, count, minSize, maxSize, spread, failFraction = 0.5, elevation = 18, elevationSmoothing = 2) +function createHills(terrainset, constraints, tileClass, count, minSize, maxSize, spread, failFraction = 0.5, elevation = 18, elevationSmoothing = 2) { g_Map.log("Creating hills"); createAreas( @@ -36,14 +36,14 @@ function createHills(terrainset, constraint, tileClass, count, minSize, maxSize, new SmoothElevationPainter(ELEVATION_SET, elevation, elevationSmoothing), new TileClassPainter(tileClass) ], - constraint, + constraints, count || scaleByMapSize(1, 4) * getNumPlayers()); } /** * Mountains are impassable smoothened cones. */ -function createMountains(terrain, constraint, tileClass, count, maxHeight, minRadius, maxRadius, numCircles) +function createMountains(terrain, constraints, tileClass, count, maxHeight, minRadius, maxRadius, numCircles) { g_Map.log("Creating mountains"); let mapSize = g_Map.getSize(); @@ -54,7 +54,7 @@ function createMountains(terrain, constraint, tileClass, count, maxHeight, minRa minRadius || Math.floor(scaleByMapSize(3, 4)), maxRadius || Math.floor(scaleByMapSize(6, 12)), numCircles || Math.floor(scaleByMapSize(4, 10)), - constraint, + constraints, randIntExclusive(0, mapSize), randIntExclusive(0, mapSize), terrain, @@ -280,7 +280,7 @@ function createVolcano(position, tileClass, terrainTexture, lavaTextures, smoke, /** * Paint the given terrain texture in the given sizes at random places of the map to diversify monotone land texturing. */ -function createPatches(sizes, terrain, constraint, count, tileClass, failFraction = 0.5) +function createPatches(sizes, terrain, constraints, count, tileClass, failFraction = 0.5) { for (let size of sizes) createAreas( @@ -289,14 +289,14 @@ function createPatches(sizes, terrain, constraint, count, tileClass, failFracti new TerrainPainter(terrain), new TileClassPainter(tileClass) ], - constraint, + constraints, count); } /** * Same as createPatches, but each patch consists of a set of textures drawn depending to the distance of the patch border. */ -function createLayeredPatches(sizes, terrains, terrainWidths, constraint, count, tileClass, failFraction = 0.5) +function createLayeredPatches(sizes, terrains, terrainWidths, constraints, count, tileClass, failFraction = 0.5) { for (let size of sizes) createAreas( @@ -305,7 +305,7 @@ function createLayeredPatches(sizes, terrains, terrainWidths, constraint, count, new LayeredPainter(terrains, terrainWidths), new TileClassPainter(tileClass) ], - constraint, + constraints, count); } diff --git a/binaries/data/mods/public/maps/random/rmgen/library.js b/binaries/data/mods/public/maps/random/rmgen/library.js index c1054eeca4..4603fea605 100644 --- a/binaries/data/mods/public/maps/random/rmgen/library.js +++ b/binaries/data/mods/public/maps/random/rmgen/library.js @@ -106,25 +106,25 @@ function retryPlacing(placeFunc, retryFactor, amount, behaveDeprecated = false) // TODO this is a hack to simulate the old behaviour of those functions // until all old maps are changed to use the correct version of these functions -function createObjectGroupsDeprecated(group, player, constraint, amount, retryFactor = 10) +function createObjectGroupsDeprecated(group, player, constraints, amount, retryFactor = 10) { - return createObjectGroups(group, player, constraint, amount, retryFactor, true); + return createObjectGroups(group, player, constraints, amount, retryFactor, true); } -function createObjectGroupsByAreasDeprecated(group, player, constraint, amount, retryFactor, areas) +function createObjectGroupsByAreasDeprecated(group, player, constraints, amount, retryFactor, areas) { - return createObjectGroupsByAreas(group, player, constraint, amount, retryFactor, areas, true); + return createObjectGroupsByAreas(group, player, constraints, amount, retryFactor, areas, true); } /** * Attempts to place the given number of areas in random places of the map. * Returns actually placed areas. */ -function createAreas(centeredPlacer, painter, constraint, amount, retryFactor = 10) +function createAreas(centeredPlacer, painter, constraints, amount, retryFactor = 10) { let placeFunc = function() { centeredPlacer.setCenterPosition(g_Map.randomCoordinate(false)); - return createArea(centeredPlacer, painter, constraint); + return createArea(centeredPlacer, painter, constraints); }; return retryPlacing(placeFunc, retryFactor, amount, false); @@ -134,11 +134,11 @@ function createAreas(centeredPlacer, painter, constraint, amount, retryFactor = * Attempts to place the given number of areas in random places of the given areas. * Returns actually placed areas. */ -function createAreasInAreas(centeredPlacer, painter, constraint, amount, retryFactor, areas) +function createAreasInAreas(centeredPlacer, painter, constraints, amount, retryFactor, areas) { let placeFunc = function() { centeredPlacer.setCenterPosition(pickRandom(pickRandom(areas).getPoints())); - return createArea(centeredPlacer, painter, constraint); + return createArea(centeredPlacer, painter, constraints); }; return retryPlacing(placeFunc, retryFactor, amount, false); @@ -148,11 +148,11 @@ function createAreasInAreas(centeredPlacer, painter, constraint, amount, retryFa * Attempts to place the given number of groups in random places of the map. * Returns the number of actually placed groups. */ -function createObjectGroups(group, player, constraint, amount, retryFactor = 10, behaveDeprecated = false) +function createObjectGroups(group, player, constraints, amount, retryFactor = 10, behaveDeprecated = false) { let placeFunc = function() { group.setCenterPosition(g_Map.randomCoordinate(true)); - return createObjectGroup(group, player, constraint); + return createObjectGroup(group, player, constraints); }; return retryPlacing(placeFunc, retryFactor, amount, behaveDeprecated); @@ -162,11 +162,11 @@ function createObjectGroups(group, player, constraint, amount, retryFactor = 10, * Attempts to place the given number of groups in random places of the given areas. * Returns the number of actually placed groups. */ -function createObjectGroupsByAreas(group, player, constraint, amount, retryFactor, areas, behaveDeprecated = false) +function createObjectGroupsByAreas(group, player, constraints, amount, retryFactor, areas, behaveDeprecated = false) { let placeFunc = function() { group.setCenterPosition(pickRandom(pickRandom(areas).getPoints())); - return createObjectGroup(group, player, constraint); + return createObjectGroup(group, player, constraints); }; return retryPlacing(placeFunc, retryFactor, amount, behaveDeprecated); -- 2.11.4.GIT