-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdwc_main.cpp
More file actions
63 lines (51 loc) · 1.82 KB
/
dwc_main.cpp
File metadata and controls
63 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <common/Common.hpp>
#include <dwc/dwc_main.h>
#include <gs/gt2/gt2Main.h>
#include <gs/gt2/gt2Utility.h>
#include <wiimmfi/ConnectionMatrix.hpp>
#include <wiimmfi/Natneg.hpp>
#include <wiimmfi/Port.hpp>
/////////////////
// Fast NATNEG //
/////////////////
// DWC_InitFriendsMatch() patch
// Replace ConnectedCallback to accept incoming connections in more cases
// Credits: Wiimmfi
kmBranchDefCpp(0x800D0FE8, NULL, void) {
stpDwcCnt->callbacks.connectedCb = &Wiimmfi::Natneg::ConnectedCallback;
}
// DWCi_GT2Startup() patch
// Replace ConnectAttemptCallback to accept incoming connections in more cases
// Credits: Wiimmfi
kmCallDefCpp(0x800D28CC, void, GT2Socket sock, GT2ConnectAttemptCallback callback) {
gt2Listen(sock, Wiimmfi::Natneg::ConnectAttemptCallback);
}
// DWCi_MatchedCallback() patch
// Update NATNEG timers
// Credits: Wiimmfi
kmCallDefCpp(0x800D3188, void, DWCError error, int cancel, int self, int isServer, int index, void* param) {
// Original call
stpDwcCnt->userMatchedCallback(error, cancel, self, isServer, index, param);
// Update NATNEG with the self value
Wiimmfi::Natneg::CalcTimers(self);
}
/////////////////////////////////////
// Fast NATNEG / Wiimmfi Telemetry //
/////////////////////////////////////
// DWCi_GT2ClosedProcess() patch
// Update the connection matrix when a connection is closed
// Credits: Wiimmfi
kmBranch(0x800D3F1C, Wiimmfi::ConnectionMatrix::Update);
//////////////////////////
// Wiimmfi Port Binding //
//////////////////////////
// DWCi_GT2Startup() patch
// Use the server-provided port for GT2Sockets
// Credits: Wiimmfi
kmCallDefCpp(0x800D2884, char*, u32 ip, u16 port, char* string) {
// Override port if set
if (Wiimmfi::Port::sPort)
port = Wiimmfi::Port::sPort;
// Original call
return gt2AddressToString(ip, port, string);
}