Skip to content

Commit

Permalink
update offset for WinStore
Browse files Browse the repository at this point in the history
fix vibration reset issue

fix getting invalid profile
  • Loading branch information
WinterSquire committed Jul 26, 2024
1 parent 0911d85 commit 7ecc2c6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/mcc/CGameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ __int64 CGameManager::get_xuid(int index) {
CInputDevice *CGameManager::get_controller(int index) {
auto mng = DeviceManager();
auto setting = AlphaRing::Global::MCC::Splitscreen();
auto profile = get_profile(index);
auto controller_index = get_profile(index)->controller_index;

if ((!index && setting->b_player0_use_km) || profile->controller_index == 4)
if ((!index && setting->b_player0_use_km) || controller_index >= 4 || controller_index < 0)
return nullptr;
else
return mng->p_input_device[get_profile(index)->controller_index];
return mng->p_input_device[controller_index];
}

int CGameManager::get_index(__int64 xuid) {
Expand Down
21 changes: 10 additions & 11 deletions src/mcc/CGameManagerSplitscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ void CGameManager::set_vibration(CGameManager *self, DWORD dwUserIndex, XINPUT_V
return;
}

if ((p_device = get_controller(dwUserIndex)) == nullptr)
if (dwUserIndex >= p_setting->player_count)
return;

if (pVibration == nullptr || (p_device = get_controller(dwUserIndex)) == nullptr)
return;

AlphaRing::Input::SetState(p_device->input_user, pVibration);
Expand Down Expand Up @@ -90,16 +93,14 @@ bool CGameManager::get_key_state(CGameManager *self, DWORD index, input_data_t *
}

CUserProfile* CGameManager::get_player_profile(CGameManager *self, __int64 xid) {
auto index = get_index(xid);
auto p_setting = AlphaRing::Global::MCC::Splitscreen();

if (!p_setting->b_override)
return ppOriginal.get_player_profile(self, xid);

if (!p_setting->b_override_profile) {
if (p_setting->b_use_player0_profile)
xid = get_xuid(0);
return ppOriginal.get_player_profile(self, xid);
}
if (!p_setting->b_override_profile && ((!index) || (index && p_setting->b_use_player0_profile)))
return ppOriginal.get_player_profile(self, get_xuid(0));

if (p_setting->b_use_player0_profile)
return &get_profile(0)->profile;
Expand All @@ -108,16 +109,14 @@ CUserProfile* CGameManager::get_player_profile(CGameManager *self, __int64 xid)
}

CGamepadMapping* CGameManager::retrive_gamepad_mapping(CGameManager *self, __int64 xid) {
auto index = get_index(xid);
auto p_setting = AlphaRing::Global::MCC::Splitscreen();

if (!p_setting->b_override)
return ppOriginal.retrive_gamepad_mapping(self, xid);

if (!p_setting->b_override_profile) {
if (p_setting->b_use_player0_profile)
xid = get_xuid(0);
return ppOriginal.retrive_gamepad_mapping(self, xid);
}
if (!p_setting->b_override_profile && ((!index) || (index && p_setting->b_use_player0_profile)))
return ppOriginal.retrive_gamepad_mapping(self, get_xuid(0));

if (p_setting->b_use_player0_profile)
return &get_profile(0)->mapping;
Expand Down
6 changes: 3 additions & 3 deletions src/mcc/mcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace MCC {
CDeviceManager** device_manager;

AlphaRing::Hook::Offset({
{0x3FFCAA8, 0, (void**)&ppGameEngine},
{0x3F76E50, 0, (void**)&game_manager},
{0x3FFFFF8, 0, (void**)&device_manager},
{0x3FFCAA8, 0x3E4B048, (void**)&ppGameEngine},
{0x3F76E50, 0x3DC54D0, (void**)&game_manager},
{0x3FFFFF8, 0x3E4E590, (void**)&device_manager},
{OFFSET_MCC_PF_DELTA_TIME, OFFSET_MCC_WS_PF_DELTA_TIME, (void**)&deltaTime},
});

Expand Down
4 changes: 1 addition & 3 deletions src/mcc/splitscreen/Splitscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace MCC::Splitscreen {

// fix: changing team freeze the game
result = AlphaRing::Hook::Detour({
{0x2D01DC, 0, get_index_by_xuid, (void**)&ppOriginal_get_index_by_xuid},
{0x2D01DC, 0x2BD620, get_index_by_xuid, (void**)&ppOriginal_get_index_by_xuid},
});

assertm(result, "MCC:Splitscreen: failed to hook");
Expand All @@ -34,8 +34,6 @@ namespace MCC::Splitscreen {
}
}

#include "../CGameEngine.h"

#include "imgui.h"

#include <string>
Expand Down

0 comments on commit 7ecc2c6

Please sign in to comment.