Skip to content

Commit 1d03278

Browse files
authored
Net manager improvements (#299)
1 parent 452cfb4 commit 1d03278

File tree

6 files changed

+23
-30
lines changed

6 files changed

+23
-30
lines changed

config/RMCP01/module/symbols.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7199,16 +7199,16 @@ setToMMSuspensionUnk3__Q23Net10NetManagerFv = .text:0x00146554; // type:function
71997199
setDisconnectInfo__Q23Net10NetManagerFQ23Net14DisconnectTypel = .text:0x0014656C; // type:function size:0x94
72007200
getDisconnectInfo__Q23Net10NetManagerFv = .text:0x00146600; // type:function size:0x7C
72017201
resetDisconnectInfo__Q23Net10NetManagerFv = .text:0x0014667C; // type:function size:0x5C
7202-
getTimeDiff__Q23Net10NetManagerFv = .text:0x001466D8; // type:function size:0x60
7202+
matchMakingElapsedSeconds__Q23Net10NetManagerFv = .text:0x001466D8; // type:function size:0x60
72037203
fn_1_146738 = .text:0x00146738; // type:function size:0x58
72047204
fn_1_146790 = .text:0x00146790; // type:function size:0x28
72057205
fn_1_1467B8 = .text:0x001467B8; // type:function size:0x134
72067206
fn_1_1468EC = .text:0x001468EC; // type:function size:0xCC
72077207
fn_1_1469B8 = .text:0x001469B8; // type:function size:0x30
7208-
isConnectionStateIdleOrInMM__Q23Net10NetManagerFv = .text:0x001469E8; // type:function size:0xA8
7209-
isTaskExist__Q23Net10NetManagerFv = .text:0x00146A90; // type:function size:0x2C
7210-
isConnectionStateIdle__Q23Net10NetManagerFv = .text:0x00146ABC; // type:function size:0x90
7211-
hasFoundMatch__Q23Net10NetManagerFv = .text:0x00146B4C; // type:function size:0x40
7208+
isConnectionStateIdleOrInMM__Q23Net10NetManagerCFv = .text:0x001469E8; // type:function size:0xA8
7209+
isTaskThreadIdle__Q23Net10NetManagerFv = .text:0x00146A90; // type:function size:0x2C
7210+
isConnectionStateIdle__Q23Net10NetManagerCFv = .text:0x00146ABC; // type:function size:0x90
7211+
hasFoundMatch__Q23Net10NetManagerCFv = .text:0x00146B4C; // type:function size:0x40
72127212
fn_1_146B8C = .text:0x00146B8C; // type:function size:0xB8
72137213
setConnectionStateIdle__Q23Net10NetManagerFv = .text:0x00146C44; // type:function size:0xC
72147214
RKNetController_construct = .text:0x00146C50; // type:function size:0x3D8 scope:global align:4

src/net/NetManager.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void NetManager::resetDisconnectInfo() {
155155
OSUnlockMutex(&m_mutex);
156156
}
157157

158-
s32 NetManager::getTimeDiff() {
158+
s32 NetManager::matchMakingElapsedSeconds() {
159159
s32 time = m_matchMakingInfos[m_currMMInfo].m_MMStartTime;
160160

161161
// has to do u64 comparison
@@ -164,10 +164,10 @@ s32 NetManager::getTimeDiff() {
164164
}
165165

166166
OSTime currTime = OSGetTime();
167-
return ((s32)currTime - time) / OS_TIMER_CLOCK;
167+
return OSTicksToSeconds((s32)currTime - time);
168168
}
169169

170-
bool NetManager::isConnectionStateIdleOrInMM() {
170+
bool NetManager::isConnectionStateIdleOrInMM() const {
171171
bool idleOrMM = false;
172172

173173
switch (getConnectionState()) {
@@ -180,16 +180,13 @@ bool NetManager::isConnectionStateIdleOrInMM() {
180180
return idleOrMM;
181181
}
182182

183-
bool NetManager::isTaskExist() {
184-
// checks if we've requested mainNetworkLoop
185-
return m_taskThread->isTaskExist() ? false : true;
186-
}
183+
bool NetManager::isTaskThreadIdle() { return !m_taskThread->isTaskExist(); }
187184

188-
bool NetManager::isConnectionStateIdle() {
185+
bool NetManager::isConnectionStateIdle() const {
189186
return getConnectionState() == CONNECTION_STATE_IDLE;
190187
}
191188

192-
bool NetManager::hasFoundMatch() {
189+
bool NetManager::hasFoundMatch() const {
193190
bool inMatch = false;
194191

195192
bool isMyAidInMatch = (1 << m_matchMakingInfos[m_currMMInfo].m_myAid) &
@@ -211,7 +208,7 @@ void NetManager::setConnectionState(ConnectionState connState) {
211208
m_connectionState = connState;
212209
}
213210

214-
NetManager::ConnectionState NetManager::getConnectionState() {
211+
NetManager::ConnectionState NetManager::getConnectionState() const {
215212
s32 code;
216213
u32 type;
217214
DWC_GetLastErrorEx(&code, &type);

src/net/NetManager.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,23 @@ class NetManager {
7676

7777
void resetDisconnectInfo();
7878

79-
s32 getTimeDiff();
79+
s32 matchMakingElapsedSeconds();
8080

8181
void initMMInfos();
8282

83-
bool isConnectionStateIdleOrInMM();
83+
bool isConnectionStateIdleOrInMM() const;
8484

85-
bool isTaskExist();
85+
bool isTaskThreadIdle();
8686

87-
bool isConnectionStateIdle();
87+
bool isConnectionStateIdle() const;
8888

89-
bool hasFoundMatch();
89+
bool hasFoundMatch() const;
9090

9191
void setConnectionStateIdle();
9292

9393
void setConnectionState(ConnectionState connState);
9494

95-
inline ConnectionState getConnectionState();
95+
inline ConnectionState getConnectionState() const;
9696

9797
void* alloc(u32 size, s32 alignment);
9898

src/net/packets/RACEHEADER1.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ static_assert(sizeof(RACEHEADER1Packet) == 0x28);
1111

1212
class RACEHEADER1Handler {
1313
public:
14-
static RACEHEADER1Handler *getInstance() {
15-
return spInstance;
16-
}
17-
1814
void setPrepared();
1915

2016
void reset();
2117

18+
static RACEHEADER1Handler *getInstance() {
19+
return spInstance;
20+
}
2221
private:
2322
bool m_prepared;
2423
u8 _004[0x260 - 0x001];

src/net/packets/ROOM.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class ROOMHandler {
3535
static ROOMHandler *getInstance() {
3636
return spInstance;
3737
}
38-
3938
private:
4039
u8 _00[0x80 - 0x00];
4140

src/net/packets/USER.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ static_assert(sizeof(USERPacket) == 0xc0);
1111

1212
class USERHandler {
1313
public:
14+
void update();
15+
1416
static USERHandler *getInstance() {
1517
return spInstance;
1618
}
17-
18-
void update();
19-
2019
private:
21-
2220
u8 _000[0x9f0 - 0x000];
2321

2422
static USERHandler *spInstance;

0 commit comments

Comments
 (0)