Skip to content

Commit

Permalink
Simplifies the function signature of CustomMessage_RetrieveIfExists.
Browse files Browse the repository at this point in the history
  • Loading branch information
leggettc18 committed Jul 17, 2022
1 parent 69d2b5b commit 98c771c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/OTRGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion soh/src/code/z_message_PAL.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 98c771c

Please sign in to comment.