mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Use ScriptInterface::CreateObject for ToJSVal<CColor>, and for ToJSVal<Grid<u8> >, ToJSVal<Grid<u16> > used by the AIManager obtaining the pathfinder grid.
Make that function static, so that it can be used for these functions without slowly having to obtain the ScriptInterface instance using GetScriptInterfaceAndCBData just to get the JSContext again. Remove few redundant conversions for CreateObject arguments. Differential Revision: https://code.wildfiregames.com/D2128 Tested on: gcc 9.1.0, clang 8.0.1, Jenkins Tedious performance testing in: D2128, D2127 This was SVN commit r22894.
This commit is contained in:
@@ -83,9 +83,10 @@ Status SavedGames::Save(const CStrW& name, const CStrW& description, CSimulation
|
||||
|
||||
JS::RootedValue metadata(cx);
|
||||
|
||||
simulation.GetScriptInterface().CreateObject(
|
||||
ScriptInterface::CreateObject(
|
||||
cx,
|
||||
&metadata,
|
||||
"engine_version", std::string(engine_version),
|
||||
"engine_version", engine_version,
|
||||
"time", static_cast<double>(now),
|
||||
"playerID", g_Game->GetPlayerID(),
|
||||
"mods", mods,
|
||||
@@ -100,7 +101,8 @@ Status SavedGames::Save(const CStrW& name, const CStrW& description, CSimulation
|
||||
|
||||
JS::RootedValue cameraMetadata(cx);
|
||||
|
||||
simulation.GetScriptInterface().CreateObject(
|
||||
ScriptInterface::CreateObject(
|
||||
cx,
|
||||
&cameraMetadata,
|
||||
"PosX", cameraPosition.X,
|
||||
"PosY", cameraPosition.Y,
|
||||
@@ -232,7 +234,7 @@ JS::Value SavedGames::GetSavedGames(const ScriptInterface& scriptInterface)
|
||||
JSAutoRequest rq(cx);
|
||||
|
||||
JS::RootedValue games(cx);
|
||||
scriptInterface.CreateArray(&games);
|
||||
ScriptInterface::CreateArray(cx, &games);
|
||||
|
||||
Status err;
|
||||
|
||||
@@ -268,7 +270,8 @@ JS::Value SavedGames::GetSavedGames(const ScriptInterface& scriptInterface)
|
||||
JS::RootedValue metadata(cx, loader.GetMetadata());
|
||||
|
||||
JS::RootedValue game(cx);
|
||||
scriptInterface.CreateObject(
|
||||
ScriptInterface::CreateObject(
|
||||
cx,
|
||||
&game,
|
||||
"id", pathnames[i].Basename(),
|
||||
"metadata", metadata);
|
||||
|
||||
Reference in New Issue
Block a user