Fix RMS library forgotten in the previous commit.

Changes some direct accesses to use the library function.

This was SVN commit r16100.
This commit is contained in:
leper 2015-01-01 23:57:00 +00:00
parent a472944689
commit 8097eeb8ab
6 changed files with 15 additions and 15 deletions

View file

@ -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);

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -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,
}
}
}
}
}

View file

@ -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 = [];

View file

@ -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"];