From 175a31f575f253f06c1a25a0ebaa32189ceb08cd Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 21 Jun 2024 15:42:58 -0700 Subject: [PATCH] make zapd addresses globals int64_t so they can store uint32_t addresses and -1 --- ZAPD/Globals.h | 6 +++--- ZAPD/Main.cpp | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ZAPD/Globals.h b/ZAPD/Globals.h index 21d58c09..2cc9c2d4 100644 --- a/ZAPD/Globals.h +++ b/ZAPD/Globals.h @@ -41,9 +41,9 @@ class Globals fs::path baseRomPath, inputPath, outputPath, sourceOutputPath, cfgPath; TextureType texType; CsFloatType floatType = CsFloatType::FloatOnly; - int baseAddress = -1; - int startOffset = -1; - int endOffset = -1; + int64_t baseAddress = -1; + int64_t startOffset = -1; + int64_t endOffset = -1; ZGame game; GameConfig cfg; bool verboseUnaccounted = false; diff --git a/ZAPD/Main.cpp b/ZAPD/Main.cpp index 271ebbc0..3d91f2e0 100644 --- a/ZAPD/Main.cpp +++ b/ZAPD/Main.cpp @@ -435,19 +435,25 @@ void Arg_CsFloatMode([[maybe_unused]] int& i, [[maybe_unused]] char* argv[]) } } +uint32_t parse_u32_hex(char* str) +{ + static_assert(sizeof(uint32_t) <= sizeof(unsigned long)); + return (uint32_t)std::stoul(str, nullptr, 16); +} + void Arg_BaseAddress(int& i, char* argv[]) { - Globals::Instance->baseAddress = std::stoul(argv[++i], nullptr, 16); + Globals::Instance->baseAddress = parse_u32_hex(argv[++i]); } void Arg_StartOffset(int& i, char* argv[]) { - Globals::Instance->startOffset = std::stoul(argv[++i], nullptr, 16); + Globals::Instance->startOffset = parse_u32_hex(argv[++i]); } void Arg_EndOffset(int& i, char* argv[]) { - Globals::Instance->endOffset = std::stoul(argv[++i], nullptr, 16); + Globals::Instance->endOffset = parse_u32_hex(argv[++i]); } int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet)