Skip to content
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
32 changes: 32 additions & 0 deletions spt/features/game_fixes/visual_fixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "..\feature.hpp"
#include "convar.hpp"
#include "ent_utils.hpp"
#include "game_detection.hpp"
#include "signals.hpp"
#include "..\visualizations\imgui\imgui_interface.hpp"
#include "spt\utils\ent_list.hpp"
Expand Down Expand Up @@ -44,6 +45,10 @@ ConVar spt_disable_render_delay("spt_disable_render_delay",
0,
"Removes the 0.25s render delay after load.",
RenderDelayCVarCallback);
ConVar spt_disable_portal_roll_offset("spt_disable_portal_roll_offset",
"0",
0,
"Removes the roll offset applied to the camera in Portal.");

// Misc visual fixes
class VisualFixes : public FeatureWrapper<VisualFixes>
Expand Down Expand Up @@ -92,6 +97,9 @@ class VisualFixes : public FeatureWrapper<VisualFixes>
const Vector& eyePosition,
const QAngle& eyeAngles);

// Vector EyeFootPosition( const QAngle &qEyeAngles );
DECL_HOOK_THISCALL(Vector*, C_Portal_Player__EyeFootPosition, void*, Vector* out, QAngle* qEyeAngles);

void OnFinishRestore(void* thisptr);
};

Expand Down Expand Up @@ -169,6 +177,8 @@ namespace patterns
"83 3D ?? ?? ?? ?? 01 75 ?? 8B 0D ?? ?? ?? ?? 8B 11",
"7122284",
"83 3D ?? ?? ?? ?? 01 75 ?? 8B 0D ?? ?? ?? ?? 8B 01 8B 40 ?? FF D0 84 C0 75 ?? F3 0F 10 05 ?? ?? ?? ??");
// TODO: Steampipe support. This function is inlined in 7122284.
PATTERNS(C_Portal_Player__EyeFootPosition, "5135", "83 EC 18 8B 44 24 ?? D9 40 ?? 8D 54 24 ?? D9 E1 52");
} // namespace patterns

void VisualFixes::InitHooks()
Expand All @@ -183,6 +193,11 @@ void VisualFixes::InitHooks()
FIND_PATTERN(client, CAM_ToThirdPerson);
HOOK_FUNCTION(client, C_BaseViewModel__CalcViewModelView);
FIND_PATTERN(engine, MiddleOfCL_FullyConnected);

if (utils::DoesGameLookLikePortal())
{
HOOK_FUNCTION(client, C_Portal_Player__EyeFootPosition);
}
}

bool VisualFixes::ShouldLoadFeature()
Expand Down Expand Up @@ -272,13 +287,19 @@ void VisualFixes::LoadFeature()
InitConcommandBase(spt_disable_render_delay);
}

if (ORIG_C_Portal_Player__EyeFootPosition)
{
InitConcommandBase(spt_disable_portal_roll_offset);
}

SptImGuiGroup::QoL_Visual.RegisterUserCallback(
[]()
{
SptImGui::CvarCheckbox(y_spt_disable_fade, "##checkbox_fade");
SptImGui::CvarCheckbox(y_spt_disable_shake, "##checkbox_shake");
SptImGui::CvarCheckbox(y_spt_disable_tone_map_reset, "##checkbox_tone_map");
SptImGui::CvarCheckbox(spt_disable_render_delay, "##checkbox_render_delay");
SptImGui::CvarCheckbox(spt_disable_portal_roll_offset, "##checkbox_portal_roll_offset");
SptImGui::CvarInputTextInteger(y_spt_override_tpose, "T-pose sequence override", "");

ConVar* cvars[] = {&spt_viewmodel_offset_x, &spt_viewmodel_offset_y, &spt_viewmodel_offset_z};
Expand Down Expand Up @@ -373,6 +394,17 @@ IMPL_HOOK_THISCALL(VisualFixes,
spt_visual_fixes.ORIG_C_BaseViewModel__CalcViewModelView(thisptr, owner, vmorigin, eyeAngles);
}

IMPL_HOOK_THISCALL(VisualFixes, Vector*, C_Portal_Player__EyeFootPosition, void*, Vector* out, QAngle* qEyeAngles)
{
if (spt_disable_portal_roll_offset.GetBool())
{
*out = utils::GetPlayerEyePosition();
return out;
}

return spt_visual_fixes.ORIG_C_Portal_Player__EyeFootPosition(thisptr, out, qEyeAngles);
}

void VisualFixes::OnFinishRestore(void* thisptr)
{
// I have no idea what this flag is, but setting it unconditionally seems to
Expand Down
12 changes: 6 additions & 6 deletions spt/features/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,24 +482,24 @@ bool Tracing::ShouldLoadFeature()

void Tracing::UnloadFeature() {}
#if defined(SSDK2013)
IMPL_HOOK_THISCALL(Tracing, void, CGameMovement__GetPlayerMins, IGameMovement*, Vector* out)
IMPL_HOOK_THISCALL(Tracing, Vector*, CGameMovement__GetPlayerMins, IGameMovement*, Vector* out)
{
if (spt_tracing.overrideMinMax)
{
*out = spt_tracing._mins;
return out;
}
else
spt_tracing.ORIG_CGameMovement__GetPlayerMins(thisptr, out);
return spt_tracing.ORIG_CGameMovement__GetPlayerMins(thisptr, out);
}

IMPL_HOOK_THISCALL(Tracing, void, CGameMovement__GetPlayerMaxs, IGameMovement*, Vector* out)
IMPL_HOOK_THISCALL(Tracing, Vector*, CGameMovement__GetPlayerMaxs, IGameMovement*, Vector* out)
{
if (spt_tracing.overrideMinMax)
{
*out = spt_tracing._maxs;
return out;
}
else
spt_tracing.ORIG_CGameMovement__GetPlayerMaxs(thisptr, out);
return spt_tracing.ORIG_CGameMovement__GetPlayerMaxs(thisptr, out);
}
#else
IMPL_HOOK_THISCALL(Tracing, const Vector&, CGameMovement__GetPlayerMins, IGameMovement*)
Expand Down
6 changes: 4 additions & 2 deletions spt/features/tracing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ class Tracing : public FeatureWrapper<Tracing>
trace_t& pm);

#if defined(SSDK2013)
DECL_HOOK_THISCALL(void, CGameMovement__GetPlayerMins, IGameMovement*, Vector*);
DECL_HOOK_THISCALL(void, CGameMovement__GetPlayerMaxs, IGameMovement*, Vector*);
// virtual Vector GetPlayerMins( void ) const;
DECL_HOOK_THISCALL(Vector*, CGameMovement__GetPlayerMins, IGameMovement*, Vector*);
// virtual Vector GetPlayerMaxs( void ) const;
DECL_HOOK_THISCALL(Vector*, CGameMovement__GetPlayerMaxs, IGameMovement*, Vector*);
#else
DECL_HOOK_THISCALL(const Vector&, CGameMovement__GetPlayerMins, IGameMovement*);
DECL_HOOK_THISCALL(const Vector&, CGameMovement__GetPlayerMaxs, IGameMovement*);
Expand Down