Skip to content

Commit

Permalink
[MKW] Refrain from reporting the same player to the server repeatedly
Browse files Browse the repository at this point in the history
Closes issue #75.
  • Loading branch information
MikeIsAStar authored and MikeIsAStar committed Aug 23, 2024
1 parent fc0097e commit cc8eff1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions payload/import/mkw/net/net.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ class NetController
{
using namespace DWC;

bool alreadyReportedAid = s_reportedAids & (1 << playerAid);
if (alreadyReportedAid) {
return;
}
s_reportedAids |= (1 << playerAid);

DWCiNodeInfo* nodeInfo = DWCi_NodeInfoList_GetNodeInfoForAid(playerAid);
if (nodeInfo) {
wwfc::GPReport::ReportU32(key, nodeInfo->profileId);
Expand All @@ -191,6 +197,11 @@ class NetController
}
}

static void ClearReportedAid(u8 playerAid)
{
s_reportedAids &= ~(1 << playerAid);
}

static NetController* Instance()
{
return s_instance;
Expand Down Expand Up @@ -229,6 +240,8 @@ class NetController
private:
/* 0x29C0 */ u8 _29C0[0x29C8 - 0x29C0];

static u32 s_reportedAids;

static NetController* s_instance
AT(RMCXD_PORT(0x809C20D8, 0x809BD918, 0x809C1138, 0x809B0718));
};
Expand Down
28 changes: 28 additions & 0 deletions payload/wwfcFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace mkw::Net

#if RMC

u32 NetController::s_reportedAids = 0x00000000;
u32 SelectHandler::s_kickTimerFrames = 0;

#endif
Expand Down Expand Up @@ -158,6 +159,33 @@ WWFC_DEFINE_PATCH = {
),
};

extern "C" {
__attribute__((__used__)) static void ClearReportedAid(u8 playerAid)
{
mkw::Net::NetController::ClearReportedAid(playerAid);
}
}

// Clear the flag that indicates whether an aid was reported to the server
// when closing the connection to them.
WWFC_DEFINE_PATCH = {
Patch::BranchWithCTR( //
WWFC_PATCH_LEVEL_FEATURE, //
RMCXD_PORT(0x806588C8, 0x80654440, 0x80657F34, 0x80646BE0), //
ASM_LAMBDA(
// clang-format off
mr r3, r28;

lwz r28, 0x10(r1);
mtlr r0;
addi r1, r1, 0x20;

b ClearReportedAid;
// clang-format on
)
),
};

// Fix a bug that leads to the rejection of one's item request without
// justification
WWFC_DEFINE_PATCH = {
Expand Down

0 comments on commit cc8eff1

Please sign in to comment.