mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Further reduce usage of TERRAIN_TILE_SIZE in non-terrain components
TERRAIN_TILE_SIZE is now only used in relevant places in the simulation. This also makes it mostly possible to use CFixed in constexpr contexts. Refs #5566 Differential Revision: https://code.wildfiregames.com/D3078 This was SVN commit r25360.
This commit is contained in:
@@ -203,7 +203,7 @@ public:
|
||||
sim2.LoadDefaultScripts();
|
||||
sim2.ResetState();
|
||||
|
||||
const entity_pos_t range = entity_pos_t::FromInt(TERRAIN_TILE_SIZE*12);
|
||||
const entity_pos_t range = entity_pos_t::FromInt(48);
|
||||
|
||||
CmpPtr<ICmpObstructionManager> cmpObstructionMan(sim2, SYSTEM_ENTITY);
|
||||
CmpPtr<ICmpPathfinder> cmpPathfinder(sim2, SYSTEM_ENTITY);
|
||||
@@ -405,7 +405,7 @@ public:
|
||||
stream << " title='length: " << length << "; tiles explored: " << debugSteps << "; time: " << debugTime*1000 << " msec'";
|
||||
stream << " class='path' points='";
|
||||
for (size_t i = 0; i < path.m_Waypoints.size(); ++i)
|
||||
stream << path.m_Waypoints[i].x.ToDouble()*Pathfinding::NAVCELLS_PER_TILE/TERRAIN_TILE_SIZE << "," << path.m_Waypoints[i].z.ToDouble()*Pathfinding::NAVCELLS_PER_TILE/TERRAIN_TILE_SIZE << " ";
|
||||
stream << path.m_Waypoints[i].x.ToDouble()*Pathfinding::NAVCELL_SIZE_INT << "," << path.m_Waypoints[i].z.ToDouble()*Pathfinding::NAVCELL_SIZE_INT << " ";
|
||||
stream << "'/>\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "graphics/Terrain.h"
|
||||
#include "graphics/TerritoryBoundary.h"
|
||||
#include "simulation2/helpers/Grid.h"
|
||||
#include "simulation2/components/ICmpTerritoryManager.h"
|
||||
|
||||
class TestCmpTerritoryManager : public CxxTest::TestSuite
|
||||
{
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
TS_ASSERT_EQUALS((player_id_t)7, boundaries[0].owner);
|
||||
TS_ASSERT_EQUALS(false, boundaries[0].blinking); // high bits aren't set by GetGrid
|
||||
|
||||
// assumes CELL_SIZE is 2; dealt with in TestBoundaryPointsEqual
|
||||
// assumes NAVCELLS_PER_TERRITORY_TILE is 8; dealt with in TestBoundaryPointsEqual
|
||||
int expectedPoints[][2] = {{ 4, 8}, {12, 8}, {20, 8}, {28, 8}, {36, 8}, {44, 8},
|
||||
{48,12}, {48,20}, {48,28},
|
||||
{44,32}, {36,32}, {28,32}, {20,32}, {12,32}, { 4,32},
|
||||
@@ -281,10 +282,10 @@ private:
|
||||
// version of 'points', so that the starting position doesn't need to match exactly.
|
||||
for (size_t i = 0; i < points.size(); i++)
|
||||
{
|
||||
// the input numbers in expectedPoints are defined under the assumption that CELL_SIZE is 2, so let's include
|
||||
// a scaling factor to protect against that should CELL_SIZE ever change
|
||||
TS_ASSERT_DELTA(points[i].X, float(expectedPoints[i][0]) * 4.f / TERRAIN_TILE_SIZE, 1e-7);
|
||||
TS_ASSERT_DELTA(points[i].Y, float(expectedPoints[i][1]) * 4.f / TERRAIN_TILE_SIZE, 1e-7);
|
||||
// the input numbers in expectedPoints are defined under the assumption that NAVCELLS_PER_TERRITORY_TILE is 8, so let's include
|
||||
// a scaling factor to protect against that should NAVCELLS_PER_TERRITORY_TILE ever change
|
||||
TS_ASSERT_DELTA(points[i].X, float(expectedPoints[i][0]) * 8.f / ICmpTerritoryManager::NAVCELLS_PER_TERRITORY_TILE, 1e-7);
|
||||
TS_ASSERT_DELTA(points[i].Y, float(expectedPoints[i][1]) * 8.f / ICmpTerritoryManager::NAVCELLS_PER_TERRITORY_TILE, 1e-7);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user