Trainer class+name expansion fix for Battle Frontier (#5699)

Co-authored-by: Hedara <hedara90@gmail.com>
This commit is contained in:
hedara90 2024-11-23 23:10:34 +01:00 committed by GitHub
parent 194f7644b8
commit e7e701f8ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2622,6 +2622,10 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)
if (*src == PLACEHOLDER_BEGIN) if (*src == PLACEHOLDER_BEGIN)
{ {
src++; src++;
u32 classLength = 0;
u32 nameLength = 0;
const u8 *classString;
const u8 *nameString;
switch (*src) switch (*src)
{ {
case B_TXT_BUFF1: case B_TXT_BUFF1:
@ -2800,9 +2804,24 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)
break; break;
case B_TXT_TRAINER1_NAME_WITH_CLASS: // trainer1 name with trainer class case B_TXT_TRAINER1_NAME_WITH_CLASS: // trainer1 name with trainer class
toCpy = textStart; toCpy = textStart;
textStart = StringCopy(textStart, BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_A)); classString = BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_A);
textStart = StringAppend(textStart, gText_Space2); while (classString[classLength] != EOS)
textStart = StringAppend(textStart, BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, textStart, multiplayerId, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))); {
textStart[classLength] = classString[classLength];
classLength++;
}
textStart[classLength] = CHAR_SPACE;
textStart += classLength + 1;
nameString = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, textStart, multiplayerId, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT));
if (nameString != textStart)
{
while (nameString[nameLength] != EOS)
{
textStart[nameLength] = nameString[nameLength];
nameLength++;
}
textStart[nameLength] = EOS;
}
break; break;
case B_TXT_LINK_PLAYER_NAME: // link player name case B_TXT_LINK_PLAYER_NAME: // link player name
toCpy = gLinkPlayers[multiplayerId].name; toCpy = gLinkPlayers[multiplayerId].name;
@ -2922,9 +2941,24 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)
break; break;
case B_TXT_TRAINER2_NAME_WITH_CLASS: case B_TXT_TRAINER2_NAME_WITH_CLASS:
toCpy = textStart; toCpy = textStart;
textStart = StringCopy(textStart, BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_B)); classString = BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_B);
textStart = StringAppend(textStart, gText_Space2); while (classString[classLength] != EOS)
textStart = StringAppend(textStart, BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_B, textStart, multiplayerId, GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))); {
textStart[classLength] = classString[classLength];
classLength++;
}
textStart[classLength] = CHAR_SPACE;
textStart += classLength + 1;
nameString = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_B, textStart, multiplayerId, GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT));
if (nameString != textStart)
{
while (nameString[nameLength] != EOS)
{
textStart[nameLength] = nameString[nameLength];
nameLength++;
}
textStart[nameLength] = EOS;
}
break; break;
case B_TXT_TRAINER2_LOSE_TEXT: case B_TXT_TRAINER2_LOSE_TEXT:
if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
@ -2962,9 +2996,24 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)
break; break;
case B_TXT_PARTNER_NAME_WITH_CLASS: case B_TXT_PARTNER_NAME_WITH_CLASS:
toCpy = textStart; toCpy = textStart;
textStart = StringCopy(textStart, gTrainerClasses[GetFrontierOpponentClass(gPartnerTrainerId)].name); classString = gTrainerClasses[GetFrontierOpponentClass(gPartnerTrainerId)].name;
textStart = StringAppend(textStart, gText_Space2); while (classString[classLength] != EOS)
textStart = StringAppend(textStart, BattleStringGetPlayerName(textStart, GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT))); {
textStart[classLength] = classString[classLength];
classLength++;
}
textStart[classLength] = CHAR_SPACE;
textStart += classLength + 1;
nameString = BattleStringGetPlayerName(textStart, GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT));
if (nameString != textStart)
{
while (nameString[nameLength] != EOS)
{
textStart[nameLength] = nameString[nameLength];
nameLength++;
}
textStart[nameLength] = EOS;
}
break; break;
case B_TXT_ATK_TRAINER_NAME: case B_TXT_ATK_TRAINER_NAME:
toCpy = BattleStringGetTrainerName(text, multiplayerId, gBattlerAttacker); toCpy = BattleStringGetTrainerName(text, multiplayerId, gBattlerAttacker);
@ -2995,24 +3044,42 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)
} }
else else
{ {
classString = NULL;
switch (GetBattlerPosition(gBattlerAttacker)) switch (GetBattlerPosition(gBattlerAttacker))
{ {
case B_POSITION_PLAYER_RIGHT: case B_POSITION_PLAYER_RIGHT:
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
textStart = StringCopy(textStart, gTrainerClasses[GetFrontierOpponentClass(gPartnerTrainerId)].name); classString = gTrainerClasses[GetFrontierOpponentClass(gPartnerTrainerId)].name;
break; break;
case B_POSITION_OPPONENT_LEFT: case B_POSITION_OPPONENT_LEFT:
textStart = StringCopy(textStart, BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_A)); classString = BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_A);
break; break;
case B_POSITION_OPPONENT_RIGHT: case B_POSITION_OPPONENT_RIGHT:
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && !BATTLE_TWO_VS_ONE_OPPONENT) if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && !BATTLE_TWO_VS_ONE_OPPONENT)
textStart = StringCopy(textStart, BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_B)); classString = BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_B);
else else
textStart = StringCopy(textStart, BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_A)); classString = BattleStringGetOpponentClassByTrainerId(gTrainerBattleOpponent_A);
break; break;
} }
textStart = StringAppend(textStart, gText_Space2); classLength = 0;
textStart = StringAppend(textStart, BattleStringGetTrainerName(textStart, multiplayerId, gBattlerAttacker)); nameLength = 0;
while (classString[classLength] != EOS)
{
textStart[classLength] = classString[classLength];
classLength++;
}
textStart[classLength] = CHAR_SPACE;
textStart += 1 + classLength;
nameString = BattleStringGetTrainerName(textStart, multiplayerId, gBattlerAttacker);
if (nameString != textStart)
{
while (nameString[nameLength] != EOS)
{
textStart[nameLength] = nameString[nameLength];
nameLength++;
}
textStart[nameLength] = EOS;
}
} }
break; break;
case B_TXT_ATK_TEAM1: case B_TXT_ATK_TEAM1: