forked from 0ad/0ad
Change some useless std::map into std::vector for LOS. Player "0" now reveals the LOS for all.
This was SVN commit r14463.
This commit is contained in:
parent
d7f18c10de
commit
fe2a97b0c9
@ -50,7 +50,7 @@ EndGameManager.prototype.MarkPlayerAsWon = function(playerID)
|
||||
|
||||
// Reveal the map to all players
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
cmpRangeManager.SetLosRevealAll(-1, true);
|
||||
cmpRangeManager.SetLosRevealAll(0, true);
|
||||
};
|
||||
|
||||
EndGameManager.prototype.SetAlliedVictory = function(flag)
|
||||
|
@ -944,15 +944,15 @@ GuiInterface.prototype.DisplayRallyPoint = function(player, cmd)
|
||||
if (cmd.queued == true)
|
||||
cmpRallyPointRenderer.AddPosition({'x': pos.x, 'y': pos.z}); // AddPosition takes a CFixedVector2D which has X/Y components, not X/Z
|
||||
else if (cmd.queued == false)
|
||||
cmpRallyPointRenderer.SetPosition({'x': pos.x, 'y': pos.z}); // SetPosition takes a CFixedVector2D which has X/Y components, not X/Z
|
||||
cmpRallyPointRenderer.SetPosition({'x': pos.x, 'y': pos.z}); // SetPosition takes a CFixedVector2D which has X/Y components, not X/Z
|
||||
// rebuild the renderer when not set (when reading saved game or in case of building update)
|
||||
else if (!cmpRallyPointRenderer.IsSet())
|
||||
for each (var posi in cmpRallyPoint.GetPositions())
|
||||
cmpRallyPointRenderer.AddPosition({'x': posi.x, 'y': posi.z});
|
||||
|
||||
cmpRallyPointRenderer.SetDisplayed(true);
|
||||
|
||||
// remember which entities have their rally points displayed so we can hide them again
|
||||
cmpRallyPointRenderer.SetDisplayed(true);
|
||||
|
||||
// remember which entities have their rally points displayed so we can hide them again
|
||||
this.entsRallyPointsDisplayed.push(ent);
|
||||
}
|
||||
}
|
||||
@ -1826,7 +1826,7 @@ GuiInterface.prototype.GetBatchTime = function(player, data)
|
||||
GuiInterface.prototype.IsMapRevealed = function(player)
|
||||
{
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
return cmpRangeManager.GetLosRevealAll(-1);
|
||||
return cmpRangeManager.GetLosRevealAll(0);
|
||||
};
|
||||
|
||||
GuiInterface.prototype.SetPathfinderDebugOverlay = function(player, enabled)
|
||||
|
@ -24,7 +24,7 @@ function Cheat(input)
|
||||
break;
|
||||
case "revealmap":
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
cmpRangeManager.SetLosRevealAll(-1, true);
|
||||
cmpRangeManager.SetLosRevealAll(0, true);
|
||||
break;
|
||||
case "maxpopulation":
|
||||
cmpPlayer.SetPopulationBonuses(500);
|
||||
|
@ -83,7 +83,7 @@ function ProcessCommand(player, cmd)
|
||||
// Reveal the map for all players, not just the current player,
|
||||
// primarily to make it obvious to everyone that the player is cheating
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
cmpRangeManager.SetLosRevealAll(-1, cmd.enable);
|
||||
cmpRangeManager.SetLosRevealAll(0, cmd.enable);
|
||||
break;
|
||||
|
||||
case "walk":
|
||||
|
@ -22,7 +22,7 @@ function LoadMapSettings(settings)
|
||||
{
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
if (cmpRangeManager)
|
||||
cmpRangeManager.SetLosRevealAll(-1, true);
|
||||
cmpRangeManager.SetLosRevealAll(0, true);
|
||||
}
|
||||
|
||||
if (settings.CircularMap)
|
||||
|
@ -277,8 +277,9 @@ public:
|
||||
SpatialSubdivision m_Subdivision; // spatial index of m_EntityData
|
||||
|
||||
// LOS state:
|
||||
static const player_id_t MAX_LOS_PLAYER_ID = 16;
|
||||
|
||||
std::map<player_id_t, bool> m_LosRevealAll;
|
||||
std::vector<bool> m_LosRevealAll;
|
||||
bool m_LosCircular;
|
||||
i32 m_TerrainVerticesPerSide;
|
||||
size_t m_TerritoriesDirtyID;
|
||||
@ -292,14 +293,13 @@ public:
|
||||
|
||||
// 2-bit ELosState per player, starting with player 1 (not 0!) up to player MAX_LOS_PLAYER_ID (inclusive)
|
||||
std::vector<u32> m_LosState;
|
||||
static const player_id_t MAX_LOS_PLAYER_ID = 16;
|
||||
|
||||
// Special static visibility data for the "reveal whole map" mode
|
||||
// (TODO: this is usually a waste of memory)
|
||||
std::vector<u32> m_LosStateRevealed;
|
||||
|
||||
// Shared LOS masks, one per player.
|
||||
std::map<player_id_t, u32> m_SharedLosMasks;
|
||||
std::vector<u32> m_SharedLosMasks;
|
||||
|
||||
// Cache explored vertices per player (not serialized)
|
||||
u32 m_TotalInworldVertices;
|
||||
@ -325,12 +325,9 @@ public:
|
||||
|
||||
// The whole map should be visible to Gaia by default, else e.g. animals
|
||||
// will get confused when trying to run from enemies
|
||||
m_LosRevealAll[0] = true;
|
||||
|
||||
// This is not really an error condition, an entity recently created or destroyed
|
||||
// might have an owner of INVALID_PLAYER
|
||||
m_SharedLosMasks[INVALID_PLAYER] = 0;
|
||||
|
||||
m_LosRevealAll.resize(17,false);
|
||||
m_SharedLosMasks.resize(17,0);
|
||||
|
||||
m_LosCircular = false;
|
||||
m_TerrainVerticesPerSide = 0;
|
||||
|
||||
@ -353,7 +350,7 @@ public:
|
||||
SerializeMap<SerializeU32_Unbounded, SerializeQuery>()(serialize, "queries", m_Queries, GetSimContext());
|
||||
SerializeEntityMap<SerializeEntityData>()(serialize, "entity data", m_EntityData);
|
||||
|
||||
SerializeMap<SerializeI32_Unbounded, SerializeBool>()(serialize, "los reveal all", m_LosRevealAll);
|
||||
SerializeVector<SerializeBool>()(serialize, "los reveal all", m_LosRevealAll);
|
||||
serialize.Bool("los circular", m_LosCircular);
|
||||
serialize.NumberI32_Unbounded("terrain verts per side", m_TerrainVerticesPerSide);
|
||||
|
||||
@ -362,8 +359,7 @@ public:
|
||||
// m_LosState must be serialized since it depends on the history of exploration
|
||||
|
||||
SerializeVector<SerializeU32_Unbounded>()(serialize, "los state", m_LosState);
|
||||
|
||||
SerializeMap<SerializeI32_Unbounded, SerializeU32_Unbounded>()(serialize, "shared los masks", m_SharedLosMasks);
|
||||
SerializeVector<SerializeU32_Unbounded>()(serialize, "shared los masks", m_SharedLosMasks);
|
||||
}
|
||||
|
||||
virtual void Serialize(ISerializer& serialize)
|
||||
@ -1390,16 +1386,12 @@ public:
|
||||
|
||||
virtual bool GetLosRevealAll(player_id_t player)
|
||||
{
|
||||
std::map<player_id_t, bool>::const_iterator it;
|
||||
|
||||
// Special player value can force reveal-all for every player
|
||||
it = m_LosRevealAll.find(-1);
|
||||
if (it != m_LosRevealAll.end() && it->second)
|
||||
if(m_LosRevealAll[0])
|
||||
return true;
|
||||
|
||||
// Otherwise check the player-specific flag
|
||||
it = m_LosRevealAll.find(player);
|
||||
if (it != m_LosRevealAll.end() && it->second)
|
||||
if (m_LosRevealAll[player])
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -1424,9 +1416,6 @@ public:
|
||||
|
||||
virtual u32 GetSharedLosMask(player_id_t player)
|
||||
{
|
||||
std::map<player_id_t, u32>::const_iterator it = m_SharedLosMasks.find(player);
|
||||
ENSURE(it != m_SharedLosMasks.end());
|
||||
|
||||
return m_SharedLosMasks[player];
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ ActorViewer::ActorViewer()
|
||||
// Remove FOW since we're in Atlas
|
||||
CmpPtr<ICmpRangeManager> cmpRangeManager(m.Simulation2, SYSTEM_ENTITY);
|
||||
if (cmpRangeManager)
|
||||
cmpRangeManager->SetLosRevealAll(-1, true);
|
||||
cmpRangeManager->SetLosRevealAll(0, true);
|
||||
}
|
||||
|
||||
ActorViewer::~ActorViewer()
|
||||
|
@ -73,7 +73,7 @@ namespace
|
||||
// as visual actors cache their visibility state on first render.
|
||||
CmpPtr<ICmpRangeManager> cmpRangeManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY);
|
||||
if (cmpRangeManager)
|
||||
cmpRangeManager->SetLosRevealAll(-1, true);
|
||||
cmpRangeManager->SetLosRevealAll(0, true);
|
||||
|
||||
PSRETURN ret = g_Game->ReallyStartGame();
|
||||
ENSURE(ret == PSRETURN_OK);
|
||||
|
Loading…
Reference in New Issue
Block a user