diff --git a/include/constants/global.h b/include/constants/global.h index 5118beb189..80378f893a 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -105,6 +105,7 @@ #define ITEM_NAME_LENGTH ((I_EXPANDED_ITEM_NAMES == TRUE) ? 20 : 14) #define ITEM_NAME_PLURAL_LENGTH ITEM_NAME_LENGTH + 2 // 2 is used for the instance where a word's suffix becomes y->ies #define POKEMON_NAME_LENGTH 10 +#define VANILLA_POKEMON_NAME_LENGTH 10 #define POKEMON_NAME_BUFFER_SIZE max(20, POKEMON_NAME_LENGTH + 1) // Frequently used buffer size. Larger than necessary #define PLAYER_NAME_LENGTH 7 #define MAIL_WORDS_COUNT 9 diff --git a/include/daycare.h b/include/daycare.h index daea812bed..2747a66850 100644 --- a/include/daycare.h +++ b/include/daycare.h @@ -10,7 +10,7 @@ struct RecordMixingDaycareMail bool16 cantHoldItem[DAYCARE_MON_COUNT]; }; -u8 *GetMonNickname2(struct Pokemon *mon, u8 *dest); +u8 *GetMonNicknameVanilla(struct Pokemon *mon, u8 *dest); u8 *GetBoxMonNickname(struct BoxPokemon *mon, u8 *dest); u8 CountPokemonInDaycare(struct DayCare *daycare); void InitDaycareMailRecordMixing(struct DayCare *daycare, struct RecordMixingDaycareMail *mixMail); diff --git a/include/global.h b/include/global.h index 83bff49c0c..cbafe29596 100644 --- a/include/global.h +++ b/include/global.h @@ -285,7 +285,7 @@ struct BattleTowerPokemon u32 gap:1; u32 abilityNum:1; u32 personality; - u8 nickname[POKEMON_NAME_LENGTH + 1]; + u8 nickname[VANILLA_POKEMON_NAME_LENGTH + 1]; u8 friendship; }; @@ -310,7 +310,7 @@ struct BattleTowerInterview u16 playerSpecies; u16 opponentSpecies; u8 opponentName[PLAYER_NAME_LENGTH + 1]; - u8 opponentMonNickname[POKEMON_NAME_LENGTH + 1]; + u8 opponentMonNickname[VANILLA_POKEMON_NAME_LENGTH + 1]; u8 opponentLanguage; }; @@ -744,7 +744,7 @@ struct ContestWinner u32 trainerId; u16 species; u8 contestCategory; - u8 monName[POKEMON_NAME_LENGTH + 1]; + u8 monName[VANILLA_POKEMON_NAME_LENGTH + 1]; u8 trainerName[PLAYER_NAME_LENGTH + 1]; u8 contestRank:7; bool8 isShiny:1; @@ -764,7 +764,7 @@ struct DaycareMail { struct Mail message; u8 otName[PLAYER_NAME_LENGTH + 1]; - u8 monName[POKEMON_NAME_LENGTH + 1]; + u8 monName[VANILLA_POKEMON_NAME_LENGTH + 1]; u8 gameLanguage:4; u8 monLanguage:4; }; diff --git a/include/global.tv.h b/include/global.tv.h index 9c3902e7cc..6bc6d08f86 100644 --- a/include/global.tv.h +++ b/include/global.tv.h @@ -82,7 +82,7 @@ typedef union // size = 0x24 /*0x00*/ u8 kind; /*0x01*/ bool8 active; /*0x02*/ u16 species; - /*0x04*/ u8 pokemonName[POKEMON_NAME_LENGTH + 1]; + /*0x04*/ u8 pokemonName[VANILLA_POKEMON_NAME_LENGTH + 1]; /*0x0F*/ u8 trainerName[PLAYER_NAME_LENGTH + 1]; /*0x17*/ u8 unused[3]; /*0x1A*/ u8 random; @@ -98,7 +98,7 @@ typedef union // size = 0x24 /*0x01*/ bool8 active; /*0x02*/ u16 species; /*0x04*/ u16 words[2]; - /*0x08*/ u8 pokemonNickname[POKEMON_NAME_LENGTH + 1]; + /*0x08*/ u8 pokemonNickname[VANILLA_POKEMON_NAME_LENGTH + 1]; /*0x13*/ u8 contestCategory:3; u8 contestRank:2; u8 contestResult:2; @@ -196,7 +196,7 @@ typedef union // size = 0x24 /*0x01*/ bool8 active; /*0x02*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x0A*/ u8 contestCategory; - /*0x0B*/ u8 nickname[POKEMON_NAME_LENGTH + 1]; + /*0x0B*/ u8 nickname[VANILLA_POKEMON_NAME_LENGTH + 1]; /*0x16*/ u8 pokeblockState; /*0x17*/ u8 language; /*0x18*/ u8 pokemonNameLanguage; @@ -209,7 +209,7 @@ typedef union // size = 0x24 /*0x01*/ bool8 active; /*0x02*/ u8 language; /*0x03*/ u8 language2; - /*0x04*/ u8 nickname[POKEMON_NAME_LENGTH + 1]; + /*0x04*/ u8 nickname[VANILLA_POKEMON_NAME_LENGTH + 1]; /*0x0F*/ u8 ball; /*0x10*/ u16 species; /*0x12*/ u8 nBallsUsed; @@ -409,7 +409,7 @@ typedef union // size = 0x24 /*0x01*/ bool8 active; /*0x02*/ u8 nRibbons; /*0x03*/ u8 selectedRibbon; - /*0x04*/ u8 nickname[POKEMON_NAME_LENGTH + 1]; + /*0x04*/ u8 nickname[VANILLA_POKEMON_NAME_LENGTH + 1]; /*0x0F*/ u8 language; /*0x10*/ u8 pokemonNameLanguage; /*0x11*/ u8 filler_12[2]; diff --git a/include/pokemon.h b/include/pokemon.h index d37e5f4ae9..1f7003fe39 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -28,6 +28,7 @@ enum { MON_DATA_HP_LOST, MON_DATA_ENCRYPT_SEPARATOR, MON_DATA_NICKNAME, + MON_DATA_NICKNAME10, MON_DATA_SPECIES, MON_DATA_HELD_ITEM, MON_DATA_MOVE1, diff --git a/src/battle_tower.c b/src/battle_tower.c index 59e9a8aeaf..7cd319b113 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -2684,7 +2684,7 @@ static void SetTowerInterviewData(void) GetBattleTowerTrainerLanguage(&gSaveBlock2Ptr->frontier.towerInterview.opponentLanguage, gTrainerBattleOpponent_A); gSaveBlock2Ptr->frontier.towerInterview.opponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[1]], MON_DATA_SPECIES, NULL); gSaveBlock2Ptr->frontier.towerInterview.playerSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[0]], MON_DATA_SPECIES, NULL); - for (i = 0; i < POKEMON_NAME_LENGTH + 1; i++) + for (i = 0; i < VANILLA_POKEMON_NAME_LENGTH + 1; i++) gSaveBlock2Ptr->frontier.towerInterview.opponentMonNickname[i] = gBattleMons[0].nickname[i]; gSaveBlock2Ptr->frontier.towerBattleOutcome = gBattleOutcome; } diff --git a/src/contest.c b/src/contest.c index c500fda60d..4a2e4e66c4 100644 --- a/src/contest.c +++ b/src/contest.c @@ -5648,7 +5648,7 @@ bool8 SaveContestWinner(u8 rank) gSaveBlock1Ptr->contestWinners[id].personality = gContestMons[i].personality; gSaveBlock1Ptr->contestWinners[id].species = gContestMons[i].species; gSaveBlock1Ptr->contestWinners[id].trainerId = gContestMons[i].otId; - StringCopy(gSaveBlock1Ptr->contestWinners[id].monName, gContestMons[i].nickname); + StringCopyN(gSaveBlock1Ptr->contestWinners[id].monName, gContestMons[i].nickname, VANILLA_POKEMON_NAME_LENGTH); StringCopy(gSaveBlock1Ptr->contestWinners[id].trainerName, gContestMons[i].trainerName); if(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) gSaveBlock1Ptr->contestWinners[id].contestRank = CONTEST_RANK_LINK; @@ -5667,7 +5667,7 @@ bool8 SaveContestWinner(u8 rank) gCurContestWinner.isShiny = gContestMons[i].isShiny; gCurContestWinner.trainerId = gContestMons[i].otId; gCurContestWinner.species = gContestMons[i].species; - StringCopy(gCurContestWinner.monName, gContestMons[i].nickname); + StringCopyN(gCurContestWinner.monName, gContestMons[i].nickname, VANILLA_POKEMON_NAME_LENGTH); StringCopy(gCurContestWinner.trainerName, gContestMons[i].trainerName); gCurContestWinner.contestCategory = captionId; } diff --git a/src/daycare.c b/src/daycare.c index 537311f99d..8f4e9e7d53 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -96,11 +96,11 @@ static const u8 *const sCompatibilityMessages[] = static const u8 sJapaneseEggNickname[] = _("タマゴ"); // "tamago" ("egg" in Japanese) -u8 *GetMonNickname2(struct Pokemon *mon, u8 *dest) +u8 *GetMonNicknameVanilla(struct Pokemon *mon, u8 *dest) { u8 nickname[POKEMON_NAME_BUFFER_SIZE]; GetMonData(mon, MON_DATA_NICKNAME, nickname); - return StringCopy_Nickname(dest, nickname); + return StringCopyN(dest, nickname, VANILLA_POKEMON_NAME_LENGTH); } u8 *GetBoxMonNickname(struct BoxPokemon *mon, u8 *dest) @@ -218,7 +218,7 @@ static void StorePokemonInDaycare(struct Pokemon *mon, struct DaycareMon *daycar u8 mailId; StringCopy(daycareMon->mail.otName, gSaveBlock2Ptr->playerName); - GetMonNickname2(mon, daycareMon->mail.monName); + GetMonNicknameVanilla(mon, daycareMon->mail.monName); StripExtCtrlCodes(daycareMon->mail.monName); daycareMon->mail.gameLanguage = GAME_LANGUAGE; daycareMon->mail.monLanguage = GetMonData(mon, MON_DATA_LANGUAGE); @@ -418,7 +418,7 @@ static void ClearDaycareMonMail(struct DaycareMail *mail) for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) mail->otName[i] = 0; - for (i = 0; i < POKEMON_NAME_LENGTH + 1; i++) + for (i = 0; i < VANILLA_POKEMON_NAME_LENGTH + 1; i++) mail->monName[i] = 0; ClearMail(&mail->message); diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 588563d5d2..beb6ba40c4 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -36,6 +36,7 @@ #include "data.h" #include "battle.h" // to get rid of later #include "constants/rgb.h" +#include "party_menu.h" #define GFXTAG_EGG 12345 #define GFXTAG_EGG_SHARD 23456 @@ -375,7 +376,7 @@ static void AddHatchedMonToParty(u8 id) GetSetPokedexFlag(species, FLAG_SET_SEEN); GetSetPokedexFlag(species, FLAG_SET_CAUGHT); - GetMonNickname2(mon, gStringVar1); + GetMonNickname(mon, gStringVar1); // A met level of 0 is interpreted on the summary screen as "hatched at" metLevel = 0; @@ -648,7 +649,7 @@ static void CB2_EggHatch(void) break; case 5: // "{mon} hatched from egg" message/fanfare - GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyId], gStringVar1); + GetMonNickname(&gPlayerParty[sEggHatchData->eggPartyId], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_HatchedFromEgg); EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 3, TEXT_SKIP_DRAW); PlayFanfare(MUS_EVOLVED); @@ -666,7 +667,7 @@ static void CB2_EggHatch(void) break; case 8: // Ready the nickname prompt - GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyId], gStringVar1); + GetMonNickname(&gPlayerParty[sEggHatchData->eggPartyId], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_NicknameHatchPrompt); EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 2, 1); sEggHatchData->state++; @@ -685,7 +686,7 @@ static void CB2_EggHatch(void) switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: // Yes - GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyId], gStringVar3); + GetMonNickname(&gPlayerParty[sEggHatchData->eggPartyId], gStringVar3); species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyId], MON_DATA_SPECIES); gender = GetMonGender(&gPlayerParty[sEggHatchData->eggPartyId]); personality = GetMonData(&gPlayerParty[sEggHatchData->eggPartyId], MON_DATA_PERSONALITY, 0); diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 80689c264e..2837931ea1 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -452,8 +452,8 @@ static void Task_Hof_InitMonData(u8 taskId) sHofMonPtr->mon[i].isShiny = GetMonData(&gPlayerParty[i], MON_DATA_IS_SHINY); sHofMonPtr->mon[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); sHofMonPtr->mon[i].lvl = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); - GetMonData(&gPlayerParty[i], MON_DATA_NICKNAME, nickname); - for (j = 0; j < POKEMON_NAME_LENGTH; j++) + GetMonData(&gPlayerParty[i], MON_DATA_NICKNAME10, nickname); + for (j = 0; j < VANILLA_POKEMON_NAME_LENGTH; j++) sHofMonPtr->mon[i].nickname[j] = nickname[j]; gTasks[taskId].tMonNumber++; } diff --git a/src/pokemon.c b/src/pokemon.c index 521e54cbbd..47544cdf4a 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1348,7 +1348,7 @@ void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerP dest->spDefenseIV = GetMonData(mon, MON_DATA_SPDEF_IV, NULL); dest->abilityNum = GetMonData(mon, MON_DATA_ABILITY_NUM, NULL); dest->personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); - GetMonData(mon, MON_DATA_NICKNAME, dest->nickname); + GetMonData(mon, MON_DATA_NICKNAME10, dest->nickname); } static void CreateEventMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) @@ -2190,6 +2190,7 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data) switch (field) { case MON_DATA_NICKNAME: + case MON_DATA_NICKNAME10: { if (boxMon->isBadEgg) { @@ -2232,7 +2233,7 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data) // so if both are 0 we assume that this is a vanilla // Pokémon and replace them with EOS. This means that // two CHAR_SPACE at the end of a nickname are trimmed. - if (POKEMON_NAME_LENGTH >= 12) + if (field != MON_DATA_NICKNAME10 && POKEMON_NAME_LENGTH >= 12) { if (substruct0->nickname11 == 0 && substruct0->nickname12 == 0) { @@ -2727,14 +2728,23 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) switch (field) { case MON_DATA_NICKNAME: + case MON_DATA_NICKNAME10: { s32 i; for (i = 0; i < min(sizeof(boxMon->nickname), POKEMON_NAME_LENGTH); i++) boxMon->nickname[i] = data[i]; - if (POKEMON_NAME_LENGTH >= 11) - substruct0->nickname11 = data[10]; - if (POKEMON_NAME_LENGTH >= 12) - substruct0->nickname12 = data[11]; + if (field != MON_DATA_NICKNAME10) + { + if (POKEMON_NAME_LENGTH >= 11) + substruct0->nickname11 = data[10]; + if (POKEMON_NAME_LENGTH >= 12) + substruct0->nickname12 = data[11]; + } + else + { + substruct0->nickname11 = EOS; + substruct0->nickname12 = EOS; + } break; } case MON_DATA_SPECIES: diff --git a/src/tv.c b/src/tv.c index 215af04dce..5530e519f6 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1455,7 +1455,7 @@ void BravoTrainerPokemonProfile_BeforeInterview2(u8 contestStandingPlace) show->bravoTrainer.contestCategory = gSpecialVar_ContestCategory; show->bravoTrainer.contestRank = gSpecialVar_ContestRank; show->bravoTrainer.species = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SPECIES, NULL); - GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_NICKNAME, show->bravoTrainer.pokemonNickname); + GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_NICKNAME10, show->bravoTrainer.pokemonNickname); StripExtCtrlCodes(show->bravoTrainer.pokemonNickname); show->bravoTrainer.pokemonNameLanguage = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_LANGUAGE); } @@ -1536,7 +1536,7 @@ void PutNameRaterShowOnTheAir(void) show->nameRaterShow.random2 = Random() % 2; show->nameRaterShow.randomSpecies = GetRandomDifferentSpeciesSeenByPlayer(show->nameRaterShow.species); StringCopy(show->nameRaterShow.trainerName, gSaveBlock2Ptr->playerName); - GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, show->nameRaterShow.pokemonName); + GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME10, show->nameRaterShow.pokemonName); StripExtCtrlCodes(show->nameRaterShow.pokemonName); StorePlayerIdInNormalShow(show); show->nameRaterShow.language = gGameLanguage; @@ -1612,7 +1612,7 @@ static void InterviewAfter_PkmnFanClubOpinions(void) show->fanclubOpinions.friendshipHighNybble = GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_FRIENDSHIP, NULL) >> 4; show->fanclubOpinions.questionAsked = gSpecialVar_0x8007; StringCopy(show->fanclubOpinions.playerName, gSaveBlock2Ptr->playerName); - GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_NICKNAME, show->fanclubOpinions.nickname); + GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_NICKNAME10, show->fanclubOpinions.nickname); StripExtCtrlCodes(show->fanclubOpinions.nickname); show->fanclubOpinions.species = GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL); StorePlayerIdInNormalShow(show); @@ -2229,7 +2229,7 @@ void TryPutSpotTheCutiesOnAir(struct Pokemon *pokemon, u8 ribbonMonDataIdx) show->cuties.kind = TVSHOW_CUTIES; show->cuties.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->cuties.playerName, gSaveBlock2Ptr->playerName); - GetMonData(pokemon, MON_DATA_NICKNAME, show->cuties.nickname); + GetMonData(pokemon, MON_DATA_NICKNAME10, show->cuties.nickname); StripExtCtrlCodes(show->cuties.nickname); show->cuties.nRibbons = GetRibbonCount(pokemon); show->cuties.selectedRibbon = MonDataIdxToRibbon(ribbonMonDataIdx);