1
0
forked from 0ad/0ad

Mediterranean bugfix for a rare case where birch trees were placed in north africa

(since the localbiome wasn't set for stronghold bases).
Remove non-existing roads which were not accessed before.

This was SVN commit r18553.
This commit is contained in:
elexis 2016-07-24 04:18:10 +00:00
parent a3da37ffd3
commit e80f0f9930
2 changed files with 26 additions and 20 deletions

View File

@ -45,8 +45,8 @@ var biomes = {
"mainTerrain": "temp_grass_d_aut",
"forestFloor1": "temp_grass_long_b_aut",
"forestFloor2": "temp_grass_long_b_aut",
"roadWild": "temp_overgrown_road_autumn",
"road": "temp_road_autumn",
"roadWild": "road_rome_a",
"road": "road_muddy",
// gaia
"tree1": "gaia/flora_tree_oak_aut_new",
"tree2": "gaia/flora_tree_oak_dead",
@ -265,18 +265,14 @@ var strongholdBases = [
[260,55]
];
randomPlayerPlacementAt(singleBases, strongholdBases, scale, 0.06, (singleBase) => {
for (let biome in biomes)
{
let classTiles = checkIfInClass(
Math.floor(singleBase[0] / scale),
Math.floor(singleBase[1] / scale),
g_TileClasses[biome]
);
randomPlayerPlacementAt(singleBases, strongholdBases, scale, 0.06, (tileX, tileY) => {
if (classTiles > 0)
for (let biome in biomes)
if (checkIfInClass(tileX, tileY, g_TileClasses[biome]))
{
setLocalBiome(biomes[biome]);
}
break;
}
});
RMS.SetProgress(50);

View File

@ -531,9 +531,9 @@ function placeStronghold(playerIDs, distance, groupedDistance)
* @param singleBases - pair of coordinates of the heightmap to place isolated bases.
* @param singleBases - pair of coordinates of the heightmap to place team bases.
* @param groupedDistance - distance between neighboring players.
* @param singleBaseFunction - A function called for every singlebase placed.
* @param func - A function called for every player base or stronghold placed.
*/
function randomPlayerPlacementAt(singleBases, strongholdBases, heightmapScale, groupedDistance, singleBaseFunction)
function randomPlayerPlacementAt(singleBases, strongholdBases, heightmapScale, groupedDistance, func)
{
let strongholdBasesRandom = shuffleArray(strongholdBases);
let singleBasesRandom = shuffleArray(singleBases);
@ -546,11 +546,18 @@ function randomPlayerPlacementAt(singleBases, strongholdBases, heightmapScale, g
{
for (let t = 0; t < g_MapInfo.teams.length; ++t)
{
let tileX = Math.floor(strongholdBasesRandom[t][0] / heightmapScale);
let tileY = Math.floor(strongholdBasesRandom[t][1] / heightmapScale);
let x = tileX / g_MapInfo.mapSize;
let z = tileY / g_MapInfo.mapSize;
let team = g_MapInfo.teams[t].map(playerID => ({ "id": playerID }));
let x = Math.floor(strongholdBasesRandom[t][0] / heightmapScale) / g_MapInfo.mapSize;
let z = Math.floor(strongholdBasesRandom[t][1] / heightmapScale) / g_MapInfo.mapSize;
let players = [];
if (func)
func(tileX, tileY);
for (let p = 0; p < team.length; ++p)
{
let angle = g_MapInfo.startAngle + (p + 1) * TWO_PI / team.length;
@ -571,13 +578,16 @@ function randomPlayerPlacementAt(singleBases, strongholdBases, heightmapScale, g
let players = randomizePlayers();
for (let p = 0; p < players.length; ++p)
{
if (singleBaseFunction)
singleBaseFunction(singleBasesRandom[p]);
let tileX = Math.floor(singleBasesRandom[p][0] / heightmapScale);
let tileY = Math.floor(singleBasesRandom[p][1] / heightmapScale);
if (func)
func(tileX, tileY);
createBase({
"id": players[p],
"x": Math.floor(singleBasesRandom[p][0] / heightmapScale) / g_MapInfo.mapSize,
"z": Math.floor(singleBasesRandom[p][1] / heightmapScale) / g_MapInfo.mapSize
"x": tileX / g_MapInfo.mapSize,
"z": tileY / g_MapInfo.mapSize
});
}
}