Ticket #3168: t3168_fog_of_war_v1.patch
File t3168_fog_of_war_v1.patch, 7.8 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/session/session.js
function init(initData, hotloadData) 198 198 Engine.EndGame(); 199 199 Engine.SwitchGuiPage("page_pregame.xml"); 200 200 return; 201 201 } 202 202 203 Engine.SetViewedPlayer(g_ViewedPlayer); 204 203 205 if (initData) 204 206 { 205 207 g_IsNetworked = initData.isNetworked; 206 208 g_IsController = initData.isController; 207 209 g_PlayerAssignments = initData.playerAssignments; … … function selectViewPlayer(playerID) 296 298 if (playerID < -1 || playerID > g_Players.length - 1 || 297 299 !g_DevSettings.changePerspective && !g_IsObserver) 298 300 return; 299 301 300 302 g_ViewedPlayer = playerID; 303 Engine.SetViewedPlayer(playerID); 301 304 Engine.SetPlayerID(g_DevSettings.changePerspective ? playerID : -1); 302 305 303 306 updateTopPanel(); 304 307 onSimulationUpdate(); 305 308 -
source/graphics/LOSTexture.cpp
void CLOSTexture::RecomputeTexture(int u 340 340 341 341 CmpPtr<ICmpRangeManager> cmpRangeManager(m_Simulation, SYSTEM_ENTITY); 342 342 if (!cmpRangeManager) 343 343 return; 344 344 345 ICmpRangeManager::CLosQuerier los(cmpRangeManager->GetLosQuerier(g_Game->Get PlayerID()));345 ICmpRangeManager::CLosQuerier los(cmpRangeManager->GetLosQuerier(g_Game->GetSimulation2()->GetSimContext().GetCurrentDisplayedPlayer())); 346 346 347 347 GenerateBitmap(los, &losData[0], m_MapSize, m_MapSize, pitch); 348 348 349 349 if (CRenderer::IsInitialised() && g_Renderer.m_Options.m_SmoothLOS && recreated) 350 350 { -
source/gui/MiniMap.cpp
1 /* Copyright (C) 201 5Wildfire Games.1 /* Copyright (C) 2016 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License as published by 6 6 * the Free Software Foundation, either version 2 of the License, or … … void CMiniMap::Draw() 528 528 for (CSimulation2::InterfaceList::const_iterator it = ents.begin(); it != ents.end(); ++it) 529 529 { 530 530 ICmpMinimap* cmpMinimap = static_cast<ICmpMinimap*>(it->second); 531 531 if (cmpMinimap->GetRenderData(v.r, v.g, v.b, posX, posZ)) 532 532 { 533 ICmpRangeManager::ELosVisibility vis = cmpRangeManager->GetLosVisibility(it->first, g_Game->Get PlayerID());533 ICmpRangeManager::ELosVisibility vis = cmpRangeManager->GetLosVisibility(it->first, g_Game->GetSimulation2()->GetSimContext().GetCurrentDisplayedPlayer()); 534 534 if (vis != ICmpRangeManager::VIS_HIDDEN) 535 535 { 536 536 v.a = 255; 537 537 v.x = posX.ToFloat() * sx; 538 538 v.y = -posZ.ToFloat() * sy; -
source/gui/scripting/ScriptFunctions.cpp
void SetPlayerID(ScriptInterface::CxPriv 217 217 { 218 218 if (g_Game) 219 219 g_Game->SetPlayerID(id); 220 220 } 221 221 222 void SetViewedPlayer(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int id) 223 { 224 if (!g_Game || id < 0) 225 return; 226 227 g_Game->GetSimulation2()->GetSimContext().SetCurrentDisplayedPlayer(id); 228 } 229 222 230 JS::Value GetEngineInfo(ScriptInterface::CxPrivate* pCxPrivate) 223 231 { 224 232 return SavedGames::GetEngineInfo(*(pCxPrivate->pScriptInterface)); 225 233 } 226 234 … … void GuiScriptingInit(ScriptInterface& s 1021 1029 // Misc functions 1022 1030 scriptInterface.RegisterFunction<std::wstring, std::wstring, &SetCursor>("SetCursor"); 1023 1031 scriptInterface.RegisterFunction<bool, &IsVisualReplay>("IsVisualReplay"); 1024 1032 scriptInterface.RegisterFunction<int, &GetPlayerID>("GetPlayerID"); 1025 1033 scriptInterface.RegisterFunction<void, int, &SetPlayerID>("SetPlayerID"); 1034 scriptInterface.RegisterFunction<void, int, &SetViewedPlayer>("SetViewedPlayer"); 1026 1035 scriptInterface.RegisterFunction<void, std::string, &OpenURL>("OpenURL"); 1027 1036 scriptInterface.RegisterFunction<std::wstring, &GetMatchID>("GetMatchID"); 1028 1037 scriptInterface.RegisterFunction<void, &RestartInAtlas>("RestartInAtlas"); 1029 1038 scriptInterface.RegisterFunction<bool, &AtlasIsAvailable>("AtlasIsAvailable"); 1030 1039 scriptInterface.RegisterFunction<bool, &IsAtlasRunning>("IsAtlasRunning"); -
source/simulation2/Simulation2.cpp
CSimulation2::InterfaceList CSimulation2 644 644 const CSimulation2::InterfaceListUnordered& CSimulation2::GetEntitiesWithInterfaceUnordered(int iid) 645 645 { 646 646 return m->m_ComponentManager.GetEntitiesWithInterfaceUnordered(iid); 647 647 } 648 648 649 constCSimContext& CSimulation2::GetSimContext() const649 CSimContext& CSimulation2::GetSimContext() const 650 650 { 651 651 return m->m_SimContext; 652 652 } 653 653 654 654 ScriptInterface& CSimulation2::GetScriptInterface() const -
source/simulation2/Simulation2.h
public: 215 215 * Returns a list of components implementing the given interface, and their 216 216 * associated entities, as an unordered map. 217 217 */ 218 218 const InterfaceListUnordered& GetEntitiesWithInterfaceUnordered(int iid); 219 219 220 constCSimContext& GetSimContext() const;220 CSimContext& GetSimContext() const; 221 221 ScriptInterface& GetScriptInterface() const; 222 222 223 223 bool ComputeStateHash(std::string& outHash, bool quick); 224 224 bool DumpDebugState(std::ostream& stream); 225 225 bool SerializeState(std::ostream& stream); -
source/simulation2/system/SimContext.cpp
1 /* Copyright (C) 201 1Wildfire Games.1 /* Copyright (C) 2016 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License as published by 6 6 * the Free Software Foundation, either version 2 of the License, or … … ScriptInterface& CSimContext::GetScriptI 65 65 return GetComponentManager().GetScriptInterface(); 66 66 } 67 67 68 68 int CSimContext::GetCurrentDisplayedPlayer() const 69 69 { 70 if (!g_Game) 71 return -1; 72 return g_Game->GetPlayerID(); 70 return g_Game ? currentDisplayedPlayer : -1; 71 } 72 73 void CSimContext::SetCurrentDisplayedPlayer(int player) 74 { 75 currentDisplayedPlayer = player; 73 76 } -
source/simulation2/system/SimContext.h
1 /* Copyright (C) 201 1Wildfire Games.1 /* Copyright (C) 2016 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License as published by 6 6 * the Free Software Foundation, either version 2 of the License, or … … public: 51 51 /** 52 52 * Returns the player ID that the current display is being rendered for. 53 53 * Currently relies on g_Game being initialised (evil globals...) 54 54 */ 55 55 int GetCurrentDisplayedPlayer() const; 56 void SetCurrentDisplayedPlayer(int player); 56 57 57 58 private: 58 59 CComponentManager* m_ComponentManager; 59 60 CUnitManager* m_UnitManager; 60 61 CTerrain* m_Terrain; 61 62 62 63 CEntityHandle m_SystemEntity; 63 64 65 int currentDisplayedPlayer = 0; 66 64 67 friend class CSimulation2Impl; 65 68 }; 66 69 67 70 #endif // INCLUDED_SIMCONTEXT