mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-26 03:53:38 +00:00
Load map descriptions from their XML file.
Add basic hold-fire stance, and use it for some test maps. Add JSON data container to map XML files, to simplify the interaction between scripts and maps. Fix fixed-point printing so it roundtrips safely through map files. Fix camera startup positions in old-format maps. This was SVN commit r7844.
This commit is contained in:
@@ -135,6 +135,7 @@ public:
|
||||
double m_DeltaTime;
|
||||
|
||||
std::wstring m_StartupScript;
|
||||
CScriptValRooted m_MapSettings;
|
||||
|
||||
std::set<std::wstring> m_LoadedScripts;
|
||||
|
||||
@@ -189,8 +190,15 @@ bool CSimulation2Impl::Update(int turnLength, const std::vector<SimulationComman
|
||||
CMessageTurnStart msgTurnStart;
|
||||
m_ComponentManager.BroadcastMessage(msgTurnStart);
|
||||
|
||||
if (m_TurnNumber == 0 && !m_StartupScript.empty())
|
||||
m_ComponentManager.GetScriptInterface().LoadScript(L"map startup script", m_StartupScript);
|
||||
if (m_TurnNumber == 0)
|
||||
{
|
||||
ScriptInterface& scriptInterface = m_ComponentManager.GetScriptInterface();
|
||||
CScriptVal ret;
|
||||
scriptInterface.CallFunction(scriptInterface.GetGlobalObject(), "LoadMapSettings", m_MapSettings, ret);
|
||||
|
||||
if (!m_StartupScript.empty())
|
||||
m_ComponentManager.GetScriptInterface().LoadScript(L"map startup script", m_StartupScript);
|
||||
}
|
||||
|
||||
CmpPtr<ICmpCommandQueue> cmpCommandQueue(m_SimContext, SYSTEM_ENTITY);
|
||||
if (!cmpCommandQueue.null())
|
||||
@@ -370,6 +378,16 @@ const std::wstring& CSimulation2::GetStartupScript()
|
||||
return m->m_StartupScript;
|
||||
}
|
||||
|
||||
void CSimulation2::SetMapSettings(const utf16string& settings)
|
||||
{
|
||||
m->m_MapSettings = m->m_ComponentManager.GetScriptInterface().ParseJSON(settings);
|
||||
}
|
||||
|
||||
std::string CSimulation2::GetMapSettings()
|
||||
{
|
||||
return m->m_ComponentManager.GetScriptInterface().StringifyJSON(m->m_MapSettings.get());
|
||||
}
|
||||
|
||||
LibError CSimulation2::ReloadChangedFile(const VfsPath& path)
|
||||
{
|
||||
return m->ReloadChangedFile(path);
|
||||
|
||||
Reference in New Issue
Block a user