Skip to content

Commit

Permalink
[MKW] Report information about the upcoming match to the server
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeIsAStar authored and MikeIsAStar committed Jun 21, 2024
1 parent 93cfeb4 commit ca11ee0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
21 changes: 21 additions & 0 deletions payload/import/mkw/net/selectHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class SelectHandler

static_assert(sizeof(Packet) == 0x38);

Packet& sendPacket()
{
return m_sendPacket;
}

void decideEngineClass()
{
LONGCALL void decideEngineClass(SelectHandler * selectHandler)
Expand All @@ -71,6 +76,22 @@ class SelectHandler
decideEngineClass(this);
}

void decideCourse()
{
LONGCALL void decideCourse(SelectHandler * selectHandler)
AT(RMCXD_PORT(0x80661CE8, 0x80659DAC, 0x80661354, 0x80650000));

decideCourse(this);
}

void initPlayerIdsToPlayerAids()
{
LONGCALL void initPlayerIdsToPlayerAids(SelectHandler * selectHandler)
AT(RMCXD_PORT(0x80662034, 0x8065A0F8, 0x806616A0, 0x8065034C));

initPlayerIdsToPlayerAids(this);
}

void decideEngineClassNo100cc(mkw::Util::Random* random)
{
if (random->nextInt(100) < 65) {
Expand Down
27 changes: 27 additions & 0 deletions payload/wwfcFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,33 @@ WWFC_DEFINE_PATCH = {
),
};

// Report information about the upcoming match to the server
WWFC_DEFINE_PATCH = {
Patch::CallWithCTR( //
WWFC_PATCH_LEVEL_FEATURE, //
RMCXD_PORT(0x8066148C, 0x80659550, 0x80660AF8, 0x8064F7A4), //
// clang-format off
[]() -> void {
using namespace mkw::Net;

SelectHandler* selectHandler = SelectHandler::Instance();
selectHandler->decideCourse();
selectHandler->initPlayerIdsToPlayerAids();

SelectHandler::Packet::SelectedCourse selectedCourse =
selectHandler->sendPacket().selectedCourse;
SelectHandler::Packet::EngineClass engineClass =
selectHandler->sendPacket().engineClass;

wwfc::GPReport::ReportU32(
"mkw_select_course", static_cast<u32>(selectedCourse)
);
wwfc::GPReport::ReportU32("mkw_select_cc", static_cast<u32>(engineClass));
}
// clang-format on
),
};

// Allow the "Open Host" feature to be enabled via the press of a button
WWFC_DEFINE_PATCH = {
Patch::WritePointer(
Expand Down

0 comments on commit ca11ee0

Please sign in to comment.