summaryrefslogtreecommitdiff
path: root/src/link_rfu_2.c
diff options
context:
space:
mode:
authoraaaaaa123456789 <aaaaaa123456789@acidch.at>2020-09-13 04:22:50 -0300
committeraaaaaa123456789 <aaaaaa123456789@acidch.at>2020-09-13 06:30:55 -0300
commit7dc95a0103af08c95c9093b6efa6c77af77a2538 (patch)
tree663537916626ab264bbdef4ea3606415457c36a3 /src/link_rfu_2.c
parent58a2b62bae1406d2c768698ed13efcd6a5ffbeec (diff)
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some harmless or completely superseded PRs have been left alone, as there is not much benefit in attempting to undo them. Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136, #1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179, #1180, #1181, #1182 and #1183.
Diffstat (limited to 'src/link_rfu_2.c')
-rw-r--r--src/link_rfu_2.c81
1 files changed, 45 insertions, 36 deletions
diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c
index 41b28ec5f..6a2605c96 100644
--- a/src/link_rfu_2.c
+++ b/src/link_rfu_2.c
@@ -876,7 +876,8 @@ static void sub_800F498(u16 *a0, u8 *a1)
static bool32 RfuProcessEnqueuedRecvBlock(void)
{
- u8 i, j;
+ u8 i;
+ u8 j;
u8 sp00[MAX_RFU_PLAYERS * (2 * (CMD_LENGTH - 1))];
u8 sp48[2 * (CMD_LENGTH - 1)];
u8 status;
@@ -922,7 +923,7 @@ static bool32 RfuProcessEnqueuedRecvBlock(void)
static void HandleSendFailure(u8 unused, u32 flags)
{
- s32 i, j, temp;
+ s32 i, j;
const u8 *r10 = Rfu.sendBlock.payload;
for (i = 0; i < Rfu.sendBlock.count; i++)
@@ -932,15 +933,14 @@ static void HandleSendFailure(u8 unused, u32 flags)
sResendBlock16[0] = RFUCMD_0x8900 | i;
for (j = 0; j < 7; j++)
{
- temp = j << 1;
- sResendBlock16[j + 1] = (r10[i * 12 + temp + 1] << 8) | r10[i * 12 + temp];
+ sResendBlock16[j + 1] = (r10[12 * i + (j << 1) + 1] << 8) | r10[12 * i + (j << 1) + 0];
}
-
for (j = 0; j < 7; j++)
{
- temp = j << 1;
- sResendBlock8[temp + 1] = sResendBlock16[j] >> 8;
- sResendBlock8[temp + 0] = sResendBlock16[j] & 0xff;
+ sResendBlock8[2 * j + 1] = sResendBlock16[j] >> 8;
+ sResendBlock8[2 * j + 0] = sResendBlock16[j];
+
+ j++;j--; // Needed to match;
}
RfuSendQueue_Enqueue(&Rfu.sendQueue, sResendBlock8);
Rfu.sendBlock.failedFlags |= (1 << i);
@@ -1024,7 +1024,8 @@ void Rfu_SetBerryBlenderLinkCallback(void)
static void RfuHandleReceiveCommand(u8 unused)
{
- u16 i, j;
+ u16 i;
+ u16 j;
for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
@@ -1038,7 +1039,7 @@ static void RfuHandleReceiveCommand(u8 unused)
if (gRfuLinkStatus->parentChild == MODE_CHILD)
{
Rfu.playerCount = gRecvCmds[i][1];
- Rfu.multiplayerId = sub_800F74C((u8 *)(&gRecvCmds[i][2]));
+ Rfu.multiplayerId = sub_800F74C((u8 *)(gRecvCmds[i] + 2));
}
break;
case RFUCMD_0x8800:
@@ -1237,9 +1238,10 @@ void Rfu_SendPacket(void *data)
bool32 Rfu_InitBlockSend(const u8 *src, size_t size)
{
bool8 r4;
- if (Rfu.callback != NULL || gSendCmd[0] != 0)
+ if (Rfu.callback != NULL)
+ return FALSE;
+ if (gSendCmd[0] != 0)
return FALSE;
-
if (Rfu.sendBlock.sending)
{
sRfuDebug.unk_83++;
@@ -1417,12 +1419,16 @@ void Rfu_SetCloseLinkCallback(void)
static void SendReadyExitStandbyUntilAllReady(void)
{
- u8 i, playerCount;
+ u8 playerCount;
+ u8 i;
- if (GetMultiplayerId() != 0 && Rfu.recvQueue.count == 0 && Rfu.resendExitStandbyTimer > 60)
+ if (GetMultiplayerId() != 0)
{
- RfuPrepareSendBuffer(RFUCMD_READY_EXIT_STANDBY);
- Rfu.resendExitStandbyTimer = 0;
+ if (Rfu.recvQueue.count == 0 && Rfu.resendExitStandbyTimer > 60)
+ {
+ RfuPrepareSendBuffer(RFUCMD_READY_EXIT_STANDBY);
+ Rfu.resendExitStandbyTimer = 0;
+ }
}
playerCount = GetLinkPlayerCount();
for (i = 0; i < playerCount; i++)
@@ -1452,7 +1458,8 @@ static void LinkLeaderReadyToExitStandby(void)
// RFU equivalent of LinkCB_Standby and LinkCB_StandbyForAll
static void Rfu_LinkStandby(void)
{
- u8 i, playerCount;
+ u8 i;
+ u8 playerCount;
if (GetMultiplayerId() != 0)
{
@@ -1548,28 +1555,28 @@ static bool8 CheckForLeavingGroupMembers(void)
bool8 memberLeft = FALSE;
for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (Rfu.partnerSendStatuses[i] == RFU_STATUS_JOIN_GROUP_OK
- || Rfu.partnerSendStatuses[i] == RFU_STATUS_JOIN_GROUP_NO)
- {
- continue;
- }
-
- if (gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS
- || gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN)
+ if (Rfu.partnerSendStatuses[i] < RFU_STATUS_JOIN_GROUP_OK
+ || Rfu.partnerSendStatuses[i] > RFU_STATUS_JOIN_GROUP_NO)
{
- if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_LEAVE_GROUP_NOTICE)
+ if (gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS
+ || gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN)
{
- Rfu.partnerSendStatuses[i] = RFU_STATUS_LEAVE_GROUP;
- Rfu.partnerRecvStatuses[i] = RFU_STATUS_10;
+ if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_LEAVE_GROUP_NOTICE)
+ {
+ Rfu.partnerSendStatuses[i] = RFU_STATUS_LEAVE_GROUP;
+ Rfu.partnerRecvStatuses[i] = RFU_STATUS_10;
+ rfu_clearSlot(TYPE_NI_RECV, i);
+ rfu_NI_setSendData(1 << i, 8, &Rfu.partnerSendStatuses[i], 1);
+ memberLeft = TRUE;
+ }
+
+ }
+ else if (gRfuSlotStatusNI[Rfu.childSlot]->recv.state == SLOT_STATE_RECV_FAILED)
rfu_clearSlot(TYPE_NI_RECV, i);
- rfu_NI_setSendData(1 << i, 8, &Rfu.partnerSendStatuses[i], 1);
- memberLeft = TRUE;
+ {
+
}
}
- else if (gRfuSlotStatusNI[Rfu.childSlot]->recv.state == SLOT_STATE_RECV_FAILED)
- {
- rfu_clearSlot(TYPE_NI_RECV, i);
- }
}
return memberLeft;
}
@@ -2044,7 +2051,8 @@ void sub_80110B8(u32 a0)
if ((r8 >> i) & 1)
{
child_sprite_genders |= ((0x80 | ((gLinkPlayers[Rfu.linkPlayerIdx[i]].gender & 1) << 3) | (gLinkPlayers[Rfu.linkPlayerIdx[i]].trainerId & 7)) << (numConnectedChildren << 3));
- if (++numConnectedChildren == a0 - 1)
+ numConnectedChildren++;
+ if (numConnectedChildren == a0 - 1)
break;
}
}
@@ -2089,7 +2097,8 @@ static void sub_80111FC(void)
static void sub_801120C(u8 msg, u8 paramCount)
{
- u8 i, disconnectFlag = 0;
+ u8 i;
+ u8 disconnectFlag = 0;
switch (msg)
{
case LMAN_MSG_INITIALIZE_COMPLETED: