Index: ps/trunk/binaries/data/mods/public/simulation/components/TerritoryDecayManager.js
===================================================================
--- ps/trunk/binaries/data/mods/public/simulation/components/TerritoryDecayManager.js
+++ ps/trunk/binaries/data/mods/public/simulation/components/TerritoryDecayManager.js
@@ -0,0 +1,12 @@
+function TerritoryDecayManager() {}
+
+TerritoryDecayManager.prototype.Schema =
+ "";
+
+TerritoryDecayManager.prototype.SetBlinkingEntities = function()
+{
+ for (let ent of Engine.GetEntitiesWithInterface(IID_TerritoryDecay))
+ Engine.QueryInterface(ent, IID_TerritoryDecay).IsConnected();
+};
+
+Engine.RegisterSystemComponentType(IID_TerritoryDecayManager, "TerritoryDecayManager", TerritoryDecayManager);
Index: ps/trunk/source/simulation2/TypeList.h
===================================================================
--- ps/trunk/source/simulation2/TypeList.h
+++ ps/trunk/source/simulation2/TypeList.h
@@ -168,6 +168,9 @@
INTERFACE(Terrain)
COMPONENT(Terrain)
+INTERFACE(TerritoryDecayManager)
+COMPONENT(TerritoryDecayManagerScripted)
+
INTERFACE(TerritoryInfluence)
COMPONENT(TerritoryInfluence)
Index: ps/trunk/source/simulation2/components/CCmpAIManager.cpp
===================================================================
--- ps/trunk/source/simulation2/components/CCmpAIManager.cpp
+++ ps/trunk/source/simulation2/components/CCmpAIManager.cpp
@@ -967,6 +967,7 @@
virtual void Init(const CParamNode& UNUSED(paramNode))
{
m_TerritoriesDirtyID = 0;
+ m_TerritoriesDirtyBlinkingID = 0;
m_JustDeserialized = false;
StartLoadEntityTemplates();
@@ -1086,10 +1087,8 @@
Grid dummyGrid2;
const Grid* territoryMap = &dummyGrid2;
CmpPtr cmpTerritoryManager(GetSystemEntity());
- if (cmpTerritoryManager && cmpTerritoryManager->NeedUpdate(&m_TerritoriesDirtyID))
- {
+ if (cmpTerritoryManager && cmpTerritoryManager->NeedUpdate(&m_TerritoriesDirtyID, &m_TerritoriesDirtyBlinkingID))
territoryMap = &cmpTerritoryManager->GetTerritoryGrid();
- }
LoadPathfinderClasses(state);
std::map nonPathfindingPassClassMasks, pathfindingPassClassMasks;
@@ -1150,7 +1149,7 @@
// Update the territory data
// Since getting the territory grid can trigger a recalculation, we check NeedUpdate first
CmpPtr cmpTerritoryManager(GetSystemEntity());
- if (cmpTerritoryManager && (cmpTerritoryManager->NeedUpdate(&m_TerritoriesDirtyID) || m_JustDeserialized))
+ if (cmpTerritoryManager && (cmpTerritoryManager->NeedUpdate(&m_TerritoriesDirtyID, &m_TerritoriesDirtyBlinkingID) || m_JustDeserialized))
{
const Grid& territoryMap = cmpTerritoryManager->GetTerritoryGrid();
m_Worker.UpdateTerritoryMap(territoryMap);
@@ -1190,6 +1189,7 @@
size_t m_TemplateLoadedIdx;
std::vector > m_Templates;
size_t m_TerritoriesDirtyID;
+ size_t m_TerritoriesDirtyBlinkingID;
bool m_JustDeserialized;
Index: ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp
===================================================================
--- ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp
+++ ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp
@@ -36,6 +36,7 @@
#include "simulation2/components/ICmpPlayer.h"
#include "simulation2/components/ICmpPlayerManager.h"
#include "simulation2/components/ICmpPosition.h"
+#include "simulation2/components/ICmpTerritoryDecayManager.h"
#include "simulation2/components/ICmpTerritoryInfluence.h"
#include "simulation2/helpers/Grid.h"
#include "simulation2/helpers/Render.h"
@@ -83,8 +84,8 @@
float m_BorderSeparation;
// Player ID in bits 0-4 (TERRITORY_PLAYER_MASK)
- // connected flag in bit 4 (TERRITORY_CONNECTED_MASK)
- // blinking flag in bit 5 (TERRITORY_BLINKING_MASK)
+ // connected flag in bit 5 (TERRITORY_CONNECTED_MASK)
+ // blinking flag in bit 6 (TERRITORY_BLINKING_MASK)
// processed flag in bit 7 (TERRITORY_PROCESSED_MASK)
Grid* m_Territories;
@@ -125,6 +126,7 @@
m_TriggerEvent = true;
m_EnableLineDebugOverlays = false;
m_DirtyID = 1;
+ m_DirtyBlinkingID = 1;
m_Visible = true;
m_AnimTime = 0.0;
@@ -251,8 +253,10 @@
// To support lazy updates of territory render data,
// we maintain a DirtyID here and increment it whenever territories change;
// if a caller has a lower DirtyID then it needs to be updated.
+ // We also do the same thing for blinking updates using DirtyBlinkingID.
size_t m_DirtyID;
+ size_t m_DirtyBlinkingID;
void MakeDirty()
{
@@ -272,6 +276,17 @@
return false;
}
+ virtual bool NeedUpdate(size_t* dirtyID, size_t* dirtyBlinkingID) const
+ {
+ if (*dirtyID != m_DirtyID || *dirtyBlinkingID != m_DirtyBlinkingID)
+ {
+ *dirtyID = m_DirtyID;
+ *dirtyBlinkingID = m_DirtyBlinkingID;
+ return true;
+ }
+ return false;
+ }
+
void CalculateCostGrid();
void CalculateTerritories();
@@ -538,6 +553,15 @@
++m_TerritoryCellCounts[owner];
);
}
+
+ // Then recomputes the blinking tiles
+ CmpPtr cmpTerritoryDecayManager(GetSystemEntity());
+ if (cmpTerritoryDecayManager)
+ {
+ size_t dirtyBlinkingID = m_DirtyBlinkingID;
+ cmpTerritoryDecayManager->SetBlinkingEntities();
+ m_DirtyBlinkingID = dirtyBlinkingID;
+ }
}
std::vector CCmpTerritoryManager::ComputeBoundaries()
@@ -766,6 +790,7 @@
else
continue;
);
+ ++m_DirtyBlinkingID;
m_BoundaryLinesDirty = true;
}
Index: ps/trunk/source/simulation2/components/ICmpTerritoryDecayManager.h
===================================================================
--- ps/trunk/source/simulation2/components/ICmpTerritoryDecayManager.h
+++ ps/trunk/source/simulation2/components/ICmpTerritoryDecayManager.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2017 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0 A.D. is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0 A.D. If not, see .
+ */
+
+#ifndef INCLUDED_ICMPTERRITORYDECAYMANAGER
+#define INCLUDED_ICMPTERRITORYDECAYMANAGER
+
+#include "simulation2/system/Interface.h"
+
+class ICmpTerritoryDecayManager : public IComponent
+{
+public:
+
+ virtual void SetBlinkingEntities() = 0;
+
+ DECLARE_INTERFACE_TYPE(TerritoryDecayManager)
+};
+
+#endif // INCLUDED_ICMPTERRITORYDECAYMANAGER
Index: ps/trunk/source/simulation2/components/ICmpTerritoryDecayManager.cpp
===================================================================
--- ps/trunk/source/simulation2/components/ICmpTerritoryDecayManager.cpp
+++ ps/trunk/source/simulation2/components/ICmpTerritoryDecayManager.cpp
@@ -0,0 +1,40 @@
+/* Copyright (C) 2017 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0 A.D. is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0 A.D. If not, see .
+ */
+
+#include "precompiled.h"
+
+#include "ICmpTerritoryDecayManager.h"
+
+#include "simulation2/system/InterfaceScripted.h"
+#include "simulation2/scripting/ScriptComponent.h"
+
+BEGIN_INTERFACE_WRAPPER(TerritoryDecayManager)
+END_INTERFACE_WRAPPER(TerritoryDecayManager)
+
+class CCmpTerritoryDecayManagerScripted : public ICmpTerritoryDecayManager
+{
+public:
+ DEFAULT_SCRIPT_WRAPPER(TerritoryDecayManagerScripted)
+
+ virtual void SetBlinkingEntities()
+ {
+ return m_Script.CallVoid("SetBlinkingEntities");
+ }
+
+};
+
+REGISTER_COMPONENT_SCRIPT_WRAPPER(TerritoryDecayManagerScripted)
Index: ps/trunk/source/simulation2/components/ICmpTerritoryManager.h
===================================================================
--- ps/trunk/source/simulation2/components/ICmpTerritoryManager.h
+++ ps/trunk/source/simulation2/components/ICmpTerritoryManager.h
@@ -28,6 +28,7 @@
{
public:
virtual bool NeedUpdate(size_t* dirtyID) const = 0;
+ virtual bool NeedUpdate(size_t* dirtyID, size_t* dirtyBlinkingID) const = 0;
/**
* Number of pathfinder navcells per territory tile.