Ticket #3891: territoryBlinking.diff
File territoryBlinking.diff, 5.3 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/TerritoryDecay.js
48 48 49 49 for (var i = 1; i < numPlayers; ++i) 50 50 if (this.connectedNeighbours[i] > 0 && cmpPlayer.IsMutualAlly(i)) 51 return true; // don't decay if connected to a connected ally 51 { 52 // don't decay if connected to a connected ally; disable blinking 53 cmpTerritoryManager.SetTerritoryBlinking(pos.x, pos.y, false); 54 return true; 55 } 52 56 53 cmpTerritoryManager.SetTerritoryBlinking(pos.x, pos.y );57 cmpTerritoryManager.SetTerritoryBlinking(pos.x, pos.y, true); 54 58 return false; 55 59 }; 56 60 … … 114 118 this.UpdateDecayState(); 115 119 }; 116 120 121 TerritoryDecay.prototype.OnDiplomacyChanged = function(msg) 122 { 123 // changes the connectedness of certain areas 124 if (!this.territoryOwnership) 125 this.UpdateDecayState(); 126 }; 127 117 128 TerritoryDecay.prototype.OnOwnershipChanged = function(msg) 118 129 { 119 130 // if it influences the territory, wait until we get a TerritoriesChanged message -
source/simulation2/components/CCmpTerritoryManager.cpp
237 237 virtual std::vector<u32> GetNeighbours(entity_pos_t x, entity_pos_t z, bool filterConnected); 238 238 virtual bool IsConnected(entity_pos_t x, entity_pos_t z); 239 239 240 virtual void SetTerritoryBlinking(entity_pos_t x, entity_pos_t z); 240 virtual void SetTerritoryBlinking(entity_pos_t x, entity_pos_t z, bool enable); 241 virtual bool IsTerritoryBlinking(entity_pos_t x, entity_pos_t z); 241 242 242 243 // To support lazy updates of territory render data, 243 244 // we maintain a DirtyID here and increment it whenever territories change; … … 731 732 return (m_Territories->get(i, j) & TERRITORY_CONNECTED_MASK) != 0; 732 733 } 733 734 734 void CCmpTerritoryManager::SetTerritoryBlinking(entity_pos_t x, entity_pos_t z )735 void CCmpTerritoryManager::SetTerritoryBlinking(entity_pos_t x, entity_pos_t z, bool enable) 735 736 { 736 737 CalculateTerritories(); 737 738 if (!m_Territories) … … 747 748 748 749 FLOODFILL(i, j, 749 750 u8 bitmask = m_Territories->get(nx, nz); 750 if ((bitmask & TERRITORY_PLAYER_MASK) != thisOwner || (bitmask & TERRITORY_BLINKING_MASK))751 if ((bitmask & TERRITORY_PLAYER_MASK) != thisOwner) 751 752 continue; 752 m_Territories->set(nx, nz, bitmask | TERRITORY_BLINKING_MASK); 753 u8 blinking = bitmask & TERRITORY_BLINKING_MASK; 754 if (enable && !blinking) 755 m_Territories->set(nx, nz, bitmask | TERRITORY_BLINKING_MASK); 756 else if (!enable && blinking) 757 m_Territories->set(nx, nz, bitmask & (0xFF - TERRITORY_BLINKING_MASK)); 758 else 759 continue; 753 760 ); 754 761 m_BoundaryLinesDirty = true; 755 762 } 756 763 764 bool CCmpTerritoryManager::IsTerritoryBlinking(entity_pos_t x, entity_pos_t z) 765 { 766 u16 i, j; 767 NearestTerritoryTile(x, z, i, j, m_Territories->m_W, m_Territories->m_H); 768 return (bool) m_Territories->get(i, j) & TERRITORY_BLINKING_MASK; 769 } 770 757 771 TerritoryOverlay::TerritoryOverlay(CCmpTerritoryManager& manager) : 758 772 TerrainTextureOverlay((float)Pathfinding::NAVCELLS_PER_TILE / ICmpTerritoryManager::NAVCELLS_PER_TERRITORY_TILE), 759 773 m_TerritoryManager(manager) -
source/simulation2/components/ICmpTerritoryManager.cpp
25 25 DEFINE_INTERFACE_METHOD_2("GetOwner", player_id_t, ICmpTerritoryManager, GetOwner, entity_pos_t, entity_pos_t) 26 26 DEFINE_INTERFACE_METHOD_3("GetNeighbours", std::vector<u32>, ICmpTerritoryManager, GetNeighbours, entity_pos_t, entity_pos_t, bool) 27 27 DEFINE_INTERFACE_METHOD_2("IsConnected", bool, ICmpTerritoryManager, IsConnected, entity_pos_t, entity_pos_t) 28 DEFINE_INTERFACE_METHOD_2("SetTerritoryBlinking", void, ICmpTerritoryManager, SetTerritoryBlinking, entity_pos_t, entity_pos_t) 28 DEFINE_INTERFACE_METHOD_3("SetTerritoryBlinking", void, ICmpTerritoryManager, SetTerritoryBlinking, entity_pos_t, entity_pos_t, bool) 29 DEFINE_INTERFACE_METHOD_2("IsTerritoryBlinking", bool, ICmpTerritoryManager, IsTerritoryBlinking, entity_pos_t, entity_pos_t) 29 30 DEFINE_INTERFACE_METHOD_1("GetTerritoryPercentage", u8, ICmpTerritoryManager, GetTerritoryPercentage, player_id_t) 30 31 END_INTERFACE_WRAPPER(TerritoryManager) -
source/simulation2/components/ICmpTerritoryManager.h
70 70 /** 71 71 * Set a piece of territory to blinking. Must be updated on every territory calculation 72 72 */ 73 virtual void SetTerritoryBlinking(entity_pos_t x, entity_pos_t z ) = 0;73 virtual void SetTerritoryBlinking(entity_pos_t x, entity_pos_t z, bool enable) = 0; 74 74 75 75 /** 76 * Check if a piece of territory is blinking. 77 */ 78 virtual bool IsTerritoryBlinking(entity_pos_t x, entity_pos_t z) = 0; 79 80 /** 76 81 * Returns the percentage of the world controlled by a given player as defined by 77 82 * the number of territory cells the given player owns 78 83 */