From 9443b33310699c4a5282d7a12a34f0b918f4a8fb Mon Sep 17 00:00:00 2001 From: florianessl Date: Thu, 30 May 2024 13:13:30 +0200 Subject: [PATCH] game_interpreter_shared: Moved explicit instantiations to .cpp & moved definition of "Game_BaseInterpreterContext" to the bottom of header file --- src/game_interpreter_shared.cpp | 16 ++++++++ src/game_interpreter_shared.h | 67 +++++++++++++-------------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/src/game_interpreter_shared.cpp b/src/game_interpreter_shared.cpp index 8e5b5ef873..3e7cbf7433 100644 --- a/src/game_interpreter_shared.cpp +++ b/src/game_interpreter_shared.cpp @@ -237,3 +237,19 @@ lcf::rpg::MoveCommand Game_Interpreter_Shared::DecodeMove(lcf::DBArray: return cmd; } + +//explicit declarations for target evaluation logic shared between ControlSwitches/ControlVariables/ControlStrings +template bool Game_BaseInterpreterContext::DecodeTargetEvaluationMode(lcf::rpg::EventCommand const&, int&, int&) const; +template bool Game_BaseInterpreterContext::DecodeTargetEvaluationMode(lcf::rpg::EventCommand const&, int&, int&) const; +template bool Game_BaseInterpreterContext::DecodeTargetEvaluationMode(lcf::rpg::EventCommand const&, int&, int&) const; + +//common variant for suggested "Ex" commands +template bool Game_BaseInterpreterContext::DecodeTargetEvaluationMode(lcf::rpg::EventCommand const&, int&, int&) const; + +//explicit declarations for default value evaluation logic +template int Game_Interpreter_Shared::ValueOrVariable(int, int, const Game_BaseInterpreterContext&); +template int Game_Interpreter_Shared::ValueOrVariableBitfield(int, int, int, const Game_BaseInterpreterContext&); +template int Game_Interpreter_Shared::ValueOrVariableBitfield(lcf::rpg::EventCommand const&, int, int, int, const Game_BaseInterpreterContext&); + +//variant for "Ex" commands +template int Game_Interpreter_Shared::ValueOrVariableBitfield(int, int, int, const Game_BaseInterpreterContext&); diff --git a/src/game_interpreter_shared.h b/src/game_interpreter_shared.h index 4d8742e46a..cbb11cb17f 100644 --- a/src/game_interpreter_shared.h +++ b/src/game_interpreter_shared.h @@ -25,35 +25,7 @@ #include class Game_Character; - -class Game_BaseInterpreterContext { -public: - virtual ~Game_BaseInterpreterContext() {} - - virtual int GetThisEventId() const = 0; - virtual Game_Character* GetCharacter(int event_id) const = 0; - virtual const lcf::rpg::SaveEventExecFrame& GetFrame() const = 0; - -protected: - template - inline bool DecodeTargetEvaluationMode(lcf::rpg::EventCommand const& com, int& id_0, int& id_1) const { - return Game_Interpreter_Shared::DecodeTargetEvaluationMode(com, id_0, id_1, *this); - } - - template - inline int ValueOrVariable(int mode, int val) const { - return Game_Interpreter_Shared::ValueOrVariable(mode, val, *this); - } - template - inline int ValueOrVariableBitfield(int mode, int shift, int val) const { - return Game_Interpreter_Shared::ValueOrVariableBitfield(mode, shift, val, *this); - } - - template - inline int ValueOrVariableBitfield(lcf::rpg::EventCommand const& com, int mode_idx, int shift, int val_idx) const { - return Game_Interpreter_Shared::ValueOrVariableBitfield(com, mode_idx, shift, val_idx, *this); - } -}; +class Game_BaseInterpreterContext; namespace Game_Interpreter_Shared { @@ -168,20 +140,33 @@ inline bool Game_Interpreter_Shared::ManiacCheckContinueLoop(int val, int val2, } } -//explicit declarations for target evaluation logic shared between ControlSwitches/ControlVariables/ControlStrings -template bool Game_BaseInterpreterContext::DecodeTargetEvaluationMode(lcf::rpg::EventCommand const&, int&, int&) const; -template bool Game_BaseInterpreterContext::DecodeTargetEvaluationMode(lcf::rpg::EventCommand const&, int&, int&) const; -template bool Game_BaseInterpreterContext::DecodeTargetEvaluationMode(lcf::rpg::EventCommand const&, int&, int&) const; +class Game_BaseInterpreterContext { +public: + virtual ~Game_BaseInterpreterContext() {} -//common variant for suggested "Ex" commands -template bool Game_BaseInterpreterContext::DecodeTargetEvaluationMode(lcf::rpg::EventCommand const&, int&, int&) const; + virtual int GetThisEventId() const = 0; + virtual Game_Character* GetCharacter(int event_id) const = 0; + virtual const lcf::rpg::SaveEventExecFrame& GetFrame() const = 0; -//explicit declarations for default value evaluation logic -template int Game_Interpreter_Shared::ValueOrVariable(int, int, const Game_BaseInterpreterContext&); -template int Game_Interpreter_Shared::ValueOrVariableBitfield(int, int, int, const Game_BaseInterpreterContext&); -template int Game_Interpreter_Shared::ValueOrVariableBitfield(lcf::rpg::EventCommand const&, int, int, int, const Game_BaseInterpreterContext&); +protected: + template + inline bool DecodeTargetEvaluationMode(lcf::rpg::EventCommand const& com, int& id_0, int& id_1) const { + return Game_Interpreter_Shared::DecodeTargetEvaluationMode(com, id_0, id_1, *this); + } -//variant for "Ex" commands -template int Game_Interpreter_Shared::ValueOrVariableBitfield(int, int, int, const Game_BaseInterpreterContext&); + template + inline int ValueOrVariable(int mode, int val) const { + return Game_Interpreter_Shared::ValueOrVariable(mode, val, *this); + } + template + inline int ValueOrVariableBitfield(int mode, int shift, int val) const { + return Game_Interpreter_Shared::ValueOrVariableBitfield(mode, shift, val, *this); + } + + template + inline int ValueOrVariableBitfield(lcf::rpg::EventCommand const& com, int mode_idx, int shift, int val_idx) const { + return Game_Interpreter_Shared::ValueOrVariableBitfield(com, mode_idx, shift, val_idx, *this); + } +}; #endif