Update argument names in link headers, link_rfu doc cleanup

This commit is contained in:
GriffinR 2021-10-07 15:32:51 -04:00
parent 846942ce48
commit e86d3410a1
6 changed files with 87 additions and 90 deletions

View File

@ -62,9 +62,9 @@ enum {
// Values for errorState // Values for errorState
enum { enum {
RFU_ERROR_STATE_NONE, RFU_ERROR_STATE_NONE,
RFU_ERROR_STATE_1, RFU_ERROR_STATE_OCCURRED,
RFU_ERROR_STATE_2, RFU_ERROR_STATE_PROCESSED,
RFU_ERROR_STATE_3, RFU_ERROR_STATE_DISCONNECTING,
RFU_ERROR_STATE_IGNORE, RFU_ERROR_STATE_IGNORE,
}; };
@ -247,8 +247,8 @@ extern u8 gWirelessStatusIndicatorSpriteId;
void WipeTrainerNameRecords(void); void WipeTrainerNameRecords(void);
void InitRFUAPI(void); void InitRFUAPI(void);
void LinkRfu_Shutdown(void); void LinkRfu_Shutdown(void);
void Rfu_SetBlockReceivedFlag(u8 who); void Rfu_SetBlockReceivedFlag(u8 linkPlayerId);
void Rfu_ResetBlockReceivedFlag(u8 who); void Rfu_ResetBlockReceivedFlag(u8 linkPlayerId);
bool32 IsSendingKeysToRfu(void); bool32 IsSendingKeysToRfu(void);
void StartSendingKeysToRfu(void); void StartSendingKeysToRfu(void);
void Rfu_SetBerryBlenderLinkCallback(void); void Rfu_SetBerryBlenderLinkCallback(void);
@ -278,9 +278,9 @@ void UpdateGameData_GroupLockedIn(u8 startedActivity);
void RfuSetErrorParams(u32 errorInfo); void RfuSetErrorParams(u32 errorInfo);
void RfuSetStatus(u8 status, u16 errorInfo); void RfuSetStatus(u8 status, u16 errorInfo);
u8 Rfu_SetLinkRecovery(bool32 enable); u8 Rfu_SetLinkRecovery(bool32 enable);
void CopyHostRfuGameDataAndUsername(struct RfuGameData *buff1, u8 *buff2); void CopyHostRfuGameDataAndUsername(struct RfuGameData *gameData, u8 *username);
void SetHostRfuGameData(u8 activity, u32 partnerInfo, bool32 startedActivity); void SetHostRfuGameData(u8 activity, u32 partnerInfo, bool32 startedActivity);
void InitializeRfuLinkManager_LinkLeader(u32 a0); void InitializeRfuLinkManager_LinkLeader(u32 groupMax);
bool32 IsRfuCommunicatingWithAllChildren(void); bool32 IsRfuCommunicatingWithAllChildren(void);
void LinkRfu_StopManagerAndFinalizeSlots(void); void LinkRfu_StopManagerAndFinalizeSlots(void);
bool32 RfuTryDisconnectLeavingChildren(void); bool32 RfuTryDisconnectLeavingChildren(void);
@ -296,21 +296,21 @@ void SendLeaveGroupNotice(void);
void RecordMixTrainerNames(void); void RecordMixTrainerNames(void);
void LinkRfu_CreateConnectionAsParent(void); void LinkRfu_CreateConnectionAsParent(void);
void LinkRfu_StopManagerBeforeEnteringChat(void); void LinkRfu_StopManagerBeforeEnteringChat(void);
void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 startedActivity); void UpdateGameData_SetActivity(u8 activity, u32 partnerInfo, bool32 startedActivity);
void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId); void CreateTask_RfuReconnectWithParent(const u8 *name, u16 trainerId);
void SetHostRfuWonderFlags(bool32 hasNews, bool32 hasCard); void SetHostRfuWonderFlags(bool32 hasNews, bool32 hasCard);
void ResetHostRfuGameData(void); void ResetHostRfuGameData(void);
void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level); void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level);
void InitializeRfuLinkManager_EnterUnionRoom(void); void InitializeRfuLinkManager_EnterUnionRoom(void);
void TryConnectToUnionRoomParent(const u8 *name, struct RfuGameData *structPtr, u8 a2); void TryConnectToUnionRoomParent(const u8 *name, struct RfuGameData *parent, u8 activity);
bool32 IsUnionRoomListenTaskActive(void); bool32 IsUnionRoomListenTaskActive(void);
void Rfu_SendPacket(void *data); void Rfu_SendPacket(void *data);
bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name);
void Rfu_DisconnectPlayerById(u32 playerIdx); void Rfu_DisconnectPlayerById(u32 playerIdx);
u8 GetLinkPlayerInfoFlags(s32 playerId); u8 GetLinkPlayerInfoFlags(s32 playerId);
void StopUnionRoomLinkManager(void); void StopUnionRoomLinkManager(void);
bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *player, u8 *username, u8 idx); bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *gameData, u8 *username, u8 idx);
bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *player, u8 *username, u8 idx); bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *gameData, u8 *username, u8 idx);
s32 Rfu_GetIndexOfNewestChild(u8 bits); s32 Rfu_GetIndexOfNewestChild(u8 bits);
void CreateTask_RfuIdle(void); void CreateTask_RfuIdle(void);
void DestroyTask_RfuIdle(void); void DestroyTask_RfuIdle(void);
@ -328,8 +328,8 @@ void RfuRecvQueue_Enqueue(struct RfuRecvQueue *queue, u8 *data);
void RfuSendQueue_Enqueue(struct RfuSendQueue *queue, u8 *data); void RfuSendQueue_Enqueue(struct RfuSendQueue *queue, u8 *data);
bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue *queue, u8 *dest); bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue *queue, u8 *dest);
bool8 RfuSendQueue_Dequeue(struct RfuSendQueue *queue, u8 *dest); bool8 RfuSendQueue_Dequeue(struct RfuSendQueue *queue, u8 *dest);
void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *q2); void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *data);
bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *q2); bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *src);
void InitHostRfuGameData(struct RfuGameData *data, u8 activity, bool32 startedActivity, s32 partnerInfo); void InitHostRfuGameData(struct RfuGameData *data, u8 activity, bool32 startedActivity, s32 partnerInfo);
void CreateWirelessStatusIndicatorSprite(u8 x, u8 y); void CreateWirelessStatusIndicatorSprite(u8 x, u8 y);
void DestroyWirelessStatusIndicatorSprite(void); void DestroyWirelessStatusIndicatorSprite(void);

