From bbf0cf0103de221fd54b9348f1ee0b1e5510c2ce Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 4 Feb 2023 00:00:38 -0500 Subject: [PATCH] Stop hard-coding number of preset names --- src/main_menu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main_menu.c b/src/main_menu.c index 8459396746..6808a8f11a 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -503,7 +503,9 @@ static const u8 *const sFemalePresetNames[] = { gText_DefaultNameHalie }; -// .text +// The number of male vs. female names is assumed to be the same. +// If they aren't, the smaller of the two sizes will be used and any extra names will be ignored. +#define NUM_PRESET_NAMES min(ARRAY_COUNT(sMalePresetNames), ARRAY_COUNT(sFemalePresetNames)) enum { @@ -1597,7 +1599,7 @@ static void Task_NewGameBirchSpeech_StartNamingScreen(u8 taskId) { FreeAllWindowBuffers(); FreeAndDestroyMonPicSprite(gTasks[taskId].tLotadSpriteId); - NewGameBirchSpeech_SetDefaultPlayerName(Random() % 20); + NewGameBirchSpeech_SetDefaultPlayerName(Random() % NUM_PRESET_NAMES); DestroyTask(taskId); DoNamingScreen(NAMING_SCREEN_PLAYER, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_NewGameBirchSpeech_ReturnFromNamingScreen); }