Skip to content

Commit

Permalink
Remove XThread check from several games. (#43)
Browse files Browse the repository at this point in the history
* Remove check for current XThread in COD,Crackdown2, DeadRising, Farcry, GearsOfWars,JustCause & RDR

* [SR2] Remove check for XThread in DoHooks, check XThread in reset_fineaim function to avoid a crash.

* DoHook when mouse movement in COD,Crackdown 2, DeadRising, Farcry, RDR.

---------

Co-authored-by: Clippy95 <[email protected]>
  • Loading branch information
2 people authored and marinesciencedude committed Nov 11, 2024
1 parent 25aaef8 commit a7312e8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 40 deletions.
14 changes: 2 additions & 12 deletions src/xenia/hid/winkey/hookables/CallOfDuty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,9 @@ bool CallOfDutyGame::DoHooks(uint32_t user_index, RawInputState& input_state,
if (!IsGameSupported()) {
return false;
}

XThread* current_thread = XThread::GetCurrentThread();

if (!current_thread) {
if ((!input_state.mouse.x_delta && !input_state.mouse.y_delta &&
!input_state.mouse.wheel_delta))
return false;
}
if (supported_builds[game_build_].Dvar_GetBool_address != NULL) {
if (!Dvar_GetBool("cl_ingame",
supported_builds[game_build_].Dvar_GetBool_address)) {
return false;
}
}

xe::be<float>* degree_x;
xe::be<float>* degree_y;

Expand Down
8 changes: 2 additions & 6 deletions src/xenia/hid/winkey/hookables/Crackdown2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,9 @@ bool Crackdown2Game::DoHooks(uint32_t user_index, RawInputState& input_state,
if (supported_builds.count(game_build_) == 0) {
return false;
}

XThread* current_thread = XThread::GetCurrentThread();

if (!current_thread) {
if ((!input_state.mouse.x_delta && !input_state.mouse.y_delta &&
!input_state.mouse.wheel_delta))
return false;
}

xe::be<uint32_t>* base_address =
kernel_memory()->TranslateVirtual<xe::be<uint32_t>*>(
supported_builds[game_build_].base_address);
Expand Down
8 changes: 2 additions & 6 deletions src/xenia/hid/winkey/hookables/DeadRising.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,9 @@ bool DeadRisingGame::DoHooks(uint32_t user_index, RawInputState& input_state,
if (!IsGameSupported()) {
return false;
}

XThread* current_thread = XThread::GetCurrentThread();

if (!current_thread) {
if ((!input_state.mouse.x_delta && !input_state.mouse.y_delta &&
!input_state.mouse.wheel_delta))
return false;
}

xe::be<float>* radian_x = kernel_memory()->TranslateVirtual<xe::be<float>*>(
supported_builds[game_build_].x_address);

Expand Down
6 changes: 2 additions & 4 deletions src/xenia/hid/winkey/hookables/Farcry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ bool FarCryGame::DoHooks(uint32_t user_index, RawInputState& input_state,
return false;
}

XThread* current_thread = XThread::GetCurrentThread();

if (!current_thread) {
if ((!input_state.mouse.x_delta && !input_state.mouse.y_delta &&
!input_state.mouse.wheel_delta))
return false;
}

xe::be<uint32_t>* base_address =
kernel_memory()->TranslateVirtual<xe::be<uint32_t>*>(
Expand Down
6 changes: 0 additions & 6 deletions src/xenia/hid/winkey/hookables/GearsOfWars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,6 @@ bool GearsOfWarsGame::DoHooks(uint32_t user_index, RawInputState& input_state,
}
}

XThread* current_thread = XThread::GetCurrentThread();

if (!current_thread) {
return false;
}

if (bypass_conditions) {
xe::be<uint16_t>* degree_x;
xe::be<uint16_t>* degree_y;
Expand Down
3 changes: 2 additions & 1 deletion src/xenia/hid/winkey/hookables/JustCause.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bool JustCauseGame::DoHooks(uint32_t user_index, RawInputState& input_state,
}

/*
TODO: Vehicle Camera which is CMachineCamera
MOUSEHOOK TODO: Vehicle Camera which is CMachineCamera
and Possibly turrets which is CMountedGunCamera
Some addresses used are in radians,
Expand Down Expand Up @@ -117,6 +117,7 @@ GTA-styled freecam.

xe::be<float>* add_y =
kernel_memory()->TranslateVirtual<xe::be<float>*>(y_address);
// MOUSEHOOK TODO do camx = and camy = instead of +=

float camx = *add_x;
float camy = *add_y;
Expand Down
9 changes: 4 additions & 5 deletions src/xenia/hid/winkey/hookables/RDR.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ bool RedDeadRedemptionGame::DoHooks(uint32_t user_index,
now - last_movement_time_y_)
.count();

XThread* current_thread = XThread::GetCurrentThread();
if (!current_thread) {
return false;
}
if (IsPaused()) return false;

xe::be<uint32_t>* base_address =
Expand Down Expand Up @@ -334,7 +330,10 @@ bool RedDeadRedemptionGame::DoHooks(uint32_t user_index,
}
}
}

if ((!input_state.mouse.x_delta && !input_state.mouse.y_delta &&
!input_state.mouse.wheel_delta))
return false; // This late because want the pattern scans to occur during
// loading screen.
xe::be<uint32_t> x_address =
*base_address - supported_builds[game_build_].x_offset;
xe::be<uint32_t> y_address =
Expand Down

0 comments on commit a7312e8

Please sign in to comment.