diff --git a/binaries/data/mods/public/maps/random/alpine_lakes.js b/binaries/data/mods/public/maps/random/alpine_lakes.js index 5c0de9805d..4dc6f290cc 100644 --- a/binaries/data/mods/public/maps/random/alpine_lakes.js +++ b/binaries/data/mods/public/maps/random/alpine_lakes.js @@ -155,8 +155,8 @@ for (var i = 0; i < numPlayers; i++) // get the x and z in tiles var fx = fractionToTiles(playerX[i]); var fz = fractionToTiles(playerZ[i]); - ix = round(fx); - iz = round(fz); + var ix = round(fx); + var iz = round(fz); addToClass(ix, iz, clPlayer); addToClass(ix+5, iz, clPlayer); addToClass(ix, iz+5, clPlayer); @@ -256,6 +256,8 @@ RMS.SetProgress(20); log("Creating hills..."); createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 8), clHill, scaleByMapSize(10, 40) * numPlayers, floor(scaleByMapSize(40, 60)), floor(scaleByMapSize(4, 5)), floor(scaleByMapSize(7, 15)), floor(scaleByMapSize(5, 15))); +RMS.SetProgress(30); + var lakeAreas = []; var playerConstraint = new AvoidTileClassConstraint(clPlayer, 20); var waterConstraint = new AvoidTileClassConstraint(clWater, 8); @@ -278,7 +280,7 @@ for (var i = 0; i < numLakes; ++i) if (!lakeAreaLen) break; - chosenPoint = lakeAreas[randInt(0, lakeAreaLen)]; + chosenPoint = lakeAreas[randInt(lakeAreaLen)]; placer = new ChainPlacer(1, floor(scaleByMapSize(4, 8)), floor(scaleByMapSize(40, 180)), 0.7, chosenPoint[0], chosenPoint[1]); var terrainPainter = new LayeredPainter( @@ -292,17 +294,17 @@ for (var i = 0; i < numLakes; ++i) avoidClasses(clPlayer, 20, clWater, 8), 1, 1 ); - - if (newLake !== undefined) + + if (newLake && newLake.length) { - var temp = [] + var n = 0; for (var j = 0; j < lakeAreaLen; ++j) { var x = lakeAreas[j][0], z = lakeAreas[j][1]; if (playerConstraint.allows(x, z) && waterConstraint.allows(x, z)) - temp.push([x, z]); + lakeAreas[n++] = lakeAreas[j]; } - lakeAreas = temp; + lakeAreas.length = n; } } @@ -446,4 +448,4 @@ setWaterWaviness(3.0); setWaterType("clap"); // Export map data -ExportMap(); \ No newline at end of file +ExportMap(); diff --git a/binaries/data/mods/public/maps/random/islands.js b/binaries/data/mods/public/maps/random/islands.js index 6389b6d2c6..a840254eb8 100644 --- a/binaries/data/mods/public/maps/random/islands.js +++ b/binaries/data/mods/public/maps/random/islands.js @@ -240,7 +240,7 @@ for (var i = 0; i < numIslands; ++i) if (!landAreaLen) break; - chosenPoint = landAreas[randInt(0, landAreaLen)]; + chosenPoint = landAreas[randInt(landAreaLen)]; // create big islands placer = new ChainPlacer(floor(scaleByMapSize(4, 8)), floor(scaleByMapSize(8, 14)), floor(scaleByMapSize(25, 60)), 0.07, chosenPoint[0], chosenPoint[1], scaleByMapSize(30,70)); @@ -256,16 +256,16 @@ for (var i = 0; i < numIslands; ++i) avoidClasses(clLand, 3, clPlayer, 3), 1, 1 ); - if (newIsland !== undefined) + if (newIsland && newIsland.length) { - var temp = [] - for (var j = 0; j < landAreaLen; ++j) + var n = 0; + for (var j = 0; j < lakeAreaLen; ++j) { - var x = landAreas[j][0], z = landAreas[j][1]; - if (playerConstraint.allows(x, z) && landConstraint.allows(x, z)) - temp.push([x, z]); + var x = lakeAreas[j][0], z = lakeAreas[j][1]; + if (playerConstraint.allows(x, z) && waterConstraint.allows(x, z)) + lakeAreas[n++] = lakeAreas[j]; } - landAreas = temp; + lakeAreas.length = n; } } diff --git a/binaries/data/mods/public/maps/random/rmgen/misc.js b/binaries/data/mods/public/maps/random/rmgen/misc.js index 79204542c5..c4cc8f0623 100644 --- a/binaries/data/mods/public/maps/random/rmgen/misc.js +++ b/binaries/data/mods/public/maps/random/rmgen/misc.js @@ -585,15 +585,6 @@ function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraint, var edges = [[x, z]] var circles = []; - var pointHeights = [] - for (var ix = sx; ix <= lx; ++ix) - { - pointHeights.push([]); - for (var iz = sz; iz <= lz; ++iz) - { - pointHeights.push(g_Map.getHeight(ix, iz)); - } - } for (var i = 0; i < numCircles; ++i) { diff --git a/binaries/data/mods/public/maps/random/rmgen/tileclass.js b/binaries/data/mods/public/maps/random/rmgen/tileclass.js index 56fd8c8b13..bd4d137ad4 100644 --- a/binaries/data/mods/public/maps/random/rmgen/tileclass.js +++ b/binaries/data/mods/public/maps/random/rmgen/tileclass.js @@ -136,19 +136,21 @@ TileClass.prototype.countInRadius = function(cx, cy, radius, returnMembers) } else // Simply check the tiles one by one to find the number { - var xmax = cx + radius; - for (var x = cx-radius; x <= xmax; x++) + var dy = (iy - cy); + var xmin = Math.floor(cx - radius); + var xmax = Math.ceil(cx + radius); + xmin = (xmin >= 0) ? xmin : 0; + xmax = ( xmax < size) ? xmax : size - 1; + for (var ix = xmin; ix <= xmax; ++ix) { - var ix = Math.floor(x); var dx = (ix - cx); - var dy = (iy - cy); if (dx*dx + dy*dy <= radius2) + { if (this.inclusionCount[ix] && this.inclusionCount[ix][iy] && this.inclusionCount[ix][iy] > 0) - { members += 1; - } else nonMembers += 1; + } } } } diff --git a/binaries/data/mods/public/maps/random/unknown_land.js b/binaries/data/mods/public/maps/random/unknown_land.js index 9a3a87d634..f7e05fa2eb 100644 --- a/binaries/data/mods/public/maps/random/unknown_land.js +++ b/binaries/data/mods/public/maps/random/unknown_land.js @@ -1119,7 +1119,7 @@ else if (md == 8) //lakes if (!lakeAreaLen) break; - chosenPoint = lakeAreas[randInt(0, lakeAreaLen)]; + chosenPoint = lakeAreas[randInt(lakeAreaLen)]; placer = new ChainPlacer(1, floor(scaleByMapSize(4, 8)), floor(scaleByMapSize(40, 180)), 0.7, chosenPoint[0], chosenPoint[1]); terrainPainter = new LayeredPainter( @@ -1133,19 +1133,18 @@ else if (md == 8) //lakes avoidClasses(clPlayer, 20, clWater, 8), 1, 1 ); - - if (newLake !== undefined) + + if (newLake && newLake.length) { - var temp = [] + var n = 0; for (var j = 0; j < lakeAreaLen; ++j) { var x = lakeAreas[j][0], z = lakeAreas[j][1]; if (playerConstraint.allows(x, z) && waterConstraint.allows(x, z)) - temp.push([x, z]); + lakeAreas[n++] = lakeAreas[j]; } - lakeAreas = temp; - } - + lakeAreas.length = n; + } } } //********************************************************************************************************