Skip to content

Commit

Permalink
fix vehicle auto-look centering applying centering too quick when unc…
Browse files Browse the repository at this point in the history
…apped
  • Loading branch information
nukeulater committed Dec 25, 2023
1 parent 6ea0c58 commit 38c52cc
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 3 deletions.
1 change: 0 additions & 1 deletion xlive/Blam/Engine/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "camera.h"

#include "Blam/Engine/objects/objects.h"
#include "Util/Hooks/Hook.h"

s_camera* get_global_camera()
{
Expand Down
27 changes: 27 additions & 0 deletions xlive/Blam/Engine/game/player_control.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
#include "stdafx.h"
#include "player_control.h"

#include "Blam/Engine/game/game_time.h"
#include "Blam/Engine/main/interpolator.h"

#include "Util/Hooks/Hook.h"

real32 g_player_control_dt = 0.0f;

void player_control_update_dt(real32 dt)
{
g_player_control_dt = dt;
}

real32 __cdecl player_control_get_autocenter_delta()
{
if (halo_interpolator_update_in_progress())
{
return time_globals::get_seconds_per_tick();
}

return g_player_control_dt;
}

s_player_control_globals* s_player_control_globals::get()
{
return *Memory::GetAddress<s_player_control_globals**>(0x4CA37C, 0x4CF0E8);
}

void player_control_apply_patches()
{
PatchCall(Memory::GetAddress(0x91149), player_control_get_autocenter_delta);
}
3 changes: 3 additions & 0 deletions xlive/Blam/Engine/game/player_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ struct s_player_control_globals
static s_player_control_globals* get();
};
CHECK_STRUCT_SIZE(s_player_control_globals, 0x2D8);

void player_control_update_dt(real32 dt);
void player_control_apply_patches();
7 changes: 6 additions & 1 deletion xlive/Blam/Engine/main/interpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ bool interpolation_enabled = false;
c_static_flags<k_maximum_objects_per_map> g_interpolator_object_updated;
c_static_flags<k_maximum_objects_per_map> g_interpolator_object_has_updated;

bool is_interpolation_enabled(void)
bool halo_interpolator_is_enabled(void)
{
return interpolation_enabled;
}

bool halo_interpolator_update_in_progress()
{
return g_update_in_progress;
}

void set_interpolation_enabled(bool enabled)
{
interpolation_enabled = enabled;
Expand Down
3 changes: 2 additions & 1 deletion xlive/Blam/Engine/main/interpolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ extern s_interpolation_data* g_frame_data_intermediate;
extern s_interpolation_data* g_previous_interpolation_frame_data;
extern s_interpolation_data* g_target_interpolation_frame_data;

bool is_interpolation_enabled(void);
bool halo_interpolator_is_enabled(void);
bool halo_interpolator_update_in_progress(void);
void set_interpolation_enabled(bool enabled);

void halo_interpolator_update_delta(void);
Expand Down
3 changes: 3 additions & 0 deletions xlive/Blam/Engine/main/main_game_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Blam/Engine/game/game_time.h"
#include "Blam/Engine/math/math.h"
#include "Blam/Engine/shell/shell_windows.h"
#include "Blam/Engine/game/player_control.h"

#include "H2MOD/Utils/Utils.h"
#include "Util/Hooks/Hook.h"
Expand Down Expand Up @@ -144,6 +145,8 @@ float __cdecl main_time_update_hook(bool fixed_time_step, float fixed_time_delta
main_time_globals->field_16[0] = *Memory::GetAddress<__int64*>(0xA3E440);
main_time_globals->field_16[1] = *Memory::GetAddress<__int64*>(0xA3E440);

player_control_update_dt(dt_sec);

//LOG_TRACE_GAME("main_time_update() - timeDeltaSeconds: {}", timeDeltaSeconds);
return dt_sec;
}
Expand Down
2 changes: 2 additions & 0 deletions xlive/H2MOD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Blam/Engine/game/game.h"
#include "Blam/Engine/game/game_globals.h"
#include "Blam/Engine/game/game_time.h"
#include "Blam/Engine/game/player_control.h"
#include "Blam/Engine/interface/hud.h"
#include "Blam/Engine/interface/hud_messaging.h"
#include "Blam/Engine/interface/motion_sensor.h"
Expand Down Expand Up @@ -936,6 +937,7 @@ void H2MOD::ApplyHooks() {
render_submit_apply_patches();
cloth_apply_patches();
camera_apply_patches();
player_control_apply_patches();
}
else {
LOG_INFO_GAME("{} - applying dedicated server hooks", __FUNCTION__);
Expand Down

0 comments on commit 38c52cc

Please sign in to comment.