reuse ImplicitRef and ExplicitRef for enable, disable, getdisabled, startscript; move scriptrunning and stopscript

This commit is contained in:
Evil Eye 2020-05-13 21:17:08 +02:00
parent 05ffda9b47
commit f0e2ee45fa
19 changed files with 155 additions and 601 deletions

View file

@ -292,65 +292,10 @@ namespace
code.push_back (Compiler::Generator::segment5 (45));
}
void opScriptRunning (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (46));
}
void opStartScript (Compiler::Generator::CodeContainer& code, bool targeted)
{
code.push_back (Compiler::Generator::segment5 (targeted ? 71 : 47));
}
void opStopScript (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (48));
}
void opGetDistance (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (49));
}
void opGetSecondsPassed (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (50));
}
void opEnable (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (51));
}
void opDisable (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (52));
}
void opGetDisabled (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (53));
}
void opEnableExplicit (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (54));
}
void opDisableExplicit (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (55));
}
void opGetDisabledExplicit (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (56));
}
void opGetDistanceExplicit (Compiler::Generator::CodeContainer& code)
{
code.push_back (Compiler::Generator::segment5 (57));
}
}
namespace Compiler
@ -812,87 +757,9 @@ namespace Compiler
opRandom (code);
}
void scriptRunning (CodeContainer& code)
{
opScriptRunning (code);
}
void startScript (CodeContainer& code, Literals& literals, const std::string& id)
{
if (id.empty())
opStartScript (code, false);
else
{
int index = literals.addString (id);
opPushInt (code, index);
opStartScript (code, true);
}
}
void stopScript (CodeContainer& code)
{
opStopScript (code);
}
void getDistance (CodeContainer& code, Literals& literals, const std::string& id)
{
if (id.empty())
{
opGetDistance (code);
}
else
{
int index = literals.addString (id);
opPushInt (code, index);
opGetDistanceExplicit (code);
}
}
void getSecondsPassed (CodeContainer& code)
{
opGetSecondsPassed (code);
}
void getDisabled (CodeContainer& code, Literals& literals, const std::string& id)
{
if (id.empty())
{
opGetDisabled (code);
}
else
{
int index = literals.addString (id);
opPushInt (code, index);
opGetDisabledExplicit (code);
}
}
void enable (CodeContainer& code, Literals& literals, const std::string& id)
{
if (id.empty())
{
opEnable (code);
}
else
{
int index = literals.addString (id);
opPushInt (code, index);
opEnableExplicit (code);
}
}
void disable (CodeContainer& code, Literals& literals, const std::string& id)
{
if (id.empty())
{
opDisable (code);
}
else
{
int index = literals.addString (id);
opPushInt (code, index);
opDisableExplicit (code);
}
}
}
}