From 98c771cf2c35af469d84e018ac1987e56e524659 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 17 Jul 2022 15:11:16 -0400 Subject: [PATCH] Simplifies the function signature of `CustomMessage_RetrieveIfExists`. --- soh/soh/OTRGlobals.cpp | 6 ++++-- soh/soh/OTRGlobals.h | 2 +- soh/src/code/z_message_PAL.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 549b69ed1..36101e05e 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1513,13 +1513,15 @@ extern "C" int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, return CopyStringToCharBuffer(getItemText, buffer, maxBufferSize); } -extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx, char* buffer, const int maxBufferSize) { +extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; Font* font = &msgCtx->font; + char* buffer = font->msgBuf; + const int maxBufferSize = sizeof(font->msgBuf); if (gSaveContext.n64ddFlag) { if (msgCtx->textId == 0xF8) { if (msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage( - (GetItemID)GET_PLAYER(globalCtx)->getItemId, font->msgBuf, sizeof(font->msgBuf))) { + (GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize)) { font->charTexBuf[0] = 0x23; return true; } else { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 0110d7ad1..8f46d13fc 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -97,7 +97,7 @@ s32 GetItemIDFromGetItemID(s32 getItemId); s32 GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); s32 GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize); -int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx, char* buffer, const int maxBufferSize); +int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx); #endif #endif diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 432c05cfd..f0ce90fbd 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1662,7 +1662,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { gSaveContext.eventInf[0] = gSaveContext.eventInf[1] = gSaveContext.eventInf[2] = gSaveContext.eventInf[3] = 0; } - if (CustomMessage_RetrieveIfExists(globalCtx, font->msgBuf, sizeof(font->msgBuf))) { + if (CustomMessage_RetrieveIfExists(globalCtx)) { osSyncPrintf("Found custom message"); } else if (sTextIsCredits) { Message_FindCreditsMessage(globalCtx, textId);