Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion config/RMCP01/module/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,31 @@ ui/SectionAutogens.cpp:
SectionDirector.o:
.text start:0x001247CC end:0x00125B04

net/MiscPacketHandler.cpp:
.text start:0x00142E54 end:0x00145484
.bss start:0x00004870 end:0x00004878

net/NetManager.cpp:
.text start:0x00145770 end:0x00149E98
.data start:0x0000DD90 end:0x0000DDC8
.bss start:0x000049F8 end:0x00004A00
.bss start:0x00004878 end:0x00004A00

net/packets/ROOM.cpp:
.text start:0x0014A6D4 end:0x0014AFA0
.bss start:0x00004A00 end:0x00004A10

net/packets/EVENT.cpp:
.text start:0x0014B134 end:0x0014BD38
.bss start:0x00004A10 end:0x00004A18

net/packets/ITEM.cpp:
.text start:0x0014BD38 end:0x0014FAD8
.bss start:0x00004A18 end:0x00004A20

net/packets/SELECT.cpp:
.text start:0x0014FAD8 end:0x001523C4
.bss start:0x00004A20 end:0x00004A28

net/packets/USER.cpp:
.text start:0x001523C4 end:0x00152DE0
.bss start:0x00004A28 end:0x00004A30
Expand Down
48 changes: 24 additions & 24 deletions config/RMCP01/module/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7146,8 +7146,8 @@ fn_1_143854 = .text:0x00143854; // type:function size:0xB0
fn_1_143904 = .text:0x00143904; // type:function size:0x5C
fn_1_143960 = .text:0x00143960; // type:function size:0x64
fn_1_1439C4 = .text:0x001439C4; // type:function size:0x64
fn_1_143A28 = .text:0x00143A28; // type:function size:0x18
fn_1_143A40 = .text:0x00143A40; // type:function size:0x58
clearAidFromUnkBitfield__Q23Net17MiscPacketHandlerFUl = .text:0x00143A28; // type:function size:0x18
__ct__Q23Net17MiscPacketHandlerFv = .text:0x00143A40; // type:function size:0x58
fn_1_143A98 = .text:0x00143A98; // type:function size:0x40
fn_1_143AD8 = .text:0x00143AD8; // type:function size:0x40
fn_1_143B18 = .text:0x00143B18; // type:function size:0x58
Expand All @@ -7165,7 +7165,7 @@ fn_1_1443A4 = .text:0x001443A4; // type:function size:0xC
fn_1_1443B0 = .text:0x001443B0; // type:function size:0xAC
fn_1_14445C = .text:0x0014445C; // type:function size:0x10
MiscPacketHandler_isPlayerConnected = .text:0x0014446C; // type:function size:0x88 scope:global align:4
MiscPacketHandler_isPlayerLocal = .text:0x001444F4; // type:function size:0x70 scope:global align:4
isPlayerLocal__Q23Net17MiscPacketHandlerFUl = .text:0x001444F4; // type:function size:0x70 scope:global align:4
fn_1_144564 = .text:0x00144564; // type:function size:0x6C
fn_1_1445D0 = .text:0x001445D0; // type:function size:0xB0
fn_1_144680 = .text:0x00144680; // type:function size:0xCC
Expand All @@ -7189,8 +7189,8 @@ startWWVSSearch__Q23Net10NetManagerFUc = .text:0x00145E00; // type:function size
startRegionalVSSearch__Q23Net10NetManagerFUc = .text:0x00145EBC; // type:function size:0xBC
startWWBattleSearch__Q23Net10NetManagerFUc = .text:0x00145F78; // type:function size:0xBC
startRegionalBattleSearch__Q23Net10NetManagerFUc = .text:0x00146034; // type:function size:0xBC
fn_1_1460F0 = .text:0x001460F0; // type:function size:0x130
fn_1_146220 = .text:0x00146220; // type:function size:0x130
joinFriendPublicVS__Q23Net10NetManagerFUlUc = .text:0x001460F0; // type:function size:0x130
joinFriendPublicBT__Q23Net10NetManagerFUlUc = .text:0x00146220; // type:function size:0x130
joinFriendRoom__Q23Net10NetManagerFUlUc = .text:0x00146350; // type:function size:0xD4
createFriendRoom__Q23Net10NetManagerFUc = .text:0x00146424; // type:function size:0xC0
resetRH1andROOM__Q23Net10NetManagerFv = .text:0x001464E4; // type:function size:0x58
Expand All @@ -7204,7 +7204,7 @@ fn_1_146738 = .text:0x00146738; // type:function size:0x58
fn_1_146790 = .text:0x00146790; // type:function size:0x28
fn_1_1467B8 = .text:0x001467B8; // type:function size:0x134
fn_1_1468EC = .text:0x001468EC; // type:function size:0xCC
fn_1_1469B8 = .text:0x001469B8; // type:function size:0x30
resetFriendData__Q23Net10NetManagerFUl = .text:0x001469B8; // type:function size:0x30
isConnectionStateIdleOrInMM__Q23Net10NetManagerCFv = .text:0x001469E8; // type:function size:0xA8
isTaskThreadIdle__Q23Net10NetManagerFv = .text:0x00146A90; // type:function size:0x2C
isConnectionStateIdle__Q23Net10NetManagerCFv = .text:0x00146ABC; // type:function size:0x90
Expand All @@ -7222,8 +7222,8 @@ RKNetController_trySendNextRACEPacket = .text:0x00147A7C; // type:function size:
fn_1_147C30 = .text:0x00147C30; // type:function size:0xE0
fn_1_147D10 = .text:0x00147D10; // type:function size:0x7C
setConnectionState__Q23Net10NetManagerFQ33Net10NetManager15ConnectionState = .text:0x00147D8C; // type:function size:0x8
getConnectionState__Q23Net10NetManagerFv = .text:0x00147D94; // type:function size:0x84
RKNetController_handleError = .text:0x00147E18; // type:function size:0x160 scope:global align:4
getConnectionState__Q23Net10NetManagerCFv = .text:0x00147D94; // type:function size:0x84
handleError__Q23Net10NetManagerFv = .text:0x00147E18; // type:function size:0x160 scope:global align:4
alloc__Q23Net10NetManagerFUll = .text:0x00147F78; // type:function size:0x88
free__Q23Net10NetManagerFPv = .text:0x00148000; // type:function size:0x64
SOAlloc__Q23Net10NetManagerFUlUl = .text:0x00148064; // type:function size:0x80
Expand All @@ -7237,15 +7237,15 @@ fn_1_1483B4 = .text:0x001483B4; // type:function size:0xBC
fn_1_148470 = .text:0x00148470; // type:function size:0xB4
fn_1_148524 = .text:0x00148524; // type:function size:0x20
fn_1_148544 = .text:0x00148544; // type:function size:0x4
fn_1_148548 = .text:0x00148548; // type:function size:0x1C
updateDWCServersAsyncCallback__Q23Net10NetManagerFUlUlPQ23Net10NetManager = .text:0x00148548; // type:function size:0x1C
fn_1_148564 = .text:0x00148564; // type:function size:0x4
fn_1_148568 = .text:0x00148568; // type:function size:0xC
DWCSetBuddyFriendCallback__Q23Net10NetManagerFUlPQ23Net10NetManager = .text:0x00148568; // type:function size:0xC
fn_1_148574 = .text:0x00148574; // type:function size:0x68
fn_1_1485DC = .text:0x001485DC; // type:function size:0x20C
NetManager_connect = .text:0x001487E8; // type:function size:0x1A0 scope:global align:4
initMMInfos__Q23Net10NetManagerFv = .text:0x00148988; // type:function size:0xA4
fn_1_148A2C = .text:0x00148A2C; // type:function size:0x1A0
fn_1_148BCC = .text:0x00148BCC; // type:function size:0xC4
resetFriends__Q23Net10NetManagerFv = .text:0x00148BCC; // type:function size:0xC4
fn_1_148C90 = .text:0x00148C90; // type:function size:0x12C
fn_1_148DBC = .text:0x00148DBC; // type:function size:0x448
fn_1_149204 = .text:0x00149204; // type:function size:0x64
Expand All @@ -7254,10 +7254,10 @@ fn_1_1492CC = .text:0x001492CC; // type:function size:0x244
fn_1_149510 = .text:0x00149510; // type:function size:0x178
fn_1_149688 = .text:0x00149688; // type:function size:0x48
RKNetController_processRACEPacket = .text:0x001496D0; // type:function size:0x13C scope:global align:4
fn_1_14980C = .text:0x0014980C; // type:function size:0x160
fn_1_14996C = .text:0x0014996C; // type:function size:0x38
RKNetController_getLocalPlayerId = .text:0x001499A4; // type:function size:0x24C scope:global align:4
fn_1_149BF0 = .text:0x00149BF0; // type:function size:0x110
updateAidMapping__Q23Net10NetManagerFv = .text:0x0014980C; // type:function size:0x160
resetPlayerIdToAidMap__Q23Net10NetManagerFv = .text:0x0014996C; // type:function size:0x38
getLocalPlayerId__Q23Net10NetManagerFUl = .text:0x001499A4; // type:function size:0x24C scope:global align:4
getFriendJoinableStatus__Q23Net10NetManagerCFUl = .text:0x00149BF0; // type:function size:0x110
RKNetController_updateStatusData = .text:0x00149D00; // type:function size:0x198 scope:global align:4
fn_1_149E98 = .text:0x00149E98; // type:function size:0x60
fn_1_149EF8 = .text:0x00149EF8; // type:function size:0x60
Expand Down Expand Up @@ -7298,7 +7298,7 @@ fn_1_14B004 = .text:0x0014B004; // type:function size:0x54
fn_1_14B058 = .text:0x0014B058; // type:function size:0x44
fn_1_14B09C = .text:0x0014B09C; // type:function size:0x40
fn_1_14B0DC = .text:0x0014B0DC; // type:function size:0x58
fn_1_14B134 = .text:0x0014B134; // type:function size:0x118
createStaticInstance__Q23Net12EVENTHandlerFv = .text:0x0014B134; // type:function size:0x118
fn_1_14B24C = .text:0x0014B24C; // type:function size:0x40
fn_1_14B28C = .text:0x0014B28C; // type:function size:0xEC
fn_1_14B378 = .text:0x0014B378; // type:function size:0x4
Expand All @@ -7315,7 +7315,7 @@ fn_1_14BC98 = .text:0x0014BC98; // type:function size:0x2C
fn_1_14BCC4 = .text:0x0014BCC4; // type:function size:0x38
fn_1_14BCFC = .text:0x0014BCFC; // type:function size:0x14
fn_1_14BD10 = .text:0x0014BD10; // type:function size:0x28
ITEMHandler_getStaticInstance = .text:0x0014BD38; // type:function size:0x27C scope:global align:4
createStaticInstance__Q23Net11ITEMHandlerFv = .text:0x0014BD38; // type:function size:0x27C scope:global align:4
fn_1_14BFB4 = .text:0x0014BFB4; // type:function size:0x40
ITEMHandler_construct = .text:0x0014BFF4; // type:function size:0x23C scope:global align:4
fn_1_14C230 = .text:0x0014C230; // type:function size:0x4
Expand Down Expand Up @@ -7367,7 +7367,7 @@ fn_1_15009C = .text:0x0015009C; // type:function size:0x20
fn_1_1500BC = .text:0x001500BC; // type:function size:0x1C
fn_1_1500D8 = .text:0x001500D8; // type:function size:0x1C
fn_1_1500F4 = .text:0x001500F4; // type:function size:0x24
fn_1_150118 = .text:0x00150118; // type:function size:0x8
getPlayerIdToAidMapping__Q23Net13SELECTHandlerCFv = .text:0x00150118; // type:function size:0x8
fn_1_150120 = .text:0x00150120; // type:function size:0x50
fn_1_150170 = .text:0x00150170; // type:function size:0x50
fn_1_1501C0 = .text:0x001501C0; // type:function size:0x50
Expand Down Expand Up @@ -7447,7 +7447,7 @@ setPrepared__Q23Net18RACEHEADER1HandlerFv = .text:0x001538C8; // type:function s
reset__Q23Net18RACEHEADER1HandlerFv = .text:0x001538D4; // type:function size:0x14C
fn_1_153A20 = .text:0x00153A20; // type:function size:0x338
fn_1_153D58 = .text:0x00153D58; // type:function size:0xA4
fn_1_153DFC = .text:0x00153DFC; // type:function size:0x210
courseValid__Q23Net18RACEHEADER1HandlerFv = .text:0x00153DFC; // type:function size:0x210
fn_1_15400C = .text:0x0015400C; // type:function size:0x18
fn_1_154024 = .text:0x00154024; // type:function size:0x18
fn_1_15403C = .text:0x0015403C; // type:function size:0x15C
Expand All @@ -7457,7 +7457,7 @@ fn_1_154314 = .text:0x00154314; // type:function size:0x108
fn_1_15441C = .text:0x0015441C; // type:function size:0x174
fn_1_154590 = .text:0x00154590; // type:function size:0xF8
fn_1_154688 = .text:0x00154688; // type:function size:0xF8
fn_1_154780 = .text:0x00154780; // type:function size:0xF8
getPlayerIdToAidMapping__Q23Net18RACEHEADER1HandlerCFv = .text:0x00154780; // type:function size:0xF8
fn_1_154878 = .text:0x00154878; // type:function size:0x170
fn_1_1549E8 = .text:0x001549E8; // type:function size:0x164
fn_1_154B4C = .text:0x00154B4C; // type:function size:0xF8
Expand Down Expand Up @@ -24511,15 +24511,15 @@ lbl_1_bss_4854 = .bss:0x00004854; // type:object size:0x4
lbl_1_bss_4858 = .bss:0x00004858; // type:object size:0x8
lbl_1_bss_4860 = .bss:0x00004860; // type:object size:0x8
lbl_1_bss_4868 = .bss:0x00004868; // type:object size:0x8
lbl_1_bss_4870 = .bss:0x00004870; // type:object size:0x8 data:4byte
spInstance__Q23Net17MiscPacketHandler = .bss:0x00004870; // type:object size:0x8 data:4byte
lbl_1_bss_4878 = .bss:0x00004878; // type:object size:0x80 data:4byte
lbl_1_bss_48F8 = .bss:0x000048F8; // type:object size:0x100
spInstance__Q23Net10NetManager = .bss:0x000049F8; // type:object size:0x8 data:4byte
spInstance__Q23Net11ROOMHandler = .bss:0x00004A00; // type:object size:0x8 data:4byte
lbl_1_bss_4A08 = .bss:0x00004A08; // type:object size:0x8 data:4byte
lbl_1_bss_4A10 = .bss:0x00004A10; // type:object size:0x8 data:4byte
lbl_1_bss_4A18 = .bss:0x00004A18; // type:object size:0x8 data:4byte
lbl_1_bss_4A20 = .bss:0x00004A20; // type:object size:0x8 data:4byte
spInstance__Q23Net12EVENTHandler = .bss:0x00004A10; // type:object size:0x8 data:4byte
spInstance__Q23Net11ITEMHandler = .bss:0x00004A18; // type:object size:0x8 data:4byte
spInstance__Q23Net13SELECTHandler = .bss:0x00004A20; // type:object size:0x8 data:4byte
spInstance__Q23Net11USERHandler = .bss:0x00004A28; // type:object size:0x8 data:4byte
lbl_1_bss_4A30 = .bss:0x00004A30; // type:object size:0x8 data:4byte
spInstance__Q23Net18RACEHEADER1Handler = .bss:0x00004A38; // type:object size:0x8 data:4byte
Expand Down
6 changes: 5 additions & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,14 @@ def MatchingFor(*versions):
Object(Matching, "geo/BoxColManager.cpp"),
Object(Matching, "geo/BoxColUnit.cpp"),

