mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
added GetSecondsPassed
This commit is contained in:
parent
f5a70abd4b
commit
9d73718ec1
16 changed files with 62 additions and 7 deletions
|
@ -115,6 +115,11 @@ namespace SAInterpreter
|
|||
return 0;
|
||||
}
|
||||
|
||||
float Context::getSecondsPassed() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Context::report()
|
||||
{
|
||||
std::size_t i = 0;
|
||||
|
|
|
@ -60,6 +60,8 @@ namespace SAInterpreter
|
|||
|
||||
virtual float getDistance (const std::string& name);
|
||||
|
||||
virtual float getSecondsPassed() const;
|
||||
|
||||
void report();
|
||||
///< Write state to std::cout
|
||||
};
|
||||
|
|
|
@ -35,6 +35,8 @@ void OMW::Engine::executeLocalScripts()
|
|||
|
||||
bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||
{
|
||||
mEnvironment.mFrameDuration = evt.timeSinceLastFrame;
|
||||
|
||||
// console
|
||||
processCommands();
|
||||
|
||||
|
|
|
@ -159,6 +159,11 @@ namespace MWScript
|
|||
return false;
|
||||
}
|
||||
|
||||
float InterpreterContext::getSecondsPassed() const
|
||||
{
|
||||
return mEnvironment.mFrameDuration;
|
||||
}
|
||||
|
||||
MWWorld::World& InterpreterContext::getWorld()
|
||||
{
|
||||
return *mEnvironment.mWorld;
|
||||
|
|
|
@ -70,6 +70,8 @@ namespace MWScript
|
|||
virtual float getDistance (const std::string& name);
|
||||
|
||||
virtual bool hasBeenActivated() const;
|
||||
|
||||
virtual float getSecondsPassed() const;
|
||||
|
||||
MWWorld::World& getWorld();
|
||||
|
||||
|
|
|
@ -18,11 +18,12 @@ namespace MWWorld
|
|||
///< Collection of script-accessable sub-systems
|
||||
struct Environment
|
||||
{
|
||||
Environment() : mWorld (0), mSoundManager (0), mGlobalScripts (0) {}
|
||||
Environment() : mWorld (0), mSoundManager (0), mGlobalScripts (0), mFrameDuration (0) {}
|
||||
|
||||
World *mWorld;
|
||||
MWSound::SoundManager *mSoundManager;
|
||||
MWScript::GlobalScripts *mGlobalScripts;
|
||||
float mFrameDuration;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Compiler
|
|||
}
|
||||
|
||||
virtual char getGlobalType (const std::string& name) const = 0;
|
||||
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
|
||||
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -337,8 +337,16 @@ namespace Compiler
|
|||
mNextOperand = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
else if (keyword==Scanner::K_getsecondspassed)
|
||||
{
|
||||
mTokenLoc = loc;
|
||||
|
||||
Generator::getSecondsPassed (mCode);
|
||||
mOperands.push_back ('f');
|
||||
|
||||
mNextOperand = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// check for custom extensions
|
||||
|
|
|
@ -279,6 +279,11 @@ namespace
|
|||
{
|
||||
code.push_back (Compiler::Generator::segment5 (49));
|
||||
}
|
||||
|
||||
void opGetSecondsPassed (Compiler::Generator::CodeContainer& code)
|
||||
{
|
||||
code.push_back (Compiler::Generator::segment5 (50));
|
||||
}
|
||||
}
|
||||
|
||||
namespace Compiler
|
||||
|
@ -675,6 +680,11 @@ namespace Compiler
|
|||
{
|
||||
opGetDistance (code);
|
||||
}
|
||||
|
||||
void getSecondsPassed (CodeContainer& code)
|
||||
{
|
||||
opGetSecondsPassed (code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ namespace Compiler
|
|||
void stopScript (CodeContainer& code);
|
||||
|
||||
void getDistance (CodeContainer& code);
|
||||
|
||||
void getSecondsPassed (CodeContainer& code);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -246,6 +246,7 @@ namespace Compiler
|
|||
"random",
|
||||
"startscript", "stopscript", "scriptrunning",
|
||||
"getdistance",
|
||||
"getsecondspassed",
|
||||
0
|
||||
};
|
||||
|
||||
|
|
|
@ -52,7 +52,8 @@ namespace Compiler
|
|||
K_menumode,
|
||||
K_random,
|
||||
K_startscript, K_stopscript, K_scriptrunning,
|
||||
K_getdistance
|
||||
K_getdistance,
|
||||
K_getsecondspassed
|
||||
};
|
||||
|
||||
enum special
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace Interpreter
|
|||
virtual void stopScript (const std::string& name) = 0;
|
||||
|
||||
virtual float getDistance (const std::string& name) = 0;
|
||||
|
||||
virtual float getSecondsPassed() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ op 46: replace stack[0] with 1, if global script stack[0] is running, 0 else
|
|||
op 47: start script stack[0] and pop
|
||||
op 48: stop script stack[0] and pop
|
||||
op 49: replace stack[0] with distance between implicit reference and a reference of ID stack[0]
|
||||
opcodes 50-33554431 unused
|
||||
op 50: push frame duration (float)
|
||||
opcodes 51-33554431 unused
|
||||
opcodes 33554432-67108863 reserved for extensions
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ namespace Interpreter
|
|||
interpreter.installSegment3 (0, new OpMessageBox);
|
||||
interpreter.installSegment5 (38, new OpMenuMode);
|
||||
interpreter.installSegment5 (45, new OpRandom);
|
||||
interpreter.installSegment5 (50, new OpGetSecondsPassed);
|
||||
|
||||
// script control
|
||||
interpreter.installSegment5 (46, new OpScriptRunning);
|
||||
|
|
|
@ -116,8 +116,20 @@ namespace Interpreter
|
|||
Type_Integer value = static_cast<Type_Integer> (r*limit); // [o, limit)
|
||||
|
||||
runtime[0] = *reinterpret_cast<Type_Data *> (&value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetSecondsPassed : public Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Runtime& runtime)
|
||||
{
|
||||
float duration = runtime.getContext().getSecondsPassed();
|
||||
|
||||
runtime.push (*reinterpret_cast<Type_Data *> (&duration));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue