@@ -9,20 +9,7 @@ namespace Net {
99void NetManager::scheduleShutdown () { m_shutdownScheduled = true ; }
1010
1111void NetManager::startWWVSSearch (u8 localPlayerCount) {
12- DisconnectInfo dcInfo;
13- s32 code;
14-
15- // we just care about the ec
16- DWC_GetLastErrorEx (&code, reinterpret_cast <u32 *>(&dcInfo.type ));
17-
18- ConnectionState connState;
19-
20- // check for 4xxxx and 98xxx (sake errors)
21- if ((code / 10000 ) == 4 || (code / 1000 ) == 98 ) {
22- connState = CONNECTION_STATE_SAKE_ERROR;
23- } else {
24- connState = m_connectionState;
25- }
12+ ConnectionState connState = getConnectionState ();
2613
2714 // were online, start search/mm
2815 if (connState == CONNECTION_STATE_IDLE) {
@@ -36,17 +23,7 @@ void NetManager::startWWVSSearch(u8 localPlayerCount) {
3623}
3724
3825void NetManager::startRegionalVSSearch (u8 localPlayerCount) {
39- DisconnectInfo dcInfo;
40- s32 code;
41- DWC_GetLastErrorEx (&code, reinterpret_cast <u32 *>(&dcInfo.type ));
42-
43- ConnectionState connState;
44-
45- if ((code / 10000 ) == 4 || (code / 1000 ) == 98 ) {
46- connState = CONNECTION_STATE_SAKE_ERROR;
47- } else {
48- connState = m_connectionState;
49- }
26+ ConnectionState connState = getConnectionState ();
5027
5128 if (connState == CONNECTION_STATE_IDLE) {
5229 initMMInfos ();
@@ -58,17 +35,7 @@ void NetManager::startRegionalVSSearch(u8 localPlayerCount) {
5835}
5936
6037void NetManager::startWWBattleSearch (u8 localPlayerCount) {
61- DisconnectInfo dcInfo;
62- s32 code;
63- DWC_GetLastErrorEx (&code, reinterpret_cast <u32 *>(&dcInfo.type ));
64-
65- ConnectionState connState;
66-
67- if ((code / 10000 ) == 4 || (code / 1000 ) == 98 ) {
68- connState = CONNECTION_STATE_SAKE_ERROR;
69- } else {
70- connState = m_connectionState;
71- }
38+ ConnectionState connState = getConnectionState ();
7239
7340 if (connState == CONNECTION_STATE_IDLE) {
7441 initMMInfos ();
@@ -80,17 +47,7 @@ void NetManager::startWWBattleSearch(u8 localPlayerCount) {
8047}
8148
8249void NetManager::startRegionalBattleSearch (u8 localPlayerCount) {
83- DisconnectInfo dcInfo;
84- s32 code;
85- DWC_GetLastErrorEx (&code, reinterpret_cast <u32 *>(&dcInfo.type ));
86-
87- ConnectionState connState;
88-
89- if ((code / 10000 ) == 4 || (code / 1000 ) == 98 ) {
90- connState = CONNECTION_STATE_SAKE_ERROR;
91- } else {
92- connState = m_connectionState;
93- }
50+ ConnectionState connState = getConnectionState ();
9451
9552 if (connState == CONNECTION_STATE_IDLE) {
9653 initMMInfos ();
@@ -102,17 +59,7 @@ void NetManager::startRegionalBattleSearch(u8 localPlayerCount) {
10259}
10360
10461void NetManager::joinFriendRoom (u32 friendRosterId, u8 localPlayerCount) {
105- u32 type;
106- s32 code;
107- DWC_GetLastErrorEx (&code, &type);
108-
109- ConnectionState connState;
110-
111- if ((code / 10000 ) == 4 || (code / 1000 ) == 98 ) {
112- connState = CONNECTION_STATE_SAKE_ERROR;
113- } else {
114- connState = m_connectionState;
115- }
62+ ConnectionState connState = getConnectionState ();
11663
11764 if (connState == CONNECTION_STATE_IDLE) {
11865 initMMInfos ();
@@ -126,18 +73,7 @@ void NetManager::joinFriendRoom(u32 friendRosterId, u8 localPlayerCount) {
12673}
12774
12875void NetManager::createFriendRoom (u8 localPlayerCount) {
129- u32 type;
130- s32 code;
131- DWC_GetLastErrorEx (&code, &type);
132-
133- ConnectionState connState;
134-
135- // check for 4xxxx and 98xxx
136- if ((code / 10000 ) == 4 || (code / 1000 ) == 98 ) {
137- connState = CONNECTION_STATE_SAKE_ERROR;
138- } else {
139- connState = m_connectionState;
140- }
76+ ConnectionState connState = getConnectionState ();
14177
14278 if (connState == CONNECTION_STATE_IDLE) {
14379 initMMInfos ();
@@ -225,24 +161,14 @@ s32 NetManager::getTimeDiff() {
225161 }
226162
227163 OSTime currTime = OSGetTime ();
228- return ((s32)currTime - time) / (__OSBusClock / 4 ) ;
164+ return ((s32)currTime - time) / OS_TIMER_CLOCK ;
229165}
230166
231167bool NetManager::isConnectionStateIdleOrInMM () {
232- DisconnectInfo dcInfo;
233- s32 code;
234168 bool idleOrMM = false ;
235- ConnectionState connState;
169+ ConnectionState connState = getConnectionState () ;
236170
237171 // we only care about the errorCode
238- DWC_GetLastErrorEx (&code, reinterpret_cast <u32 *>(&dcInfo.type ));
239-
240- // check for 4xxxx or 98xxx
241- if ((code / 10000 ) == 4 || (code / 1000 ) == 98 ) {
242- connState = CONNECTION_STATE_SAKE_ERROR;
243- } else {
244- connState = m_connectionState;
245- }
246172
247173 // had to write it slightly weird to match
248174 if (connState >= CONNECTION_STATE_IDLE &&
@@ -258,20 +184,7 @@ bool NetManager::isTaskExist() {
258184}
259185
260186bool NetManager::isConnectionStateIdle () {
261- DisconnectInfo dcInfo;
262- s32 code;
263- DWC_GetLastErrorEx (&code, reinterpret_cast <u32 *>(&dcInfo.type ));
264-
265- ConnectionState connState;
266-
267- // 4xxxx and 98xxx are sake erorrs, otherwise set connectionState
268- if ((code / 10000 ) == 4 || (code / 1000 ) == 98 ) {
269- connState = CONNECTION_STATE_SAKE_ERROR;
270- } else {
271- connState = m_connectionState;
272- }
273-
274- return connState == CONNECTION_STATE_IDLE;
187+ return getConnectionState () == CONNECTION_STATE_IDLE;
275188}
276189
277190bool NetManager::hasFoundMatch () {
0 commit comments