diff --git a/rwengine/include/engine/GameWorld.hpp b/rwengine/include/engine/GameWorld.hpp index 0b0c3714..ee72b334 100644 --- a/rwengine/include/engine/GameWorld.hpp +++ b/rwengine/include/engine/GameWorld.hpp @@ -23,8 +23,6 @@ class VehicleObject; struct WeaponScan; -class ScriptMachine; - #include #include @@ -70,8 +68,6 @@ public: */ bool defineItems(const std::string& name); - void runScript(const std::string& name); - /** * Loads an IPL into the game. * @param name The name of the IPL as it appears in the games' gta.dat @@ -241,8 +237,6 @@ public: */ WorkContext* _work; - ScriptMachine* script; - /** * @brief Loads and starts the named cutscene. * @param name diff --git a/rwengine/include/script/ScriptMachine.hpp b/rwengine/include/script/ScriptMachine.hpp index f9da947b..63aa945b 100644 --- a/rwengine/include/script/ScriptMachine.hpp +++ b/rwengine/include/script/ScriptMachine.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #define SCM_NEGATE_CONDITIONAL_MASK 0x8000 #define SCM_CONDITIONAL_MASK_PASSED 0xFF @@ -130,18 +131,20 @@ struct SCMThread std::stack calls; }; +/** + * Breakpoint callback information + */ +struct SCMBreakpoint +{ + SCMThread::pc_t pc; + SCMThread* thread; + ScriptMachine* vm; + ScriptFunctionMeta* function; + ScriptArguments* args; +}; + class ScriptMachine { - SCMFile* _file; - SCMOpcodes* _ops; - GameWorld* _world; - - std::vector _activeThreads; - - void executeThread(SCMThread& t, int msPassed); - - SCMByte* _globals; - public: ScriptMachine(GameWorld* world, SCMFile* file, SCMOpcodes* ops); ~ScriptMachine(); @@ -153,11 +156,32 @@ public: SCMByte* getGlobals(); GameWorld* getWorld() const { return _world; } + + typedef std::function BreakpointHandler; + + void setBreakpointHandler(const BreakpointHandler& handler); + + void addBreakpoint(SCMThread::pc_t pc); + void removeBreakpoint(SCMThread::pc_t pc); /** * @brief executes threads until they are all in waiting state. */ void execute(float dt); + +private: + SCMFile* _file; + SCMOpcodes* _ops; + GameWorld* _world; + + std::vector _activeThreads; + + void executeThread(SCMThread& t, int msPassed); + + SCMByte* _globals; + + BreakpointHandler bpHandler; + std::set breakpoints; }; #endif diff --git a/rwengine/src/engine/GameWorld.cpp b/rwengine/src/engine/GameWorld.cpp index 7dfb6d46..da077efc 100644 --- a/rwengine/src/engine/GameWorld.cpp +++ b/rwengine/src/engine/GameWorld.cpp @@ -11,11 +11,6 @@ #include #include -#include