Ticket #2969: InitGame.js.2.patch
File InitGame.js.2.patch, 6.5 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/components/PlayerManager.js
52 52 this.playerEntities[id] = ent; 53 53 cmpPlayer.SetDiplomacy(diplo); 54 54 Engine.DestroyEntity(oldent); 55 Engine.FlushDestroyed Components();55 Engine.FlushDestroyedEntities(); 56 56 57 57 for (var e of entities) 58 58 { -
binaries/data/mods/public/simulation/helpers/InitGame.js
4 4 */ 5 5 function PreInitGame() 6 6 { 7 // We need to replace skirmish "default" entities with real ones. 8 // This needs to happen before AI initialization (in InitGame). 9 // And we need to flush destroyed entities otherwise the AI gets the wrong game state in 10 // the beginning and a bunch of "destroy" messages on turn 0, which just shouldn't happen. 7 11 Engine.BroadcastMessage(MT_SkirmishReplace, {}); 12 Engine.FlushDestroyedEntities(); 8 13 9 14 let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 10 15 let playerIds = cmpPlayerManager.GetAllPlayerEntities().slice(1); // ignore gaia … … 14 19 if (cmpTechnologyManager) 15 20 cmpTechnologyManager.UpdateAutoResearch(); 16 21 } 22 23 // Explore the map inside the players' territory borders 24 let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 25 cmpRangeManager.ExploreTerritories(); 17 26 } 18 27 19 28 function InitGame(settings) … … 22 31 if (!settings) 23 32 return; 24 33 25 let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);26 34 if (settings.ExploreMap) 35 { 36 let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 27 37 for (let i = 1; i < settings.PlayerData.length; ++i) 28 38 cmpRangeManager.ExploreAllTiles(i); 29 else 30 // Explore the map only inside the players' territory borders 31 cmpRangeManager.ExploreTerritories(); 39 } 32 40 33 41 let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 34 42 let cmpAIManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AIManager); -
source/ps/Game.cpp
1 /* Copyright (C) 201 3Wildfire Games.1 /* Copyright (C) 2015 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 … … 213 213 if (!m_IsSavedGame) 214 214 { 215 215 if (!g_AtlasGameLoop->running) 216 {217 // We need to replace skirmish "default" entities with real ones.218 // This needs to happen before AI initialization (in InitGame).219 // And we need to flush destroyed entities otherwise the AI220 // gets the wrong game state in the beginning and a bunch of221 // "destroy" messages on turn 0, which just shouldn't happen.222 216 m_Simulation2->PreInitGame(); 223 m_Simulation2->FlushDestroyedEntities(); 224 } 217 225 218 JS::RootedValue settings(cx); 226 219 JS::RootedValue tmpInitAttributes(cx, m_Simulation2->GetInitAttributes().get()); 227 220 m_Simulation2->GetScriptInterface().GetProperty(tmpInitAttributes, "settings", &settings); -
source/simulation2/system/ComponentManager.cpp
1 /* Copyright (C) 201 4Wildfire Games.1 /* Copyright (C) 2015 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 … … 84 84 m_ScriptInterface.RegisterFunction<int, std::string, CComponentManager::Script_AddEntity> ("AddEntity"); 85 85 m_ScriptInterface.RegisterFunction<int, std::string, CComponentManager::Script_AddLocalEntity> ("AddLocalEntity"); 86 86 m_ScriptInterface.RegisterFunction<void, int, CComponentManager::Script_DestroyEntity> ("DestroyEntity"); 87 m_ScriptInterface.RegisterFunction<void, CComponentManager::Script_FlushDestroyed Components> ("FlushDestroyedComponents");87 m_ScriptInterface.RegisterFunction<void, CComponentManager::Script_FlushDestroyedEntities> ("FlushDestroyedEntities"); 88 88 m_ScriptInterface.RegisterFunction<CScriptVal, std::wstring, CComponentManager::Script_ReadJSONFile> ("ReadJSONFile"); 89 89 m_ScriptInterface.RegisterFunction<CScriptVal, std::wstring, CComponentManager::Script_ReadCivJSONFile> ("ReadCivJSONFile"); 90 90 m_ScriptInterface.RegisterFunction<std::vector<std::string>, std::wstring, bool, CComponentManager::Script_FindJSONFiles> ("FindJSONFiles"); … … 508 508 componentManager->DestroyComponentsSoon(ent); 509 509 } 510 510 511 void CComponentManager::Script_FlushDestroyed Components(ScriptInterface::CxPrivate *pCxPrivate)511 void CComponentManager::Script_FlushDestroyedEntities(ScriptInterface::CxPrivate *pCxPrivate) 512 512 { 513 513 CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData); 514 514 componentManager->FlushDestroyedComponents(); -
source/simulation2/system/ComponentManager.h
1 /* Copyright (C) 201 1Wildfire Games.1 /* Copyright (C) 2015 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 … … 283 283 static int Script_AddEntity(ScriptInterface::CxPrivate* pCxPrivate, std::string templateName); 284 284 static int Script_AddLocalEntity(ScriptInterface::CxPrivate* pCxPrivate, std::string templateName); 285 285 static void Script_DestroyEntity(ScriptInterface::CxPrivate* pCxPrivate, int ent); 286 static void Script_FlushDestroyed Components(ScriptInterface::CxPrivate* pCxPrivate);286 static void Script_FlushDestroyedEntities(ScriptInterface::CxPrivate* pCxPrivate); 287 287 static CScriptVal Script_ReadJSONFile(ScriptInterface::CxPrivate* pCxPrivate, std::wstring fileName); 288 288 static CScriptVal Script_ReadCivJSONFile(ScriptInterface::CxPrivate* pCxPrivate, std::wstring fileName); 289 289 static std::vector<std::string> Script_FindJSONFiles(ScriptInterface::CxPrivate* pCxPrivate, std::wstring subPath, bool recursive);