Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MKW] Report information about the upcoming match to the server #67

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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