Skip to content

Commit

Permalink
Merge pull request #71 from MikeIsAStar/do-not-overwrite-gpiprocessco…
Browse files Browse the repository at this point in the history
…nnect-return-value

[MKW] Do not overwrite the return value of the function 'gpiProcessConnect'
  • Loading branch information
mkwcat authored Jul 20, 2024
2 parents e10c127 + 993bd43 commit 6d21e50
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 17 deletions.
1 change: 1 addition & 0 deletions payload/import/egg/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace EGG
class Exception
{
public:
Exception();
virtual ~Exception();

static void SetUserCallBack(void* arg)
Expand Down
1 change: 1 addition & 0 deletions payload/import/mkw/net/eventHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "import/mkw/item.hpp"
#include <cstddef>
#include <wwfcUtil.h>

namespace mkw::Net
{
Expand Down
1 change: 1 addition & 0 deletions payload/import/mkw/net/userHandler.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "import/dwc.h"
#include <bit>
#include <wwfcMii.hpp>

namespace mkw::Net
Expand Down
5 changes: 3 additions & 2 deletions payload/import/mkw/ui/menuInputManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MenuInputManager
class Handler final : public IHandler
{
public:
Handler(T* object, void (T::*function)(u32))
Handler(T* object, void (T::*function)(u32 localPlayerId))
{
m_object = object;
m_function = function;
Expand All @@ -47,9 +47,10 @@ class MenuInputManager

private:
T* m_object;
void (T::*m_function)(u32);
void (T::*m_function)(u32 localPlayerId);
};

MenuInputManager();
virtual ~MenuInputManager();

private:
Expand Down
10 changes: 5 additions & 5 deletions payload/import/mkw/ui/page/openHostPage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class OpenHostPage : public Page
L"the server.\n\n"
L"Please try again later.";
} else {
if (s_enableOpenHost) {
if (s_openHostEnabled) {
formatParam.strings[0] = L"Open Host is now enabled!";
} else {
formatParam.strings[0] = L"Open Host is now disabled!";
Expand Down Expand Up @@ -155,22 +155,22 @@ class OpenHostPage : public Page
}
s_sentOpenHostValue = true;

bool enableOpenHost = choice == 0;
bool openHostEnabled = choice == 0;

char openHostValue[2];
openHostValue[0] = '0' + enableOpenHost;
openHostValue[0] = '0' + openHostEnabled;
openHostValue[1] = '\0';
GameSpy::gpiSendLocalInfo(
gpConnection, "\\wwfc_openhost\\", openHostValue
);

s_enableOpenHost = enableOpenHost;
s_openHostEnabled = openHostEnabled;
}

static State s_state;
static mkw::UI::MenuInputManager::Handler<OpenHostPage>* s_onOption;
static mkw::UI::YesNoPage::Handler<OpenHostPage>* s_onYesOrNo;
static bool s_enableOpenHost;
static bool s_openHostEnabled;
static bool s_sentOpenHostValue;
};

Expand Down
2 changes: 1 addition & 1 deletion payload/import/mkw/ui/page/yesNoPage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class YesNoPage : public Page
class Handler final : public IHandler
{
public:
Handler(T* object, void (T::*function)(int, void*))
Handler(T* object, void (T::*function)(int choice, void* pushButton))
{
m_object = object;
m_function = function;
Expand Down
18 changes: 9 additions & 9 deletions payload/wwfcFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace mkw::UI
OpenHostPage::State OpenHostPage::s_state = OpenHostPage::State::Previous;
MenuInputManager::Handler<OpenHostPage>* OpenHostPage::s_onOption = nullptr;
YesNoPage::Handler<OpenHostPage>* OpenHostPage::s_onYesOrNo = nullptr;
bool OpenHostPage::s_enableOpenHost = false;
bool OpenHostPage::s_openHostEnabled = false;
bool OpenHostPage::s_sentOpenHostValue = false;

const wchar_t* WifiMenuPage::s_messageOfTheDay =
Expand All @@ -45,21 +45,21 @@ namespace wwfc::Feature

extern "C" {
__attribute__((__used__)) static GameSpy::GPResult
GetMessageOfTheDay(const char* message)
GetMessageOfTheDay(GameSpy::GPResult gpResult, const char* message)
{
using namespace mkw::UI;

const char loginChallenge2Message[] = "\\lc\\2";
if (strncmp(
message, loginChallenge2Message, sizeof(loginChallenge2Message) - 1
)) {
return GameSpy::GPNoError;
return gpResult;
}

const char motdKey[] = "\\wwfc_motd\\";
char value[512];
if (!GameSpy::gpiValueForKey(message, motdKey, value, sizeof(value))) {
return GameSpy::GPNoError;
return gpResult;
}

wchar_t* messageOfTheDayBuffer = WifiMenuPage::MessageOfTheDayBuffer();
Expand All @@ -71,24 +71,24 @@ GetMessageOfTheDay(const char* message)
);
if (messageOfTheDayLength == -1 ||
messageOfTheDayLength == messageOfTheDayBufferSize) {
return GameSpy::GPNoError;
return gpResult;
}
messageOfTheDayBuffer[messageOfTheDayLength / sizeof(wchar_t)] = L'\0';

WifiMenuPage::SetMessageOfTheDay(messageOfTheDayBuffer);

return GameSpy::GPNoError;
return gpResult;
}
}

// Get the "Message Of The Day" from the "Login Challenge" message
// Get the Message Of The Day from the "Login Challenge 2" message
WWFC_DEFINE_PATCH = {
Patch::BranchWithCTR(
WWFC_PATCH_LEVEL_FEATURE,
RMCXD_PORT(0x80101074, 0x80100FD4, 0x80100F94, 0x801010EC), //
ASM_LAMBDA(
// clang-format off
mr r3, r26;
mr r4, r26;

bl _restgpr_26;
lwz r0, 0x2D4(r1);
Expand All @@ -101,7 +101,7 @@ WWFC_DEFINE_PATCH = {
),
};

// Display a "Message Of The Day" when a client connects to the server
// Display the Message Of The Day when a client connects to the server
WWFC_DEFINE_PATCH = {
Patch::BranchWithCTR(
WWFC_PATCH_LEVEL_FEATURE,
Expand Down
1 change: 1 addition & 0 deletions payload/wwfcMii.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "import/mkw/net/userHandler.hpp"
#include "wwfcGPReport.hpp"
#include "wwfcPatch.hpp"
#include <cstring>

namespace wwfc::Mii
{
Expand Down
2 changes: 2 additions & 0 deletions payload/wwfcSecurity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "import/mkw/net/selectHandler.hpp"
#include "import/mkw/net/userHandler.hpp"
#include "import/mkw/registry.hpp"
#include "import/mkw/system/raceConfig.hpp"
#include "import/mkw/system/system.hpp"
#include "wwfcLog.hpp"
#include "wwfcPatch.hpp"

namespace wwfc::Security
Expand Down

0 comments on commit 6d21e50

Please sign in to comment.