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

Revert commit "Fix a bug that leads to the rejection of one's item request without justification" #80

Merged
merged 1 commit into from
Sep 13, 2024
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
33 changes: 2 additions & 31 deletions payload/import/mkw/net/itemHandler.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once

#include "import/mkw/item.hpp"
#include "import/mkw/system/raceManager.hpp"
#include "net.hpp"

namespace mkw::Net
{
Expand Down Expand Up @@ -100,7 +98,7 @@ class ItemHandler
}
}

/* 0x00 */ u8 receivedTime;
/* 0x00 */ u8 _00;
/* 0x01 */ u8 heldItem;
/* 0x02 */ u8 trailedItem;
/* 0x03 */ HeldPhase heldPhase;
Expand All @@ -110,40 +108,13 @@ class ItemHandler

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

Packet& sendPacket(u32 localPlayerIndex)
{
return m_sendPacket[localPlayerIndex];
}

void setReceivedTime(u32 receivedTime, u32 playerIndex)
{
m_receivedTime[playerIndex] = receivedTime;
}

void broadcastDecidedItem(u32 playerId, mkw::Item::ItemBox item)
{
u32 localPlayerIndex =
RacePacketHandler::Instance()->playerIdToLocalPlayerIndex(playerId);
u32 timer = mkw::System::RaceManager::Instance()->timer();
u8 myAid = NetController::Instance()->myAid();

Packet& packet = sendPacket(localPlayerIndex);
packet.receivedTime = (myAid << 1) + localPlayerIndex;
packet.heldItem = static_cast<u8>(item);
packet.heldPhase = Packet::HeldPhase::Decided;
setReceivedTime(timer & 0xFFFFFFF8, playerId);
}

static ItemHandler* Instance()
{
return s_instance;
}

private:
/* 0x000 */ Packet m_sendPacket[2];
/* 0x010 */ u8 _010[0x0A0 - 0x010];
/* 0x0A0 */ u32 m_receivedTime[12];
/* 0x0D0 */ u8 _0D0[0x184 - 0x0D0];
/* 0x000 */ u8 _000[0x184 - 0x000];

static ItemHandler* s_instance
AT(RMCXD_PORT(0x809C20F8, 0x809BD950, 0x809C1158, 0x809B0738));
Expand Down
26 changes: 0 additions & 26 deletions payload/import/mkw/net/net.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,6 @@ namespace mkw::Net

#if RMC

class RacePacketHandler
{
public:
u32 playerIdToLocalPlayerIndex(u32 playerId)
{
LONGCALL u32 playerIdToLocalPlayerIndex(
RacePacketHandler * racePacketHandler, u32 playerId
) AT(RMCXD_PORT(0x80654918, 0x80650490, 0x80653F84, 0x80642C30));

return playerIdToLocalPlayerIndex(this, playerId);
}

static RacePacketHandler* Instance()
{
return s_instance;
}

private:
/* 0x000 */ u8 _000[0x1C8 - 0x000];

static RacePacketHandler* s_instance
AT(RMCXD_PORT(0x809C1F50, 0x809BD790, 0x809C0FB0, 0x809B0590));
};

static_assert(sizeof(RacePacketHandler) == 0x1C8);

struct __attribute__((packed)) RacePacket {
enum EType {
Header,
Expand Down
36 changes: 0 additions & 36 deletions payload/import/mkw/system/raceManager.hpp

This file was deleted.

16 changes: 0 additions & 16 deletions payload/wwfcFeature.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "import/mkw/net/itemHandler.hpp"
#include "import/mkw/net/selectHandler.hpp"
#include "import/mkw/net/userHandler.hpp"
#include "import/mkw/ui/page/friendRoomPage.hpp"
Expand Down Expand Up @@ -255,21 +254,6 @@ WWFC_DEFINE_PATCH = {
),
};

// Fix a bug that leads to the rejection of one's item request without
// justification
WWFC_DEFINE_PATCH = {
Patch::BranchWithCTR( //
WWFC_PATCH_LEVEL_BUGFIX | WWFC_PATCH_LEVEL_PARITY, //
RMCXD_PORT(0x8065C6C0, 0x8065D348, 0x8065BD2C, 0x8064A9D8), //
// clang-format off
[](mkw::Net::ItemHandler* itemHandler, u32 playerId,
mkw::Item::ItemBox item) -> void {
itemHandler->broadcastDecidedItem(playerId, item);
}
// clang-format on
),
};

// Reset the timer that is used to detect if clients are stalling the room
WWFC_DEFINE_PATCH = {
Patch::CallWithCTR( //
Expand Down