Ticket #958: territory_fow_building-11222011.patch
File territory_fow_building-11222011.patch, 6.3 KB (added by , 12 years ago) |
---|
-
binaries/data/mods/public/simulation/components/GuiInterface.js
255 255 } 256 256 257 257 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 258 ret.visibility = cmpRangeManager.GetLosVisibility(ent, player );258 ret.visibility = cmpRangeManager.GetLosVisibility(ent, player, false); 259 259 260 260 return ret; 261 261 }; … … 508 508 pos.SetYRotation(cmd.angle); 509 509 } 510 510 511 // Check whether it's in a visible region 511 // Check whether it's in a visible or fogged region 512 // tell GetLosVisibility to force RetainInFog because preview entities set this to false, 513 // which would show them as hidden instead of fogged 512 514 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 513 var visible = (cmpRangeManager && cmpRangeManager.GetLosVisibility(ent, player ) == "visible");515 var visible = (cmpRangeManager && cmpRangeManager.GetLosVisibility(ent, player, true) != "hidden"); 514 516 var validPlacement = false; 515 517 516 518 if (visible) -
binaries/data/mods/public/simulation/components/UnitAI.js
1945 1945 if (!cmpRangeManager) 1946 1946 return false; 1947 1947 1948 if (cmpRangeManager.GetLosVisibility(target, cmpOwnership.GetOwner() ) == "hidden")1948 if (cmpRangeManager.GetLosVisibility(target, cmpOwnership.GetOwner(), false) == "hidden") 1949 1949 return false; 1950 1950 1951 1951 // Either visible directly, or visible in fog -
binaries/data/mods/public/simulation/helpers/Commands.js
216 216 // TODO: AI has no visibility info 217 217 if (!cmpPlayer.IsAI()) 218 218 { 219 // Check whether it's in a visible region219 // Check whether it's in a visible or fogged region 220 220 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 221 var visible = (cmpRangeManager.GetLosVisibility(ent, player ) == "visible");221 var visible = (cmpRangeManager.GetLosVisibility(ent, player, true) != "hidden"); 222 222 if (!visible) 223 223 { 224 224 if (g_DebugCommands) -
source/simulation2/components/CCmpRangeManager.cpp
872 872 return CLosQuerier(player, m_LosState, m_TerrainVerticesPerSide); 873 873 } 874 874 875 virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player )875 virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player, bool forceRetainInFog) 876 876 { 877 877 // (We can't use m_EntityData since this needs to handle LOCAL entities too) 878 878 … … 906 906 if (los.IsExplored(i, j)) 907 907 { 908 908 CmpPtr<ICmpVision> cmpVision(GetSimContext(), ent); 909 if ( !cmpVision.null() && cmpVision->GetRetainInFog())909 if (forceRetainInFog || (!cmpVision.null() && cmpVision->GetRetainInFog())) 910 910 return VIS_FOGGED; 911 911 } 912 912 -
source/simulation2/components/ICmpRangeManager.cpp
21 21 22 22 #include "simulation2/system/InterfaceScripted.h" 23 23 24 std::string ICmpRangeManager::GetLosVisibility_wrapper(entity_id_t ent, int player )24 std::string ICmpRangeManager::GetLosVisibility_wrapper(entity_id_t ent, int player, bool forceRetainInFog) 25 25 { 26 ELosVisibility visibility = GetLosVisibility(ent, player );26 ELosVisibility visibility = GetLosVisibility(ent, player, forceRetainInFog); 27 27 switch (visibility) 28 28 { 29 29 case VIS_HIDDEN: return "hidden"; … … 43 43 DEFINE_INTERFACE_METHOD_1("GetEntitiesByPlayer", std::vector<entity_id_t>, ICmpRangeManager, GetEntitiesByPlayer, player_id_t) 44 44 DEFINE_INTERFACE_METHOD_1("SetDebugOverlay", void, ICmpRangeManager, SetDebugOverlay, bool) 45 45 DEFINE_INTERFACE_METHOD_2("SetLosRevealAll", void, ICmpRangeManager, SetLosRevealAll, player_id_t, bool) 46 DEFINE_INTERFACE_METHOD_ 2("GetLosVisibility", std::string, ICmpRangeManager, GetLosVisibility_wrapper, entity_id_t, player_id_t)46 DEFINE_INTERFACE_METHOD_3("GetLosVisibility", std::string, ICmpRangeManager, GetLosVisibility_wrapper, entity_id_t, player_id_t, bool) 47 47 DEFINE_INTERFACE_METHOD_1("SetLosCircular", void, ICmpRangeManager, SetLosCircular, bool) 48 48 DEFINE_INTERFACE_METHOD_0("GetLosCircular", bool, ICmpRangeManager, GetLosCircular) 49 49 DEFINE_INTERFACE_METHOD_1("GetPercentMapExplored", i32, ICmpRangeManager, GetPercentMapExplored, player_id_t) -
source/simulation2/components/ICmpRangeManager.h
260 260 * Returns the visibility status of the given entity, with respect to the given player. 261 261 * Returns VIS_HIDDEN if the entity doesn't exist or is not in the world. 262 262 * This respects the GetLosRevealAll flag. 263 * If forceRetainInFog is true, the visibility acts as if CCmpVision's RetainInFog flag were set. 264 * TODO: This is a hack to allow preview entities in FoW to return fogged instead of hidden, 265 * see http://trac.wildfiregames.com/ticket/958 263 266 */ 264 virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player ) = 0;267 virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player, bool forceRetainInFog = false) = 0; 265 268 266 269 /** 267 270 * GetLosVisibility wrapped for script calls. 268 271 * Returns "hidden", "fogged" or "visible". 269 272 */ 270 std::string GetLosVisibility_wrapper(entity_id_t ent, player_id_t player );273 std::string GetLosVisibility_wrapper(entity_id_t ent, player_id_t player, bool forceRetainInFog); 271 274 272 275 /** 273 276 * Set whether the whole map should be made visible to the given player.