mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 17:15:35 +00:00
reuse ImplicitRef and ExplicitRef for enable, disable, getdisabled, startscript; move scriptrunning and stopscript
This commit is contained in:
parent
05ffda9b47
commit
f0e2ee45fa
19 changed files with 155 additions and 601 deletions
|
@ -415,58 +415,6 @@ namespace MWScript
|
||||||
return MWBase::Environment::get().getWorld()->getCellName();
|
return MWBase::Environment::get().getWorld()->getCellName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterpreterContext::isScriptRunning (const std::string& name) const
|
|
||||||
{
|
|
||||||
return MWBase::Environment::get().getScriptManager()->getGlobalScripts().isRunning (name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterContext::startScript (const std::string& name, const std::string& targetId)
|
|
||||||
{
|
|
||||||
MWWorld::Ptr target;
|
|
||||||
if (targetId.empty())
|
|
||||||
target = getReference(false);
|
|
||||||
else
|
|
||||||
target = getReferenceImp(targetId);
|
|
||||||
MWBase::Environment::get().getScriptManager()->getGlobalScripts().addScript (name, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterContext::stopScript (const std::string& name)
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getScriptManager()->getGlobalScripts().removeScript (name);
|
|
||||||
}
|
|
||||||
|
|
||||||
float InterpreterContext::getDistance (const std::string& name, const std::string& id) const
|
|
||||||
{
|
|
||||||
// NOTE: id may be empty, indicating an implicit reference
|
|
||||||
|
|
||||||
MWWorld::Ptr ref2 = getReferenceImp(id);
|
|
||||||
|
|
||||||
if (ref2.getContainerStore()) // is the object contained?
|
|
||||||
{
|
|
||||||
MWWorld::Ptr container = MWBase::Environment::get().getWorld()->findContainer(ref2);
|
|
||||||
|
|
||||||
if (!container.isEmpty())
|
|
||||||
ref2 = container;
|
|
||||||
else
|
|
||||||
throw std::runtime_error("failed to find container ptr");
|
|
||||||
}
|
|
||||||
|
|
||||||
const MWWorld::Ptr ref = MWBase::Environment::get().getWorld()->getPtr(name, false);
|
|
||||||
|
|
||||||
// If the objects are in different worldspaces, return a large value (just like vanilla)
|
|
||||||
if (!ref.isInCell() || !ref2.isInCell() || ref.getCell()->getCell()->getCellId().mWorldspace != ref2.getCell()->getCell()->getCellId().mWorldspace)
|
|
||||||
return std::numeric_limits<float>::max();
|
|
||||||
|
|
||||||
double diff[3];
|
|
||||||
|
|
||||||
const float* const pos1 = ref.getRefData().getPosition().pos;
|
|
||||||
const float* const pos2 = ref2.getRefData().getPosition().pos;
|
|
||||||
for (int i=0; i<3; ++i)
|
|
||||||
diff[i] = pos1[i] - pos2[i];
|
|
||||||
|
|
||||||
return static_cast<float>(std::sqrt(diff[0] * diff[0] + diff[1] * diff[1] + diff[2] * diff[2]));
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterContext::executeActivation(MWWorld::Ptr ptr, MWWorld::Ptr actor)
|
void InterpreterContext::executeActivation(MWWorld::Ptr ptr, MWWorld::Ptr actor)
|
||||||
{
|
{
|
||||||
std::shared_ptr<MWWorld::Action> action = (ptr.getClass().activate(ptr, actor));
|
std::shared_ptr<MWWorld::Action> action = (ptr.getClass().activate(ptr, actor));
|
||||||
|
@ -482,24 +430,6 @@ namespace MWScript
|
||||||
return MWBase::Environment::get().getFrameDuration();
|
return MWBase::Environment::get().getFrameDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterpreterContext::isDisabled (const std::string& id) const
|
|
||||||
{
|
|
||||||
const MWWorld::Ptr ref = getReferenceImp (id, false);
|
|
||||||
return !ref.getRefData().isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterContext::enable (const std::string& id)
|
|
||||||
{
|
|
||||||
MWWorld::Ptr ref = getReferenceImp (id, false);
|
|
||||||
MWBase::Environment::get().getWorld()->enable (ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterpreterContext::disable (const std::string& id)
|
|
||||||
{
|
|
||||||
MWWorld::Ptr ref = getReferenceImp (id, false);
|
|
||||||
MWBase::Environment::get().getWorld()->disable (ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
int InterpreterContext::getMemberShort (const std::string& id, const std::string& name,
|
int InterpreterContext::getMemberShort (const std::string& id, const std::string& name,
|
||||||
bool global) const
|
bool global) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,26 +121,11 @@ namespace MWScript
|
||||||
|
|
||||||
virtual std::string getCurrentCellName() const;
|
virtual std::string getCurrentCellName() const;
|
||||||
|
|
||||||
virtual bool isScriptRunning (const std::string& name) const;
|
|
||||||
|
|
||||||
virtual void startScript (const std::string& name, const std::string& targetId = "");
|
|
||||||
|
|
||||||
virtual void stopScript (const std::string& name);
|
|
||||||
|
|
||||||
virtual float getDistance (const std::string& name, const std::string& id = "") const;
|
|
||||||
///< @note if \a id is empty, assumes an implicit reference
|
|
||||||
|
|
||||||
void executeActivation(MWWorld::Ptr ptr, MWWorld::Ptr actor);
|
void executeActivation(MWWorld::Ptr ptr, MWWorld::Ptr actor);
|
||||||
///< Execute the activation action for this ptr. If ptr is mActivated, mark activation as handled.
|
///< Execute the activation action for this ptr. If ptr is mActivated, mark activation as handled.
|
||||||
|
|
||||||
virtual float getSecondsPassed() const;
|
virtual float getSecondsPassed() const;
|
||||||
|
|
||||||
virtual bool isDisabled (const std::string& id = "") const;
|
|
||||||
|
|
||||||
virtual void enable (const std::string& id = "");
|
|
||||||
|
|
||||||
virtual void disable (const std::string& id = "");
|
|
||||||
|
|
||||||
virtual int getMemberShort (const std::string& id, const std::string& name, bool global) const;
|
virtual int getMemberShort (const std::string& id, const std::string& name, bool global) const;
|
||||||
|
|
||||||
virtual int getMemberLong (const std::string& id, const std::string& name, bool global) const;
|
virtual int getMemberLong (const std::string& id, const std::string& name, bool global) const;
|
||||||
|
|
|
@ -78,6 +78,80 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Misc
|
namespace Misc
|
||||||
{
|
{
|
||||||
|
template<class R>
|
||||||
|
class OpStartScript : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
MWWorld::Ptr target = R()(runtime, false);
|
||||||
|
MWBase::Environment::get().getScriptManager()->getGlobalScripts().addScript (name, target);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class OpScriptRunning : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
runtime.push(MWBase::Environment::get().getScriptManager()->getGlobalScripts().isRunning (name));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class OpStopScript : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
MWBase::Environment::get().getScriptManager()->getGlobalScripts().removeScript (name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpEnable : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
MWBase::Environment::get().getWorld()->enable (ptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpDisable : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
MWBase::Environment::get().getWorld()->disable (ptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpGetDisabled : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
runtime.push (!ptr.getRefData().isEnabled());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class OpPlayBink : public Interpreter::Opcode0
|
class OpPlayBink : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1456,6 +1530,16 @@ namespace MWScript
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeScriptRunning, new OpScriptRunning);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeStartScript, new OpStartScript<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeStartScriptExplicit, new OpStartScript<ExplicitRef>);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeStopScript, new OpStopScript);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeEnable, new OpEnable<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeEnableExplicit, new OpEnable<ExplicitRef>);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeDisable, new OpDisable<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeDisableExplicit, new OpDisable<ExplicitRef>);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeGetDisabled, new OpGetDisabled<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeGetDisabledExplicit, new OpGetDisabled<ExplicitRef>);
|
||||||
interpreter.installSegment5 (Compiler::Misc::opcodeXBox, new OpXBox);
|
interpreter.installSegment5 (Compiler::Misc::opcodeXBox, new OpXBox);
|
||||||
interpreter.installSegment5 (Compiler::Misc::opcodeOnActivate, new OpOnActivate<ImplicitRef>);
|
interpreter.installSegment5 (Compiler::Misc::opcodeOnActivate, new OpOnActivate<ImplicitRef>);
|
||||||
interpreter.installSegment5 (Compiler::Misc::opcodeOnActivateExplicit, new OpOnActivate<ExplicitRef>);
|
interpreter.installSegment5 (Compiler::Misc::opcodeOnActivateExplicit, new OpOnActivate<ExplicitRef>);
|
||||||
|
|
|
@ -39,6 +39,49 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpGetDistance : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
MWWorld::Ptr from = R()(runtime);
|
||||||
|
if (from.getContainerStore()) // is the object contained?
|
||||||
|
{
|
||||||
|
MWWorld::Ptr container = MWBase::Environment::get().getWorld()->findContainer(from);
|
||||||
|
|
||||||
|
if (!container.isEmpty())
|
||||||
|
from = container;
|
||||||
|
else
|
||||||
|
throw std::runtime_error("failed to find container ptr");
|
||||||
|
}
|
||||||
|
|
||||||
|
const MWWorld::Ptr to = MWBase::Environment::get().getWorld()->getPtr(name, false);
|
||||||
|
|
||||||
|
float distance;
|
||||||
|
// If the objects are in different worldspaces, return a large value (just like vanilla)
|
||||||
|
if (!to.isInCell() || !from.isInCell() || to.getCell()->getCell()->getCellId().mWorldspace != from.getCell()->getCell()->getCellId().mWorldspace)
|
||||||
|
distance = std::numeric_limits<float>::max();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double diff[3];
|
||||||
|
|
||||||
|
const float* const pos1 = to.getRefData().getPosition().pos;
|
||||||
|
const float* const pos2 = from.getRefData().getPosition().pos;
|
||||||
|
for (int i=0; i<3; ++i)
|
||||||
|
diff[i] = pos1[i] - pos2[i];
|
||||||
|
|
||||||
|
distance = static_cast<float>(std::sqrt(diff[0] * diff[0] + diff[1] * diff[1] + diff[2] * diff[2]));
|
||||||
|
}
|
||||||
|
|
||||||
|
runtime.push(distance);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<class R>
|
template<class R>
|
||||||
class OpSetScale : public Interpreter::Opcode0
|
class OpSetScale : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
|
@ -730,6 +773,8 @@ namespace MWScript
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
|
interpreter.installSegment5(Compiler::Transformation::opcodeGetDistance, new OpGetDistance<ImplicitRef>);
|
||||||
|
interpreter.installSegment5(Compiler::Transformation::opcodeGetDistanceExplicit, new OpGetDistance<ExplicitRef>);
|
||||||
interpreter.installSegment5(Compiler::Transformation::opcodeSetScale,new OpSetScale<ImplicitRef>);
|
interpreter.installSegment5(Compiler::Transformation::opcodeSetScale,new OpSetScale<ImplicitRef>);
|
||||||
interpreter.installSegment5(Compiler::Transformation::opcodeSetScaleExplicit,new OpSetScale<ExplicitRef>);
|
interpreter.installSegment5(Compiler::Transformation::opcodeSetScaleExplicit,new OpSetScale<ExplicitRef>);
|
||||||
interpreter.installSegment5(Compiler::Transformation::opcodeSetAngle,new OpSetAngle<ImplicitRef>);
|
interpreter.installSegment5(Compiler::Transformation::opcodeSetAngle,new OpSetAngle<ImplicitRef>);
|
||||||
|
|
|
@ -111,7 +111,7 @@ add_component_dir (compiler
|
||||||
|
|
||||||
add_component_dir (interpreter
|
add_component_dir (interpreter
|
||||||
context controlopcodes genericopcodes installopcodes interpreter localopcodes mathopcodes
|
context controlopcodes genericopcodes installopcodes interpreter localopcodes mathopcodes
|
||||||
miscopcodes opcodes runtime scriptopcodes spatialopcodes types defines
|
miscopcodes opcodes runtime types defines
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (translation
|
add_component_dir (translation
|
||||||
|
|
|
@ -372,9 +372,7 @@ namespace Compiler
|
||||||
keyword==Scanner::K_elseif || keyword==Scanner::K_while ||
|
keyword==Scanner::K_elseif || keyword==Scanner::K_while ||
|
||||||
keyword==Scanner::K_endwhile || keyword==Scanner::K_return ||
|
keyword==Scanner::K_endwhile || keyword==Scanner::K_return ||
|
||||||
keyword==Scanner::K_messagebox || keyword==Scanner::K_set ||
|
keyword==Scanner::K_messagebox || keyword==Scanner::K_set ||
|
||||||
keyword==Scanner::K_to || keyword==Scanner::K_startscript ||
|
keyword==Scanner::K_to)
|
||||||
keyword==Scanner::K_stopscript || keyword==Scanner::K_enable ||
|
|
||||||
keyword==Scanner::K_disable)
|
|
||||||
{
|
{
|
||||||
return parseName (loc.mLiteral, loc, scanner);
|
return parseName (loc.mLiteral, loc, scanner);
|
||||||
}
|
}
|
||||||
|
@ -385,53 +383,6 @@ namespace Compiler
|
||||||
{
|
{
|
||||||
if (mRefOp && mNextOperand)
|
if (mRefOp && mNextOperand)
|
||||||
{
|
{
|
||||||
if (keyword==Scanner::K_getdisabled)
|
|
||||||
{
|
|
||||||
start();
|
|
||||||
|
|
||||||
mTokenLoc = loc;
|
|
||||||
|
|
||||||
Generator::getDisabled (mCode, mLiterals, mExplicit);
|
|
||||||
mOperands.push_back ('l');
|
|
||||||
mExplicit.clear();
|
|
||||||
mRefOp = false;
|
|
||||||
|
|
||||||
std::vector<Interpreter::Type_Code> ignore;
|
|
||||||
parseArguments ("x", scanner, ignore);
|
|
||||||
|
|
||||||
mNextOperand = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (keyword==Scanner::K_getdistance)
|
|
||||||
{
|
|
||||||
start();
|
|
||||||
|
|
||||||
mTokenLoc = loc;
|
|
||||||
parseArguments ("c", scanner);
|
|
||||||
|
|
||||||
Generator::getDistance (mCode, mLiterals, mExplicit);
|
|
||||||
mOperands.push_back ('f');
|
|
||||||
mExplicit.clear();
|
|
||||||
mRefOp = false;
|
|
||||||
|
|
||||||
mNextOperand = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (keyword==Scanner::K_scriptrunning)
|
|
||||||
{
|
|
||||||
start();
|
|
||||||
|
|
||||||
mTokenLoc = loc;
|
|
||||||
parseArguments ("c", scanner);
|
|
||||||
|
|
||||||
Generator::scriptRunning (mCode);
|
|
||||||
mOperands.push_back ('l');
|
|
||||||
|
|
||||||
mExplicit.clear();
|
|
||||||
mRefOp = false;
|
|
||||||
mNextOperand = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for custom extensions
|
// check for custom extensions
|
||||||
if (const Extensions *extensions = getContext().getExtensions())
|
if (const Extensions *extensions = getContext().getExtensions())
|
||||||
|
@ -508,32 +459,6 @@ namespace Compiler
|
||||||
mNextOperand = false;
|
mNextOperand = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (keyword==Scanner::K_scriptrunning)
|
|
||||||
{
|
|
||||||
start();
|
|
||||||
|
|
||||||
mTokenLoc = loc;
|
|
||||||
parseArguments ("c", scanner);
|
|
||||||
|
|
||||||
Generator::scriptRunning (mCode);
|
|
||||||
mOperands.push_back ('l');
|
|
||||||
|
|
||||||
mNextOperand = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (keyword==Scanner::K_getdistance)
|
|
||||||
{
|
|
||||||
start();
|
|
||||||
|
|
||||||
mTokenLoc = loc;
|
|
||||||
parseArguments ("c", scanner);
|
|
||||||
|
|
||||||
Generator::getDistance (mCode, mLiterals, "");
|
|
||||||
mOperands.push_back ('f');
|
|
||||||
|
|
||||||
mNextOperand = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (keyword==Scanner::K_getsecondspassed)
|
else if (keyword==Scanner::K_getsecondspassed)
|
||||||
{
|
{
|
||||||
start();
|
start();
|
||||||
|
@ -546,21 +471,6 @@ namespace Compiler
|
||||||
mNextOperand = false;
|
mNextOperand = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (keyword==Scanner::K_getdisabled)
|
|
||||||
{
|
|
||||||
start();
|
|
||||||
|
|
||||||
mTokenLoc = loc;
|
|
||||||
|
|
||||||
Generator::getDisabled (mCode, mLiterals, "");
|
|
||||||
mOperands.push_back ('l');
|
|
||||||
|
|
||||||
std::vector<Interpreter::Type_Code> ignore;
|
|
||||||
parseArguments ("x", scanner, ignore);
|
|
||||||
|
|
||||||
mNextOperand = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check for custom extensions
|
// check for custom extensions
|
||||||
|
|
|
@ -241,6 +241,12 @@ namespace Compiler
|
||||||
{
|
{
|
||||||
void registerExtensions (Extensions& extensions)
|
void registerExtensions (Extensions& extensions)
|
||||||
{
|
{
|
||||||
|
extensions.registerFunction ("scriptrunning", 'l', "c", opcodeScriptRunning);
|
||||||
|
extensions.registerInstruction ("startscript", "c", opcodeStartScript, opcodeStartScriptExplicit);
|
||||||
|
extensions.registerInstruction ("stopscript", "c", opcodeStopScript);
|
||||||
|
extensions.registerInstruction ("enable", "", opcodeEnable, opcodeEnableExplicit);
|
||||||
|
extensions.registerInstruction ("disable", "", opcodeDisable, opcodeDisableExplicit);
|
||||||
|
extensions.registerFunction ("getdisabled", 'l', "x", opcodeGetDisabled, opcodeGetDisabledExplicit);
|
||||||
extensions.registerFunction ("xbox", 'l', "", opcodeXBox);
|
extensions.registerFunction ("xbox", 'l', "", opcodeXBox);
|
||||||
extensions.registerFunction ("onactivate", 'l', "", opcodeOnActivate, opcodeOnActivateExplicit);
|
extensions.registerFunction ("onactivate", 'l', "", opcodeOnActivate, opcodeOnActivateExplicit);
|
||||||
extensions.registerInstruction ("activate", "x", opcodeActivate, opcodeActivateExplicit);
|
extensions.registerInstruction ("activate", "x", opcodeActivate, opcodeActivateExplicit);
|
||||||
|
@ -533,6 +539,7 @@ namespace Compiler
|
||||||
{
|
{
|
||||||
void registerExtensions (Extensions& extensions)
|
void registerExtensions (Extensions& extensions)
|
||||||
{
|
{
|
||||||
|
extensions.registerFunction("getdistance",'f',"c",opcodeGetDistance,opcodeGetDistanceExplicit);
|
||||||
extensions.registerInstruction("setscale","f",opcodeSetScale,opcodeSetScaleExplicit);
|
extensions.registerInstruction("setscale","f",opcodeSetScale,opcodeSetScaleExplicit);
|
||||||
extensions.registerFunction("getscale",'f',"",opcodeGetScale,opcodeGetScaleExplicit);
|
extensions.registerFunction("getscale",'f',"",opcodeGetScale,opcodeGetScaleExplicit);
|
||||||
extensions.registerInstruction("setangle","cf",opcodeSetAngle,opcodeSetAngleExplicit);
|
extensions.registerInstruction("setangle","cf",opcodeSetAngle,opcodeSetAngleExplicit);
|
||||||
|
|
|
@ -292,65 +292,10 @@ namespace
|
||||||
code.push_back (Compiler::Generator::segment5 (45));
|
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)
|
void opGetSecondsPassed (Compiler::Generator::CodeContainer& code)
|
||||||
{
|
{
|
||||||
code.push_back (Compiler::Generator::segment5 (50));
|
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
|
namespace Compiler
|
||||||
|
@ -812,87 +757,9 @@ namespace Compiler
|
||||||
opRandom (code);
|
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)
|
void getSecondsPassed (CodeContainer& code)
|
||||||
{
|
{
|
||||||
opGetSecondsPassed (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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,21 +109,7 @@ namespace Compiler
|
||||||
|
|
||||||
void random (CodeContainer& code);
|
void random (CodeContainer& code);
|
||||||
|
|
||||||
void scriptRunning (CodeContainer& code);
|
|
||||||
|
|
||||||
void startScript (CodeContainer& code, Literals& literals, const std::string& id);
|
|
||||||
|
|
||||||
void stopScript (CodeContainer& code);
|
|
||||||
|
|
||||||
void getDistance (CodeContainer& code, Literals& literals, const std::string& id);
|
|
||||||
|
|
||||||
void getSecondsPassed (CodeContainer& code);
|
void getSecondsPassed (CodeContainer& code);
|
||||||
|
|
||||||
void getDisabled (CodeContainer& code, Literals& literals, const std::string& id);
|
|
||||||
|
|
||||||
void enable (CodeContainer& code, Literals& literals, const std::string& id);
|
|
||||||
|
|
||||||
void disable (CodeContainer& code, Literals& literals, const std::string& id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -247,35 +247,6 @@ namespace Compiler
|
||||||
|
|
||||||
if (mState==BeginState || mState==ExplicitState)
|
if (mState==BeginState || mState==ExplicitState)
|
||||||
{
|
{
|
||||||
switch (keyword)
|
|
||||||
{
|
|
||||||
case Scanner::K_enable:
|
|
||||||
|
|
||||||
Generator::enable (mCode, mLiterals, mExplicit);
|
|
||||||
mState = PotentialEndState;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case Scanner::K_disable:
|
|
||||||
|
|
||||||
Generator::disable (mCode, mLiterals, mExplicit);
|
|
||||||
mState = PotentialEndState;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case Scanner::K_startscript:
|
|
||||||
|
|
||||||
mExprParser.parseArguments ("c", scanner, mCode);
|
|
||||||
Generator::startScript (mCode, mLiterals, mExplicit);
|
|
||||||
mState = EndState;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case Scanner::K_stopscript:
|
|
||||||
|
|
||||||
mExprParser.parseArguments ("c", scanner, mCode);
|
|
||||||
Generator::stopScript (mCode);
|
|
||||||
mState = EndState;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for custom extensions
|
// check for custom extensions
|
||||||
if (const Extensions *extensions = getContext().getExtensions())
|
if (const Extensions *extensions = getContext().getExtensions())
|
||||||
{
|
{
|
||||||
|
@ -323,21 +294,6 @@ namespace Compiler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyword==Scanner::K_getdisabled || keyword==Scanner::K_getdistance)
|
|
||||||
{
|
|
||||||
if (mAllowExpression)
|
|
||||||
{
|
|
||||||
scanner.putbackKeyword (keyword, loc);
|
|
||||||
parseExpression (scanner, loc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getErrorHandler().warning ("Unexpected naked expression", loc);
|
|
||||||
}
|
|
||||||
mState = EndState;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (const Extensions *extensions = getContext().getExtensions())
|
if (const Extensions *extensions = getContext().getExtensions())
|
||||||
{
|
{
|
||||||
char returnType;
|
char returnType;
|
||||||
|
@ -416,13 +372,6 @@ namespace Compiler
|
||||||
mState = EndState;
|
mState = EndState;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Scanner::K_stopscript:
|
|
||||||
|
|
||||||
mExprParser.parseArguments ("c", scanner, mCode);
|
|
||||||
Generator::stopScript (mCode);
|
|
||||||
mState = EndState;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case Scanner::K_else:
|
case Scanner::K_else:
|
||||||
|
|
||||||
getErrorHandler().warning ("Stray else", loc);
|
getErrorHandler().warning ("Stray else", loc);
|
||||||
|
@ -487,8 +436,7 @@ namespace Compiler
|
||||||
if (mAllowExpression)
|
if (mAllowExpression)
|
||||||
{
|
{
|
||||||
if (keyword==Scanner::K_getsquareroot || keyword==Scanner::K_menumode ||
|
if (keyword==Scanner::K_getsquareroot || keyword==Scanner::K_menumode ||
|
||||||
keyword==Scanner::K_random || keyword==Scanner::K_scriptrunning ||
|
keyword==Scanner::K_random || keyword==Scanner::K_getsecondspassed)
|
||||||
keyword==Scanner::K_getsecondspassed)
|
|
||||||
{
|
{
|
||||||
scanner.putbackKeyword (keyword, loc);
|
scanner.putbackKeyword (keyword, loc);
|
||||||
parseExpression (scanner, loc);
|
parseExpression (scanner, loc);
|
||||||
|
|
|
@ -201,6 +201,16 @@ namespace Compiler
|
||||||
|
|
||||||
namespace Misc
|
namespace Misc
|
||||||
{
|
{
|
||||||
|
const int opcodeScriptRunning = 46;
|
||||||
|
const int opcodeStartScript = 47;
|
||||||
|
const int opcodeStopScript = 48;
|
||||||
|
const int opcodeEnable = 51;
|
||||||
|
const int opcodeDisable = 52;
|
||||||
|
const int opcodeGetDisabled = 53;
|
||||||
|
const int opcodeEnableExplicit = 54;
|
||||||
|
const int opcodeDisableExplicit = 55;
|
||||||
|
const int opcodeGetDisabledExplicit = 56;
|
||||||
|
const int opcodeStartScriptExplicit = 71;
|
||||||
const int opcodeXBox = 0x200000c;
|
const int opcodeXBox = 0x200000c;
|
||||||
const int opcodeOnActivate = 0x200000d;
|
const int opcodeOnActivate = 0x200000d;
|
||||||
const int opcodeOnActivateExplicit = 0x2000306;
|
const int opcodeOnActivateExplicit = 0x2000306;
|
||||||
|
@ -473,6 +483,8 @@ namespace Compiler
|
||||||
|
|
||||||
namespace Transformation
|
namespace Transformation
|
||||||
{
|
{
|
||||||
|
const int opcodeGetDistance = 49;
|
||||||
|
const int opcodeGetDistanceExplicit = 57;
|
||||||
const int opcodeSetScale = 0x2000164;
|
const int opcodeSetScale = 0x2000164;
|
||||||
const int opcodeSetScaleExplicit = 0x2000165;
|
const int opcodeSetScaleExplicit = 0x2000165;
|
||||||
const int opcodeSetAngle = 0x2000166;
|
const int opcodeSetAngle = 0x2000166;
|
||||||
|
|
|
@ -268,10 +268,7 @@ namespace Compiler
|
||||||
"getsquareroot",
|
"getsquareroot",
|
||||||
"menumode",
|
"menumode",
|
||||||
"random",
|
"random",
|
||||||
"startscript", "stopscript", "scriptrunning",
|
|
||||||
"getdistance",
|
|
||||||
"getsecondspassed",
|
"getsecondspassed",
|
||||||
"enable", "disable", "getdisabled",
|
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -211,10 +211,7 @@ namespace Compiler
|
||||||
K_getsquareroot,
|
K_getsquareroot,
|
||||||
K_menumode,
|
K_menumode,
|
||||||
K_random,
|
K_random,
|
||||||
K_startscript, K_stopscript, K_scriptrunning,
|
K_getsecondspassed
|
||||||
K_getdistance,
|
|
||||||
K_getsecondspassed,
|
|
||||||
K_enable, K_disable, K_getdisabled
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum special
|
enum special
|
||||||
|
|
|
@ -63,12 +63,9 @@ namespace Compiler
|
||||||
keyword==Scanner::K_elseif || keyword==Scanner::K_while ||
|
keyword==Scanner::K_elseif || keyword==Scanner::K_while ||
|
||||||
keyword==Scanner::K_endwhile || keyword==Scanner::K_return ||
|
keyword==Scanner::K_endwhile || keyword==Scanner::K_return ||
|
||||||
keyword==Scanner::K_messagebox || keyword==Scanner::K_set ||
|
keyword==Scanner::K_messagebox || keyword==Scanner::K_set ||
|
||||||
keyword==Scanner::K_to || keyword==Scanner::K_startscript ||
|
keyword==Scanner::K_to || keyword==Scanner::K_getsquareroot ||
|
||||||
keyword==Scanner::K_stopscript || keyword==Scanner::K_enable ||
|
keyword==Scanner::K_menumode || keyword==Scanner::K_random ||
|
||||||
keyword==Scanner::K_disable || keyword==Scanner::K_getdisabled ||
|
keyword==Scanner::K_getsecondspassed)
|
||||||
keyword==Scanner::K_getdistance || keyword==Scanner::K_scriptrunning ||
|
|
||||||
keyword==Scanner::K_getsquareroot || keyword==Scanner::K_menumode ||
|
|
||||||
keyword==Scanner::K_random || keyword==Scanner::K_getsecondspassed)
|
|
||||||
{
|
{
|
||||||
return parseName (loc.mLiteral, loc, scanner);
|
return parseName (loc.mLiteral, loc, scanner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,23 +79,8 @@ namespace Interpreter
|
||||||
|
|
||||||
virtual std::string getCurrentCellName() const = 0;
|
virtual std::string getCurrentCellName() const = 0;
|
||||||
|
|
||||||
virtual bool isScriptRunning (const std::string& name) const = 0;
|
|
||||||
|
|
||||||
virtual void startScript (const std::string& name, const std::string& targetId = "") = 0;
|
|
||||||
|
|
||||||
virtual void stopScript (const std::string& name) = 0;
|
|
||||||
|
|
||||||
virtual float getDistance (const std::string& name, const std::string& id = "") const
|
|
||||||
= 0;
|
|
||||||
|
|
||||||
virtual float getSecondsPassed() const = 0;
|
virtual float getSecondsPassed() const = 0;
|
||||||
|
|
||||||
virtual bool isDisabled (const std::string& id = "") const = 0;
|
|
||||||
|
|
||||||
virtual void enable (const std::string& id = "") = 0;
|
|
||||||
|
|
||||||
virtual void disable (const std::string& id = "") = 0;
|
|
||||||
|
|
||||||
virtual int getMemberShort (const std::string& id, const std::string& name, bool global) const = 0;
|
virtual int getMemberShort (const std::string& id, const std::string& name, bool global) const = 0;
|
||||||
|
|
||||||
virtual int getMemberLong (const std::string& id, const std::string& name, bool global) const = 0;
|
virtual int getMemberLong (const std::string& id, const std::string& name, bool global) const = 0;
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
#include "mathopcodes.hpp"
|
#include "mathopcodes.hpp"
|
||||||
#include "controlopcodes.hpp"
|
#include "controlopcodes.hpp"
|
||||||
#include "miscopcodes.hpp"
|
#include "miscopcodes.hpp"
|
||||||
#include "scriptopcodes.hpp"
|
|
||||||
#include "spatialopcodes.hpp"
|
|
||||||
|
|
||||||
namespace Interpreter
|
namespace Interpreter
|
||||||
{
|
{
|
||||||
|
@ -100,22 +98,6 @@ namespace Interpreter
|
||||||
interpreter.installSegment5 (38, new OpMenuMode);
|
interpreter.installSegment5 (38, new OpMenuMode);
|
||||||
interpreter.installSegment5 (45, new OpRandom);
|
interpreter.installSegment5 (45, new OpRandom);
|
||||||
interpreter.installSegment5 (50, new OpGetSecondsPassed);
|
interpreter.installSegment5 (50, new OpGetSecondsPassed);
|
||||||
interpreter.installSegment5 (51, new OpEnable);
|
|
||||||
interpreter.installSegment5 (52, new OpDisable);
|
|
||||||
interpreter.installSegment5 (53, new OpGetDisabled);
|
|
||||||
interpreter.installSegment5 (54, new OpEnableExplicit);
|
|
||||||
interpreter.installSegment5 (55, new OpDisableExplicit);
|
|
||||||
interpreter.installSegment5 (56, new OpGetDisabledExplicit);
|
|
||||||
interpreter.installSegment5 (58, new OpReport);
|
interpreter.installSegment5 (58, new OpReport);
|
||||||
|
|
||||||
// script control
|
|
||||||
interpreter.installSegment5 (46, new OpScriptRunning);
|
|
||||||
interpreter.installSegment5 (47, new OpStartScript);
|
|
||||||
interpreter.installSegment5 (48, new OpStopScript);
|
|
||||||
interpreter.installSegment5 (71, new OpStartScriptExplicit);
|
|
||||||
|
|
||||||
// spacial
|
|
||||||
interpreter.installSegment5 (49, new OpGetDistance);
|
|
||||||
interpreter.installSegment5 (57, new OpGetDistanceExplicit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,78 +206,6 @@ namespace Interpreter
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpEnable : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
runtime.getContext().enable();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpDisable : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
runtime.getContext().disable();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetDisabled : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
runtime.push (runtime.getContext().isDisabled());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpEnableExplicit : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
int index = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
std::string id = runtime.getStringLiteral (index);
|
|
||||||
|
|
||||||
runtime.getContext().enable (id);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpDisableExplicit : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
int index = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
std::string id = runtime.getStringLiteral (index);
|
|
||||||
|
|
||||||
runtime.getContext().disable (id);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetDisabledExplicit : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
int index = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
std::string id = runtime.getStringLiteral (index);
|
|
||||||
|
|
||||||
runtime.push (runtime.getContext().isDisabled (id));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
#ifndef INTERPRETER_SCRIPTOPCODES_H_INCLUDED
|
|
||||||
#define INTERPRETER_SCRIPTOPCODES_H_INCLUDED
|
|
||||||
|
|
||||||
#include "opcodes.hpp"
|
|
||||||
#include "runtime.hpp"
|
|
||||||
#include "context.hpp"
|
|
||||||
|
|
||||||
namespace Interpreter
|
|
||||||
{
|
|
||||||
class OpScriptRunning : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime[0].mInteger = runtime.getContext().isScriptRunning (name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpStartScript : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
runtime.getContext().startScript (name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpStartScriptExplicit : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
std::string targetId = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
runtime.getContext().startScript (name, targetId);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpStopScript : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
runtime.getContext().stopScript (name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
#ifndef INTERPRETER_SPATIALOPCODES_H_INCLUDED
|
|
||||||
#define INTERPRETER_SPATIALOPCODES_H_INCLUDED
|
|
||||||
|
|
||||||
#include "opcodes.hpp"
|
|
||||||
#include "runtime.hpp"
|
|
||||||
|
|
||||||
namespace Interpreter
|
|
||||||
{
|
|
||||||
class OpGetDistance : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
|
|
||||||
Type_Float distance = runtime.getContext().getDistance (name);
|
|
||||||
|
|
||||||
runtime[0].mFloat = distance;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetDistanceExplicit : public Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
|
||||||
{
|
|
||||||
int index = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
std::string id = runtime.getStringLiteral (index);
|
|
||||||
|
|
||||||
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
|
|
||||||
Type_Float distance = runtime.getContext().getDistance (name, id);
|
|
||||||
|
|
||||||
runtime[0].mFloat = distance;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in a new issue