Resolve link comm buffers in gBattleStruct
This commit is contained in:
parent
665dffe048
commit
e32a1571af
2 changed files with 29 additions and 21 deletions
|
@ -344,6 +344,15 @@ struct BattleTvMovePoints
|
||||||
s16 points[2][PARTY_SIZE * 4];
|
s16 points[2][PARTY_SIZE * 4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MultiPartnerEnigmaBerry
|
||||||
|
{
|
||||||
|
u8 field_0;
|
||||||
|
u8 field_1;
|
||||||
|
u8 vsScreenHealthFlagsLo;
|
||||||
|
u8 vsScreenHealthFlagsHi;
|
||||||
|
struct BattleEnigmaBerry battleEnigmaBerry;
|
||||||
|
};
|
||||||
|
|
||||||
struct BattleStruct
|
struct BattleStruct
|
||||||
{
|
{
|
||||||
u8 turnEffectsTracker;
|
u8 turnEffectsTracker;
|
||||||
|
@ -419,11 +428,10 @@ struct BattleStruct
|
||||||
u8 givenExpMons; // Bits for enemy party's pokemon that gave exp to player's party.
|
u8 givenExpMons; // Bits for enemy party's pokemon that gave exp to player's party.
|
||||||
u8 lastTakenMoveFrom[MAX_BATTLERS_COUNT * MAX_BATTLERS_COUNT * 2]; // a 3-D array [target][attacker][byte]
|
u8 lastTakenMoveFrom[MAX_BATTLERS_COUNT * MAX_BATTLERS_COUNT * 2]; // a 3-D array [target][attacker][byte]
|
||||||
u16 castformPalette[MAX_BATTLERS_COUNT][16];
|
u16 castformPalette[MAX_BATTLERS_COUNT][16];
|
||||||
u8 field_180; // weird field, used in battle_main.c, once accessed as an array of u32 overwriting the field below
|
union {
|
||||||
u8 field_181;
|
struct MultiPartnerEnigmaBerry multiPartnerEnigmaBerry;
|
||||||
u8 vsScreenHealthFlagsLo;
|
u32 battleVideo[2];
|
||||||
u8 vsScreenHealthFlagsHi; // Last bit is 'has frontier pass'
|
} multiBuffer;
|
||||||
struct BattleEnigmaBerry battleEnigmaBerry;
|
|
||||||
u8 wishPerishSongState;
|
u8 wishPerishSongState;
|
||||||
u8 wishPerishSongBattlerId;
|
u8 wishPerishSongBattlerId;
|
||||||
bool8 overworldWeatherDone;
|
bool8 overworldWeatherDone;
|
||||||
|
|
|
@ -733,16 +733,16 @@ static void BufferPartyVsScreenHealth_AtStart(void)
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
BUFFER_PARTY_VS_SCREEN_STATUS(gPlayerParty, flags, i);
|
BUFFER_PARTY_VS_SCREEN_STATUS(gPlayerParty, flags, i);
|
||||||
gBattleStruct->vsScreenHealthFlagsLo = flags;
|
gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.vsScreenHealthFlagsLo = flags;
|
||||||
*(&gBattleStruct->vsScreenHealthFlagsHi) = flags >> 8;
|
*(&gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.vsScreenHealthFlagsHi) = flags >> 8;
|
||||||
gBattleStruct->vsScreenHealthFlagsHi |= FlagGet(FLAG_SYS_FRONTIER_PASS) << 7;
|
gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.vsScreenHealthFlagsHi |= FlagGet(FLAG_SYS_FRONTIER_PASS) << 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetPlayerBerryDataInBattleStruct(void)
|
static void SetPlayerBerryDataInBattleStruct(void)
|
||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
struct BattleStruct *battleStruct = gBattleStruct;
|
struct BattleStruct *battleStruct = gBattleStruct;
|
||||||
struct BattleEnigmaBerry *battleBerry = &battleStruct->battleEnigmaBerry;
|
struct BattleEnigmaBerry *battleBerry = &battleStruct->multiBuffer.multiPartnerEnigmaBerry.battleEnigmaBerry;
|
||||||
|
|
||||||
if (IsEnigmaBerryValid() == TRUE)
|
if (IsEnigmaBerryValid() == TRUE)
|
||||||
{
|
{
|
||||||
|
@ -970,8 +970,8 @@ static void CB2_HandleStartBattle(void)
|
||||||
{
|
{
|
||||||
if (IsLinkTaskFinished())
|
if (IsLinkTaskFinished())
|
||||||
{
|
{
|
||||||
*(&gBattleStruct->field_180) = 0;
|
*(&gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.field_0) = 0;
|
||||||
*(&gBattleStruct->field_181) = 3;
|
*(&gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.field_1) = 3;
|
||||||
BufferPartyVsScreenHealth_AtStart();
|
BufferPartyVsScreenHealth_AtStart();
|
||||||
SetPlayerBerryDataInBattleStruct();
|
SetPlayerBerryDataInBattleStruct();
|
||||||
|
|
||||||
|
@ -981,7 +981,7 @@ static void CB2_HandleStartBattle(void)
|
||||||
gLinkPlayers[1].id = 1;
|
gLinkPlayers[1].id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32);
|
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->multiBuffer.multiPartnerEnigmaBerry, sizeof(gBattleStruct->multiBuffer.multiPartnerEnigmaBerry));
|
||||||
gBattleCommunication[MULTIUSE_STATE] = 2;
|
gBattleCommunication[MULTIUSE_STATE] = 2;
|
||||||
}
|
}
|
||||||
if (gWirelessCommType)
|
if (gWirelessCommType)
|
||||||
|
@ -1008,7 +1008,7 @@ static void CB2_HandleStartBattle(void)
|
||||||
gTasks[taskId].data[1] = 0x10E;
|
gTasks[taskId].data[1] = 0x10E;
|
||||||
gTasks[taskId].data[2] = 0x5A;
|
gTasks[taskId].data[2] = 0x5A;
|
||||||
gTasks[taskId].data[5] = 0;
|
gTasks[taskId].data[5] = 0;
|
||||||
gTasks[taskId].data[3] = gBattleStruct->vsScreenHealthFlagsLo | (gBattleStruct->vsScreenHealthFlagsHi << 8);
|
gTasks[taskId].data[3] = gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.vsScreenHealthFlagsLo | (gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.vsScreenHealthFlagsHi << 8);
|
||||||
gTasks[taskId].data[4] = gBlockRecvBuffer[enemyMultiplayerId][1];
|
gTasks[taskId].data[4] = gBlockRecvBuffer[enemyMultiplayerId][1];
|
||||||
sub_8185F90(gBlockRecvBuffer[playerMultiplayerId][1]);
|
sub_8185F90(gBlockRecvBuffer[playerMultiplayerId][1]);
|
||||||
sub_8185F90(gBlockRecvBuffer[enemyMultiplayerId][1]);
|
sub_8185F90(gBlockRecvBuffer[enemyMultiplayerId][1]);
|
||||||
|
@ -1178,11 +1178,11 @@ static void CB2_HandleStartMultiPartnerBattle(void)
|
||||||
|
|
||||||
if (IsLinkTaskFinished())
|
if (IsLinkTaskFinished())
|
||||||
{
|
{
|
||||||
*(&gBattleStruct->field_180) = 0;
|
*(&gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.field_0) = 0;
|
||||||
*(&gBattleStruct->field_181) = 3;
|
*(&gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.field_1) = 3;
|
||||||
BufferPartyVsScreenHealth_AtStart();
|
BufferPartyVsScreenHealth_AtStart();
|
||||||
SetPlayerBerryDataInBattleStruct();
|
SetPlayerBerryDataInBattleStruct();
|
||||||
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32);
|
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->multiBuffer.multiPartnerEnigmaBerry, sizeof(gBattleStruct->multiBuffer.multiPartnerEnigmaBerry));
|
||||||
gBattleCommunication[MULTIUSE_STATE] = 2;
|
gBattleCommunication[MULTIUSE_STATE] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1565,12 +1565,12 @@ static void CB2_HandleStartMultiBattle(void)
|
||||||
{
|
{
|
||||||
if (IsLinkTaskFinished())
|
if (IsLinkTaskFinished())
|
||||||
{
|
{
|
||||||
*(&gBattleStruct->field_180) = 0;
|
*(&gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.field_0) = 0;
|
||||||
*(&gBattleStruct->field_181) = 3;
|
*(&gBattleStruct->multiBuffer.multiPartnerEnigmaBerry.field_1) = 3;
|
||||||
BufferPartyVsScreenHealth_AtStart();
|
BufferPartyVsScreenHealth_AtStart();
|
||||||
SetPlayerBerryDataInBattleStruct();
|
SetPlayerBerryDataInBattleStruct();
|
||||||
|
|
||||||
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32);
|
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->multiBuffer.multiPartnerEnigmaBerry, sizeof(gBattleStruct->multiBuffer.multiPartnerEnigmaBerry));
|
||||||
gBattleCommunication[MULTIUSE_STATE]++;
|
gBattleCommunication[MULTIUSE_STATE]++;
|
||||||
}
|
}
|
||||||
if (gWirelessCommType)
|
if (gWirelessCommType)
|
||||||
|
@ -1786,10 +1786,10 @@ static void CB2_HandleStartMultiBattle(void)
|
||||||
case 8:
|
case 8:
|
||||||
if (IsLinkTaskFinished())
|
if (IsLinkTaskFinished())
|
||||||
{
|
{
|
||||||
u32* ptr = (u32*)(&gBattleStruct->field_180);
|
u32* ptr = gBattleStruct->multiBuffer.battleVideo;
|
||||||
ptr[0] = gBattleTypeFlags;
|
ptr[0] = gBattleTypeFlags;
|
||||||
ptr[1] = gRecordedBattleRngSeed; // UB: overwrites berry data
|
ptr[1] = gRecordedBattleRngSeed; // UB: overwrites berry data
|
||||||
SendBlock(bitmask_all_link_players_but_self(), ptr, 8);
|
SendBlock(bitmask_all_link_players_but_self(), ptr, sizeof(gBattleStruct->multiBuffer.battleVideo));
|
||||||
gBattleCommunication[MULTIUSE_STATE]++;
|
gBattleCommunication[MULTIUSE_STATE]++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue