fix custom dialog boxes not being properly reset

This commit is contained in:
Isaac0-dev 2025-06-04 09:41:36 +10:00
parent 5a9f4b10bd
commit b8fe342c17
2 changed files with 14 additions and 5 deletions

View file

@ -131,9 +131,10 @@ void smlua_text_utils_reset_all(void) {
for (s32 i = 0; i < DIALOG_COUNT; i++) {
if (!sReplacedDialog[i]) { continue; }
const struct DialogEntry *dialogOrig = segmented_to_virtual(dialogTableOrg[i]);
struct DialogEntry *dialog = segmented_to_virtual(dialogTable[i]);
free((u8*)dialog->str);
dialog->str = dialogTableOrg[i];
memcpy(dialog, dialogOrig, sizeof(struct DialogEntry));
sReplacedDialog[i] = false;
}

View file

@ -7,12 +7,12 @@
#include "dialogs.h"
#undef DEFINE_DIALOG
#define DEFINE_DIALOG(id, _1, _2, _3, _4, _5) dialog_text_ ## id,
#define DEFINE_DIALOG(id, unused, linesPerBox, leftOffset, width, _) \
static const struct DialogEntry dialog_entry_orig_ ## id = { \
unused, linesPerBox, leftOffset, width, dialog_text_ ## id \
};
const u8* seg2_dialog_original[] = {
#include "dialogs.h"
NULL
};
#undef DEFINE_DIALOG
#define DEFINE_DIALOG(id, unused, linesPerBox, leftOffset, width, _) \
@ -22,6 +22,14 @@ const u8* seg2_dialog_original[] = {
#include "dialogs.h"
#undef DEFINE_DIALOG
#define DEFINE_DIALOG(id, _1, _2, _3, _4, _5) &dialog_entry_orig_ ## id,
const struct DialogEntry *const seg2_dialog_original[] = {
#include "dialogs.h"
NULL
};
#undef DEFINE_DIALOG
#define DEFINE_DIALOG(id, _1, _2, _3, _4, _5) &dialog_entry_ ## id,