mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 10:03:43 +00:00
Use only one coordinate system for locations in the rmgen system.
Thereby fix the distance check of the SimpleObject, refs #4338, D189 and remove the CELL_SIZE engine constant magic number, refs #4034. Differential Revision: https://code.wildfiregames.com/D996 Thanks a lot to rapidelectron and temple who independently discovered this! This was SVN commit r20396.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* The Entity class stores the given template name, owner and location of an entity and assigns an entityID.
|
||||
* Instances of this class are passed as such to the engine.
|
||||
* Instances of this class (with the position using the tile coordinate system) are passed as such to the engine.
|
||||
*
|
||||
* @param orientation - rotation of this entity about the y-axis (up).
|
||||
*/
|
||||
@@ -12,9 +12,9 @@ function Entity(templateName, playerID, x, z, orientation = 0)
|
||||
this.player = playerID;
|
||||
|
||||
this.position = {
|
||||
"x": x * CELL_SIZE,
|
||||
"x": x,
|
||||
"y": 0,
|
||||
"z": z * CELL_SIZE
|
||||
"z": z
|
||||
};
|
||||
|
||||
this.rotation = {
|
||||
|
||||
@@ -46,14 +46,11 @@ SimpleGroup.prototype.place = function(player, constraint)
|
||||
// Add all objects to the map
|
||||
for (let obj of resultObjs)
|
||||
{
|
||||
let x = obj.position.x / CELL_SIZE;
|
||||
let z = obj.position.z / CELL_SIZE;
|
||||
|
||||
if (g_Map.validT(x, z))
|
||||
if (g_Map.validT(obj.position.x, obj.position.z))
|
||||
g_Map.addObject(obj);
|
||||
|
||||
if (this.tileClass !== undefined)
|
||||
getTileClass(this.tileClass).add(Math.floor(x), Math.floor(z));
|
||||
getTileClass(this.tileClass).add(Math.floor(obj.position.x), Math.floor(obj.position.z));
|
||||
}
|
||||
|
||||
return resultObjs;
|
||||
|
||||
@@ -2,7 +2,6 @@ const PI = Math.PI;
|
||||
const TWO_PI = 2 * Math.PI;
|
||||
const TERRAIN_SEPARATOR = "|";
|
||||
const SEA_LEVEL = 20.0;
|
||||
const CELL_SIZE = 4;
|
||||
const HEIGHT_UNITS_PER_METRE = 92;
|
||||
const MAP_BORDER_WIDTH = 3;
|
||||
const FALLBACK_CIV = "athen";
|
||||
|
||||
@@ -1383,7 +1383,7 @@ int CMapReader::ParseEntities()
|
||||
CmpPtr<ICmpPosition> cmpPosition(sim, ent);
|
||||
if (cmpPosition)
|
||||
{
|
||||
cmpPosition->JumpTo(currEnt.position.X, currEnt.position.Z);
|
||||
cmpPosition->JumpTo(currEnt.position.X * (int)TERRAIN_TILE_SIZE, currEnt.position.Z * (int)TERRAIN_TILE_SIZE);
|
||||
cmpPosition->SetYRotation(currEnt.rotation.Y);
|
||||
// TODO: other parts of the position
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user