Index: binaries/data/mods/public/maps/random/african_plains.js =================================================================== --- binaries/data/mods/public/maps/random/african_plains.js +++ binaries/data/mods/public/maps/random/african_plains.js @@ -200,7 +200,7 @@ // Roaming animals { - var placeRoaming = function(name, objs) + const placeRoaming = function(name, objs) { g_Map.log("Creating roaming " + name); const group = new SimpleGroup(objs, true, clFood); @@ -237,7 +237,7 @@ // Animals that hang around watering holes { // TODO: these have a high retry factor because our mapgen constraint logic is bad. - var placeWateringHoleAnimals = function(name, objs, numberOfGroups) + const placeWateringHoleAnimals = function(name, objs, numberOfGroups) { g_Map.log("Creating " + name + " around watering holes"); const group = new SimpleGroup(objs, true, clFood); Index: binaries/data/mods/public/maps/random/alpine_valley.js =================================================================== --- binaries/data/mods/public/maps/random/alpine_valley.js +++ binaries/data/mods/public/maps/random/alpine_valley.js @@ -236,10 +236,10 @@ setBiome(g_MapSettings.Biome ?? "alpine/winter"); -var heightLand = 3; -var heightOffsetBump = 2; -var snowlineHeight = 29; -var heightMountain = 30; +const heightLand = 3; +const heightOffsetBump = 2; +const snowlineHeight = 29; +const heightMountain = 30; const pForest = [g_Terrains.forestFloor + TERRAIN_SEPARATOR + g_Gaia.tree1, g_Terrains.forestFloor]; @@ -257,7 +257,7 @@ const clFood = g_Map.createTileClass(); const clBaseResource = g_Map.createTileClass(); -var [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); placePlayerBases({ "PlayerPlacement": [playerIDs, playerPosition], @@ -341,7 +341,7 @@ [[g_Terrains.forestFloor, g_Terrains.mainTerrain, pForest], [g_Terrains.forestFloor, pForest]] ]; -var size = forestTrees / (scaleByMapSize(2,8) * numPlayers); +const size = forestTrees / (scaleByMapSize(2, 8) * numPlayers); const num = Math.floor(size / types.length); for (const type of types) @@ -382,7 +382,7 @@ Engine.SetProgress(65); g_Map.log("Creating stone mines"); -var group = new SimpleGroup( +let group = new SimpleGroup( [ new SimpleObject(g_Gaia.stoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(g_Gaia.stoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4) @@ -473,7 +473,7 @@ stragglerTrees); g_Map.log("Creating small grass tufts"); -var planetm = 1; +const planetm = 1; group = new SimpleGroup( [new SimpleObject(g_Decoratives.grassShort, 1, 2, 0, 1, -Math.PI / 8, Math.PI / 8)] Index: binaries/data/mods/public/maps/random/ardennes_forest.js =================================================================== --- binaries/data/mods/public/maps/random/ardennes_forest.js +++ binaries/data/mods/public/maps/random/ardennes_forest.js @@ -302,32 +302,32 @@ Engine.SetProgress(60); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(1300, 8000, 0.8); -var [forestTreesJoin, forestTrees] = getTreeCounts(forestTrees, forestTrees, 0.25); +const [protoPorestTrees, stragglerTrees] = getTreeCounts(1300, 8000, 0.8); +const [forestTreesJoin, forestTrees] = getTreeCounts(protoPorestTrees, protoPorestTrees, 0.25); -var num = forestTrees / scaleByMapSize(20, 70); +const treeNum = forestTrees / scaleByMapSize(20, 70); createAreasInAreas( - new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), + new ClumpPlacer(forestTrees / treeNum, 0.1, 0.1, Infinity), [ new TerrainPainter(pForest), new TileClassPainter(clForest) ], avoidClasses(clPlayer, 5, clBaseResource, 4, clForest, 5, clHill, 4), - num, + treeNum, 100, [explorableArea] ); -var num = forestTreesJoin / (scaleByMapSize(4, 6) * numPlayers); +const joinNum = forestTreesJoin / (scaleByMapSize(4, 6) * numPlayers); createAreasInAreas( - new ClumpPlacer(forestTreesJoin / num, 0.1, 0.1, Infinity), + new ClumpPlacer(forestTreesJoin / joinNum, 0.1, 0.1, Infinity), [ new TerrainPainter(pForest), new TileClassPainter(clForest), new TileClassPainter(clForestJoin) ], [avoidClasses(clPlayer, 5, clBaseResource, 4, clForestJoin, 5, clHill, 4), borderClasses(clForest, 1, 4)], - num, + joinNum, 100, [explorableArea] ); @@ -436,13 +436,13 @@ g_Map.log("Creating straggler trees"); const types = [oOak, oOakLarge, oPine, oAleppoPine]; -var num = Math.floor(stragglerTrees / types.length); +const stragglerNum = Math.floor(stragglerTrees / types.length); for (const type of types) createObjectGroupsByAreasDeprecated( new SimpleGroup([new SimpleObject(type, 1, 1, 0, 3)], true, clForest), 0, avoidClasses(clForest, 4, clHill, 5, clPlayer, 10, clBaseResource, 2, clMetal, 5, clRock, 5), - num, 20, + stragglerNum, 20, [explorableArea]); Engine.SetProgress(95); Index: binaries/data/mods/public/maps/random/cycladic_archipelago.js =================================================================== --- binaries/data/mods/public/maps/random/cycladic_archipelago.js +++ binaries/data/mods/public/maps/random/cycladic_archipelago.js @@ -85,8 +85,8 @@ const areas = []; -var nPlayer = 0; -var playerPosition = []; +let nPlayer = 0; +const playerPosition = []; function createCycladicArchipelagoIsland(position, tileClass, radius, coralRadius) { @@ -186,7 +186,7 @@ paintTileClassBasedOnHeight(-Infinity, 0, Elevation_ExcludeMin_ExcludeMax, clWater); g_Map.log("Creating forests"); -var forestTypes = [ +const forestTypes = [ [[tForestFloor, tGrass, pPalmForest], [tForestFloor, pPalmForest]], [[tForestFloor, tGrass, pPineForest], [tForestFloor, pPineForest]], [[tForestFloor, tGrass, pPoplarForest], [tForestFloor, pPoplarForest]], Index: binaries/data/mods/public/maps/random/flood.js =================================================================== --- binaries/data/mods/public/maps/random/flood.js +++ binaries/data/mods/public/maps/random/flood.js @@ -196,19 +196,19 @@ 10 * numPlayers, 60); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(0.7)); +const [forestTreesMainIsland, stragglerTreesMainIsland] = getTreeCounts(...rBiomeTreeCount(0.7)); createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, 25, clForest, 10, clBaseResource, 3, clMetal, 6, clRock, 6, clMountain, 2), stayClasses(clHill, 6)], clForest, - forestTrees); + forestTreesMainIsland); const types = [oTree1, oTree2, oTree4, oTree3]; createStragglerTrees( types, [avoidClasses(clBaseResource, 2, clMetal, 6, clRock, 6, clMountain, 2, clPlayer, 25), stayClasses(clHill, 6)], clForest, - stragglerTrees); + stragglerTreesMainIsland); Engine.SetProgress(65); g_Map.log("Creating dirt patches"); @@ -256,7 +256,7 @@ Engine.SetProgress(85); -var planetm = currentBiome() == "generic/india" ? 8 : 1; +const planetm = currentBiome() == "generic/india" ? 8 : 1; createDecoration( [ [new SimpleObject(aRockMedium, 1, 3, 0, 1)], @@ -274,12 +274,12 @@ ], avoidClasses(clForest, 2, clPlayer, 20, clMountain, 5, clFood, 1, clBaseResource, 2)); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(0.1)); +const [forestTreesSurrounding, stragglerTreesSurrounding] = getTreeCounts(...rBiomeTreeCount(0.1)); createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], avoidClasses(clPlayer, 30, clHill, 10, clFood, 5), clForest, - forestTrees); + forestTreesSurrounding); g_Map.log("Creating small grass tufts"); createObjectGroupsDeprecated( Index: binaries/data/mods/public/maps/random/latium.js =================================================================== --- binaries/data/mods/public/maps/random/latium.js +++ binaries/data/mods/public/maps/random/latium.js @@ -71,12 +71,12 @@ const clPlayer = g_Map.createTileClass(); const clBaseResource = g_Map.createTileClass(); -var WATER_WIDTH = 0.1; -var horizontal = randBool(); +const WATER_WIDTH = 0.1; g_Map.log("Creating players"); -var startAngle = randBool() ? 0 : Math.PI / 2; -var playerPosition = playerPlacementLine(startAngle + Math.PI / 2, mapCenter, fractionToTiles(randFloat(0.42, 0.46))); +const startAngle = randBool() ? 0 : Math.PI / 2; +const playerPosition = playerPlacementLine(startAngle + Math.PI / 2, mapCenter, + fractionToTiles(randFloat(0.42, 0.46))); function distanceToPlayers(x, z) { @@ -122,32 +122,36 @@ Engine.SetProgress(10); g_Map.log("Painting elevation"); -var noise0 = new Noise2D(scaleByMapSize(4, 16)); -var noise1 = new Noise2D(scaleByMapSize(8, 32)); -var noise2 = new Noise2D(scaleByMapSize(15, 60)); +const noise0 = new Noise2D(scaleByMapSize(4, 16)); +const noise1 = new Noise2D(scaleByMapSize(8, 32)); +const noise2 = new Noise2D(scaleByMapSize(15, 60)); -var noise2a = new Noise2D(scaleByMapSize(20, 80)); -var noise2b = new Noise2D(scaleByMapSize(35, 140)); +const noise2a = new Noise2D(scaleByMapSize(20, 80)); +const noise2b = new Noise2D(scaleByMapSize(35, 140)); -var noise3 = new Noise2D(scaleByMapSize(4, 16)); -var noise4 = new Noise2D(scaleByMapSize(6, 24)); -var noise5 = new Noise2D(scaleByMapSize(11, 44)); +const noise3 = new Noise2D(scaleByMapSize(4, 16)); +const noise4 = new Noise2D(scaleByMapSize(6, 24)); +const noise5 = new Noise2D(scaleByMapSize(11, 44)); -for (var ix = 0; ix <= mapSize; ix++) - for (var iz = 0; iz <= mapSize; iz++) +for (let ix = 0; ix <= mapSize; ix++) + for (let iz = 0; iz <= mapSize; iz++) { const position = new Vector2D(ix, iz); - var x = ix / (mapSize + 1.0); - var z = iz / (mapSize + 1.0); - var pn = playerNearness(x, z); + const x = ix / (mapSize + 1.0); + const z = iz / (mapSize + 1.0); + const pn = playerNearness(x, z); const c = startAngle ? z : x; const distToWater = clWater.has(position) ? 0 : (0.5 - WATER_WIDTH - Math.abs(c - 0.5)); let h = distToWater ? heightHill * (1 - Math.abs(c - 0.5) / (0.5 - WATER_WIDTH)) : g_Map.getHeight(position); // add some base noise - var baseNoise = 16*noise0.get(x,z) + 8*noise1.get(x,z) + 4*noise2.get(x,z) - (16+8+4)/2; + let baseNoise = + 16 * noise0.get(x, z) + + 8 * noise1.get(x, z) + + 4 * noise2.get(x, z) - + (16 + 8 + 4) / 2; if ( baseNoise < 0 ) { baseNoise *= pn; @@ -186,19 +190,19 @@ Engine.SetProgress(20); g_Map.log("Painting terrain"); -var noise6 = new Noise2D(scaleByMapSize(10, 40)); -var noise7 = new Noise2D(scaleByMapSize(20, 80)); -var noise8 = new Noise2D(scaleByMapSize(13, 52)); -var noise9 = new Noise2D(scaleByMapSize(26, 104)); -var noise10 = new Noise2D(scaleByMapSize(50, 200)); - -for (var ix = 0; ix < mapSize; ix++) - for (var iz = 0; iz < mapSize; iz++) +const noise6 = new Noise2D(scaleByMapSize(10, 40)); +const noise7 = new Noise2D(scaleByMapSize(20, 80)); +const noise8 = new Noise2D(scaleByMapSize(13, 52)); +const noise9 = new Noise2D(scaleByMapSize(26, 104)); +const noise10 = new Noise2D(scaleByMapSize(50, 200)); + +for (let ix = 0; ix < mapSize; ix++) + for (let iz = 0; iz < mapSize; iz++) { const position = new Vector2D(ix, iz); - var x = ix / (mapSize + 1.0); - var z = iz / (mapSize + 1.0); - var pn = playerNearness(x, z); + const x = ix / (mapSize + 1.0); + const z = iz / (mapSize + 1.0); + const pn = playerNearness(x, z); // Compute height difference let minH = +Infinity; @@ -209,14 +213,14 @@ minH = Math.min(minH, height); maxH = Math.max(maxH, height); } - var diffH = maxH - minH; + const diffH = maxH - minH; // figure out if we're at the top of a cliff using min adjacent height - var minAdjHeight = minH; + let minAdjHeight = minH; if (maxH > 15) { - var maxNx = Math.min(ix + 2, mapSize); - var maxNz = Math.min(iz + 2, mapSize); + const maxNx = Math.min(ix + 2, mapSize); + const maxNz = Math.min(iz + 2, mapSize); for (let nx = Math.max(ix - 1, 0); nx <= maxNx; ++nx) for (let nz = Math.max(iz - 1, 0); nz <= maxNz; ++nz) minAdjHeight = Math.min(minAdjHeight, g_Map.getHeight(new Vector2D(nx, nz))); @@ -269,7 +273,7 @@ // forests if (g_Map.getHeight(position) < 11 && diffH < 2 && minH > 1) { - var forestNoise = (noise6.get(x,z) + 0.5*noise7.get(x,z)) / 1.5 * pn - 0.59; + const forestNoise = (noise6.get(x, z) + 0.5 * noise7.get(x, z)) / 1.5 * pn - 0.59; // Thin out trees a bit if (forestNoise > 0 && randBool()) @@ -298,7 +302,7 @@ // grass variations if (t == tGrass) { - var grassNoise = (noise8.get(x,z) + 0.6*noise9.get(x,z)) / 1.6; + const grassNoise = (noise8.get(x, z) + 0.6 * noise9.get(x, z)) / 1.6; if (grassNoise < 0.3) t = (diffH > 1.2) ? tDirtCliff : tDirt; else if (grassNoise < 0.34) @@ -357,7 +361,7 @@ Engine.SetProgress(40); g_Map.log("Creating bushes"); -var group = new SimpleGroup( +let group = new SimpleGroup( [new SimpleObject(aBushSmall, 0,2, 0,2), new SimpleObject(aBushSmallDry, 0,2, 0,2), new SimpleObject(aBushMed, 0,1, 0,2), new SimpleObject(aBushMedDry, 0,1, 0,2)] ); Index: binaries/data/mods/public/maps/random/snowflake_searocks.js =================================================================== --- binaries/data/mods/public/maps/random/snowflake_searocks.js +++ binaries/data/mods/public/maps/random/snowflake_searocks.js @@ -65,11 +65,11 @@ const islandBetweenPlayerAndCenterRadius = 0.81; const centralIslandRadius = 0.36; -var [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); -var numIslands = 0; -var isConnected = []; -var islandPos = []; +let numIslands = 0; +const isConnected = []; +const islandPos = []; function initIsConnected() { @@ -99,10 +99,9 @@ createIsland(islandID, islandRadius, clLand); } -function createSnowflakeSearockWithCenter(sizeID) +function createSnowflakeSearockWithCenter([tertiaryIslandDist, tertiaryIslandRadius, + islandBetweenPlayersDist, islandBetweenPlayersRadius]) { - const [tertiaryIslandDist, tertiaryIslandRadius, islandBetweenPlayersDist, islandBetweenPlayersRadius] = islandSizes[sizeID]; - const islandID_center = 4 * numPlayers; numIslands = islandID_center + 1; initIsConnected(); @@ -199,19 +198,19 @@ else if (mapSize <= 256) { if (numPlayers < 6) - createSnowflakeSearockWithCenter("medium"); + createSnowflakeSearockWithCenter(islandSizes.medium); else createSnowflakeSearockWithoutCenter(); } else if (mapSize <= 320) { if (numPlayers < 8) - createSnowflakeSearockWithCenter("medium"); + createSnowflakeSearockWithCenter(islandSizes.medium); else createSnowflakeSearockWithoutCenter(); } else - createSnowflakeSearockWithCenter(numPlayers < 6 ? "large1" : "large2"); + createSnowflakeSearockWithCenter(islandSizes["large" + (numPlayers < 6 ? "1" : "2")]); g_Map.log("Creating player islands"); for (let i = 0; i < numPlayers; ++i) Index: binaries/data/mods/public/maps/random/unknown.js =================================================================== --- binaries/data/mods/public/maps/random/unknown.js +++ binaries/data/mods/public/maps/random/unknown.js @@ -72,9 +72,9 @@ const clLand = g_Map.createTileClass(); const clShallow = g_Map.createTileClass(); -var landElevationPainter = new SmoothElevationPainter(ELEVATION_SET, heightLand, 4); +const landElevationPainter = new SmoothElevationPainter(ELEVATION_SET, heightLand, 4); -var unknownMapFunctions = { +const unknownMapFunctions = { "land": [ "Continent", "Isthmus", @@ -99,11 +99,11 @@ * because nomad maps randomize the locations after the terrain generation. * The locations should only determined by the landscape functions to avoid placing bodies of water and resources into civic centers and the starting resources. */ -var playerIDs = sortAllPlayers(); -var playerPosition = []; +let playerIDs = sortAllPlayers(); +let playerPosition = []; -var g_StartingTreasures = false; -var g_StartingWalls = true; +let g_StartingTreasures = false; +let g_StartingWalls = true; function createUnknownMap() {