1
0
forked from mirrors/0ad

Change createPassage function from cfdd37f6d9 to optionally consume a Constraint argument instead of an optional maxHeight argument.

This allows constraining the passage using tileclasses for instance.

This was SVN commit r21356.
This commit is contained in:
elexis
2018-02-24 16:01:20 +00:00
parent 79090bfa63
commit d35d6cc9f9
5 changed files with 7 additions and 7 deletions
@@ -129,7 +129,7 @@ for (let i = 0; i <= randIntInclusive(3, scaleByMapSize(4, 6)); ++i)
"smoothWidth": 2,
"startHeight": heightShallows,
"endHeight": heightShallows,
"maxHeight": heightShallows,
"constraint": new HeightConstraint(-Infinity, heightShallows),
"tileClass": clShallow
});
}
@@ -86,8 +86,7 @@ for (let i = 0; i < scaleByMapSize(5, 12); ++i)
"smoothWidth": 2,
"startHeight": heightShallow,
"endHeight": heightShallow,
"maxHeight": heightShallow,
"terrain": "blue"
"constraint": new HeightConstraint(-Infinity, heightShallow)
});
}
@@ -509,9 +509,9 @@ function createTributaryRivers(riverAngle, riverCount, riverWidth, heightRiverbe
"startWidth": scaleByMapSize(8, 12),
"endWidth": scaleByMapSize(8, 12),
"smoothWidth": 2,
"constraint": new HeightConstraint(-Infinity, heightShallow),
"startHeight": heightShallow,
"endHeight": heightShallow,
"maxHeight": heightShallow,
"tileClass": shallowTileClass
});
}
@@ -523,6 +523,7 @@ function createTributaryRivers(riverAngle, riverCount, riverWidth, heightRiverbe
*
* @property {Vector2D} start - Location of the passage.
* @property {Vector2D} end
* @property {Constraint} [constraint] - Only tiles that meet this constraint are changed.
* @property {number} startWidth - Size of the passage (perpendicular to the direction of the passage).
* @property {number} endWidth
* @property {number} [startHeight] - Fixed height to be used if the height at the location shouldn't be used.
@@ -557,7 +558,7 @@ function createPassage(args)
let location = Vector2D.add(locationLength, Vector2D.mult(widthDirection, stepWidth)).round();
if (!g_Map.inMapBounds(location) ||
args.maxHeight !== undefined && g_Map.getHeight(location) > args.maxHeight)
args.constraint && !args.constraint.allows(location))
continue;
points.push(location);
@@ -135,7 +135,7 @@ for (let i = 0; i < numPlayers; ++i)
"smoothWidth": 4,
"startHeight": heightShallows,
"endHeight": heightShallows,
"maxHeight": heightShallows,
"constraint": new HeightConstraint(-Infinity, heightShallows),
"tileClass": clShallows
});
@@ -263,7 +263,7 @@ for (let i = 0; i < numIslands; ++i)
"startWidth": 11,
"endWidth": 11,
"smoothWidth": 3,
"maxHeight": heightIsland - 1,
"constraint": new HeightConstraint(-Infinity, heightIsland - 1),
"tileClass": clLand,
"terrain": tHill,
"edgeTerrain": tCliff