diff --git a/src/client/component/gsc/script_loading.cpp b/src/client/component/gsc/script_loading.cpp index ba8d24c..1b958f1 100644 --- a/src/client/component/gsc/script_loading.cpp +++ b/src/client/component/gsc/script_loading.cpp @@ -121,7 +121,7 @@ namespace gsc return nullptr; } - const auto script_file_ptr = static_cast(game::PMem_AllocFromSource_NoDebug(sizeof(game::ScriptFile), 4, 1, 5)); + const auto script_file_ptr = static_cast(game::Hunk_AllocateTempMemoryHighInternal(sizeof(game::ScriptFile))); script_file_ptr->name = file_name; const auto stack = assembler->output_stack(); @@ -130,16 +130,15 @@ namespace gsc const auto script = assembler->output_script(); script_file_ptr->bytecodeLen = static_cast(script.size()); - const auto script_size = script.size(); - // Use PMem for both stack and byte code - const auto buffer_size = script_size + stack.size() + 2; + const auto stack_size = static_cast(stack.size() + 1); + const auto byte_code_size = static_cast(script.size() + 1); - const auto buffer = static_cast(game::PMem_AllocFromSource_NoDebug(static_cast(buffer_size), 4, 1, 5)); - std::memcpy(buffer, script.data(), script_size); - std::memcpy(&buffer[script_size], stack.data(), stack.size()); + script_file_ptr->buffer = static_cast(game::Hunk_AllocateTempMemoryHighInternal(stack_size)); + std::memcpy(const_cast(script_file_ptr->buffer), stack.data(), stack.size()); + + script_file_ptr->bytecode = static_cast(game::PMem_AllocFromSource_NoDebug(byte_code_size, 4, 1, 5)); + std::memcpy(script_file_ptr->bytecode, script.data(), script.size()); - script_file_ptr->bytecode = &buffer[0]; - script_file_ptr->buffer = reinterpret_cast(&buffer[script.size()]); script_file_ptr->compressedLen = 0; loaded_scripts[real_name] = script_file_ptr; diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 4488a48..7e1daa3 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -217,8 +217,8 @@ namespace game WEAK symbol SEH_GetCurrentLanguageName{0x140339300, 0x1404745C0}; - WEAK symbol PMem_AllocFromSource_NoDebug{0x0, 0x1404C7BA0}; - WEAK symbol Hunk_AllocateTempMemoryHighInternal{0x0, 0x1404B68B0}; + WEAK symbol PMem_AllocFromSource_NoDebug{0x1403775F0, 0x1404C7BA0}; + WEAK symbol Hunk_AllocateTempMemoryHighInternal{0x140369D60, 0x1404B68B0}; WEAK symbol longjmp{0x14059C5C0, 0x1406FD930}; WEAK symbol _setjmp{0x14059CD00, 0x1406FE070};