Object(NonMatching, "net/MiscPacketHandler.cpp"),
Object(NonMatching, "net/NetManager.cpp"),
Object(NonMatching, "net/packets/ROOM.cpp"),
Object(NonMatching, "net/packets/EVENT.cpp"),
Object(NonMatching, "net/packets/ITEM.cpp"),
Object(NonMatching, "net/packets/SELECT.cpp"),
Object(NonMatching, "net/packets/USER.cpp"),
Object(NonMatching, "net/packets/RACEHEADER1.cpp"),
Object(NonMatching, "net/packets/ROOM.cpp"),
],
},
{
Expand Down
2 changes: 2 additions & 0 deletions include/rk_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

#define MAX_PLAYER_COUNT 12
#define ARRAY_COUNT(array) (sizeof(array) / sizeof((array)[0]))

#define MAX_FRIEND_COUNT 30
16 changes: 7 additions & 9 deletions lib/dwc/common/dwc_error.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "dwc_error.h"

#include "dwci_error.h"

//! @brief The last error code encountered.
//!
int stDwcErrorCode;
Expand All @@ -17,7 +15,7 @@ int DWC_GetLastError(int* errorCode) {
return stDwcLastError;
}

s32 DWC_GetLastErrorEx(s32* errorCode, u32* errorType) {
s32 DWC_GetLastErrorEx(s32* errorCode, DWCErrorType* errorType) {
if (errorCode)
*errorCode = stDwcErrorCode;
if (errorType) {
Expand Down Expand Up @@ -45,7 +43,7 @@ s32 DWC_GetLastErrorEx(s32* errorCode, u32* errorType) {
*errorType = 1;
break;
case 1:
case DWCErrorFatal:
case DWC_ERROR_FATAL:
*errorType = 7;
break;

Expand Down Expand Up @@ -74,21 +72,21 @@ s32 DWC_GetLastErrorEx(s32* errorCode, u32* errorType) {
}

void DWC_ClearError() {
if (stDwcLastError != DWCErrorFatal) {
stDwcLastError = DWCErrorNone;
if (stDwcLastError != DWC_ERROR_FATAL) {
stDwcLastError = DWC_ERROR_NONE;
stDwcErrorCode = 0;
}
}

int DWCi_IsError() { return stDwcLastError != DWCErrorNone; }
int DWCi_IsError() { return stDwcLastError != DWC_ERROR_NONE; }

void DWCi_SetError(int lastError, int errorCode) {
if (stDwcLastError != DWCErrorFatal) {
if (stDwcLastError != DWC_ERROR_FATAL) {
stDwcLastError = lastError;
stDwcErrorCode = errorCode;
}
#ifdef DEBUG
if (stDwcLastError == DWCErrorFatal)
if (stDwcLastError == DWC_ERROR_FATAL)
DWC_Printf(-1, "FATALERROR_SET\n");
#endif
}
4 changes: 3 additions & 1 deletion lib/dwc/common/dwc_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

#include <rk_types.h>

#include "dwci_error.h"

#ifdef __cplusplus
extern "C" {
#endif

int DWC_GetLastError(int* errorCode);
s32 DWC_GetLastErrorEx(s32* errorCode, u32* errorType);
s32 DWC_GetLastErrorEx(s32* errorCode, DWCErrorType* errorType);
void DWC_ClearError();

#ifdef __cplusplus
Expand Down
12 changes: 11 additions & 1 deletion lib/dwc/common/dwci_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@
extern "C" {
#endif

enum dwcError { DWCErrorNone = 0, DWCErrorFatal = 9 };
typedef enum {
DWC_ERROR_NONE = 0,
DWC_ERROR_TYPE_1 = 1,
DWC_ERROR_TYPE_2 = 2,
DWC_ERROR_TYPE_3 = 3,
DWC_ERROR_TYPE_4 = 4,
DWC_ERROR_TYPE_5 = 5,
DWC_ERROR_TYPE_6 = 6,
DWC_ERROR_TYPE_7 = 7,
DWC_ERROR_FATAL = 9,
} DWCErrorType;

//! @brief @return Return if there is an error.
//!
Expand Down
60 changes: 60 additions & 0 deletions src/net/FriendInfo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#pragma once

// this maybe should go in NetManager

namespace Net {

enum FriendStatus {
FRIEND_STATUS_IDLE = 0x0, // Is this any different than ONLINE?
FRIEND_STATUS_ONLINE = 0x2,
FRIEND_STATUS_OPEN_ROOM = 0x3, // or hosting
FRIEND_STATUS_PLAYING_WITH_FRIENDS = 0x4,
FRIEND_STATUS_PUBLIC_VS = 0x5,
FRIEND_STATUS_PUBLIC_BT = 0x8,
FRIEND_STATUS_FROOM_VS_HOST = 0xB,
FRIEND_STATUS_FROOM_BATTLE_HOST = 0xC,
FRIEND_STATUS_FROOM_VS_NON_HOST = 0xD,
FRIEND_STATUS_FROOM_BATTLE_NON_HOST = 0xE,
};

// The enums here are a little confusing and deserve some explanation
// Whereas FriendStatus only makes a destinction between public and private
// rooms, FriendJoinableStatus goes a bit further in whether you can join the
// public room or not.
enum FriendJoinableStatus {
STATUS_NONE = 0x0,
STATUS_OFFLINE = 0x1,
STATUS_ONLINE = 0x2,
STATUS_OPEN_ROOM = 0x3,
STATUS_PLAYING_WITH_FRIEND = 0x4,
STATUS_WW_VS = 0x5,
STATUS_JOINABLE_REGIONAL_VS = 0x6,
STATUS_UNJOINABLE_REGIONAL_VS = 0x7,
STATUS_WW_BT = 0x8,
STATUS_JOINABLE_REGIONAL_BT = 0x9,
STATUS_UNJOINABLE_REGIONAL_BT = 0xA,
STATUS_HOSTING_GP = 0xB,
STATUS_HOSTING_BT = 0xC,
STATUS_PLAYING_WITH_FRIENDS_RACE_COUNT = 0xD,
STATUS_PLAYING_WITH_FRIEND_BATTLE_COUNT = 0xE,
};

struct StatusData {
u32 roomId; // note to self, this is the one used 80659680, not to be confused
// with a similar field in matchMakingInfo
s8 regionId;
u8 status; // FriendStatus
u8 playerCount;
u8 currRace;
};
static_assert(sizeof(StatusData) == 0x8);

struct FriendInfo {
StatusData statusData;
u8 dwcFriendStatus; // Updated in NetManager::updateStatusDatas
bool addedBack;
u8 _a[0xc - 0xa];
};
static_assert(sizeof(FriendInfo) == 0xc);

} // namespace Net
30 changes: 30 additions & 0 deletions src/net/MiscPacketHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "MiscPacketHandler.hpp"

#include "net/NetManager.hpp"

#include "net/packets/EVENT.hpp"
#include "net/packets/ITEM.hpp"

namespace Net {

void MiscPacketHandler::clearAidFromUnkBitfield(u32 aid) {
m_unkBitfield_4 &= ~(1 << aid);
}

MiscPacketHandler::MiscPacketHandler()
: _000(0), m_unk1(false), m_unkBitfield_4(0), m_unkBitfield_8(0),
m_unkBitfield_C(0), m_unk10(0), m_unk12(3000) {
EVENTHandler::createStaticInstance();
ITEMHandler::createStaticInstance();
}

bool MiscPacketHandler::isPlayerLocal(u32 playerId) {
bool isPlayerIdLocal = false;
if (playerId == NetManager::getInstance()->getLocalPlayerId(0) ||
playerId == NetManager::getInstance()->getLocalPlayerId(1)) {
isPlayerIdLocal = true;
}
return isPlayerIdLocal;
}

} // namespace Net
Loading