From c677c7091e5eaa52048078412ccfcbf1b750087b Mon Sep 17 00:00:00 2001 From: drxgb Date: Mon, 11 Nov 2024 08:39:41 -0300 Subject: [PATCH] Destiny: Issues corrected based on the new EasyRpg changes. --- src/game_config_game.cpp | 1 + src/game_destiny.cpp | 18 +++++------------- src/game_destiny.h | 9 +++++++-- src/player.cpp | 2 -- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/game_config_game.cpp b/src/game_config_game.cpp index 9cb133e4af..4a719b5556 100644 --- a/src/game_config_game.cpp +++ b/src/game_config_game.cpp @@ -241,6 +241,7 @@ void Game_ConfigGame::PrintActivePatches() { }; add_bool(patch_easyrpg); + add_bool(patch_destiny); add_bool(patch_dynrpg); add_bool(patch_common_this_event); add_bool(patch_unlock_pics); diff --git a/src/game_destiny.cpp b/src/game_destiny.cpp index de4fb24b18..8a79019d66 100644 --- a/src/game_destiny.cpp +++ b/src/game_destiny.cpp @@ -17,7 +17,6 @@ // Headers #include "game_destiny.h" -#include #ifndef EMSCRIPTEN #include "exe_reader.h" @@ -210,15 +209,12 @@ void Game_Destiny::CheckVersionInfo() Interpreter::Interpreter() { CleanUpData(); - _destinyScript = nullptr; _scriptPtr = nullptr; } const char* Interpreter::MakeString(SaveEventExecFrame& frame) { std::string code; - size_t length; - char* destinyScript; int32_t& current = frame.current_command; const std::vector& cmdList = frame.commands; @@ -233,18 +229,14 @@ const char* Interpreter::MakeString(SaveEventExecFrame& frame) ++current; } - length = code.length() + 1; - destinyScript = new char[length]; - strcpy_s(destinyScript, length, code.c_str()); - - return _destinyScript = _scriptPtr = destinyScript; + _destinyScript = code; + return _scriptPtr = _destinyScript.data(); } void Interpreter::FreeString() { - delete[] _destinyScript; - _destinyScript = nullptr; - _scriptPtr = nullptr; + _destinyScript = ""; + _scriptPtr = _destinyScript.data(); } void Interpreter::SkipWhiteSpace() @@ -270,7 +262,7 @@ const size_t Interpreter::GetWordLen() const InterpretFlag Interpreter::Interpret() { char* code; - uint8_t flags[4]; + //uint8_t flags[4]; InterpretFlag returnType; size_t wordLen; diff --git a/src/game_destiny.h b/src/game_destiny.h index 2692d65f3f..341494bd86 100644 --- a/src/game_destiny.h +++ b/src/game_destiny.h @@ -304,7 +304,7 @@ namespace Destiny private: // Member data - char* _destinyScript; + std::string _destinyScript; char* _scriptPtr; uint32_t _breaks; uint32_t _continues; @@ -335,7 +335,7 @@ namespace Destiny const bool BlockComment(); /** - * Check whether character is a whitespace.. + * Check whether character is a whitespace. * * @return Flag of whitespace character. */ @@ -348,6 +348,11 @@ namespace Destiny ch == 0x0B; // Vertical Tabulator (VT) } + /** + * Check whether character is a part of a word. + * + * @return Flag of word character. + */ inline const bool IsWordChar(const char ch) const { return ch == '_' || diff --git a/src/player.cpp b/src/player.cpp index 60d8e6ee86..494f09a052 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -833,8 +833,6 @@ void Player::CreateGameObjects() { } } - Output::Debug("Patch configuration: dynrpg={} maniac={} key-patch={} common-this={} pic-unlock={} 2k3-commands={} destiny={}", - Player::IsPatchDynRpg(), Player::IsPatchManiac(), Player::IsPatchKeyPatch(), game_config.patch_common_this_event.Get(), game_config.patch_unlock_pics.Get(), game_config.patch_rpg2k3_commands.Get(), Player::IsPatchDestiny()); game_config.PrintActivePatches(); ResetGameObjects();