View File

@ -32,8 +32,8 @@ struct RfuPlayer
u16 timeoutCounter; u16 timeoutCounter;
u8 groupScheduledAnim:2; u8 groupScheduledAnim:2;
bool8 useRedText:1; // Never set bool8 useRedText:1; // Never set
u8 field_1B; u8 newPlayerCountdown;
u8 filler[3]; u8 unused;
}; };
struct RfuPlayerList struct RfuPlayerList
@ -108,7 +108,7 @@ struct WirelessLink_URoom
struct RfuPlayerList *spawnPlayer; struct RfuPlayerList *spawnPlayer;
struct RfuIncomingPlayerList *incomingParentList; struct RfuIncomingPlayerList *incomingParentList;
u16 unknown; // Never read u16 unknown; // Never read
u16 field_12; u16 unreadPlayerId;
u8 state; u8 state;
u8 stateAfterPrint; u8 stateAfterPrint;
u8 textState; u8 textState;
@ -153,9 +153,9 @@ extern u8 gUnionRoomRequestedMonType;
u8 CreateTask_CreateTradeMenu(void); u8 CreateTask_CreateTradeMenu(void);
void SetUsingUnionRoomStartMenu(void); void SetUsingUnionRoomStartMenu(void);
void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0); void MEvent_CreateTask_CardOrNewsWithFriend(u32 activity);
void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0); void MEvent_CreateTask_CardOrNewsOverWireless(u32 activity);
void MEvent_CreateTask_Leader(u32 arg0); void MEvent_CreateTask_Leader(u32 activity);
u8 CreateTask_ListenToWireless(void); u8 CreateTask_ListenToWireless(void);
void StartUnionRoomBattle(u16 battleFlags); void StartUnionRoomBattle(u16 battleFlags);

View File

@ -3,12 +3,12 @@
u8 InitUnionRoomPlayerObjects(struct UnionRoomObject *players); u8 InitUnionRoomPlayerObjects(struct UnionRoomObject *players);
void DestroyUnionRoomPlayerObjects(void); void DestroyUnionRoomPlayerObjects(void);
void CreateUnionRoomPlayerSprites(u8 *spriteIds, s32 playerIdx); void CreateUnionRoomPlayerSprites(u8 *spriteIds, s32 leaderId);
void DestroyUnionRoomPlayerSprites(u8 *spriteIds); void DestroyUnionRoomPlayerSprites(u8 *spriteIds);
void SetTilesAroundUnionRoomPlayersPassable(void); void SetTilesAroundUnionRoomPlayersPassable(void);
void ScheduleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom); void ScheduleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom);
void HandleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom); void HandleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom);
bool32 TryInteractWithUnionRoomMember(struct RfuPlayerList *main0, s16 *directionPtr, s16 *playerIdxPtr, u8 *spriteIds); bool32 TryInteractWithUnionRoomMember(struct RfuPlayerList *list, s16 *memberIdPtr, s16 *leaderIdPtr, u8 *spriteIds);
void UpdateUnionRoomMemberFacing(u32 currDirection, u32 playerIdx, struct RfuPlayerList *main0); void UpdateUnionRoomMemberFacing(u32 memberId, u32 leaderId, struct RfuPlayerList *list);
#endif //GUARD_UNION_ROOM_PLAYER_AVATAR_H #endif //GUARD_UNION_ROOM_PLAYER_AVATAR_H

