Fix the strings length issue
This commit is contained in:
@@ -6449,12 +6449,12 @@ static void CopyDomeTrainerName(u8 *dst, u16 trainerId)
|
||||
{
|
||||
if (trainerId == TRAINER_PLAYER)
|
||||
{
|
||||
for (i = 0; i < OT_NAME_LENGTH; i++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
||||
dst[i] = gSaveBlock2Ptr->playerName[i];
|
||||
}
|
||||
else if (trainerId < 300)
|
||||
{
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < FRONTIER_TRAINER_NAME_LENGTH; i++)
|
||||
dst[i] = gFacilityTrainers[trainerId].trainerName[i];
|
||||
}
|
||||
dst[i] = EOS;
|
||||
@@ -6475,7 +6475,7 @@ static void CopyDomeBrainTrainerName(u8 *dst)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < FRONTIER_TRAINER_NAME_LENGTH; i++)
|
||||
dst[i] = gTrainers[TRAINER_TUCKER].trainerName[i];
|
||||
dst[i] = EOS;
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ static void SetPlayerBerryDataInBattleStruct(void)
|
||||
|
||||
if (IsEnigmaBerryValid() == TRUE)
|
||||
{
|
||||
for (i = 0; i < BERRY_NAME_COUNT - 1; i++)
|
||||
for (i = 0; i < BERRY_NAME_LENGTH; i++)
|
||||
battleBerry->name[i] = gSaveBlock1Ptr->enigmaBerry.berry.name[i];
|
||||
battleBerry->name[i] = EOS;
|
||||
|
||||
@@ -748,7 +748,7 @@ static void SetPlayerBerryDataInBattleStruct(void)
|
||||
{
|
||||
const struct Berry *berryData = GetBerryInfo(ItemIdToBerryType(ITEM_ENIGMA_BERRY));
|
||||
|
||||
for (i = 0; i < BERRY_NAME_COUNT - 1; i++)
|
||||
for (i = 0; i < BERRY_NAME_LENGTH; i++)
|
||||
battleBerry->name[i] = berryData->name[i];
|
||||
battleBerry->name[i] = EOS;
|
||||
|
||||
@@ -769,7 +769,7 @@ static void SetAllPlayersBerryData(void)
|
||||
{
|
||||
if (IsEnigmaBerryValid() == TRUE)
|
||||
{
|
||||
for (i = 0; i < BERRY_NAME_COUNT - 1; i++)
|
||||
for (i = 0; i < BERRY_NAME_LENGTH; i++)
|
||||
{
|
||||
gEnigmaBerries[0].name[i] = gSaveBlock1Ptr->enigmaBerry.berry.name[i];
|
||||
gEnigmaBerries[2].name[i] = gSaveBlock1Ptr->enigmaBerry.berry.name[i];
|
||||
@@ -792,7 +792,7 @@ static void SetAllPlayersBerryData(void)
|
||||
{
|
||||
const struct Berry *berryData = GetBerryInfo(ItemIdToBerryType(ITEM_ENIGMA_BERRY));
|
||||
|
||||
for (i = 0; i < BERRY_NAME_COUNT - 1; i++)
|
||||
for (i = 0; i < BERRY_NAME_LENGTH; i++)
|
||||
{
|
||||
gEnigmaBerries[0].name[i] = berryData->name[i];
|
||||
gEnigmaBerries[2].name[i] = berryData->name[i];
|
||||
@@ -830,7 +830,7 @@ static void SetAllPlayersBerryData(void)
|
||||
src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2);
|
||||
battlerId = gLinkPlayers[i].id;
|
||||
|
||||
for (j = 0; j < BERRY_NAME_COUNT - 1; j++)
|
||||
for (j = 0; j < BERRY_NAME_LENGTH; j++)
|
||||
gEnigmaBerries[battlerId].name[j] = src->name[j];
|
||||
gEnigmaBerries[battlerId].name[j] = EOS;
|
||||
|
||||
@@ -847,7 +847,7 @@ static void SetAllPlayersBerryData(void)
|
||||
{
|
||||
src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2);
|
||||
|
||||
for (j = 0; j < BERRY_NAME_COUNT - 1; j++)
|
||||
for (j = 0; j < BERRY_NAME_LENGTH; j++)
|
||||
{
|
||||
gEnigmaBerries[i].name[j] = src->name[j];
|
||||
gEnigmaBerries[i + 2].name[j] = src->name[j];
|
||||
|
||||
@@ -107,7 +107,7 @@ static s32 FindLinkBattleRecord(struct LinkBattleRecord *records, const u8 *name
|
||||
|
||||
for (i = 0; i < LINK_B_RECORDS_COUNT; i++)
|
||||
{
|
||||
if (!StringCompareN(records[i].name, name, OT_NAME_LENGTH) && records[i].trainerId == trainerId)
|
||||
if (!StringCompareN(records[i].name, name, PLAYER_NAME_LENGTH) && records[i].trainerId == trainerId)
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ static void UpdateLinkBattleRecords(struct LinkBattleRecords *records, const u8
|
||||
{
|
||||
index = LINK_B_RECORDS_COUNT - 1;
|
||||
ClearLinkBattleRecord(&records->entries[index]);
|
||||
StringCopyN(records->entries[index].name, name, OT_NAME_LENGTH);
|
||||
StringCopyN(records->entries[index].name, name, PLAYER_NAME_LENGTH);
|
||||
records->entries[index].trainerId = trainerId;
|
||||
records->languages[index] = gLinkPlayers[battlerId].language;
|
||||
}
|
||||
|
||||
@@ -1076,8 +1076,8 @@ u16 BerryTypeToItemId(u16 berry)
|
||||
|
||||
void GetBerryNameByBerryType(u8 berry, u8 *string)
|
||||
{
|
||||
memcpy(string, GetBerryInfo(berry)->name, BERRY_NAME_COUNT - 1);
|
||||
string[BERRY_NAME_COUNT - 1] = EOS;
|
||||
memcpy(string, GetBerryInfo(berry)->name, BERRY_NAME_LENGTH);
|
||||
string[BERRY_NAME_LENGTH] = EOS;
|
||||
}
|
||||
|
||||
void GetBerryCountStringByBerryType(u8 berry, u8* dest, u32 berryCount)
|
||||
|
||||
@@ -51,7 +51,7 @@ enum
|
||||
struct BlenderBerry
|
||||
{
|
||||
u16 itemId;
|
||||
u8 name[BERRY_NAME_COUNT];
|
||||
u8 name[BERRY_NAME_LENGTH + 1];
|
||||
u8 flavors[FLAVOR_COUNT];
|
||||
u8 smoothness;
|
||||
};
|
||||
|
||||
@@ -368,7 +368,7 @@ static void ClearDaycareMonMail(struct DayCareMail *mail)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < OT_NAME_LENGTH + 1; i++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
|
||||
mail->OT_name[i] = 0;
|
||||
for (i = 0; i < POKEMON_NAME_LENGTH + 1; i++)
|
||||
mail->monName[i] = 0;
|
||||
|
||||
@@ -22,7 +22,7 @@ void ClearMailStruct(struct MailStruct *mail)
|
||||
for (i = 0; i < MAIL_WORDS_COUNT; i++)
|
||||
mail->words[i] = 0xFFFF;
|
||||
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
|
||||
mail->playerName[i] = EOS;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
@@ -58,7 +58,7 @@ u8 GiveMailToMon(struct Pokemon *mon, u16 itemId)
|
||||
for (i = 0; i < MAIL_WORDS_COUNT; i++)
|
||||
gSaveBlock1Ptr->mail[id].words[i] = 0xFFFF;
|
||||
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH - 1; i++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH + 1 - 1; i++)
|
||||
gSaveBlock1Ptr->mail[id].playerName[i] = gSaveBlock2Ptr->playerName[i];
|
||||
gSaveBlock1Ptr->mail[id].playerName[i] = EOS;
|
||||
PadNameString(gSaveBlock1Ptr->mail[id].playerName, CHAR_SPACE);
|
||||
|
||||
@@ -226,9 +226,9 @@ bool8 MEScrCmd_setenigmaberry(struct ScriptContext *ctx)
|
||||
const u8 *message;
|
||||
bool32 haveBerry = IsEnigmaBerryValid();
|
||||
u8 *berry = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
StringCopyN(gStringVar1, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_COUNT);
|
||||
StringCopyN(gStringVar1, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_LENGTH + 1);
|
||||
SetEnigmaBerry(berry);
|
||||
StringCopyN(gStringVar2, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_COUNT);
|
||||
StringCopyN(gStringVar2, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_LENGTH + 1);
|
||||
|
||||
if (!haveBerry)
|
||||
{
|
||||
|
||||
@@ -4112,7 +4112,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data)
|
||||
{
|
||||
retVal = 0;
|
||||
|
||||
while (retVal < OT_NAME_LENGTH)
|
||||
while (retVal < PLAYER_NAME_LENGTH)
|
||||
{
|
||||
data[retVal] = boxMon->otName[retVal];
|
||||
retVal++;
|
||||
@@ -4480,7 +4480,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg)
|
||||
case MON_DATA_OT_NAME:
|
||||
{
|
||||
s32 i;
|
||||
for (i = 0; i < OT_NAME_LENGTH; i++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
||||
boxMon->otName[i] = data[i];
|
||||
break;
|
||||
}
|
||||
@@ -6778,7 +6778,7 @@ s8 GetFlavorRelationByPersonality(u32 personality, u8 flavor)
|
||||
|
||||
bool8 IsTradedMon(struct Pokemon *mon)
|
||||
{
|
||||
u8 otName[OT_NAME_LENGTH + 1];
|
||||
u8 otName[PLAYER_NAME_LENGTH + 1];
|
||||
u32 otId;
|
||||
GetMonData(mon, MON_DATA_OT_NAME, otName);
|
||||
otId = GetMonData(mon, MON_DATA_OT_ID, 0);
|
||||
|
||||
@@ -28,7 +28,7 @@ extern u8 gUnknown_03001279;
|
||||
struct PlayerInfo
|
||||
{
|
||||
u32 trainerId;
|
||||
u8 name[PLAYER_NAME_LENGTH];
|
||||
u8 name[PLAYER_NAME_LENGTH + 1];
|
||||
u8 gender;
|
||||
u16 battlerId;
|
||||
u16 language;
|
||||
@@ -44,7 +44,7 @@ struct RecordedBattleSave
|
||||
{
|
||||
struct Pokemon playerParty[PARTY_SIZE];
|
||||
struct Pokemon opponentParty[PARTY_SIZE];
|
||||
u8 playersName[MAX_BATTLERS_COUNT][PLAYER_NAME_LENGTH];
|
||||
u8 playersName[MAX_BATTLERS_COUNT][PLAYER_NAME_LENGTH + 1];
|
||||
u8 playersGender[MAX_BATTLERS_COUNT];
|
||||
u32 playersTrainerId[MAX_BATTLERS_COUNT];
|
||||
u8 playersLanguage[MAX_BATTLERS_COUNT];
|
||||
@@ -170,7 +170,7 @@ void sub_8184E58(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < PLAYER_NAME_LENGTH; j++)
|
||||
for (j = 0; j < PLAYER_NAME_LENGTH + 1; j++)
|
||||
sPlayers[i].name[j] = gLinkPlayers[i].name[j];
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ void sub_8184E58(void)
|
||||
sPlayers[0].battlerId = 0;
|
||||
sPlayers[0].language = gGameLanguage;
|
||||
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
|
||||
sPlayers[0].name[i] = gSaveBlock2Ptr->playerName[i];
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ u32 MoveRecordedBattleToSaveData(void)
|
||||
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
for (j = 0; j < PLAYER_NAME_LENGTH; j++)
|
||||
for (j = 0; j < PLAYER_NAME_LENGTH + 1; j++)
|
||||
{
|
||||
battleSave->playersName[i][j] = sPlayers[i].name[j];
|
||||
}
|
||||
@@ -1332,7 +1332,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src)
|
||||
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
for (var = FALSE, j = 0; j < PLAYER_NAME_LENGTH; j++)
|
||||
for (var = FALSE, j = 0; j < PLAYER_NAME_LENGTH + 1; j++)
|
||||
{
|
||||
gLinkPlayers[i].name[j] = src->playersName[i][j];
|
||||
if (src->playersName[i][j] == EOS)
|
||||
|
||||
@@ -40,7 +40,7 @@ struct UnkStruct_Shared
|
||||
{
|
||||
struct UnkLinkRfuStruct_02022B14 field_0;
|
||||
u8 needingPadding[3];
|
||||
u8 playerName[PLAYER_NAME_LENGTH];
|
||||
u8 playerName[PLAYER_NAME_LENGTH + 1];
|
||||
};
|
||||
|
||||
struct UnkStruct_x1C
|
||||
|
||||
@@ -1354,7 +1354,7 @@ bool8 sub_80EA904(struct SecretBaseRecord *sbr1, struct SecretBaseRecord *sbr2)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < OT_NAME_LENGTH && (sbr1->trainerName[i] != EOS || sbr2->trainerName[i] != EOS); i++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH && (sbr1->trainerName[i] != EOS || sbr2->trainerName[i] != EOS); i++)
|
||||
{
|
||||
if (sbr1->trainerName[i] != sbr2->trainerName[i])
|
||||
{
|
||||
@@ -1509,7 +1509,7 @@ bool8 DoesSecretBaseBelongToPlayer(struct SecretBaseRecord *secretBase)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < OT_NAME_LENGTH && (secretBase->trainerName[i] != EOS || gSaveBlock2Ptr->playerName[i] != EOS); i ++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH && (secretBase->trainerName[i] != EOS || gSaveBlock2Ptr->playerName[i] != EOS); i ++)
|
||||
{
|
||||
if (secretBase->trainerName[i] != gSaveBlock2Ptr->playerName[i])
|
||||
return FALSE;
|
||||
|
||||
Reference in New Issue
Block a user