- Timestamp:
- 08/18/11 22:28:53 (13 years ago)
- Location:
- ps/trunk
- Files:
-
- 2 added
- 30 edited
-
binaries/data/mods/public/shaders/overlayline.fp (modified) (1 diff)
-
binaries/data/mods/public/simulation/components/TerritoryDecay.js (added)
-
binaries/data/mods/public/simulation/components/Timer.js (modified) (1 diff)
-
binaries/data/mods/public/simulation/components/interfaces/TerritoryDecay.js (added)
-
binaries/data/mods/public/simulation/templates/other/hellenic_propylaea.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/other/hellenic_royal_stoa.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/other/hellenic_stoa.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/special/territory_block.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/special/territory_pull.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_civic_house.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_civic_temple.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_defense_scout_tower.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_economic_farmstead.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_economic_mill.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_military_barracks.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_military_fortress.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_structure_special.xml (modified) (1 diff)
-
source/graphics/TerritoryTexture.cpp (modified) (2 diffs)
-
source/simulation2/MessageTypes.h (modified) (1 diff)
-
source/simulation2/TypeList.h (modified) (1 diff)
-
source/simulation2/components/CCmpRangeManager.cpp (modified) (1 diff)
-
source/simulation2/components/CCmpTerrain.cpp (modified) (1 diff)
-
source/simulation2/components/CCmpTerritoryInfluence.cpp (modified) (4 diffs)
-
source/simulation2/components/CCmpTerritoryManager.cpp (modified) (22 diffs)
-
source/simulation2/components/ICmpTerrain.h (modified) (1 diff)
-
source/simulation2/components/ICmpTerritoryInfluence.h (modified) (1 diff)
-
source/simulation2/components/ICmpTerritoryManager.cpp (modified) (1 diff)
-
source/simulation2/components/ICmpTerritoryManager.h (modified) (2 diffs)
-
source/simulation2/scripting/MessageTypeConversions.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/binaries/data/mods/public/shaders/overlayline.fp
r9929 r10034 16 16 17 17 // Use alpha from base texture 18 M OV result.color.a, base.a;18 MUL result.color.a, objectColor.a, base.a; 19 19 20 20 END -
ps/trunk/binaries/data/mods/public/simulation/components/Timer.js
r8678 r10034 83 83 var cmp = Engine.QueryInterface(t[0], t[1]); 84 84 if (!cmp) 85 continue; // the entity was probably destroyed 85 { 86 // The entity was probably destroyed; clean up the timer 87 delete this.timers[id]; 88 continue; 89 } 86 90 87 91 try { -
ps/trunk/binaries/data/mods/public/simulation/templates/other/hellenic_propylaea.xml
r9963 r10034 45 45 </Obstruction> 46 46 <TerritoryInfluence> 47 <Root>false</Root> 47 48 <Radius>40</Radius> 48 49 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/other/hellenic_royal_stoa.xml
r9963 r10034 45 45 </Obstruction> 46 46 <TerritoryInfluence> 47 <Root>false</Root> 47 48 <Radius>40</Radius> 48 49 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/other/hellenic_stoa.xml
r9963 r10034 45 45 </Obstruction> 46 46 <TerritoryInfluence> 47 <Root>false</Root> 47 48 <Radius>36</Radius> 48 49 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/special/territory_block.xml
r9936 r10034 25 25 <TerritoryInfluence> 26 26 <OverrideCost>64</OverrideCost> 27 <Root>false</Root> 27 28 <Weight>0</Weight> 28 29 <Radius>0</Radius> -
ps/trunk/binaries/data/mods/public/simulation/templates/special/territory_pull.xml
r9936 r10034 25 25 <TerritoryInfluence> 26 26 <OverrideCost>0</OverrideCost> 27 <Root>false</Root> 27 28 <Weight>0</Weight> 28 29 <Radius>0</Radius> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure.xml
r9970 r10034 67 67 <HeightOffset>12.0</HeightOffset> 68 68 </StatusBars> 69 <TerritoryDecay> 70 <HealthDecayRate>20</HealthDecayRate> 71 </TerritoryDecay> 69 72 <Vision> 70 73 <Range>40</Range> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml
r9994 r10034 77 77 </Sound> 78 78 <TerritoryInfluence> 79 <Root>true</Root> 79 80 <Radius>180</Radius> 80 81 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_civic_house.xml
r9995 r10034 46 46 </StatusBars> 47 47 <TerritoryInfluence> 48 <Root>false</Root> 48 49 <Radius>20</Radius> 49 50 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_civic_temple.xml
r9956 r10034 52 52 </Sound> 53 53 <TerritoryInfluence> 54 <Root>false</Root> 54 55 <Radius>40</Radius> 55 56 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_defense_scout_tower.xml
r9956 r10034 67 67 </StatusBars> 68 68 <TerritoryInfluence> 69 <Root>false</Root> 69 70 <Radius>32</Radius> 70 71 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_economic_farmstead.xml
r9956 r10034 43 43 </Sound> 44 44 <TerritoryInfluence> 45 <Root>false</Root> 45 46 <Radius>20</Radius> 46 47 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml
r9956 r10034 39 39 </Sound> 40 40 <TerritoryInfluence> 41 <Root>false</Root> 41 42 <Radius>40</Radius> 42 43 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_economic_mill.xml
r9970 r10034 43 43 </Sound> 44 44 <TerritoryInfluence> 45 <Root>false</Root> 45 46 <Radius>20</Radius> 46 47 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_military_barracks.xml
r9956 r10034 47 47 </Sound> 48 48 <TerritoryInfluence> 49 <Root>false</Root> 49 50 <Radius>60</Radius> 50 51 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_military_fortress.xml
r9994 r10034 63 63 </Sound> 64 64 <TerritoryInfluence> 65 <Root>false</Root> 65 66 <Radius>100</Radius> 66 67 <Weight>65536</Weight> -
ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_special.xml
r9942 r10034 21 21 </Obstruction> 22 22 <TerritoryInfluence> 23 <Root>false</Root> 23 24 <Radius>40</Radius> 24 25 <Weight>65536</Weight> -
ps/trunk/source/graphics/TerritoryTexture.cpp
r10019 r10034 193 193 for (ssize_t i = 0; i < w; ++i) 194 194 { 195 u8 val = territories.get(i, j) ;195 u8 val = territories.get(i, j) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK; 196 196 197 197 CColor color(1, 0, 1, 1); … … 203 203 *p++ = (int)(color.r*255.f); 204 204 205 if ((i > 0 && territories.get(i-1, j) != val) 206 || (i < w-1 && territories.get(i+1, j) != val) 207 || (j > 0 && territories.get(i, j-1) != val) 208 || (j < h-1 && territories.get(i, j+1) != val) 209 // || (i > 0 && j > 0 && territories.get(i-1, j-1) != val) 210 // || (i < w-1 && j > 0 && territories.get(i+1, j-1) != val) 211 // || (i > 0 && j > h-1 && territories.get(i-1, j+1) != val) 212 // || (i < w-1 && j < h-1 && territories.get(i+1, j+1) != val) 205 if ((i > 0 && (territories.get(i-1, j) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val) 206 || (i < w-1 && (territories.get(i+1, j) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val) 207 || (j > 0 && (territories.get(i, j-1) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val) 208 || (j < h-1 && (territories.get(i, j+1) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val) 213 209 ) 214 210 { -
ps/trunk/source/simulation2/MessageTypes.h
r9951 r10034 288 288 289 289 /** 290 * Sent when territory assignments have changed. 291 */ 292 class CMessageTerritoriesChanged : public CMessage 293 { 294 public: 295 DEFAULT_MESSAGE_IMPL(TerritoriesChanged) 296 297 CMessageTerritoriesChanged() 298 { 299 } 300 }; 301 302 /** 290 303 * Sent by CCmpRangeManager at most once per turn, when an active range query 291 304 * has had matching units enter/leave the range since the last RangeUpdate. -
ps/trunk/source/simulation2/TypeList.h
r9889 r10034 46 46 MESSAGE(RangeUpdate) 47 47 MESSAGE(TerrainChanged) 48 MESSAGE(TerritoriesChanged) 48 49 MESSAGE(PathResult) 49 50 -
ps/trunk/source/simulation2/components/CCmpRangeManager.cpp
r10017 r10034 917 917 for (u16 i = 0; i < grid.m_W; ++i) 918 918 { 919 u8 p = grid.get(i, j) ;919 u8 p = grid.get(i, j) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK; 920 920 if (p > 0 && p <= MAX_LOS_PLAYER_ID) 921 921 { -
ps/trunk/source/simulation2/components/CCmpTerrain.cpp
r10017 r10034 59 59 { 60 60 Init(paramNode); 61 } 62 63 virtual bool IsLoaded() 64 { 65 return m_Terrain->GetVerticesPerSide() != 0; 61 66 } 62 67 -
ps/trunk/source/simulation2/components/CCmpTerritoryInfluence.cpp
r10017 r10034 31 31 32 32 i32 m_Cost; 33 bool m_Root; 33 34 u32 m_Weight; 34 35 u32 m_Radius; … … 44 45 "</element>" 45 46 "</optional>" 47 "<element name='Root'>" 48 "<data type='boolean'/>" 49 "</element>" 46 50 "<element name='Weight'>" 47 51 "<data type='nonNegativeInteger'/>" … … 59 63 m_Cost = -1; 60 64 65 m_Root = paramNode.GetChild("Root").ToBool(); 61 66 m_Weight = paramNode.GetChild("Weight").ToInt(); 62 67 m_Radius = paramNode.GetChild("Radius").ToInt(); … … 81 86 } 82 87 88 virtual bool IsRoot() 89 { 90 return m_Root; 91 } 92 83 93 virtual u32 GetWeight() 84 94 { -
ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp
r10017 r10034 67 67 componentManager.SubscribeGloballyToMessageType(MT_PositionChanged); 68 68 componentManager.SubscribeToMessageType(MT_TerrainChanged); 69 componentManager.SubscribeToMessageType(MT_Update); 70 componentManager.SubscribeToMessageType(MT_Interpolate); 69 71 componentManager.SubscribeToMessageType(MT_RenderSubmit); 70 72 } … … 81 83 float m_BorderSeparation; 82 84 85 // Player ID in lower 7 bits; connected flag in high bit 83 86 Grid<u8>* m_Territories; 87 88 // Set to true when territories change; will send a TerritoriesChanged message 89 // during the Update phase 90 bool m_TriggerEvent; 91 92 struct SBoundaryLine 93 { 94 bool connected; 95 CColor color; 96 SOverlayTexturedLine overlay; 97 }; 98 99 std::vector<SBoundaryLine> m_BoundaryLines; 100 bool m_BoundaryLinesDirty; 101 102 double m_AnimTime; // time since start of rendering, in seconds 103 84 104 TerritoryOverlay* m_DebugOverlay; 85 std::vector<SOverlayTexturedLine> m_BoundaryLines;86 bool m_BoundaryLinesDirty;87 105 88 106 virtual void Init(const CParamNode& UNUSED(paramNode)) … … 92 110 // m_DebugOverlay = new TerritoryOverlay(*this); 93 111 m_BoundaryLinesDirty = true; 112 m_TriggerEvent = true; 94 113 95 114 m_DirtyID = 1; 115 116 m_AnimTime = 0.0; 96 117 97 118 CParamNode externalParamNode; … … 142 163 break; 143 164 } 165 case MT_Update: 166 { 167 if (m_TriggerEvent) 168 { 169 m_TriggerEvent = false; 170 CMessageTerritoriesChanged msg; 171 GetSimContext().GetComponentManager().BroadcastMessage(msg); 172 } 173 break; 174 } 175 case MT_Interpolate: 176 { 177 const CMessageInterpolate& msgData = static_cast<const CMessageInterpolate&> (msg); 178 Interpolate(msgData.frameTime, msgData.offset); 179 break; 180 } 144 181 case MT_RenderSubmit: 145 182 { … … 167 204 { 168 205 CalculateTerritories(); 206 ENSURE(m_Territories); 169 207 return *m_Territories; 170 208 } 171 209 172 virtual int32_t GetOwner(entity_pos_t x, entity_pos_t z); 210 virtual player_id_t GetOwner(entity_pos_t x, entity_pos_t z); 211 virtual bool IsConnected(entity_pos_t x, entity_pos_t z); 173 212 174 213 // To support lazy updates of territory render data, … … 183 222 ++m_DirtyID; 184 223 m_BoundaryLinesDirty = true; 224 m_TriggerEvent = true; 185 225 } 186 226 … … 206 246 struct TerritoryBoundary 207 247 { 248 bool connected; 208 249 player_id_t owner; 209 250 std::vector<CVector2D> points; … … 213 254 214 255 void UpdateBoundaryLines(); 256 257 void Interpolate(float frameTime, float frameOffset); 215 258 216 259 void RenderSubmit(SceneCollector& collector); … … 251 294 static void FloodFill(Grid<u32>& grid, Grid<u8>& costGrid, OpenQueue& openTiles, u32 falloff) 252 295 { 253 u 32tilesW = grid.m_W;254 u 32tilesH = grid.m_H;296 u16 tilesW = grid.m_W; 297 u16 tilesH = grid.m_H; 255 298 256 299 while (!openTiles.empty()) … … 282 325 void CCmpTerritoryManager::CalculateTerritories() 283 326 { 284 PROFILE("CalculateTerritories");285 286 327 if (m_Territories) 287 328 return; 288 329 330 PROFILE("CalculateTerritories"); 331 289 332 CmpPtr<ICmpTerrain> cmpTerrain(GetSimContext(), SYSTEM_ENTITY); 333 334 // If the terrain hasn't been loaded (e.g. this is called during map initialisation), 335 // abort the computation (and assume callers can cope with m_Territories == NULL) 336 if (!cmpTerrain->IsLoaded()) 337 return; 338 290 339 u16 tilesW = cmpTerrain->GetTilesPerSide(); 291 340 u16 tilesH = cmpTerrain->GetTilesPerSide(); 292 341 293 SAFE_DELETE(m_Territories);294 342 m_Territories = new Grid<u8>(tilesW, tilesH); 295 343 … … 325 373 // Split influence entities into per-player lists, ignoring any with invalid properties 326 374 std::map<player_id_t, std::vector<entity_id_t> > influenceEntities; 375 std::vector<entity_id_t> rootInfluenceEntities; 327 376 for (CComponentManager::InterfaceList::iterator it = influences.begin(); it != influences.end(); ++it) 328 377 { … … 341 390 continue; 342 391 392 // We only have 7 bits to store tile ownership, so ignore unrepresentable players 393 if (owner > TERRITORY_PLAYER_MASK) 394 continue; 395 343 396 // Ignore if invalid position 344 397 CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), it->first); … … 347 400 348 401 influenceEntities[owner].push_back(it->first); 402 403 if (cmpTerritoryInfluence->IsRoot()) 404 rootInfluenceEntities.push_back(it->first); 349 405 } 350 406 … … 414 470 } 415 471 } 472 473 // Detect territories connected to a 'root' influence (typically a civ center) 474 // belonging to their player, and mark them with the connected flag 475 for (std::vector<entity_id_t>::iterator it = rootInfluenceEntities.begin(); it != rootInfluenceEntities.end(); ++it) 476 { 477 // (These components must be valid else the entities wouldn't be added to this list) 478 CmpPtr<ICmpOwnership> cmpOwnership(GetSimContext(), *it); 479 CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), *it); 480 481 CFixedVector2D pos = cmpPosition->GetPosition2D(); 482 u16 i = (u16)clamp((pos.X / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1); 483 u16 j = (u16)clamp((pos.Y / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1); 484 485 u8 owner = (u8)cmpOwnership->GetOwner(); 486 487 if (m_Territories->get(i, j) != owner) 488 continue; 489 490 // TODO: would be nice to refactor some of the many flood fill 491 // algorithms in this component 492 493 Grid<u8>& grid = *m_Territories; 494 495 u16 maxi = (u16)(grid.m_W-1); 496 u16 maxj = (u16)(grid.m_H-1); 497 498 std::vector<std::pair<u16, u16> > tileStack; 499 500 #define MARK_AND_PUSH(i, j) STMT(grid.set(i, j, owner | TERRITORY_CONNECTED_MASK); tileStack.push_back(std::make_pair(i, j)); ) 501 502 MARK_AND_PUSH(i, j); 503 while (!tileStack.empty()) 504 { 505 int ti = tileStack.back().first; 506 int tj = tileStack.back().second; 507 tileStack.pop_back(); 508 509 if (ti > 0 && grid.get(ti-1, tj) == owner) 510 MARK_AND_PUSH(ti-1, tj); 511 if (ti < maxi && grid.get(ti+1, tj) == owner) 512 MARK_AND_PUSH(ti+1, tj); 513 if (tj > 0 && grid.get(ti, tj-1) == owner) 514 MARK_AND_PUSH(ti, tj-1); 515 if (tj < maxj && grid.get(ti, tj+1) == owner) 516 MARK_AND_PUSH(ti, tj+1); 517 518 if (ti > 0 && tj > 0 && grid.get(ti-1, tj-1) == owner) 519 MARK_AND_PUSH(ti-1, tj-1); 520 if (ti > 0 && tj < maxj && grid.get(ti-1, tj+1) == owner) 521 MARK_AND_PUSH(ti-1, tj+1); 522 if (ti < maxi && tj > 0 && grid.get(ti+1, tj-1) == owner) 523 MARK_AND_PUSH(ti+1, tj-1); 524 if (ti < maxi && tj < maxj && grid.get(ti+1, tj+1) == owner) 525 MARK_AND_PUSH(ti+1, tj+1); 526 } 527 528 #undef MARK_AND_PUSH 529 } 416 530 } 417 531 … … 482 596 483 597 CalculateTerritories(); 598 ENSURE(m_Territories); 484 599 485 600 // Copy the territories grid so we can mess with it … … 507 622 508 623 boundaries.push_back(TerritoryBoundary()); 509 boundaries.back().owner = owner; 624 boundaries.back().connected = (owner & TERRITORY_CONNECTED_MASK); 625 boundaries.back().owner = (owner & TERRITORY_PLAYER_MASK); 510 626 std::vector<CVector2D>& points = boundaries.back().points; 511 627 … … 586 702 std::vector<std::pair<u16, u16> > tileStack; 587 703 588 #define ZERO_AND_PUSH(i, j) STMT(grid.set(i, j, 0); tileStack.push_back(std::make_pair(i, j)); )589 590 ZERO_AND_PUSH(i, j);704 #define MARK_AND_PUSH(i, j) STMT(grid.set(i, j, 0); tileStack.push_back(std::make_pair(i, j)); ) 705 706 MARK_AND_PUSH(i, j); 591 707 while (!tileStack.empty()) 592 708 { … … 596 712 597 713 if (ti > 0 && grid.get(ti-1, tj) == owner) 598 ZERO_AND_PUSH(ti-1, tj);714 MARK_AND_PUSH(ti-1, tj); 599 715 if (ti < maxi && grid.get(ti+1, tj) == owner) 600 ZERO_AND_PUSH(ti+1, tj);716 MARK_AND_PUSH(ti+1, tj); 601 717 if (tj > 0 && grid.get(ti, tj-1) == owner) 602 ZERO_AND_PUSH(ti, tj-1);718 MARK_AND_PUSH(ti, tj-1); 603 719 if (tj < maxj && grid.get(ti, tj+1) == owner) 604 ZERO_AND_PUSH(ti, tj+1);720 MARK_AND_PUSH(ti, tj+1); 605 721 606 722 if (ti > 0 && tj > 0 && grid.get(ti-1, tj-1) == owner) 607 ZERO_AND_PUSH(ti-1, tj-1);723 MARK_AND_PUSH(ti-1, tj-1); 608 724 if (ti > 0 && tj < maxj && grid.get(ti-1, tj+1) == owner) 609 ZERO_AND_PUSH(ti-1, tj+1);725 MARK_AND_PUSH(ti-1, tj+1); 610 726 if (ti < maxi && tj > 0 && grid.get(ti+1, tj-1) == owner) 611 ZERO_AND_PUSH(ti+1, tj-1);727 MARK_AND_PUSH(ti+1, tj-1); 612 728 if (ti < maxi && tj < maxj && grid.get(ti+1, tj+1) == owner) 613 ZERO_AND_PUSH(ti+1, tj+1);729 MARK_AND_PUSH(ti+1, tj+1); 614 730 } 615 731 616 #undef ZERO_AND_PUSH732 #undef MARK_AND_PUSH 617 733 } 618 734 } … … 659 775 color = cmpPlayer->GetColour(); 660 776 661 m_BoundaryLines.push_back(SOverlayTexturedLine()); 662 m_BoundaryLines.back().m_Terrain = terrain; 663 m_BoundaryLines.back().m_TextureBase = textureBase; 664 m_BoundaryLines.back().m_TextureMask = textureMask; 665 m_BoundaryLines.back().m_Color = color; 666 m_BoundaryLines.back().m_Thickness = m_BorderThickness; 777 m_BoundaryLines.push_back(SBoundaryLine()); 778 m_BoundaryLines.back().connected = boundaries[i].connected; 779 m_BoundaryLines.back().color = color; 780 781 m_BoundaryLines.back().overlay.m_Terrain = terrain; 782 m_BoundaryLines.back().overlay.m_TextureBase = textureBase; 783 m_BoundaryLines.back().overlay.m_TextureMask = textureMask; 784 m_BoundaryLines.back().overlay.m_Color = color; 785 m_BoundaryLines.back().overlay.m_Thickness = m_BorderThickness; 667 786 668 787 SimRender::SmoothPointsAverage(boundaries[i].points, true); … … 670 789 SimRender::InterpolatePointsRNS(boundaries[i].points, true, m_BorderSeparation); 671 790 672 std::vector<float>& points = m_BoundaryLines.back(). m_Coords;791 std::vector<float>& points = m_BoundaryLines.back().overlay.m_Coords; 673 792 for (size_t j = 0; j < boundaries[i].points.size(); ++j) 674 793 { … … 679 798 } 680 799 681 void CCmpTerritoryManager::RenderSubmit(SceneCollector& collector) 682 { 800 void CCmpTerritoryManager::Interpolate(float frameTime, float UNUSED(frameOffset)) 801 { 802 m_AnimTime += frameTime; 803 683 804 if (m_BoundaryLinesDirty) 684 805 { … … 688 809 689 810 for (size_t i = 0; i < m_BoundaryLines.size(); ++i) 690 collector.Submit(&m_BoundaryLines[i]); 691 } 692 693 int32_t CCmpTerritoryManager::GetOwner(entity_pos_t x, entity_pos_t z) 811 { 812 if (!m_BoundaryLines[i].connected) 813 { 814 CColor c = m_BoundaryLines[i].color; 815 c.a *= 0.2f + 0.8f * fabsf((float)cos(m_AnimTime * M_PI)); // TODO: should let artists tweak this 816 m_BoundaryLines[i].overlay.m_Color = c; 817 } 818 } 819 } 820 821 void CCmpTerritoryManager::RenderSubmit(SceneCollector& collector) 822 { 823 for (size_t i = 0; i < m_BoundaryLines.size(); ++i) 824 collector.Submit(&m_BoundaryLines[i].overlay); 825 } 826 827 player_id_t CCmpTerritoryManager::GetOwner(entity_pos_t x, entity_pos_t z) 694 828 { 695 829 u16 i, j; 696 830 CalculateTerritories(); 831 if (!m_Territories) 832 return 0; 833 697 834 NearestTile(x, z, i, j, m_Territories->m_W, m_Territories->m_H); 698 return m_Territories->get(i, j); 835 return m_Territories->get(i, j) & TERRITORY_PLAYER_MASK; 836 } 837 838 bool CCmpTerritoryManager::IsConnected(entity_pos_t x, entity_pos_t z) 839 { 840 u16 i, j; 841 CalculateTerritories(); 842 if (!m_Territories) 843 return false; 844 845 NearestTile(x, z, i, j, m_Territories->m_W, m_Territories->m_H); 846 return m_Territories->get(i, j) & TERRITORY_CONNECTED_MASK; 699 847 } 700 848 -
ps/trunk/source/simulation2/components/ICmpTerrain.h
r10017 r10034 30 30 { 31 31 public: 32 virtual bool IsLoaded() = 0; 33 32 34 virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z) = 0; 33 35 -
ps/trunk/source/simulation2/components/ICmpTerritoryInfluence.h
r10017 r10034 31 31 virtual i32 GetCost() = 0; 32 32 33 virtual bool IsRoot() = 0; 34 33 35 virtual u32 GetWeight() = 0; 34 36 -
ps/trunk/source/simulation2/components/ICmpTerritoryManager.cpp
r9970 r10034 23 23 24 24 BEGIN_INTERFACE_WRAPPER(TerritoryManager) 25 DEFINE_INTERFACE_METHOD_2("GetOwner", int32_t, ICmpTerritoryManager, GetOwner, entity_pos_t, entity_pos_t) 25 DEFINE_INTERFACE_METHOD_2("GetOwner", player_id_t, ICmpTerritoryManager, GetOwner, entity_pos_t, entity_pos_t) 26 DEFINE_INTERFACE_METHOD_2("IsConnected", bool, ICmpTerritoryManager, IsConnected, entity_pos_t, entity_pos_t) 26 27 END_INTERFACE_WRAPPER(TerritoryManager) -
ps/trunk/source/simulation2/components/ICmpTerritoryManager.h
r9970 r10034 19 19 #define INCLUDED_ICMPTERRITORYMANAGER 20 20 21 #include "simulation2/system/Interface.h" 22 21 23 #include "simulation2/helpers/Grid.h" 22 #include "simulation2/ system/Interface.h"24 #include "simulation2/helpers/Player.h" 23 25 #include "simulation2/components/ICmpPosition.h" 24 26 … … 28 30 virtual bool NeedUpdate(size_t* dirtyID) = 0; 29 31 32 static const int TERRITORY_PLAYER_MASK = 0x7F; 33 static const int TERRITORY_CONNECTED_MASK = 0x80; 34 35 /** 36 * For each tile, the TERRITORY_PLAYER_MASK bits are player ID; 37 * TERRITORY_CONNECTED_MASK is set if the tile is connected to a root object 38 * (civ center etc). 39 */ 30 40 virtual const Grid<u8>& GetTerritoryGrid() = 0; 31 41 32 42 /** 33 * Get owner of territory at given position 34 * 43 * Get owner of territory at given position. 35 44 * @return player ID of owner; 0 if neutral territory 36 45 */ 37 virtual int32_t GetOwner(entity_pos_t x, entity_pos_t z) = 0; 46 virtual player_id_t GetOwner(entity_pos_t x, entity_pos_t z) = 0; 47 48 /** 49 * Get whether territory at given position is connected to a root object 50 * (civ center etc) owned by that territory's player. 51 */ 52 virtual bool IsConnected(entity_pos_t x, entity_pos_t z) = 0; 38 53 39 54 DECLARE_INTERFACE_TYPE(TerritoryManager) -
ps/trunk/source/simulation2/scripting/MessageTypeConversions.cpp
r9950 r10034 1 /* Copyright (C) 201 0Wildfire Games.1 /* Copyright (C) 2011 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 27 27 JSObject* obj = JS_NewObject(scriptInterface.GetContext(), NULL, NULL, NULL); \ 28 28 if (! obj) \ 29 return JSVAL_VOID 29 return JSVAL_VOID; 30 30 31 31 #define SET_MSG_PROPERTY(name) \ … … 34 34 if (! JS_SetProperty(scriptInterface.GetContext(), obj, #name, &prop)) \ 35 35 return JSVAL_VOID; \ 36 } while (0) 36 } while (0); 37 37 38 38 #define FROMJSVAL_SETUP() \ 39 39 if (! JSVAL_IS_OBJECT(val)) \ 40 40 return NULL; \ 41 JSObject* obj = JSVAL_TO_OBJECT(val) 42 jsval prop;41 JSObject* obj = JSVAL_TO_OBJECT(val); \ 42 jsval prop; 43 43 44 44 #define GET_MSG_PROPERTY(type, name) \ … … 59 59 //////////////////////////////// 60 60 61 jsval CMessageTurnStart::ToJSVal(ScriptInterface& UNUSED(scriptInterface)) const62 { 63 LOGWARNING(L"CMessageTurnStart::ToJSVal not implemented");64 return JSVAL_VOID;61 jsval CMessageTurnStart::ToJSVal(ScriptInterface& scriptInterface) const 62 { 63 TOJSVAL_SETUP(); 64 return OBJECT_TO_JSVAL(obj); 65 65 } 66 66 … … 255 255 //////////////////////////////// 256 256 257 jsval CMessageTerritoriesChanged::ToJSVal(ScriptInterface& scriptInterface) const 258 { 259 TOJSVAL_SETUP(); 260 return OBJECT_TO_JSVAL(obj); 261 } 262 263 CMessage* CMessageTerritoriesChanged::FromJSVal(ScriptInterface& UNUSED(scriptInterface), jsval UNUSED(val)) 264 { 265 return new CMessageTerritoriesChanged(); 266 } 267 268 //////////////////////////////// 269 257 270 jsval CMessageRangeUpdate::ToJSVal(ScriptInterface& scriptInterface) const 258 271 {
Note:
See TracChangeset
for help on using the changeset viewer.