View File

@ -989,7 +989,7 @@ static u32 QuitBerryCrush(MainCallback exitCallback)
SetMainCallback2(exitCallback); \ SetMainCallback2(exitCallback); \
gRfu.errorParam0 = 0; \ gRfu.errorParam0 = 0; \
gRfu.errorParam1 = 0; \ gRfu.errorParam1 = 0; \
gRfu.errorState = RFU_ERROR_STATE_1; \ gRfu.errorState = RFU_ERROR_STATE_OCCURRED; \
} }
void StartBerryCrush(MainCallback exitCallback) void StartBerryCrush(MainCallback exitCallback)

View File

@ -27,7 +27,7 @@ enum {
RFUSTATE_STOP_MANAGER_END, RFUSTATE_STOP_MANAGER_END,
RFUSTATE_CHILD_CONNECT, RFUSTATE_CHILD_CONNECT,
RFUSTATE_CHILD_CONNECT_END, RFUSTATE_CHILD_CONNECT_END,
RFUSTATE_8, // Unused RFUSTATE_UNUSED,
RFUSTATE_RECONNECTED, RFUSTATE_RECONNECTED,
RFUSTATE_CONNECTED, RFUSTATE_CONNECTED,
RFUSTATE_CHILD_TRY_JOIN, RFUSTATE_CHILD_TRY_JOIN,
@ -39,9 +39,6 @@ enum {
}; };
// These states are used for different purposes // These states are used for different purposes
// depending on the link mode (parent, child, union room) // depending on the link mode (parent, child, union room)
#define RFUSTATE_17 17
#define RFUSTATE_PARENT_RECONNECT 18
#define RFUSTATE_PARENT_FINALIZE_START 17 #define RFUSTATE_PARENT_FINALIZE_START 17
#define RFUSTATE_PARENT_FINALIZE 18 #define RFUSTATE_PARENT_FINALIZE 18
#define RFUSTATE_UR_CONNECT 17 #define RFUSTATE_UR_CONNECT 17
@ -1443,7 +1440,7 @@ static void WaitAllReadyToCloseLink(void)
gBattleTypeFlags &= ~BATTLE_TYPE_LINK_IN_BATTLE; gBattleTypeFlags &= ~BATTLE_TYPE_LINK_IN_BATTLE;
if (gRfu.parentChild == MODE_CHILD) if (gRfu.parentChild == MODE_CHILD)
{ {
gRfu.errorState = RFU_ERROR_STATE_3; gRfu.errorState = RFU_ERROR_STATE_DISCONNECTING;
TryDisconnectRfu(); TryDisconnectRfu();
} }
else else
@ -1982,14 +1979,14 @@ static void Task_PlayerExchangeChat(u8 taskId)
static void RfuCheckErrorStatus(void) static void RfuCheckErrorStatus(void)
{ {
if (gRfu.errorState == RFU_ERROR_STATE_1 && lman.childClockSlave_flag == 0) if (gRfu.errorState == RFU_ERROR_STATE_OCCURRED && lman.childClockSlave_flag == 0)
{ {
if (gMain.callback2 == c2_mystery_gift_e_reader_run || lman.init_param->mboot_flag) if (gMain.callback2 == c2_mystery_gift_e_reader_run || lman.init_param->mboot_flag)
gWirelessCommType = 2; gWirelessCommType = 2;
SetMainCallback2(CB2_LinkError); SetMainCallback2(CB2_LinkError);
gMain.savedCallback = CB2_LinkError; gMain.savedCallback = CB2_LinkError;
SetLinkErrorBuffer((gRfu.errorInfo << 16) | (gRfu.errorParam0 << 8) | gRfu.errorParam1, gRfu.recvQueue.count, gRfu.sendQueue.count, RfuGetStatus() == RFU_STATUS_CONNECTION_ERROR); SetLinkErrorBuffer((gRfu.errorInfo << 16) | (gRfu.errorParam0 << 8) | gRfu.errorParam1, gRfu.recvQueue.count, gRfu.sendQueue.count, RfuGetStatus() == RFU_STATUS_CONNECTION_ERROR);
gRfu.errorState = RFU_ERROR_STATE_2; gRfu.errorState = RFU_ERROR_STATE_PROCESSED;
CloseLink(); CloseLink();
} }
else if (gRfu.sendQueue.full == TRUE || gRfu.recvQueue.full == TRUE) else if (gRfu.sendQueue.full == TRUE || gRfu.recvQueue.full == TRUE)
@ -2100,10 +2097,10 @@ void UpdateGameData_GroupLockedIn(bool8 startedActivity)
rfu_REQ_configGameData(0, RFU_SERIAL_GAME, (void *)&gHostRfuGameData, gHostRfuUsername); rfu_REQ_configGameData(0, RFU_SERIAL_GAME, (void *)&gHostRfuGameData, gHostRfuUsername);
} }
void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 startedActivity) void UpdateGameData_SetActivity(u8 activity, u32 partnerInfo, bool32 startedActivity)
{ {
if (activity != ACTIVITY_NONE) if (activity != ACTIVITY_NONE)
SetHostRfuGameData(activity, flags, startedActivity); SetHostRfuGameData(activity, partnerInfo, startedActivity);
rfu_REQ_configGameData(0, RFU_SERIAL_GAME, (void *)&gHostRfuGameData, gHostRfuUsername); rfu_REQ_configGameData(0, RFU_SERIAL_GAME, (void *)&gHostRfuGameData, gHostRfuUsername);
} }
@ -2144,7 +2141,7 @@ void RfuSetErrorParams(u32 errorInfo)
gRfu.errorParam0 = lman.param[0]; gRfu.errorParam0 = lman.param[0];
gRfu.errorParam1 = lman.param[1]; gRfu.errorParam1 = lman.param[1];
gRfu.errorInfo = errorInfo; gRfu.errorInfo = errorInfo;
gRfu.errorState = RFU_ERROR_STATE_1; gRfu.errorState = RFU_ERROR_STATE_OCCURRED;
} }
} }
@ -2370,7 +2367,7 @@ static void LinkManagerCB_UnionRoom(u8 msg, u8 paramCount)
switch (msg) switch (msg)
{ {
case LMAN_MSG_INITIALIZE_COMPLETED: case LMAN_MSG_INITIALIZE_COMPLETED:
gRfu.state = RFUSTATE_17; gRfu.state = RFUSTATE_UR_CONNECT;
break; break;
case LMAN_MSG_NEW_CHILD_CONNECT_DETECTED: case LMAN_MSG_NEW_CHILD_CONNECT_DETECTED:
RfuSetStatus(RFU_STATUS_NEW_CHILD_DETECTED, 0); RfuSetStatus(RFU_STATUS_NEW_CHILD_DETECTED, 0);
@ -2430,7 +2427,7 @@ static void LinkManagerCB_UnionRoom(u8 msg, u8 paramCount)
gRfu.childSlot = lman.param[0]; gRfu.childSlot = lman.param[0];
break; break;
case LMAN_MSG_CONNECT_PARENT_FAILED: case LMAN_MSG_CONNECT_PARENT_FAILED:
gRfu.state = RFUSTATE_PARENT_RECONNECT; gRfu.state = RFUSTATE_UR_CONNECT_END;
if (gRfu.connectParentFailures < 2) if (gRfu.connectParentFailures < 2)
{ {
gRfu.connectParentFailures++; gRfu.connectParentFailures++;
@ -2483,7 +2480,7 @@ static void LinkManagerCB_UnionRoom(u8 msg, u8 paramCount)
if (gRfuLinkStatus->parentChild == MODE_NEUTRAL if (gRfuLinkStatus->parentChild == MODE_NEUTRAL
&& !lman.pcswitch_flag && !lman.pcswitch_flag
&& FuncIsActiveTask(Task_UnionRoomListen) == TRUE) && FuncIsActiveTask(Task_UnionRoomListen) == TRUE)
gRfu.state = RFUSTATE_17; gRfu.state = RFUSTATE_UR_CONNECT;
RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, msg); RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, msg);
break; break;
@ -2617,13 +2614,13 @@ static void CB2_RfuIdle(void)
UpdatePaletteFade(); UpdatePaletteFade();
} }
void InitializeRfuLinkManager_LinkLeader(u32 a0) void InitializeRfuLinkManager_LinkLeader(u32 groupMax)
{ {
gRfu.parentChild = MODE_PARENT; gRfu.parentChild = MODE_PARENT;
SetHostRfuUsername(); SetHostRfuUsername();
rfu_LMAN_initializeManager(LinkManagerCB_Parent, NULL); rfu_LMAN_initializeManager(LinkManagerCB_Parent, NULL);
sRfuReqConfig = sRfuReqConfigTemplate; sRfuReqConfig = sRfuReqConfigTemplate;
sRfuReqConfig.availSlot_flag = sAvailSlots[a0 - 1]; sRfuReqConfig.availSlot_flag = sAvailSlots[groupMax - 1];
CreateTask_ParentSearchForChildren(); CreateTask_ParentSearchForChildren();
} }

