mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-25 00:08:14 +00:00
Move Script* classes to Script namespace
- Rename ScriptEngine, ScriptContext, ScriptInterface, ScriptRequest to
Script::Engine, Script::Context, Script::Interface, Script::Request
- Remove 'Script' prefix from filenames:
ScriptContext.* → Context.*
ScriptInterface.* → Interface.*
ScriptRequest.* → Request.*
ScriptEngine.* → Engine.*
ScriptConversions.* → Conversions.*
ScriptExceptions.* → Exceptions.*
ScriptForward.* → ForwardDeclarations.*
ScriptStats.* → Stats.*
- Update all includes, forward declarations, and friend classes
- Use namespace Script { ... } in .cpp definitions to avoid repetitive
Script:: prefix (keeping global callbacks outside)
- Rename internal implementation structs:
ScriptInterface_impl → Interface_impl
ScriptFunction → Function
- Update copyright year to 2026 in all touched files
- Suppress pre-existing cppcheck warnings (uninitvar, nullPointer, unknown
macro) by adding them to suppressions-list.txt (these are not caused
by this refactor)
Fixes #7516
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
#include "ps/Pyrogenesis.h"
|
||||
#include "scriptinterface/FunctionWrapper.h"
|
||||
#include "scriptinterface/Object.h"
|
||||
#include "scriptinterface/ScriptRequest.h"
|
||||
#include "scriptinterface/Request.h"
|
||||
#include "scriptinterface/StructuredClone.h"
|
||||
#include "simulation2/Simulation2.h"
|
||||
#include "simulation2/components/ICmpAIManager.h"
|
||||
@@ -57,11 +57,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class ScriptInterface;
|
||||
namespace Script { class Interface; }
|
||||
|
||||
namespace JSI_Simulation
|
||||
{
|
||||
JS::Value GuiInterfaceCall(const ScriptInterface& scriptInterface, const std::wstring& name, JS::HandleValue data)
|
||||
JS::Value GuiInterfaceCall(const Script::Interface& scriptInterface, const std::wstring& name, JS::HandleValue data)
|
||||
{
|
||||
if (!g_Game)
|
||||
return JS::UndefinedValue();
|
||||
@@ -73,7 +73,7 @@ JS::Value GuiInterfaceCall(const ScriptInterface& scriptInterface, const std::ws
|
||||
if (!cmpGuiInterface)
|
||||
return JS::UndefinedValue();
|
||||
|
||||
ScriptRequest rqSim(sim->GetScriptInterface());
|
||||
Script::Request rqSim(sim->GetScriptInterface());
|
||||
JS::RootedValue arg(rqSim.cx, Script::CloneValueFromOtherCompartment(sim->GetScriptInterface(), scriptInterface, data));
|
||||
JS::RootedValue ret(rqSim.cx);
|
||||
cmpGuiInterface->ScriptCall(g_Game->GetViewedPlayerID(), name, arg, &ret);
|
||||
@@ -81,7 +81,7 @@ JS::Value GuiInterfaceCall(const ScriptInterface& scriptInterface, const std::ws
|
||||
return Script::CloneValueFromOtherCompartment(scriptInterface, sim->GetScriptInterface(), ret);
|
||||
}
|
||||
|
||||
void PostNetworkCommand(const ScriptInterface& scriptInterface, JS::HandleValue cmd)
|
||||
void PostNetworkCommand(const Script::Interface& scriptInterface, JS::HandleValue cmd)
|
||||
{
|
||||
if (!g_Game)
|
||||
return;
|
||||
@@ -93,7 +93,7 @@ void PostNetworkCommand(const ScriptInterface& scriptInterface, JS::HandleValue
|
||||
if (!cmpCommandQueue)
|
||||
return;
|
||||
|
||||
ScriptRequest rqSim(sim->GetScriptInterface());
|
||||
Script::Request rqSim(sim->GetScriptInterface());
|
||||
JS::RootedValue cmd2(rqSim.cx, Script::CloneValueFromOtherCompartment(sim->GetScriptInterface(), scriptInterface, cmd));
|
||||
|
||||
cmpCommandQueue->PostNetworkCommand(cmd2);
|
||||
@@ -139,7 +139,7 @@ std::vector<entity_id_t> GetEntitiesWithStaticObstructionOnScreen()
|
||||
return EntitySelection::GetEntitiesWithComponentInRect<StaticObstructionFilter>(*g_Game->GetSimulation2(), IID_Obstruction, *g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres);
|
||||
}
|
||||
|
||||
JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(const ScriptInterface& scriptInterface, entity_pos_t x, entity_pos_t z)
|
||||
JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(const Script::Interface& scriptInterface, entity_pos_t x, entity_pos_t z)
|
||||
{
|
||||
if (!g_Game)
|
||||
return JS::UndefinedValue();
|
||||
@@ -147,7 +147,7 @@ JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(const ScriptInterface& scri
|
||||
CSimulation2* sim = g_Game->GetSimulation2();
|
||||
ENSURE(sim);
|
||||
|
||||
ScriptRequest rq(scriptInterface);
|
||||
Script::Request rq(scriptInterface);
|
||||
JS::RootedValueVector edgeList{rq.cx};
|
||||
|
||||
const float distanceThreshold{g_ConfigDB.Get("gui.session.snaptoedgesdistancethreshold", 10.0f)};
|
||||
@@ -212,7 +212,7 @@ std::vector<entity_id_t> PickSimilarPlayerEntities(const std::string& templateNa
|
||||
return EntitySelection::PickSimilarEntities(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), templateName, g_Game->GetViewedPlayerID(), includeOffScreen, matchRank, false, allowFoundations);
|
||||
}
|
||||
|
||||
JS::Value GetAIs(const ScriptInterface& scriptInterface)
|
||||
JS::Value GetAIs(const Script::Interface& scriptInterface)
|
||||
{
|
||||
return ICmpAIManager::GetAIs(scriptInterface);
|
||||
}
|
||||
@@ -222,19 +222,19 @@ void SetBoundingBoxDebugOverlay(bool enabled)
|
||||
ICmpSelectable::ms_EnableDebugOverlays = enabled;
|
||||
}
|
||||
|
||||
void RegisterScriptFunctions(const ScriptRequest& rq)
|
||||
void RegisterScriptFunctions(const Script::Request& rq)
|
||||
{
|
||||
ScriptFunction::Register<&GuiInterfaceCall>(rq, "GuiInterfaceCall");
|
||||
ScriptFunction::Register<&PostNetworkCommand>(rq, "PostNetworkCommand");
|
||||
ScriptFunction::Register<&DumpSimState>(rq, "DumpSimState");
|
||||
ScriptFunction::Register<&GetAIs>(rq, "GetAIs");
|
||||
ScriptFunction::Register<&PickEntityAtPoint>(rq, "PickEntityAtPoint");
|
||||
ScriptFunction::Register<&PickPlayerEntitiesInRect>(rq, "PickPlayerEntitiesInRect");
|
||||
ScriptFunction::Register<&PickPlayerEntitiesOnScreen>(rq, "PickPlayerEntitiesOnScreen");
|
||||
ScriptFunction::Register<&PickNonGaiaEntitiesOnScreen>(rq, "PickNonGaiaEntitiesOnScreen");
|
||||
ScriptFunction::Register<&GetEntitiesWithStaticObstructionOnScreen>(rq, "GetEntitiesWithStaticObstructionOnScreen");
|
||||
ScriptFunction::Register<&GetEdgesOfStaticObstructionsOnScreenNearTo>(rq, "GetEdgesOfStaticObstructionsOnScreenNearTo");
|
||||
ScriptFunction::Register<&PickSimilarPlayerEntities>(rq, "PickSimilarPlayerEntities");
|
||||
ScriptFunction::Register<&SetBoundingBoxDebugOverlay>(rq, "SetBoundingBoxDebugOverlay");
|
||||
Script::Function::Register<&GuiInterfaceCall>(rq, "GuiInterfaceCall");
|
||||
Script::Function::Register<&PostNetworkCommand>(rq, "PostNetworkCommand");
|
||||
Script::Function::Register<&DumpSimState>(rq, "DumpSimState");
|
||||
Script::Function::Register<&GetAIs>(rq, "GetAIs");
|
||||
Script::Function::Register<&PickEntityAtPoint>(rq, "PickEntityAtPoint");
|
||||
Script::Function::Register<&PickPlayerEntitiesInRect>(rq, "PickPlayerEntitiesInRect");
|
||||
Script::Function::Register<&PickPlayerEntitiesOnScreen>(rq, "PickPlayerEntitiesOnScreen");
|
||||
Script::Function::Register<&PickNonGaiaEntitiesOnScreen>(rq, "PickNonGaiaEntitiesOnScreen");
|
||||
Script::Function::Register<&GetEntitiesWithStaticObstructionOnScreen>(rq, "GetEntitiesWithStaticObstructionOnScreen");
|
||||
Script::Function::Register<&GetEdgesOfStaticObstructionsOnScreenNearTo>(rq, "GetEdgesOfStaticObstructionsOnScreenNearTo");
|
||||
Script::Function::Register<&PickSimilarPlayerEntities>(rq, "PickSimilarPlayerEntities");
|
||||
Script::Function::Register<&SetBoundingBoxDebugOverlay>(rq, "SetBoundingBoxDebugOverlay");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user