diff --git a/binaries/data/mods/public/simulation/components/EndGameManager.js b/binaries/data/mods/public/simulation/components/EndGameManager.js index aa3afaed8e..a841ca9688 100644 --- a/binaries/data/mods/public/simulation/components/EndGameManager.js +++ b/binaries/data/mods/public/simulation/components/EndGameManager.js @@ -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) diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js index a40ebfa1bb..910535f9d0 100644 --- a/binaries/data/mods/public/simulation/components/GuiInterface.js +++ b/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -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) diff --git a/binaries/data/mods/public/simulation/helpers/Cheat.js b/binaries/data/mods/public/simulation/helpers/Cheat.js index ea2987587d..0e00ab9606 100644 --- a/binaries/data/mods/public/simulation/helpers/Cheat.js +++ b/binaries/data/mods/public/simulation/helpers/Cheat.js @@ -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); diff --git a/binaries/data/mods/public/simulation/helpers/Commands.js b/binaries/data/mods/public/simulation/helpers/Commands.js index 48d3872998..aa3036dbd6 100644 --- a/binaries/data/mods/public/simulation/helpers/Commands.js +++ b/binaries/data/mods/public/simulation/helpers/Commands.js @@ -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": diff --git a/binaries/data/mods/public/simulation/helpers/Setup.js b/binaries/data/mods/public/simulation/helpers/Setup.js index 0d7a012a8f..81e7795fbc 100644 --- a/binaries/data/mods/public/simulation/helpers/Setup.js +++ b/binaries/data/mods/public/simulation/helpers/Setup.js @@ -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) diff --git a/source/simulation2/components/CCmpRangeManager.cpp b/source/simulation2/components/CCmpRangeManager.cpp index 42eb4c0551..7305f6e561 100644 --- a/source/simulation2/components/CCmpRangeManager.cpp +++ b/source/simulation2/components/CCmpRangeManager.cpp @@ -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 m_LosRevealAll; + std::vector 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 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 m_LosStateRevealed; // Shared LOS masks, one per player. - std::map m_SharedLosMasks; + std::vector 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()(serialize, "queries", m_Queries, GetSimContext()); SerializeEntityMap()(serialize, "entity data", m_EntityData); - SerializeMap()(serialize, "los reveal all", m_LosRevealAll); + SerializeVector()(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()(serialize, "los state", m_LosState); - - SerializeMap()(serialize, "shared los masks", m_SharedLosMasks); + SerializeVector()(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::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::const_iterator it = m_SharedLosMasks.find(player); - ENSURE(it != m_SharedLosMasks.end()); - return m_SharedLosMasks[player]; } diff --git a/source/tools/atlas/GameInterface/ActorViewer.cpp b/source/tools/atlas/GameInterface/ActorViewer.cpp index c8c171b7ed..26e5092c95 100644 --- a/source/tools/atlas/GameInterface/ActorViewer.cpp +++ b/source/tools/atlas/GameInterface/ActorViewer.cpp @@ -295,7 +295,7 @@ ActorViewer::ActorViewer() // Remove FOW since we're in Atlas CmpPtr cmpRangeManager(m.Simulation2, SYSTEM_ENTITY); if (cmpRangeManager) - cmpRangeManager->SetLosRevealAll(-1, true); + cmpRangeManager->SetLosRevealAll(0, true); } ActorViewer::~ActorViewer() diff --git a/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp index 26111335bc..21b12b225e 100644 --- a/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp @@ -73,7 +73,7 @@ namespace // as visual actors cache their visibility state on first render. CmpPtr 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);