Fix the strings length issue

This commit is contained in:
DizzyEggg
2018-09-01 22:03:21 +02:00
parent 5c7ca813e7
commit e28ce3be78
18 changed files with 58 additions and 58 deletions
+1
View File
@@ -207,6 +207,7 @@ extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
extern const u8 BattleScript_ArenaTurnBeginning[]; extern const u8 BattleScript_ArenaTurnBeginning[];
extern const u8 BattleScript_82DB881[]; extern const u8 BattleScript_82DB881[];
extern const u8 BattleScript_82DB8F3[]; extern const u8 BattleScript_82DB8F3[];
extern const u8 BattleScript_82DAA0B[];
extern const u8 BattleScript_AskIfWantsToForfeitMatch[]; extern const u8 BattleScript_AskIfWantsToForfeitMatch[];
extern const u8 BattleScript_PrintPlayerForfeited[]; extern const u8 BattleScript_PrintPlayerForfeited[];
extern const u8 BattleScript_PrintPlayerForfeitedLinkBattle[]; extern const u8 BattleScript_PrintPlayerForfeitedLinkBattle[];
+4 -2
View File
@@ -6,7 +6,7 @@ struct RSBattleTowerRecord
/*0x00*/ u8 battleTowerLevelType; // 0 = level 50, 1 = level 100 /*0x00*/ u8 battleTowerLevelType; // 0 = level 50, 1 = level 100
/*0x01*/ u8 trainerClass; /*0x01*/ u8 trainerClass;
/*0x02*/ u16 winStreak; /*0x02*/ u16 winStreak;
/*0x04*/ u8 name[8]; /*0x04*/ u8 name[PLAYER_NAME_LENGTH + 1];
/*0x0C*/ u8 trainerId[4]; /*0x0C*/ u8 trainerId[4];
/*0x10*/ struct { /*0x10*/ struct {
u16 easyChat[6]; u16 easyChat[6];
@@ -22,10 +22,12 @@ union BattleTowerRecord
struct EmeraldBattleTowerRecord emerald; struct EmeraldBattleTowerRecord emerald;
}; };
#define FRONTIER_TRAINER_NAME_LENGTH 7
struct BattleFrontierTrainer struct BattleFrontierTrainer
{ {
u32 facilityClass; u32 facilityClass;
u8 trainerName[8]; u8 trainerName[FRONTIER_TRAINER_NAME_LENGTH + 1];
u16 speechBefore[6]; u16 speechBefore[6];
u16 speechWin[6]; u16 speechWin[6];
u16 speechLose[6]; u16 speechLose[6];
+4 -4
View File
@@ -1,12 +1,12 @@
#ifndef GUARD_GLOBAL_BERRY_H #ifndef GUARD_GLOBAL_BERRY_H
#define GUARD_GLOBAL_BERRY_H #define GUARD_GLOBAL_BERRY_H
#define BERRY_NAME_COUNT 7 #define BERRY_NAME_LENGTH 6
#define BERRY_ITEM_EFFECT_COUNT 18 #define BERRY_ITEM_EFFECT_COUNT 18
struct Berry struct Berry
{ {
const u8 name[BERRY_NAME_COUNT]; const u8 name[BERRY_NAME_LENGTH + 1];
u8 firmness; u8 firmness;
u16 size; u16 size;
u8 maxYield; u8 maxYield;
@@ -26,7 +26,7 @@ struct Berry
struct Berry2 struct Berry2
{ {
u8 name[BERRY_NAME_COUNT]; u8 name[BERRY_NAME_LENGTH + 1];
u8 firmness; u8 firmness;
u16 size; u16 size;
u8 maxYield; u8 maxYield;
@@ -53,7 +53,7 @@ struct EnigmaBerry
struct BattleEnigmaBerry struct BattleEnigmaBerry
{ {
/*0x00*/ u8 name[BERRY_NAME_COUNT]; /*0x00*/ u8 name[BERRY_NAME_LENGTH + 1];
/*0x07*/ u8 holdEffect; /*0x07*/ u8 holdEffect;
/*0x08*/ u8 itemEffect[BERRY_ITEM_EFFECT_COUNT]; /*0x08*/ u8 itemEffect[BERRY_ITEM_EFFECT_COUNT];
/*0x1A*/ u8 holdEffectParam; /*0x1A*/ u8 holdEffectParam;
+14 -17
View File
@@ -57,8 +57,6 @@
#define PARTY_SIZE 6 #define PARTY_SIZE 6
#define POKEMON_SLOTS_NUMBER 412 #define POKEMON_SLOTS_NUMBER 412
#define POKEMON_NAME_LENGTH 10
#define OT_NAME_LENGTH 7
#define min(a, b) ((a) < (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) >= (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b))
@@ -134,8 +132,7 @@ enum LanguageId
// string lengths // string lengths
#define ITEM_NAME_LENGTH 14 #define ITEM_NAME_LENGTH 14
#define POKEMON_NAME_LENGTH 10 #define POKEMON_NAME_LENGTH 10
#define OT_NAME_LENGTH 7 #define PLAYER_NAME_LENGTH 7
#define PLAYER_NAME_LENGTH 8
#define MAIL_WORDS_COUNT 9 #define MAIL_WORDS_COUNT 9
enum enum
@@ -326,7 +323,7 @@ struct EmeraldBattleTowerRecord
/*0x00*/ u8 battleTowerLevelType; // 0 = level 50, 1 = level 100 /*0x00*/ u8 battleTowerLevelType; // 0 = level 50, 1 = level 100
/*0x01*/ u8 trainerClass; /*0x01*/ u8 trainerClass;
/*0x02*/ u16 winStreak; /*0x02*/ u16 winStreak;
/*0x04*/ u8 name[8]; /*0x04*/ u8 name[PLAYER_NAME_LENGTH + 1];
/*0x0C*/ u8 trainerId[4]; /*0x0C*/ u8 trainerId[4];
/*0x10*/ struct { /*0x10*/ struct {
u16 easyChat[6]; u16 easyChat[6];
@@ -450,7 +447,7 @@ struct BattleFrontier
/*0xEBF*/ u8 field_EBF; /*0xEBF*/ u8 field_EBF;
/*0xEC0*/ u16 field_EC0[16]; /*0xEC0*/ u16 field_EC0[16];
/*0xEE0*/ u8 field_EE0; /*0xEE0*/ u8 field_EE0;
/*0xEE1*/ u8 field_EE1[2][PLAYER_NAME_LENGTH]; /*0xEE1*/ u8 field_EE1[2][PLAYER_NAME_LENGTH + 1];
/*0xEF1*/ u8 field_EF1[2][4]; /*0xEF1*/ u8 field_EF1[2][4];
/*0xEF9*/ u8 field_EF9; /*0xEF9*/ u8 field_EF9;
/*0xEFA*/ u8 field_EFA; /*0xEFA*/ u8 field_EFA;
@@ -460,7 +457,7 @@ struct BattleFrontier
struct SaveBlock2 struct SaveBlock2
{ {
/*0x00*/ u8 playerName[PLAYER_NAME_LENGTH]; /*0x00*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
/*0x08*/ u8 playerGender; // MALE, FEMALE /*0x08*/ u8 playerGender; // MALE, FEMALE
/*0x09*/ u8 specialSaveWarp; /*0x09*/ u8 specialSaveWarp;
/*0x0A*/ u8 playerTrainerId[4]; /*0x0A*/ u8 playerTrainerId[4];
@@ -516,7 +513,7 @@ struct SecretBaseRecord
/*0x1A9D*/ u8 gender:1; /*0x1A9D*/ u8 gender:1;
/*0x1A9D*/ u8 sbr_field_1_5:1; /*0x1A9D*/ u8 sbr_field_1_5:1;
/*0x1A9D*/ u8 sbr_field_1_6:2; /*0x1A9D*/ u8 sbr_field_1_6:2;
/*0x1A9E*/ u8 trainerName[OT_NAME_LENGTH]; /*0x1A9E*/ u8 trainerName[PLAYER_NAME_LENGTH];
/*0x1AA5*/ u8 trainerId[4]; // byte 0 is used for determining trainer class /*0x1AA5*/ u8 trainerId[4]; // byte 0 is used for determining trainer class
/*0x1AA9*/ u8 language; /*0x1AA9*/ u8 language;
/*0x1AAA*/ u16 sbr_field_e; /*0x1AAA*/ u16 sbr_field_e;
@@ -602,7 +599,7 @@ struct EasyChatPair
struct MailStruct struct MailStruct
{ {
/*0x00*/ u16 words[MAIL_WORDS_COUNT]; /*0x00*/ u16 words[MAIL_WORDS_COUNT];
/*0x12*/ u8 playerName[PLAYER_NAME_LENGTH]; /*0x12*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
/*0x1A*/ u8 trainerId[4]; /*0x1A*/ u8 trainerId[4];
/*0x1E*/ u16 species; /*0x1E*/ u16 species;
/*0x20*/ u16 itemId; /*0x20*/ u16 itemId;
@@ -691,7 +688,7 @@ struct RecordMixing_UnknownStruct
struct LinkBattleRecord struct LinkBattleRecord
{ {
u8 name[8]; u8 name[PLAYER_NAME_LENGTH + 1];
u16 trainerId; u16 trainerId;
u16 wins; u16 wins;
u16 losses; u16 losses;
@@ -724,15 +721,15 @@ struct ContestWinner
u32 trainerId; u32 trainerId;
u16 species; u16 species;
u8 contestCategory; u8 contestCategory;
u8 monName[11]; u8 monName[POKEMON_NAME_LENGTH + 1];
u8 trainerName[8]; u8 trainerName[PLAYER_NAME_LENGTH + 1];
u8 contestRank; u8 contestRank;
}; };
struct DayCareMail struct DayCareMail
{ {
struct MailStruct message; struct MailStruct message;
u8 OT_name[OT_NAME_LENGTH + 1]; u8 OT_name[PLAYER_NAME_LENGTH + 1];
u8 monName[POKEMON_NAME_LENGTH + 1]; u8 monName[POKEMON_NAME_LENGTH + 1];
u8 gameLanguage:4; u8 gameLanguage:4;
u8 monLanguage:4; u8 monLanguage:4;
@@ -773,7 +770,7 @@ struct LilycoveLadyQuiz
/*0x002*/ u16 unk_002[9]; /*0x002*/ u16 unk_002[9];
/*0x014*/ u16 unk_014; /*0x014*/ u16 unk_014;
/*0x016*/ u16 unk_016; /*0x016*/ u16 unk_016;
/*0x018*/ u8 playerName[8]; /*0x018*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
/*0x020*/ u16 playerTrainerId[4]; /*0x020*/ u16 playerTrainerId[4];
/*0x028*/ u16 itemId; /*0x028*/ u16 itemId;
/*0x02a*/ u8 unk_02a; /*0x02a*/ u8 unk_02a;
@@ -788,7 +785,7 @@ struct LilycoveLadyFavour
/*0x001*/ u8 phase; /*0x001*/ u8 phase;
/*0x002*/ u8 unk_002; /*0x002*/ u8 unk_002;
/*0x003*/ u8 unk_003; /*0x003*/ u8 unk_003;
/*0x004*/ u8 playerName[8]; /*0x004*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
/*0x00c*/ u8 unk_00c; /*0x00c*/ u8 unk_00c;
/*0x00e*/ u16 itemId; /*0x00e*/ u16 itemId;
/*0x010*/ u16 unk_010; /*0x010*/ u16 unk_010;
@@ -801,7 +798,7 @@ struct LilycoveLadyContest
/*0x001*/ u8 phase; /*0x001*/ u8 phase;
/*0x002*/ u8 fave_pkblk; /*0x002*/ u8 fave_pkblk;
/*0x003*/ u8 other_pkblk; /*0x003*/ u8 other_pkblk;
/*0x004*/ u8 playerName[8]; /*0x004*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
/*0x00c*/ u8 max_sheen; /*0x00c*/ u8 max_sheen;
/*0x00d*/ u8 category; /*0x00d*/ u8 category;
/*0x00e*/ u8 language; /*0x00e*/ u8 language;
@@ -828,7 +825,7 @@ struct WaldaPhrase
struct UnkSaveSubstruct_3b98 { struct UnkSaveSubstruct_3b98 {
u32 trainerId; u32 trainerId;
u8 trainerName[8]; u8 trainerName[PLAYER_NAME_LENGTH + 1];
}; };
struct SaveBlock1 struct SaveBlock1
+1 -1
View File
@@ -205,7 +205,7 @@ struct BoxPokemon
u8 hasSpecies:1; u8 hasSpecies:1;
u8 isEgg:1; u8 isEgg:1;
u8 unused:5; u8 unused:5;
u8 otName[OT_NAME_LENGTH]; u8 otName[PLAYER_NAME_LENGTH];
u8 markings; u8 markings;
u16 checksum; u16 checksum;
u16 unknown; u16 unknown;
+3 -3
View File
@@ -6,7 +6,7 @@ struct UnkRecordMixingStruct2a
{ {
u8 playerId[4]; u8 playerId[4];
u16 field_4; u16 field_4;
u8 playerName[PLAYER_NAME_LENGTH]; u8 playerName[PLAYER_NAME_LENGTH + 1];
u8 language; u8 language;
}; };
@@ -15,8 +15,8 @@ struct UnkRecordMixingStruct2b
u8 playerId1[4]; u8 playerId1[4];
u8 playerId2[4]; u8 playerId2[4];
u16 field_8; u16 field_8;
u8 playerName1[PLAYER_NAME_LENGTH]; u8 playerName1[PLAYER_NAME_LENGTH + 1];
u8 playerName2[PLAYER_NAME_LENGTH]; u8 playerName2[PLAYER_NAME_LENGTH + 1];
u8 language; u8 language;
}; };
+3 -3
View File
@@ -6449,12 +6449,12 @@ static void CopyDomeTrainerName(u8 *dst, u16 trainerId)
{ {
if (trainerId == TRAINER_PLAYER) 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]; dst[i] = gSaveBlock2Ptr->playerName[i];
} }
else if (trainerId < 300) 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] = gFacilityTrainers[trainerId].trainerName[i];
} }
dst[i] = EOS; dst[i] = EOS;
@@ -6475,7 +6475,7 @@ static void CopyDomeBrainTrainerName(u8 *dst)
{ {
s32 i; 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] = gTrainers[TRAINER_TUCKER].trainerName[i];
dst[i] = EOS; dst[i] = EOS;
} }
+6 -6
View File
@@ -734,7 +734,7 @@ static void SetPlayerBerryDataInBattleStruct(void)
if (IsEnigmaBerryValid() == TRUE) 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] = gSaveBlock1Ptr->enigmaBerry.berry.name[i];
battleBerry->name[i] = EOS; battleBerry->name[i] = EOS;
@@ -748,7 +748,7 @@ static void SetPlayerBerryDataInBattleStruct(void)
{ {
const struct Berry *berryData = GetBerryInfo(ItemIdToBerryType(ITEM_ENIGMA_BERRY)); 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] = berryData->name[i];
battleBerry->name[i] = EOS; battleBerry->name[i] = EOS;
@@ -769,7 +769,7 @@ static void SetAllPlayersBerryData(void)
{ {
if (IsEnigmaBerryValid() == TRUE) 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[0].name[i] = gSaveBlock1Ptr->enigmaBerry.berry.name[i];
gEnigmaBerries[2].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)); 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[0].name[i] = berryData->name[i];
gEnigmaBerries[2].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); src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2);
battlerId = gLinkPlayers[i].id; 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] = src->name[j];
gEnigmaBerries[battlerId].name[j] = EOS; gEnigmaBerries[battlerId].name[j] = EOS;
@@ -847,7 +847,7 @@ static void SetAllPlayersBerryData(void)
{ {
src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2); 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].name[j] = src->name[j];
gEnigmaBerries[i + 2].name[j] = src->name[j]; gEnigmaBerries[i + 2].name[j] = src->name[j];
+2 -2
View File
@@ -107,7 +107,7 @@ static s32 FindLinkBattleRecord(struct LinkBattleRecord *records, const u8 *name
for (i = 0; i < LINK_B_RECORDS_COUNT; i++) 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; return i;
} }
@@ -198,7 +198,7 @@ static void UpdateLinkBattleRecords(struct LinkBattleRecords *records, const u8
{ {
index = LINK_B_RECORDS_COUNT - 1; index = LINK_B_RECORDS_COUNT - 1;
ClearLinkBattleRecord(&records->entries[index]); 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->entries[index].trainerId = trainerId;
records->languages[index] = gLinkPlayers[battlerId].language; records->languages[index] = gLinkPlayers[battlerId].language;
} }
+2 -2
View File
@@ -1076,8 +1076,8 @@ u16 BerryTypeToItemId(u16 berry)
void GetBerryNameByBerryType(u8 berry, u8 *string) void GetBerryNameByBerryType(u8 berry, u8 *string)
{ {
memcpy(string, GetBerryInfo(berry)->name, BERRY_NAME_COUNT - 1); memcpy(string, GetBerryInfo(berry)->name, BERRY_NAME_LENGTH);
string[BERRY_NAME_COUNT - 1] = EOS; string[BERRY_NAME_LENGTH] = EOS;
} }
void GetBerryCountStringByBerryType(u8 berry, u8* dest, u32 berryCount) void GetBerryCountStringByBerryType(u8 berry, u8* dest, u32 berryCount)
+1 -1
View File
@@ -51,7 +51,7 @@ enum
struct BlenderBerry struct BlenderBerry
{ {
u16 itemId; u16 itemId;
u8 name[BERRY_NAME_COUNT]; u8 name[BERRY_NAME_LENGTH + 1];
u8 flavors[FLAVOR_COUNT]; u8 flavors[FLAVOR_COUNT];
u8 smoothness; u8 smoothness;
}; };
+1 -1
View File
@@ -368,7 +368,7 @@ static void ClearDaycareMonMail(struct DayCareMail *mail)
{ {
s32 i; 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; mail->OT_name[i] = 0;
for (i = 0; i < POKEMON_NAME_LENGTH + 1; i++) for (i = 0; i < POKEMON_NAME_LENGTH + 1; i++)
mail->monName[i] = 0; mail->monName[i] = 0;
+2 -2
View File
@@ -22,7 +22,7 @@ void ClearMailStruct(struct MailStruct *mail)
for (i = 0; i < MAIL_WORDS_COUNT; i++) for (i = 0; i < MAIL_WORDS_COUNT; i++)
mail->words[i] = 0xFFFF; 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; mail->playerName[i] = EOS;
for (i = 0; i < 4; i++) 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++) for (i = 0; i < MAIL_WORDS_COUNT; i++)
gSaveBlock1Ptr->mail[id].words[i] = 0xFFFF; 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] = gSaveBlock2Ptr->playerName[i];
gSaveBlock1Ptr->mail[id].playerName[i] = EOS; gSaveBlock1Ptr->mail[id].playerName[i] = EOS;
PadNameString(gSaveBlock1Ptr->mail[id].playerName, CHAR_SPACE); PadNameString(gSaveBlock1Ptr->mail[id].playerName, CHAR_SPACE);
+2 -2
View File
@@ -226,9 +226,9 @@ bool8 MEScrCmd_setenigmaberry(struct ScriptContext *ctx)
const u8 *message; const u8 *message;
bool32 haveBerry = IsEnigmaBerryValid(); bool32 haveBerry = IsEnigmaBerryValid();
u8 *berry = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]); 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); SetEnigmaBerry(berry);
StringCopyN(gStringVar2, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_COUNT); StringCopyN(gStringVar2, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_LENGTH + 1);
if (!haveBerry) if (!haveBerry)
{ {
+3 -3
View File
@@ -4112,7 +4112,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data)
{ {
retVal = 0; retVal = 0;
while (retVal < OT_NAME_LENGTH) while (retVal < PLAYER_NAME_LENGTH)
{ {
data[retVal] = boxMon->otName[retVal]; data[retVal] = boxMon->otName[retVal];
retVal++; retVal++;
@@ -4480,7 +4480,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg)
case MON_DATA_OT_NAME: case MON_DATA_OT_NAME:
{ {
s32 i; s32 i;
for (i = 0; i < OT_NAME_LENGTH; i++) for (i = 0; i < PLAYER_NAME_LENGTH; i++)
boxMon->otName[i] = data[i]; boxMon->otName[i] = data[i];
break; break;
} }
@@ -6778,7 +6778,7 @@ s8 GetFlavorRelationByPersonality(u32 personality, u8 flavor)
bool8 IsTradedMon(struct Pokemon *mon) bool8 IsTradedMon(struct Pokemon *mon)
{ {
u8 otName[OT_NAME_LENGTH + 1]; u8 otName[PLAYER_NAME_LENGTH + 1];
u32 otId; u32 otId;
GetMonData(mon, MON_DATA_OT_NAME, otName); GetMonData(mon, MON_DATA_OT_NAME, otName);
otId = GetMonData(mon, MON_DATA_OT_ID, 0); otId = GetMonData(mon, MON_DATA_OT_ID, 0);
+6 -6
View File
@@ -28,7 +28,7 @@ extern u8 gUnknown_03001279;
struct PlayerInfo struct PlayerInfo
{ {
u32 trainerId; u32 trainerId;
u8 name[PLAYER_NAME_LENGTH]; u8 name[PLAYER_NAME_LENGTH + 1];
u8 gender; u8 gender;
u16 battlerId; u16 battlerId;
u16 language; u16 language;
@@ -44,7 +44,7 @@ struct RecordedBattleSave
{ {
struct Pokemon playerParty[PARTY_SIZE]; struct Pokemon playerParty[PARTY_SIZE];
struct Pokemon opponentParty[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]; u8 playersGender[MAX_BATTLERS_COUNT];
u32 playersTrainerId[MAX_BATTLERS_COUNT]; u32 playersTrainerId[MAX_BATTLERS_COUNT];
u8 playersLanguage[MAX_BATTLERS_COUNT]; u8 playersLanguage[MAX_BATTLERS_COUNT];
@@ -170,7 +170,7 @@ void sub_8184E58(void)
} }
else 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]; sPlayers[i].name[j] = gLinkPlayers[i].name[j];
} }
} }
@@ -186,7 +186,7 @@ void sub_8184E58(void)
sPlayers[0].battlerId = 0; sPlayers[0].battlerId = 0;
sPlayers[0].language = gGameLanguage; 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]; sPlayers[0].name[i] = gSaveBlock2Ptr->playerName[i];
} }
} }
@@ -343,7 +343,7 @@ u32 MoveRecordedBattleToSaveData(void)
for (i = 0; i < MAX_BATTLERS_COUNT; i++) 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]; 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 (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]; gLinkPlayers[i].name[j] = src->playersName[i][j];
if (src->playersName[i][j] == EOS) if (src->playersName[i][j] == EOS)
+1 -1
View File
@@ -40,7 +40,7 @@ struct UnkStruct_Shared
{ {
struct UnkLinkRfuStruct_02022B14 field_0; struct UnkLinkRfuStruct_02022B14 field_0;
u8 needingPadding[3]; u8 needingPadding[3];
u8 playerName[PLAYER_NAME_LENGTH]; u8 playerName[PLAYER_NAME_LENGTH + 1];
}; };
struct UnkStruct_x1C struct UnkStruct_x1C
+2 -2
View File
@@ -1354,7 +1354,7 @@ bool8 sub_80EA904(struct SecretBaseRecord *sbr1, struct SecretBaseRecord *sbr2)
{ {
u8 i; 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]) if (sbr1->trainerName[i] != sbr2->trainerName[i])
{ {
@@ -1509,7 +1509,7 @@ bool8 DoesSecretBaseBelongToPlayer(struct SecretBaseRecord *secretBase)
return FALSE; 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]) if (secretBase->trainerName[i] != gSaveBlock2Ptr->playerName[i])
return FALSE; return FALSE;