1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 21:45:33 +00:00

Remove unneeded casts

This commit is contained in:
scrawl 2015-03-03 23:46:53 +01:00
parent a8cb4e807b
commit 8931ddf428
4 changed files with 16 additions and 47 deletions

View file

@ -466,12 +466,9 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
InterpreterContext& context
= static_cast<InterpreterContext&> (runtime.getContext());
bool enabled = MWBase::Environment::get().getMechanicsManager()->toggleAI(); bool enabled = MWBase::Environment::get().getMechanicsManager()->toggleAI();
context.report (enabled ? "AI -> On" : "AI -> Off"); runtime.getContext().report (enabled ? "AI -> On" : "AI -> Off");
} }
}; };

View file

@ -65,12 +65,9 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
InterpreterContext& context
= static_cast<InterpreterContext&> (runtime.getContext());
bool enabled = MWBase::Environment::get().getWorld()->toggleCollisionMode(); bool enabled = MWBase::Environment::get().getWorld()->toggleCollisionMode();
context.report (enabled ? "Collision -> On" : "Collision -> Off"); runtime.getContext().report (enabled ? "Collision -> On" : "Collision -> Off");
} }
}; };

View file

@ -212,13 +212,10 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
bool enabled = bool enabled =
MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_CollisionDebug); MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_CollisionDebug);
context.report (enabled ? runtime.getContext().report (enabled ?
"Collision Mesh Rendering -> On" : "Collision Mesh Rendering -> Off"); "Collision Mesh Rendering -> On" : "Collision Mesh Rendering -> Off");
} }
}; };
@ -230,13 +227,10 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
bool enabled = bool enabled =
MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_BoundingBoxes); MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_BoundingBoxes);
context.report (enabled ? runtime.getContext().report (enabled ?
"Bounding Box Rendering -> On" : "Bounding Box Rendering -> Off"); "Bounding Box Rendering -> On" : "Bounding Box Rendering -> Off");
} }
}; };
@ -247,13 +241,10 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
bool enabled = bool enabled =
MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_Wireframe); MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_Wireframe);
context.report (enabled ? runtime.getContext().report (enabled ?
"Wireframe Rendering -> On" : "Wireframe Rendering -> Off"); "Wireframe Rendering -> On" : "Wireframe Rendering -> Off");
} }
}; };
@ -263,13 +254,10 @@ namespace MWScript
public: public:
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
bool enabled = bool enabled =
MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_Pathgrid); MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_Pathgrid);
context.report (enabled ? runtime.getContext().report (enabled ?
"Path Grid rendering -> On" : "Path Grid Rendering -> Off"); "Path Grid rendering -> On" : "Path Grid Rendering -> Off");
} }
}; };
@ -386,17 +374,14 @@ namespace MWScript
virtual void execute(Interpreter::Runtime &runtime) virtual void execute(Interpreter::Runtime &runtime)
{ {
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
MWBase::World *world = MWBase::World *world =
MWBase::Environment::get().getWorld(); MWBase::Environment::get().getWorld();
if (world->toggleVanityMode(sActivate)) { if (world->toggleVanityMode(sActivate)) {
context.report(sActivate ? "Vanity Mode -> On" : "Vanity Mode -> Off"); runtime.getContext().report(sActivate ? "Vanity Mode -> On" : "Vanity Mode -> Off");
sActivate = !sActivate; sActivate = !sActivate;
} else { } else {
context.report("Vanity Mode -> No"); runtime.getContext().report("Vanity Mode -> No");
} }
} }
}; };
@ -862,14 +847,11 @@ namespace MWScript
void printGlobalVars(Interpreter::Runtime &runtime) void printGlobalVars(Interpreter::Runtime &runtime)
{ {
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
std::stringstream str; std::stringstream str;
str<< "Global variables:"; str<< "Global variables:";
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
std::vector<std::string> names = context.getGlobals(); std::vector<std::string> names = runtime.getContext().getGlobals();
for(size_t i = 0;i < names.size();++i) for(size_t i = 0;i < names.size();++i)
{ {
char type = world->getGlobalVariableType (names[i]); char type = world->getGlobalVariableType (names[i]);
@ -879,17 +861,17 @@ namespace MWScript
{ {
case 's': case 's':
str << context.getGlobalShort (names[i]) << " (short)"; str << runtime.getContext().getGlobalShort (names[i]) << " (short)";
break; break;
case 'l': case 'l':
str << context.getGlobalLong (names[i]) << " (long)"; str << runtime.getContext().getGlobalLong (names[i]) << " (long)";
break; break;
case 'f': case 'f':
str << context.getGlobalFloat (names[i]) << " (float)"; str << runtime.getContext().getGlobalFloat (names[i]) << " (float)";
break; break;
default: default:
@ -898,7 +880,7 @@ namespace MWScript
} }
} }
context.report (str.str()); runtime.getContext().report (str.str());
} }
public: public:
@ -920,11 +902,9 @@ namespace MWScript
public: public:
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
InterpreterContext& context = static_cast<InterpreterContext&> (runtime.getContext());
bool enabled = MWBase::Environment::get().getWorld()->toggleScripts(); bool enabled = MWBase::Environment::get().getWorld()->toggleScripts();
context.report(enabled ? "Scripts -> On" : "Scripts -> Off"); runtime.getContext().report(enabled ? "Scripts -> On" : "Scripts -> Off");
} }
}; };
@ -933,11 +913,9 @@ namespace MWScript
public: public:
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
InterpreterContext& context = static_cast<InterpreterContext&> (runtime.getContext());
bool enabled = MWBase::Environment::get().getWorld()->toggleGodMode(); bool enabled = MWBase::Environment::get().getWorld()->toggleGodMode();
context.report (enabled ? "God Mode -> On" : "God Mode -> Off"); runtime.getContext().report (enabled ? "God Mode -> On" : "God Mode -> Off");
} }
}; };

View file

@ -25,10 +25,7 @@ namespace MWScript
{ {
bool enabled = MWBase::Environment::get().getWorld()->toggleSky(); bool enabled = MWBase::Environment::get().getWorld()->toggleSky();
InterpreterContext& context = runtime.getContext().report (enabled ? "Sky -> On" : "Sky -> Off");
static_cast<InterpreterContext&> (runtime.getContext());
context.report (enabled ? "Sky -> On" : "Sky -> Off");
} }
}; };