Compare commits

...

1 Commits

Author SHA1 Message Date
coah
51212aa9b8 cleanup(iplContest): name session NAT/HTTP unk fields
Rename clear Contest session placeholders from usage:
- unk_0x030 → natState (GameSpy/NAT detect state machine)
- unk_0x034 → gsAvailable
- unk_0x038 → natTimedOut
- unk_0x03c → natFailed
- unk_0x7f0 → httpBuf (NHTTP response buffer)

Verified: iplContest 100%/100%, build/43U/ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d
2026-10-02 14:01:27 -05:00

View File

@@ -25,16 +25,16 @@ typedef struct {
undefined4 result; undefined4 result;
undefined4 errCode; undefined4 errCode;
HTTPTestState httpTestState; HTTPTestState httpTestState;
undefined4 unk_0x030; undefined4 natState;
undefined4 unk_0x034; undefined4 gsAvailable;
undefined4 unk_0x038; undefined4 natTimedOut;
undefined4 unk_0x03c; undefined4 natFailed;
OSTime detectStartTime; OSTime detectStartTime;
NHTTPConnection httpConnection; NHTTPConnection httpConnection;
NHTTPRequest* httpRequest; NHTTPRequest* httpRequest;
NHTTPResponse* httpResponse; NHTTPResponse* httpResponse;
NCDProxyProfile proxy; NCDProxyProfile proxy;
void* unk_0x7f0; void* httpBuf;
NAT nat; NAT nat;
} StaticSession; } StaticSession;
@@ -64,14 +64,14 @@ void IPLContestInitialize(void* heapBuf, NCDProxyProfile* proxy) {
g_session.result = 0xFF00; g_session.result = 0xFF00;
g_session.errCode = 0; g_session.errCode = 0;
g_session.httpTestState = HTTP_TEST_NOT_STARTED; g_session.httpTestState = HTTP_TEST_NOT_STARTED;
g_session.unk_0x030 = 0; g_session.natState = 0;
g_session.detectStartTime = 0; g_session.detectStartTime = 0;
g_session.httpConnection = 0; g_session.httpConnection = 0;
g_session.httpRequest = 0; g_session.httpRequest = 0;
g_session.httpResponse = NULL; g_session.httpResponse = NULL;
g_session.unk_0x034 = 0; g_session.gsAvailable = 0;
g_session.unk_0x038 = 0; g_session.natTimedOut = 0;
g_session.unk_0x03c = 1; g_session.natFailed = 1;
g_session.proxy = *proxy; g_session.proxy = *proxy;
} }
@@ -100,7 +100,7 @@ int IPLContestProcess() {
g_session.errCode = g_session.errCode != 0 ? g_session.errCode : -52200; g_session.errCode = g_session.errCode != 0 ? g_session.errCode : -52200;
OSReport("[error] Failed to start up NHTTP.\n"); OSReport("[error] Failed to start up NHTTP.\n");
} else { } else {
g_session.unk_0x7f0 = IPLContestAlloc(0x400); g_session.httpBuf = IPLContestAlloc(0x400);
g_session.httpTestState = HTTP_TEST_STARTED; g_session.httpTestState = HTTP_TEST_STARTED;
OSReport("Starting HTTP conectting test.\n"); OSReport("Starting HTTP conectting test.\n");
} }
@@ -108,7 +108,7 @@ int IPLContestProcess() {
} }
case HTTP_TEST_STARTED: { case HTTP_TEST_STARTED: {
g_session.httpRequest = g_session.httpRequest =
NHTTPCreateRequest("http://conntest.nintendowifi.net/", 0, g_session.unk_0x7f0, 0x400, sNHTTPReqCallback, 0); NHTTPCreateRequest("http://conntest.nintendowifi.net/", 0, g_session.httpBuf, 0x400, sNHTTPReqCallback, 0);
if (g_session.httpRequest == 0) { if (g_session.httpRequest == 0) {
g_session.httpTestState = HTTP_TEST_RESPONSE_ERRORED; g_session.httpTestState = HTTP_TEST_RESPONSE_ERRORED;
g_session.result |= 4; g_session.result |= 4;
@@ -156,9 +156,9 @@ int IPLContestProcess() {
NHTTPDestroyResponse(g_session.httpResponse); NHTTPDestroyResponse(g_session.httpResponse);
g_session.httpResponse = NULL; g_session.httpResponse = NULL;
} }
if (g_session.unk_0x7f0 != NULL) { if (g_session.httpBuf != NULL) {
IPLContestFree(g_session.unk_0x7f0, 0); IPLContestFree(g_session.httpBuf, 0);
g_session.unk_0x7f0 = NULL; g_session.httpBuf = NULL;
} }
g_session.httpTestState = HTTP_TEST_DONE; g_session.httpTestState = HTTP_TEST_DONE;
NHTTPCleanupAsync(sNHTTPCleanupCallback); NHTTPCleanupAsync(sNHTTPCleanupCallback);
@@ -176,9 +176,9 @@ int IPLContestProcess() {
NHTTPDestroyResponse(g_session.httpResponse); NHTTPDestroyResponse(g_session.httpResponse);
g_session.httpResponse = NULL; g_session.httpResponse = NULL;
} }
if (g_session.unk_0x7f0 != NULL) { if (g_session.httpBuf != NULL) {
IPLContestFree(g_session.unk_0x7f0, 0); IPLContestFree(g_session.httpBuf, 0);
g_session.unk_0x7f0 = NULL; g_session.httpBuf = NULL;
} }
g_session.httpTestState = HTTP_TEST_DONE; g_session.httpTestState = HTTP_TEST_DONE;
NHTTPCleanupAsync(sNHTTPCleanupCallback); NHTTPCleanupAsync(sNHTTPCleanupCallback);
@@ -198,11 +198,11 @@ int IPLContestProcess() {
OSReport("Port mapping detectioning test has been skipped.\n"); OSReport("Port mapping detectioning test has been skipped.\n");
} else } else
switch (g_session.unk_0x030) { switch (g_session.natState) {
case 0: { case 0: {
gsiMemoryCallbacksSet(IPLContestGSMalloc, IPLContestGSFree, IPLContestGSRealloc, IPLContestGSMemalign); gsiMemoryCallbacksSet(IPLContestGSMalloc, IPLContestGSFree, IPLContestGSRealloc, IPLContestGSMemalign);
GSIStartAvailableCheckA("wiinat"); GSIStartAvailableCheckA("wiinat");
g_session.unk_0x030 = 1; g_session.natState = 1;
OSReport("Starting GameSpy available check.\n"); OSReport("Starting GameSpy available check.\n");
break; break;
} }
@@ -212,14 +212,14 @@ int IPLContestProcess() {
break; break;
} }
case GSIACAvailable: { case GSIACAvailable: {
g_session.unk_0x034 = 1; g_session.gsAvailable = 1;
g_session.unk_0x030 = 2; g_session.natState = 2;
OSReport("GameSpy server is currently available.\n"); OSReport("GameSpy server is currently available.\n");
break; break;
} }
default: { default: {
g_session.unk_0x034 = 0; g_session.gsAvailable = 0;
g_session.unk_0x030 = 5; g_session.natState = 5;
OSReport("GameSpy server is currently unavailable.\n"); OSReport("GameSpy server is currently unavailable.\n");
break; break;
} }
@@ -228,7 +228,7 @@ int IPLContestProcess() {
} }
case 2: { case 2: {
NNStartNatDetection(onNatDetectionDone); NNStartNatDetection(onNatDetectionDone);
g_session.unk_0x030 = 3; g_session.natState = 3;
OSReport("Port mapping detectioning test has been started.\n"); OSReport("Port mapping detectioning test has been started.\n");
g_session.detectStartTime = OSGetTime(); g_session.detectStartTime = OSGetTime();
break; break;
@@ -238,8 +238,8 @@ int IPLContestProcess() {
if (OSGetTime() - g_session.detectStartTime < OSMillisecondsToTicks((OSTime)90000)) { if (OSGetTime() - g_session.detectStartTime < OSMillisecondsToTicks((OSTime)90000)) {
break; break;
} }
g_session.unk_0x030 = 5; g_session.natState = 5;
g_session.unk_0x038 = 1; g_session.natTimedOut = 1;
OSReport("[error] NAT timeout.\n"); OSReport("[error] NAT timeout.\n");
break; break;
} }
@@ -289,10 +289,10 @@ int IPLGetNATSupportCode(int conntype) {
nat = g_session.nat; nat = g_session.nat;
if (g_session.unk_0x034 != 0) { if (g_session.gsAvailable != 0) {
if (g_session.unk_0x038 != 0) { if (g_session.natTimedOut != 0) {
code = 11180; code = 11180;
} else if (g_session.unk_0x03c != 0) { } else if (g_session.natFailed != 0) {
code = 11170; code = 11170;
} else { } else {
if (nat.mappingScheme == 0 && nat.mappings[2].publicPort == nat.mappings[1].publicPort * 2 - nat.mappings[0].publicPort) { if (nat.mappingScheme == 0 && nat.mappings[2].publicPort == nat.mappings[1].publicPort * 2 - nat.mappings[0].publicPort) {
@@ -464,10 +464,10 @@ void sNHTTPCleanupCallback() {
void onNatDetectionDone(gsi_bool success, NAT nat) { void onNatDetectionDone(gsi_bool success, NAT nat) {
if (success) { if (success) {
g_session.nat = nat; g_session.nat = nat;
g_session.unk_0x03c = 0; g_session.natFailed = 0;
} else { } else {
g_session.unk_0x03c = 1; g_session.natFailed = 1;
} }
g_session.unk_0x030 = 4; g_session.natState = 4;
return; return;
} }