more fakematch fixing

This commit is contained in:
PokeCodec
2020-08-26 22:31:25 -04:00
parent 5054cff7e8
commit ab73820ce0
+23 -31
View File
@@ -923,7 +923,7 @@ static bool32 RfuProcessEnqueuedRecvBlock(void)
static void HandleSendFailure(u8 unused, u32 flags) static void HandleSendFailure(u8 unused, u32 flags)
{ {
s32 i, j; s32 i, j, temp;
const u8 *r10 = Rfu.sendBlock.payload; const u8 *r10 = Rfu.sendBlock.payload;
for (i = 0; i < Rfu.sendBlock.count; i++) for (i = 0; i < Rfu.sendBlock.count; i++)
@@ -933,14 +933,14 @@ static void HandleSendFailure(u8 unused, u32 flags)
sResendBlock16[0] = RFU_COMMAND_0x8900 | i; sResendBlock16[0] = RFU_COMMAND_0x8900 | i;
for (j = 0; j < 7; j++) for (j = 0; j < 7; j++)
{ {
sResendBlock16[j + 1] = (r10[12 * i + (j << 1) + 1] << 8) | r10[12 * i + (j << 1) + 0]; temp = j << 1;
sResendBlock16[j + 1] = (r10[i * 12 + temp + 1] << 8) | r10[i * 12 + temp];
} }
for (j = 0; j < 7; j++) for (j = 0; j < 7; j++)
{ {
sResendBlock8[2 * j + 1] = sResendBlock16[j] >> 8; temp = j << 1;
sResendBlock8[2 * j + 0] = sResendBlock16[j]; sResendBlock8[temp + 1] = sResendBlock16[j] >> 8;
sResendBlock8[temp + 0] = sResendBlock16[j]&0xff;
j++;j--; // Needed to match;
} }
RfuSendQueue_Enqueue(&Rfu.sendQueue, sResendBlock8); RfuSendQueue_Enqueue(&Rfu.sendQueue, sResendBlock8);
Rfu.sendBlock.failedFlags |= (1 << i); Rfu.sendBlock.failedFlags |= (1 << i);
@@ -1024,8 +1024,7 @@ void sub_800F850(void)
static void RfuHandleReceiveCommand(u8 unused) static void RfuHandleReceiveCommand(u8 unused)
{ {
u16 i; u16 i, j;
u16 j;
for (i = 0; i < MAX_RFU_PLAYERS; i++) for (i = 0; i < MAX_RFU_PLAYERS; i++)
{ {
@@ -1039,7 +1038,7 @@ static void RfuHandleReceiveCommand(u8 unused)
if (gRfuLinkStatus->parentChild == MODE_CHILD) if (gRfuLinkStatus->parentChild == MODE_CHILD)
{ {
Rfu.playerCount = gRecvCmds[i][1]; Rfu.playerCount = gRecvCmds[i][1];
Rfu.multiplayerId = sub_800F74C((u8 *)(gRecvCmds[i] + 2)); Rfu.multiplayerId = sub_800F74C((u8 *)(&gRecvCmds[i][2]));
} }
break; break;
case RFU_COMMAND_0x8800: case RFU_COMMAND_0x8800:
@@ -1238,10 +1237,9 @@ void sub_800FE50(void *a0)
bool32 Rfu_InitBlockSend(const u8 *src, size_t size) bool32 Rfu_InitBlockSend(const u8 *src, size_t size)
{ {
bool8 r4; bool8 r4;
if (Rfu.callback != NULL) if (Rfu.callback != NULL || gSendCmd[0] != 0)
return FALSE;
if (gSendCmd[0] != 0)
return FALSE; return FALSE;
if (Rfu.sendBlock.sending) if (Rfu.sendBlock.sending)
{ {
sRfuDebug.unk_83++; sRfuDebug.unk_83++;
@@ -1458,8 +1456,7 @@ static void LinkLeaderReadyToExitStandby(void)
// RFU equivalent of LinkCB_Standby and LinkCB_StandbyForAll // RFU equivalent of LinkCB_Standby and LinkCB_StandbyForAll
static void Rfu_LinkStandby(void) static void Rfu_LinkStandby(void)
{ {
u8 i; u8 i, playerCount;
u8 playerCount;
if (GetMultiplayerId() != 0) if (GetMultiplayerId() != 0)
{ {
@@ -1555,28 +1552,23 @@ static bool8 CheckForLeavingGroupMembers(void)
bool8 memberLeft = FALSE; bool8 memberLeft = FALSE;
for (i = 0; i < RFU_CHILD_MAX; i++) for (i = 0; i < RFU_CHILD_MAX; i++)
{ {
if (Rfu.partnerSendStatuses[i] < RFU_STATUS_JOIN_GROUP_OK if (Rfu.partnerSendStatuses[i] == RFU_STATUS_JOIN_GROUP_OK || Rfu.partnerSendStatuses[i] == RFU_STATUS_JOIN_GROUP_NO)
|| 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 (gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_LEAVE_GROUP_NOTICE)
|| gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN)
{ {
if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_LEAVE_GROUP_NOTICE) Rfu.partnerSendStatuses[i] = RFU_STATUS_LEAVE_GROUP;
{ Rfu.partnerRecvStatuses[i] = RFU_STATUS_10;
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_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; return memberLeft;
} }