forked from 0ad/0ad
Replace hardcoded copies of a C++ simulation constant in JS used to compute the mapsize with a call to a new getter in the C++ interface.
Differential Revision: https://code.wildfiregames.com/D577 Patch By: Sandarac This was SVN commit r19699.
This commit is contained in:
parent
72f6e02747
commit
77c4e649af
@ -500,7 +500,7 @@ Trigger.prototype.UngarrisonShipsOrder = function()
|
||||
let ungarrisonLeft = false;
|
||||
let ungarrisonRight = false;
|
||||
|
||||
let mapSize = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain).GetTilesPerSide() * 4;
|
||||
let mapSize = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain).GetMapSize();
|
||||
|
||||
for (let ent of Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetNonGaiaEntities())
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ GuiInterface.prototype.GetSimulationState = function()
|
||||
|
||||
let cmpTerrain = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain);
|
||||
if (cmpTerrain)
|
||||
ret.mapSize = 4 * cmpTerrain.GetTilesPerSide();
|
||||
ret.mapSize = cmpTerrain.GetMapSize();
|
||||
|
||||
// Add timeElapsed
|
||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
|
||||
|
@ -106,7 +106,7 @@ UnitMotionFlying.prototype.OnUpdate = function(msg)
|
||||
this.hasTarget = false;
|
||||
this.landing = false;
|
||||
// summon planes back from the edge of the map
|
||||
var terrainSize = cmpTerrain.GetTilesPerSide() * 4;
|
||||
var terrainSize = cmpTerrain.GetMapSize();
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
if (cmpRangeManager.GetLosCircular())
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ AddMock(entity, IID_RangeManager, {
|
||||
|
||||
AddMock(entity, IID_Terrain, {
|
||||
"GetGroundLevel": () => 4,
|
||||
"GetTilesPerSide": () => 5
|
||||
"GetMapSize": () => 20
|
||||
});
|
||||
|
||||
AddMock(entity, IID_WaterManager, {
|
||||
|
@ -102,6 +102,11 @@ public:
|
||||
return (u16)tiles;
|
||||
}
|
||||
|
||||
virtual u32 GetMapSize() const
|
||||
{
|
||||
return GetTilesPerSide() * TERRAIN_TILE_SIZE;
|
||||
}
|
||||
|
||||
virtual u16 GetVerticesPerSide() const
|
||||
{
|
||||
ssize_t vertices = m_Terrain->GetVerticesPerSide();
|
||||
|
@ -25,4 +25,5 @@ BEGIN_INTERFACE_WRAPPER(Terrain)
|
||||
DEFINE_INTERFACE_METHOD_CONST_2("GetGroundLevel", entity_pos_t, ICmpTerrain, GetGroundLevel, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_2("CalcNormal", CFixedVector3D, ICmpTerrain, CalcNormal, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetTilesPerSide", u16, ICmpTerrain, GetTilesPerSide)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetMapSize", u32, ICmpTerrain, GetMapSize)
|
||||
END_INTERFACE_WRAPPER(Terrain)
|
||||
|
@ -52,6 +52,11 @@ public:
|
||||
*/
|
||||
virtual u16 GetVerticesPerSide() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the map size in metres (world space units).
|
||||
*/
|
||||
virtual u32 GetMapSize() const = 0;
|
||||
|
||||
virtual CTerrain* GetCTerrain() = 0;
|
||||
|
||||
/**
|
||||
|
@ -212,6 +212,11 @@ public:
|
||||
return 16;
|
||||
}
|
||||
|
||||
virtual u32 GetMapSize() const
|
||||
{
|
||||
return GetTilesPerSide() * TERRAIN_TILE_SIZE;
|
||||
}
|
||||
|
||||
virtual u16 GetVerticesPerSide() const
|
||||
{
|
||||
return 17;
|
||||
|
Loading…
Reference in New Issue
Block a user