diff --git a/binaries/data/mods/public/maps/random/fortress.js b/binaries/data/mods/public/maps/random/fortress.js index 14003fbaba..ad5c078ef3 100644 --- a/binaries/data/mods/public/maps/random/fortress.js +++ b/binaries/data/mods/public/maps/random/fortress.js @@ -153,7 +153,7 @@ for (var i=0; i < numPlayers; i++) createObjectGroup(group, 0); // Base texture - var civ = g_MapSettings.PlayerData[i].Civ; + var civ = getCivCode(i); var tilesSize = (civ == "cart" ? 27 : 22); const minBoundX = (playerX[i] > tilesSize ? playerX[i] - tilesSize : 0); diff --git a/binaries/data/mods/public/maps/random/migration.js b/binaries/data/mods/public/maps/random/migration.js index 290de2fd8d..ca57df2178 100644 --- a/binaries/data/mods/public/maps/random/migration.js +++ b/binaries/data/mods/public/maps/random/migration.js @@ -225,7 +225,7 @@ for (var i = 0; i < numPlayers; i++) //create docks var dockLocation = getTIPIADBON([ix, iz], [mapSize / 2, mapSize / 2], [-3 , 2.6], 0.5, 3); if (dockLocation !== undefined) - placeObject(dockLocation[0], dockLocation[1], "structures/" + g_MapSettings.PlayerData[id-1].Civ + "_dock", id, playerAngle[i] + PI); + placeObject(dockLocation[0], dockLocation[1], "structures/" + getCivCode(id-1) + "_dock", id, playerAngle[i] + PI); } diff --git a/binaries/data/mods/public/maps/random/rmgen/library.js b/binaries/data/mods/public/maps/random/rmgen/library.js index 26c01cd3c1..b3623e27f7 100644 --- a/binaries/data/mods/public/maps/random/rmgen/library.js +++ b/binaries/data/mods/public/maps/random/rmgen/library.js @@ -391,13 +391,13 @@ function getMapArea() function getNumPlayers() { - return g_MapSettings.PlayerData.length; + return g_MapSettings.PlayerData.length - 1; } function getCivCode(player) { - if (g_MapSettings.PlayerData[player].Civ) - return g_MapSettings.PlayerData[player].Civ; + if (g_MapSettings.PlayerData[player+1].Civ) + return g_MapSettings.PlayerData[player+1].Civ; warn("undefined civ specified for player " + (player + 1) + ", falling back to '" + FALLBACK_CIV + "'"); return FALLBACK_CIV; @@ -405,25 +405,25 @@ function getCivCode(player) function areAllies(player1, player2) { - if ((g_MapSettings.PlayerData[player1].Team === undefined) || (g_MapSettings.PlayerData[player2].Team === undefined) || (g_MapSettings.PlayerData[player2].Team == -1) || (g_MapSettings.PlayerData[player1].Team == -1)) + if ((g_MapSettings.PlayerData[player1+1].Team === undefined) || (g_MapSettings.PlayerData[player2+1].Team === undefined) || (g_MapSettings.PlayerData[player2+1].Team == -1) || (g_MapSettings.PlayerData[player1+1].Team == -1)) { return false; } else { - return (g_MapSettings.PlayerData[player1].Team === g_MapSettings.PlayerData[player2].Team); + return (g_MapSettings.PlayerData[player1+1].Team === g_MapSettings.PlayerData[player2+1].Team); } } function getPlayerTeam(player) { - if (g_MapSettings.PlayerData[player].Team === undefined) + if (g_MapSettings.PlayerData[player+1].Team === undefined) { return -1; } else { - return g_MapSettings.PlayerData[player].Team; + return g_MapSettings.PlayerData[player+1].Team; } } diff --git a/binaries/data/mods/public/maps/random/rmgen/misc.js b/binaries/data/mods/public/maps/random/rmgen/misc.js index bb5b8ee756..79204542c5 100644 --- a/binaries/data/mods/public/maps/random/rmgen/misc.js +++ b/binaries/data/mods/public/maps/random/rmgen/misc.js @@ -178,7 +178,7 @@ function placeCivDefaultEntities(fx, fz, playerid, angle, kwargs) if ('iberWall' in kwargs) iberWall = kwargs['iberWall']; // Place default civ starting entities - var civ = g_MapSettings.PlayerData[playerid-1].Civ; + var civ = getCivCode(playerid-1); var civEntities = getStartingEntities(playerid-1); var uDist = 6; var uSpace = 2; @@ -768,4 +768,4 @@ function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraint, } } } -} \ No newline at end of file +} diff --git a/binaries/data/mods/public/maps/random/schwarzwald.js b/binaries/data/mods/public/maps/random/schwarzwald.js index 80242fdc7c..d8f7e53711 100644 --- a/binaries/data/mods/public/maps/random/schwarzwald.js +++ b/binaries/data/mods/public/maps/random/schwarzwald.js @@ -276,7 +276,7 @@ Takes heightmap Optional, default is g_Map.height, an array of (map width) arrays of (map depth) floats maxTries Optional, default is 1000, an integer, how often random player distributions are rolled to be compared minDistToBorder Optional, default is 20, an integer, how far start locations have to be - numberOfPlayers Optional, default is g_MapSettings.PlayerData.length, an integer, how many start locations should be placed + numberOfPlayers Optional, default is getNumPlayers, an integer, how many start locations should be placed Returns An array of 2D points (arrays of length 2) */ @@ -284,7 +284,7 @@ function getStartLocationsByHeightmap(hightRange, maxTries, minDistToBorder, num { maxTries = (maxTries || 1000); minDistToBorder = (minDistToBorder || 20); - numberOfPlayers = (numberOfPlayers || g_MapSettings.PlayerData.length); + numberOfPlayers = (numberOfPlayers || getNumPlayers()); heightmap = (heightmap || g_Map.height); var validStartLocTiles = []; diff --git a/binaries/data/mods/public/maps/random/wall_demo.js b/binaries/data/mods/public/maps/random/wall_demo.js index 45fefd9341..6a1a0fd69b 100644 --- a/binaries/data/mods/public/maps/random/wall_demo.js +++ b/binaries/data/mods/public/maps/random/wall_demo.js @@ -35,7 +35,7 @@ const BUILDING_ANlE = -PI/4; // It takes an instance of the Fortress class instead of the default fortress type strings // The next argument is always the wall style string -// Wall styles are chosen by strings so the civ strings got by g_MapSettings.PlayerData[playerId - 1].Civ can be used +// Wall styles are chosen by strings so the civ strings got by getCivCode() can be used // Other styles may be present as well but besides the civ styles only 'palisades' includes all wall element types (yet) // The next argument is always the index of the player that owns the wall. @@ -61,7 +61,7 @@ const distToOtherWalls = 10; var buildableMapSize = mapSize - 2 * distToMapBorder; var actualX = distToMapBorder; var actualY = distToMapBorder; -// Wall styles are chosen by strings so the civ strings got by g_MapSettings.PlayerData[playerId - 1].Civ can be used +// Wall styles are chosen by strings so the civ strings got by getCivCode() can be used // Other styles may be present as well but besides the civ styles only 'palisades' includes all wall element types (yet) const wallStyleList = ["athen", "brit", "cart", "celt", "gaul", "hele", "iber", "mace", "maur", "pers", "ptol", "rome", "sele", "spart", "rome_siege", "palisades"];