Remove trailing whitespace.
This was SVN commit r18158.
This commit is contained in:
parent
8b14bfe78b
commit
0e5815b78f
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2016 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -107,11 +107,11 @@ Status SavedGames::Save(const std::wstring& name, const std::wstring& descriptio
|
|||||||
simulation.GetScriptInterface().SetProperty(cameraMetadata, "Zoom", g_Game->GetView()->GetCameraZoom());
|
simulation.GetScriptInterface().SetProperty(cameraMetadata, "Zoom", g_Game->GetView()->GetCameraZoom());
|
||||||
simulation.GetScriptInterface().SetProperty(guiMetadata, "camera", cameraMetadata);
|
simulation.GetScriptInterface().SetProperty(guiMetadata, "camera", cameraMetadata);
|
||||||
simulation.GetScriptInterface().SetProperty(metadata, "gui", guiMetadata);
|
simulation.GetScriptInterface().SetProperty(metadata, "gui", guiMetadata);
|
||||||
|
|
||||||
simulation.GetScriptInterface().SetProperty(metadata, "description", description);
|
simulation.GetScriptInterface().SetProperty(metadata, "description", description);
|
||||||
|
|
||||||
std::string metadataString = simulation.GetScriptInterface().StringifyJSON(&metadata, true);
|
std::string metadataString = simulation.GetScriptInterface().StringifyJSON(&metadata, true);
|
||||||
|
|
||||||
// Write the saved game as zip file containing the various components
|
// Write the saved game as zip file containing the various components
|
||||||
PIArchiveWriter archiveWriter = CreateArchiveWriter_Zip(tempSaveFileRealPath, false);
|
PIArchiveWriter archiveWriter = CreateArchiveWriter_Zip(tempSaveFileRealPath, false);
|
||||||
if (!archiveWriter)
|
if (!archiveWriter)
|
||||||
@ -142,15 +142,15 @@ class CGameLoader
|
|||||||
{
|
{
|
||||||
NONCOPYABLE(CGameLoader);
|
NONCOPYABLE(CGameLoader);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param scriptInterface the ScriptInterface used for loading metadata.
|
* @param scriptInterface the ScriptInterface used for loading metadata.
|
||||||
* @param[out] savedState serialized simulation state stored as string of bytes,
|
* @param[out] savedState serialized simulation state stored as string of bytes,
|
||||||
* loaded from simulation.dat inside the archive.
|
* loaded from simulation.dat inside the archive.
|
||||||
*
|
*
|
||||||
* Note: We use a different approach for returning the string and the metadata JS::Value.
|
* Note: We use a different approach for returning the string and the metadata JS::Value.
|
||||||
* We use a pointer for the string to avoid copies (efficiency). We don't use this approach
|
* We use a pointer for the string to avoid copies (efficiency). We don't use this approach
|
||||||
* for the metadata because it would be error prone with rooting and the stack-based rooting
|
* for the metadata because it would be error prone with rooting and the stack-based rooting
|
||||||
* types and confusing (a chain of pointers pointing to other pointers).
|
* types and confusing (a chain of pointers pointing to other pointers).
|
||||||
*/
|
*/
|
||||||
CGameLoader(ScriptInterface& scriptInterface, std::string* savedState) :
|
CGameLoader(ScriptInterface& scriptInterface, std::string* savedState) :
|
||||||
@ -169,7 +169,7 @@ public:
|
|||||||
{
|
{
|
||||||
JSContext* cx = m_ScriptInterface.GetContext();
|
JSContext* cx = m_ScriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
if (pathname == L"metadata.json")
|
if (pathname == L"metadata.json")
|
||||||
{
|
{
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
@ -183,12 +183,12 @@ public:
|
|||||||
WARN_IF_ERR(archiveFile->Load("", DummySharedPtr((u8*)m_SavedState->data()), m_SavedState->size()));
|
WARN_IF_ERR(archiveFile->Load("", DummySharedPtr((u8*)m_SavedState->data()), m_SavedState->size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value GetMetadata()
|
JS::Value GetMetadata()
|
||||||
{
|
{
|
||||||
return m_Metadata.get();
|
return m_Metadata.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ScriptInterface& m_ScriptInterface;
|
ScriptInterface& m_ScriptInterface;
|
||||||
@ -217,7 +217,7 @@ Status SavedGames::Load(const std::wstring& name, ScriptInterface& scriptInterfa
|
|||||||
WARN_RETURN_STATUS_IF_ERR(archiveReader->ReadEntries(CGameLoader::ReadEntryCallback, (uintptr_t)&loader));
|
WARN_RETURN_STATUS_IF_ERR(archiveReader->ReadEntries(CGameLoader::ReadEntryCallback, (uintptr_t)&loader));
|
||||||
metadata.set(loader.GetMetadata());
|
metadata.set(loader.GetMetadata());
|
||||||
|
|
||||||
return INFO::OK;
|
return INFO::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value SavedGames::GetSavedGames(ScriptInterface& scriptInterface)
|
JS::Value SavedGames::GetSavedGames(ScriptInterface& scriptInterface)
|
||||||
@ -225,7 +225,7 @@ JS::Value SavedGames::GetSavedGames(ScriptInterface& scriptInterface)
|
|||||||
TIMER(L"GetSavedGames");
|
TIMER(L"GetSavedGames");
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
JS::RootedObject games(cx, JS_NewArrayObject(cx, 0));
|
JS::RootedObject games(cx, JS_NewArrayObject(cx, 0));
|
||||||
|
|
||||||
Status err;
|
Status err;
|
||||||
@ -260,7 +260,7 @@ JS::Value SavedGames::GetSavedGames(ScriptInterface& scriptInterface)
|
|||||||
continue; // skip this file
|
continue; // skip this file
|
||||||
}
|
}
|
||||||
JS::RootedValue metadata(cx, loader.GetMetadata());
|
JS::RootedValue metadata(cx, loader.GetMetadata());
|
||||||
|
|
||||||
JS::RootedValue game(cx);
|
JS::RootedValue game(cx);
|
||||||
scriptInterface.Eval("({})", &game);
|
scriptInterface.Eval("({})", &game);
|
||||||
scriptInterface.SetProperty(game, "id", pathnames[i].Basename());
|
scriptInterface.SetProperty(game, "id", pathnames[i].Basename());
|
||||||
@ -293,15 +293,15 @@ bool SavedGames::DeleteSavedGame(const std::wstring& name)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value SavedGames::GetEngineInfo(ScriptInterface& scriptInterface)
|
JS::Value SavedGames::GetEngineInfo(ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
JS::RootedValue metainfo(cx);
|
JS::RootedValue metainfo(cx);
|
||||||
scriptInterface.Eval("({})", &metainfo);
|
scriptInterface.Eval("({})", &metainfo);
|
||||||
scriptInterface.SetProperty(metainfo, "version_major", SAVED_GAME_VERSION_MAJOR);
|
scriptInterface.SetProperty(metainfo, "version_major", SAVED_GAME_VERSION_MAJOR);
|
||||||
scriptInterface.SetProperty(metainfo, "version_minor", SAVED_GAME_VERSION_MINOR);
|
scriptInterface.SetProperty(metainfo, "version_minor", SAVED_GAME_VERSION_MINOR);
|
||||||
scriptInterface.SetProperty(metainfo, "engine_version", std::string(engine_version));
|
scriptInterface.SetProperty(metainfo, "engine_version", std::string(engine_version));
|
||||||
scriptInterface.SetProperty(metainfo, "mods", g_modsLoaded);
|
scriptInterface.SetProperty(metainfo, "mods", g_modsLoaded);
|
||||||
return metainfo;
|
return metainfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user