Fix first_time text entries in payload (untested)

first_time entries would be longer, therefore the reference pointers inside the payload would shift.

To avoid that, we now reserve space for the longest entry, knowing that the texts will get stripped after
the payloads have been generated.

Doing so ensures that the text offsets remain constant, no matter if we're dealing with the first_time or othertimes payload.

This also means we need to take that reservation into account on the PTGB rom side of things of course.
To do so, I created a pair array indicating the first time entries and there non-first_time counterparts.

We'll determine which entry is the longest and ensure we use that length for the offset of the next entry.
This commit is contained in:
Philippe Symons
2026-09-22 17:10:20 +02:00
parent 12183e51d7
commit 11a581061f
6 changed files with 142 additions and 59 deletions

View File

@@ -487,6 +487,22 @@ const script_obj_params event_script_params[SCRIPT_SIZE] = {
{}, // COND_CHECK_MISSINGNO
};
static bool isFirstTime()
{
bool firstTime = true;
// This determines if the event has been done before
for (unsigned i = 1; i <= 251; i++)
{
if (is_caught(i))
{
firstTime = false;
break;
}
}
return firstTime;
}
static void __attribute__((noinline)) convertPokeBox()
{
PokemonTables tables;
@@ -694,9 +710,14 @@ bool run_conditional(int index)
return true;
case CMD_IMPORT_POKEMON:
{
// we need to determine firstTime BEFORE calling convertPokeBox()
// because convertPokeBox will call set_caught()
const bool firstTime = isFirstTime();
convertPokeBox();
inject_mystery(&box);
inject_mystery(&box, firstTime);
return true;
}
case CMD_BACK_TO_MENU:
set_text_exit();
REG_BG1HOFS = 0;