View File

@ -187,11 +187,11 @@ enum {
// Return values for HandlePlayerListUpdate // Return values for HandlePlayerListUpdate
enum { enum {
PLIST_0, PLIST_NONE,
PLIST_1, PLIST_NEW_PLAYER,
PLIST_2, PLIST_RECENT_UPDATE,
PLIST_3, PLIST_UNUSED,
PLIST_4, PLIST_CONTACTED,
}; };
static EWRAM_DATA u8 sUnionRoomPlayerName[12] = {}; static EWRAM_DATA u8 sUnionRoomPlayerName[12] = {};
@ -414,7 +414,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId)
data->playerList->players[0].timeoutCounter = 0; data->playerList->players[0].timeoutCounter = 0;
data->playerList->players[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN; data->playerList->players[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
data->playerList->players[0].useRedText = FALSE; data->playerList->players[0].useRedText = FALSE;
data->playerList->players[0].field_1B = 0; data->playerList->players[0].newPlayerCountdown = 0;
data->listenTaskId = CreateTask_ListenForCompatiblePartners(data->incomingPlayerList, 0xFF); data->listenTaskId = CreateTask_ListenForCompatiblePartners(data->incomingPlayerList, 0xFF);
data->bButtonCancelWindowId = AddWindow(&sWindowTemplate_BButtonCancel); data->bButtonCancelWindowId = AddWindow(&sWindowTemplate_BButtonCancel);
switch (GROUP_MAX(sPlayerActivityGroupSize)) switch (GROUP_MAX(sPlayerActivityGroupSize))
@ -559,7 +559,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId)
{ {
if (data->joinRequestAnswer == RFU_STATUS_JOIN_GROUP_OK) if (data->joinRequestAnswer == RFU_STATUS_JOIN_GROUP_OK)
{ {
data->playerList->players[data->playerCount].field_1B = 0; data->playerList->players[data->playerCount].newPlayerCountdown = 0;
RedrawListMenu(data->listTaskId); RedrawListMenu(data->listTaskId);
data->playerCount++; data->playerCount++;
if (data->playerCount == GROUP_MAX(sPlayerActivityGroupSize)) if (data->playerCount == GROUP_MAX(sPlayerActivityGroupSize))
@ -867,7 +867,7 @@ static void ItemPrintFunc_PossibleGroupMembers(u8 windowId, u32 id, u8 y)
switch (data->playerList->players[id].groupScheduledAnim) switch (data->playerList->players[id].groupScheduledAnim)
{ {
case UNION_ROOM_SPAWN_IN: case UNION_ROOM_SPAWN_IN:
if (data->playerList->players[id].field_1B != 0) if (data->playerList->players[id].newPlayerCountdown != 0)
colorIdx = UR_COLOR_GREEN; colorIdx = UR_COLOR_GREEN;
break; break;
case UNION_ROOM_SPAWN_OUT: case UNION_ROOM_SPAWN_OUT:
@ -913,7 +913,7 @@ static u8 LeaderUpdateGroupMembership(struct RfuPlayerList *list)
{ {
for (id = 0; id < MAX_RFU_PLAYERS; id++) for (id = 0; id < MAX_RFU_PLAYERS; id++)
{ {
if (data->playerList->players[id].field_1B != 0) if (data->playerList->players[id].newPlayerCountdown != 0)
ret = UNION_ROOM_SPAWN_IN; ret = UNION_ROOM_SPAWN_IN;
} }
} }
@ -948,14 +948,14 @@ static u8 LeaderPrunePlayerList(struct RfuPlayerList *list)
data->playerList->players[copiedCount].timeoutCounter = 0; data->playerList->players[copiedCount].timeoutCounter = 0;
data->playerList->players[copiedCount].groupScheduledAnim = UNION_ROOM_SPAWN_NONE; data->playerList->players[copiedCount].groupScheduledAnim = UNION_ROOM_SPAWN_NONE;
data->playerList->players[copiedCount].useRedText = FALSE; data->playerList->players[copiedCount].useRedText = FALSE;
data->playerList->players[copiedCount].field_1B = 0; data->playerList->players[copiedCount].newPlayerCountdown = 0;
} }
for (i = 0; i < MAX_RFU_PLAYERS; i++) for (i = 0; i < MAX_RFU_PLAYERS; i++)
{ {
if (data->playerList->players[i].groupScheduledAnim != UNION_ROOM_SPAWN_IN) if (data->playerList->players[i].groupScheduledAnim != UNION_ROOM_SPAWN_IN)
continue; continue;
if (data->playerList->players[i].field_1B != 64) if (data->playerList->players[i].newPlayerCountdown != 64)
continue; continue;
playerCount = i; playerCount = i;
@ -1382,7 +1382,7 @@ static u8 GetGroupListTextColor(struct WirelessLink_Group *data, u32 id)
return UR_COLOR_WHITE; return UR_COLOR_WHITE;
else if (data->playerList->players[id].useRedText) else if (data->playerList->players[id].useRedText)
return UR_COLOR_RED; return UR_COLOR_RED;
else if (data->playerList->players[id].field_1B != 0) else if (data->playerList->players[id].newPlayerCountdown != 0)
return UR_COLOR_GREEN; return UR_COLOR_GREEN;
} }
return UR_COLOR_DEFAULT; return UR_COLOR_DEFAULT;
@ -1415,15 +1415,15 @@ static u8 GetNewLeaderCandidate(void)
if (ArePlayerDataDifferent(&data->playerList->players[i].rfu, &data->incomingPlayerList->players[id].rfu)) if (ArePlayerDataDifferent(&data->playerList->players[i].rfu, &data->incomingPlayerList->players[id].rfu))
{ {
data->playerList->players[i].rfu = data->incomingPlayerList->players[id].rfu; data->playerList->players[i].rfu = data->incomingPlayerList->players[id].rfu;
data->playerList->players[i].field_1B = 64; data->playerList->players[i].newPlayerCountdown = 64;
ret = 1; ret = 1;
} }
else else
{ {
if (data->playerList->players[i].field_1B != 0) if (data->playerList->players[i].newPlayerCountdown != 0)
{ {
data->playerList->players[i].field_1B--; data->playerList->players[i].newPlayerCountdown--;
if (data->playerList->players[i].field_1B == 0) if (data->playerList->players[i].newPlayerCountdown == 0)
ret = 2; ret = 2;
} }
} }
@ -1431,7 +1431,7 @@ static u8 GetNewLeaderCandidate(void)
else else
{ {
data->playerList->players[i].groupScheduledAnim = UNION_ROOM_SPAWN_IN; data->playerList->players[i].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
data->playerList->players[i].field_1B = 64; data->playerList->players[i].newPlayerCountdown = 64;
ret = 1; ret = 1;
} }
@ -1899,7 +1899,7 @@ static void Task_MEvent_Leader(u8 taskId)
data->playerList->players[0].timeoutCounter = 0; data->playerList->players[0].timeoutCounter = 0;
data->playerList->players[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN; data->playerList->players[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
data->playerList->players[0].useRedText = FALSE; data->playerList->players[0].useRedText = FALSE;
data->playerList->players[0].field_1B = 0; data->playerList->players[0].newPlayerCountdown = 0;
data->listenTaskId = CreateTask_ListenForCompatiblePartners(data->incomingPlayerList, 0xFF); data->listenTaskId = CreateTask_ListenForCompatiblePartners(data->incomingPlayerList, 0xFF);
winTemplate = sWindowTemplate_PlayerList; winTemplate = sWindowTemplate_PlayerList;
@ -1949,7 +1949,7 @@ static void Task_MEvent_Leader(u8 taskId)
case 0: case 0:
LoadWirelessStatusIndicatorSpriteGfx(); LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(0, 0); CreateWirelessStatusIndicatorSprite(0, 0);
data->playerList->players[data->playerCount].field_1B = 0; data->playerList->players[data->playerCount].newPlayerCountdown = 0;
RedrawListMenu(data->listTaskId); RedrawListMenu(data->listTaskId);
data->joinRequestAnswer = RFU_STATUS_JOIN_GROUP_OK; data->joinRequestAnswer = RFU_STATUS_JOIN_GROUP_OK;
SendRfuStatusToPartner(data->joinRequestAnswer, ReadAsU16(data->playerList->players[data->playerCount].rfu.data.compatibility.playerTrainerId), data->playerList->players[data->playerCount].rfu.name); SendRfuStatusToPartner(data->joinRequestAnswer, ReadAsU16(data->playerList->players[data->playerCount].rfu.data.compatibility.playerTrainerId), data->playerList->players[data->playerCount].rfu.name);
@ -1969,7 +1969,7 @@ static void Task_MEvent_Leader(u8 taskId)
{ {
if (data->joinRequestAnswer == RFU_STATUS_JOIN_GROUP_OK) if (data->joinRequestAnswer == RFU_STATUS_JOIN_GROUP_OK)
{ {
data->playerList->players[data->playerCount].field_1B = 0; data->playerList->players[data->playerCount].newPlayerCountdown = 0;
RedrawListMenu(data->listTaskId); RedrawListMenu(data->listTaskId);
data->playerCount++; data->playerCount++;
CopyAndTranslatePlayerName(gStringVar1, &data->playerList->players[data->playerCount - 1]); CopyAndTranslatePlayerName(gStringVar1, &data->playerList->players[data->playerCount - 1]);
@ -2430,7 +2430,7 @@ void RunUnionRoom(void)
uroom->state = UR_STATE_INIT; uroom->state = UR_STATE_INIT;
uroom->textState = 0; uroom->textState = 0;
uroom->unknown = 0; uroom->unknown = 0;
uroom->field_12 = 0; uroom->unreadPlayerId = 0;
gSpecialVar_Result = 0; gSpecialVar_Result = 0;
ListMenuLoadStdPalAt(0xD0, 1); ListMenuLoadStdPalAt(0xD0, 1);
@ -2610,12 +2610,12 @@ static void Task_RunUnionRoom(u8 taskId)
switch (HandlePlayerListUpdate()) switch (HandlePlayerListUpdate())
{ {
case PLIST_1: case PLIST_NEW_PLAYER:
PlaySE(SE_PC_LOGIN); PlaySE(SE_PC_LOGIN);
case PLIST_2: case PLIST_RECENT_UPDATE:
ScheduleUnionRoomPlayerRefresh(uroom); ScheduleUnionRoomPlayerRefresh(uroom);
break; break;
case PLIST_4: case PLIST_CONTACTED:
uroom->state = UR_STATE_PLAYER_CONTACTED_YOU; uroom->state = UR_STATE_PLAYER_CONTACTED_YOU;
StartScriptInteraction(); StartScriptInteraction();
SetTradeBoardRegisteredMonInfo(TYPE_NORMAL, SPECIES_NONE, 0); SetTradeBoardRegisteredMonInfo(TYPE_NORMAL, SPECIES_NONE, 0);
@ -2643,7 +2643,7 @@ static void Task_RunUnionRoom(u8 taskId)
break; break;
case 1: // Link communicating case 1: // Link communicating
TryConnectToUnionRoomParent(uroom->playerList->players[taskData[1]].rfu.name, &uroom->playerList->players[taskData[1]].rfu.data, gPlayerCurrActivity); TryConnectToUnionRoomParent(uroom->playerList->players[taskData[1]].rfu.name, &uroom->playerList->players[taskData[1]].rfu.data, gPlayerCurrActivity);
uroom->field_12 = id; // Should be just 0, but won't match any other way. uroom->unreadPlayerId = id; // Should be just 0, but won't match any other way.
uroom->state = UR_STATE_TRY_COMMUNICATING; uroom->state = UR_STATE_TRY_COMMUNICATING;
break; break;
case 2: // Ask to join chat case 2: // Ask to join chat
@ -2833,7 +2833,7 @@ static void Task_RunUnionRoom(u8 taskId)
gPlayerCurrActivity = ACTIVITY_CHAT | IN_UNION_ROOM; gPlayerCurrActivity = ACTIVITY_CHAT | IN_UNION_ROOM;
UpdateGameData_SetActivity(ACTIVITY_CHAT | IN_UNION_ROOM, 0, TRUE); UpdateGameData_SetActivity(ACTIVITY_CHAT | IN_UNION_ROOM, 0, TRUE);
TryConnectToUnionRoomParent(uroom->playerList->players[taskData[1]].rfu.name, &uroom->playerList->players[taskData[1]].rfu.data, gPlayerCurrActivity); TryConnectToUnionRoomParent(uroom->playerList->players[taskData[1]].rfu.name, &uroom->playerList->players[taskData[1]].rfu.data, gPlayerCurrActivity);
uroom->field_12 = taskData[1]; uroom->unreadPlayerId = taskData[1];
uroom->state = UR_STATE_TRY_ACCEPT_CHAT_REQUEST_DELAY; uroom->state = UR_STATE_TRY_ACCEPT_CHAT_REQUEST_DELAY;
taskData[3] = 0; taskData[3] = 0;
break; break;
@ -2942,7 +2942,7 @@ static void Task_RunUnionRoom(u8 taskId)
else else
UpdateGameData_SetActivity(gPlayerCurrActivity | IN_UNION_ROOM, GetLinkPlayerInfoFlags(1), TRUE); UpdateGameData_SetActivity(gPlayerCurrActivity | IN_UNION_ROOM, GetLinkPlayerInfoFlags(1), TRUE);
uroom->spawnPlayer->players[0].field_1B = 0; uroom->spawnPlayer->players[0].newPlayerCountdown = 0;
taskData[3] = 0; taskData[3] = 0;
if (gPlayerCurrActivity == (ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM)) if (gPlayerCurrActivity == (ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM))
{ {
@ -3298,7 +3298,7 @@ void InitUnionRoom(void)
data->state = 0; data->state = 0;
data->textState = 0; data->textState = 0;
data->unknown = 0; data->unknown = 0;
data->field_12 = 0; data->unreadPlayerId = 0;
sUnionRoomPlayerName[0] = EOS; sUnionRoomPlayerName[0] = EOS;
} }
@ -3336,8 +3336,8 @@ static void Task_InitUnionRoom(u8 taskId)
case 3: case 3:
switch (HandlePlayerListUpdate()) switch (HandlePlayerListUpdate())
{ {
case PLIST_1: case PLIST_NEW_PLAYER:
case PLIST_2: case PLIST_RECENT_UPDATE:
if (sUnionRoomPlayerName[0] == EOS) if (sUnionRoomPlayerName[0] == EOS)
{ {
for (i = 0; i < MAX_UNION_ROOM_LEADERS; i++) for (i = 0; i < MAX_UNION_ROOM_LEADERS; i++)
@ -3354,7 +3354,7 @@ static void Task_InitUnionRoom(u8 taskId)
} }
} }
break; break;
case PLIST_3: case PLIST_UNUSED:
break; break;
} }
break; break;
@ -3390,7 +3390,7 @@ static u8 HandlePlayerListUpdate(void)
s32 i; s32 i;
u8 j; u8 j;
struct WirelessLink_URoom *data = sWirelessLinkMain.uRoom; struct WirelessLink_URoom *data = sWirelessLinkMain.uRoom;
s32 retVal = PLIST_0; s32 retVal = PLIST_NONE;
for (i = 0; i < RFU_CHILD_MAX; i++) for (i = 0; i < RFU_CHILD_MAX; i++)
{ {
@ -3399,8 +3399,8 @@ static u8 HandlePlayerListUpdate(void)
data->spawnPlayer->players[0].rfu = data->incomingParentList->players[i].rfu; data->spawnPlayer->players[0].rfu = data->incomingParentList->players[i].rfu;
data->spawnPlayer->players[0].timeoutCounter = 0; data->spawnPlayer->players[0].timeoutCounter = 0;
data->spawnPlayer->players[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN; data->spawnPlayer->players[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
data->spawnPlayer->players[0].field_1B = 1; data->spawnPlayer->players[0].newPlayerCountdown = 1;
return PLIST_4; return PLIST_CONTACTED;
} }
} }
for (j = 0; j < MAX_UNION_ROOM_LEADERS; j++) for (j = 0; j < MAX_UNION_ROOM_LEADERS; j++)
@ -3415,21 +3415,21 @@ static u8 HandlePlayerListUpdate(void)
if (ArePlayerDataDifferent(&data->playerList->players[j].rfu, &data->incomingChildList->players[i].rfu)) if (ArePlayerDataDifferent(&data->playerList->players[j].rfu, &data->incomingChildList->players[i].rfu))
{ {
data->playerList->players[j].rfu = data->incomingChildList->players[i].rfu; data->playerList->players[j].rfu = data->incomingChildList->players[i].rfu;
data->playerList->players[j].field_1B = 64; data->playerList->players[j].newPlayerCountdown = 64;
retVal = PLIST_1; retVal = PLIST_NEW_PLAYER;
} }
else if (data->playerList->players[j].field_1B != 0) else if (data->playerList->players[j].newPlayerCountdown != 0)
{ {
data->playerList->players[j].field_1B--; data->playerList->players[j].newPlayerCountdown--;
if (data->playerList->players[j].field_1B == 0) if (data->playerList->players[j].newPlayerCountdown == 0)
retVal = PLIST_2; retVal = PLIST_RECENT_UPDATE;
} }
} }
else else
{ {
data->playerList->players[j].groupScheduledAnim = UNION_ROOM_SPAWN_IN; data->playerList->players[j].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
data->playerList->players[j].field_1B = 0; data->playerList->players[j].newPlayerCountdown = 0;
retVal = PLIST_2; retVal = PLIST_RECENT_UPDATE;
} }
data->playerList->players[j].timeoutCounter = 0; data->playerList->players[j].timeoutCounter = 0;
} }
@ -3439,7 +3439,7 @@ static u8 HandlePlayerListUpdate(void)
if (data->playerList->players[j].timeoutCounter >= 600) if (data->playerList->players[j].timeoutCounter >= 600)
{ {
data->playerList->players[j].groupScheduledAnim = UNION_ROOM_SPAWN_OUT; data->playerList->players[j].groupScheduledAnim = UNION_ROOM_SPAWN_OUT;
retVal = PLIST_2; retVal = PLIST_RECENT_UPDATE;
} }
} }
else if (data->playerList->players[j].groupScheduledAnim == UNION_ROOM_SPAWN_OUT) else if (data->playerList->players[j].groupScheduledAnim == UNION_ROOM_SPAWN_OUT)
@ -3452,7 +3452,7 @@ static u8 HandlePlayerListUpdate(void)
} }
for (i = 0; i < RFU_CHILD_MAX; i++) for (i = 0; i < RFU_CHILD_MAX; i++)
if (TryAddIncomingPlayerToList(&data->playerList->players[0], &data->incomingChildList->players[i], MAX_UNION_ROOM_LEADERS) != 0xFF) if (TryAddIncomingPlayerToList(&data->playerList->players[0], &data->incomingChildList->players[i], MAX_UNION_ROOM_LEADERS) != 0xFF)
retVal = PLIST_1; retVal = PLIST_NEW_PLAYER;
return retVal; return retVal;
} }
@ -3858,7 +3858,7 @@ static void ClearRfuPlayerList(struct RfuPlayer *players, u8 count)
players[i].timeoutCounter = 255; players[i].timeoutCounter = 255;
players[i].groupScheduledAnim = UNION_ROOM_SPAWN_NONE; players[i].groupScheduledAnim = UNION_ROOM_SPAWN_NONE;
players[i].useRedText = FALSE; players[i].useRedText = FALSE;
players[i].field_1B = 0; players[i].newPlayerCountdown = 0;
} }
} }
@ -3948,7 +3948,7 @@ static u8 TryAddIncomingPlayerToList(struct RfuPlayer *players, struct RfuIncomi
players[i].rfu = incomingPlayer->rfu; players[i].rfu = incomingPlayer->rfu;
players[i].timeoutCounter = 0; players[i].timeoutCounter = 0;
players[i].groupScheduledAnim = UNION_ROOM_SPAWN_IN; players[i].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
players[i].field_1B = 64; players[i].newPlayerCountdown = 64;
incomingPlayer->active = FALSE; incomingPlayer->active = FALSE;
return i; return i;
} }