Skip to content

Commit

Permalink
Small cleanup, 6DoF on by deafault, support for comments in config
Browse files Browse the repository at this point in the history
  • Loading branch information
Gistix committed Sep 23, 2023
1 parent 7c26ca0 commit f7e003c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 106 deletions.
13 changes: 5 additions & 8 deletions L4D2VR/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ TurnSpeed=0.15
SnapTurning=false
SnapTurnAngle=45.0
LeftHanded=false
VRScale=43.2
IPDScale=1.0
6DOF=false
HudDistance=1.3
HudSize=4.0
HudAlwaysVisible=false
AimMode=2
AntiAliasing=0
VRScale=43.2 # Real word units to source units scale
IPDScale=1.0 # Scale of interpupillary distance
6DOF=true
AimMode=2 # 0 = None, 1 = Crosshair (does not work properly), 2 = Laser sight/beam
AntiAliasing=0 # 0, 2, 4 8
ViewmodelPosCustomOffsetX=0.0
ViewmodelPosCustomOffsetY=0.0
ViewmodelPosCustomOffsetZ=0.0
Expand Down
98 changes: 7 additions & 91 deletions L4D2VR/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,18 @@ Hooks::Hooks(Game *game)
//hkWriteUsercmdDeltaToBuffer.enableHook();
hkWriteUsercmd.enableHook();

//hkAdjustEngineViewport.enableHook();
//hkViewport.enableHook();
//hkGetViewport.enableHook();

hkCreateMove.enableHook();

hkEyePosition.enableHook();

//hkDrawModelExecute.enableHook();
hkRenderView.enableHook();

/*hkPushRenderTargetAndViewport.enableHook();
hkPopRenderTargetAndViewport.enableHook();*/
//hkVgui_Paint.enableHook();
/*hkIsSplitScreen.enableHook();
hkPrePushRenderTarget.enableHook();*/
//hkGetFullScreenTexture.enableHook();

hkWeapon_ShootPosition.enableHook();
hkTraceFirePortal.enableHook();
hkCWeaponPortalgun_FirePortal.enableHook();

hkDrawSelf.enableHook();
hkPlayerPortalled.enableHook();

//hkGetModeHeight.enableHook();
/*hkVGui_GetHudBounds.enableHook();
hkVGui_GetPanelBounds.enableHook();
hkVGUI_UpdateScreenSpaceBounds.enableHook();
hkSetBounds.enableHook();
hkSetSize.enableHook();
hkGetScreenSize.enableHook();
hkGetHudSize.enableHook();*/

//hkPush2DView.enableHook();
//hkRender.enableHook();

//hkGetClipRect.enableHook();

//hkComputeError.enableHook();
hkUpdateObject.enableHook();
hkUpdateObjectVM.enableHook();
Expand All @@ -79,7 +54,7 @@ Hooks::Hooks(Game *game)
hkGetViewModelFOV.enableHook();

hkSetDrawOnlyForSplitScreenUser.enableHook();
hkClientThink.enableHook();
//kClientThink.enableHook();
hkPrecache.enableHook();
hkCHudCrosshair_ShouldDraw.enableHook();
}
Expand Down Expand Up @@ -155,6 +130,8 @@ int Hooks::initSourceHooks()
LPVOID TraceFirePortalAddr = (LPVOID)(m_Game->m_Offsets->TraceFirePortalServer.address);
hkTraceFirePortal.createHook(TraceFirePortalAddr, &dTraceFirePortal);

hkCWeaponPortalgun_FirePortal.createHook((LPVOID)m_Game->m_Offsets->CWeaponPortalgun_FirePortal.address, &dCWeaponPortalgun_FirePortal);

LPVOID DrawSelfAddr = (LPVOID)(m_Game->m_Offsets->DrawSelf.address);
hkDrawSelf.createHook(DrawSelfAddr, &dDrawSelf);

Expand All @@ -169,45 +146,8 @@ int Hooks::initSourceHooks()
UTIL_IntersectRayWithPortal = (tUTIL_IntersectRayWithPortal)m_Game->m_Offsets->UTIL_IntersectRayWithPortal.address;
UTIL_Portal_AngleTransform = (tUTIL_Portal_AngleTransform)m_Game->m_Offsets->UTIL_Portal_AngleTransform.address;

/*void *clientMode = nullptr;
while (!clientMode)
{
Sleep(10);
clientMode = **(void ***)(m_Game->m_Offsets->g_pClientMode.address);
}
hkCreateMove.createHook( (*(void ***)clientMode)[23], dCreateMove );*/

LPVOID CreateMoveAddr = (LPVOID)(m_Game->m_Offsets->CreateMove.address);
hkCreateMove.createHook(CreateMoveAddr, &dCreateMove);

LPVOID VGui_GetHudBoundsAddr = (LPVOID)(m_Game->m_Offsets->VGui_GetHudBounds.address);
hkVGui_GetHudBounds.createHook(VGui_GetHudBoundsAddr, &dVGui_GetHudBounds);

hkVGui_GetPanelBounds.createHook((LPVOID)(m_Game->m_Offsets->VGui_GetPanelBounds.address), &dVGui_GetPanelBounds);

hkVGUI_UpdateScreenSpaceBounds.createHook((LPVOID)(m_Game->m_Offsets->VGUI_UpdateScreenSpaceBounds.address), &dVGUI_UpdateScreenSpaceBounds);
hkVGui_GetTrueScreenSize.createHook((LPVOID)(m_Game->m_Offsets->VGui_GetTrueScreenSize.address), &dVGui_GetTrueScreenSize);

//hkSetBounds.createHook((LPVOID)m_Game->m_Offsets->SetBoundsC.address, &dSetBounds);
hkSetBounds.createHook((LPVOID)m_Game->m_Offsets->SetBoundsE.address, &dSetBounds);

//hkSetSize.createHook((LPVOID)(m_Game->m_Offsets->SetSizeC.address), &dSetSize);
//hkSetSize.createHook((LPVOID)(m_Game->m_Offsets->SetSizeE.address), &dSetSize);
hkSetSize.createHook((LPVOID)(m_Game->m_Offsets->SetSizeV.address), &dSetSize);

hkGetScreenSize.createHook((LPVOID)(m_Game->m_Offsets->GetScreenSize.address), &dGetScreenSize);
hkGetHudSize.createHook((LPVOID)(m_Game->m_Offsets->GetHudSize.address), &dGetHudSize);

LPVOID Push2DViewAddr = (LPVOID)(m_Game->m_Offsets->Push2DView.address);
hkPush2DView.createHook(Push2DViewAddr, &dPush2DView);

LPVOID RenderAddr = (LPVOID)(m_Game->m_Offsets->Render.address);
hkRender.createHook(RenderAddr, &dRender);

hkGetClipRect.createHook((LPVOID)(m_Game->m_Offsets->GetClipRect.address), &dGetClipRect);

hkGetModeHeight.createHook((LPVOID)(m_Game->m_Offsets->GetModeHeight.address), &dGetModeHeight);

// Grababbles
hkComputeError.createHook((LPVOID)(m_Game->m_Offsets->ComputeError.address), &dComputeError);
Expand All @@ -232,12 +172,9 @@ int Hooks::initSourceHooks()
hkCHudCrosshair_ShouldDraw.createHook((LPVOID)m_Game->m_Offsets->CHudCrosshair_ShouldDraw.address, &dCHudCrosshair_ShouldDraw);

//
hkClientThink.createHook((LPVOID)(m_Game->m_Offsets->ClientThink.address), &dClientThink);
EntityIndex = (tEntindex)m_Game->m_Offsets->CBaseEntity_entindex.address;
GetOwner = (tGetOwner)m_Game->m_Offsets->GetOwner.address;

hkCWeaponPortalgun_FirePortal.createHook((LPVOID)m_Game->m_Offsets->CWeaponPortalgun_FirePortal.address, &dCWeaponPortalgun_FirePortal);

return 1;
}

Expand Down Expand Up @@ -298,22 +235,10 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie
if (m_Game->m_VguiSurface->IsCursorVisible())
return hkRenderView.fOriginal(ecx, setup, hudViewSetup, nClearFlags, whatToDraw);

VPanel* g_pFullscreenRootPanel = *(VPanel**)(m_Game->m_Offsets->g_pFullscreenRootPanel.address);

/*int w, h;
g_pFullscreenRootPanel->GetSize(w, h);*/
//VPanel* g_pFullscreenRootPanel = *(VPanel**)(m_Game->m_Offsets->g_pFullscreenRootPanel.address);

IMaterialSystem* matSystem = m_Game->m_MaterialSystem;

/*int windowWidth, windowHeight;
m_Game->m_MaterialSystem->GetRenderContext()->GetWindowSize(windowWidth, windowHeight);*/

/*hudViewSetup.x = m_VR->m_RenderWidth - windowWidth;
hudViewSetup.y = m_VR->m_RenderHeight - windowHeight;*/

/*hudViewSetup.x = 500;
hudViewSetup.y = 250;*/

hudViewSetup.width = m_VR->m_RenderWidth;
hudViewSetup.height = m_VR->m_RenderHeight;
hudViewSetup.fov = m_VR->m_Fov;
Expand All @@ -329,8 +254,6 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie
Vector vec = position - m_VR->m_SetupOrigin;
float distance = sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z);

//std::cout << "dRenderView: " << distance << "\n";

// Rudimentary portalling detection
if (distance > 35) {
//m_VR->m_RotationOffset.x += m_VR->m_PortalRotationOffset.x;
Expand Down Expand Up @@ -379,10 +302,6 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie
rndrContext->Release();
hkRenderView.fOriginal(ecx, leftEyeView, hudViewSetup, nClearFlags, whatToDraw);

//m_VR->m_HUDTexture

//std::cout << "dRenderView - Left End\n";

// Right eye CViewSetup
tempAngle = QAngle(setup.angles.x, setup.angles.y, setup.angles.z);
rightEyeView.origin = m_VR->TraceEye((uint32_t*)localPlayer, position, m_VR->GetViewOriginRight(position), tempAngle);
Expand All @@ -393,7 +312,6 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie
rndrContext->SetRenderTarget(m_VR->m_RightEyeTexture);
rndrContext->Release();
hkRenderView.fOriginal(ecx, rightEyeView, hudViewSetup, nClearFlags, whatToDraw);
//std::cout << "dRenderView - Right End\n";

m_PushedHud = false;

Expand Down Expand Up @@ -855,7 +773,7 @@ Vector* Hooks::dWeapon_ShootPosition(void* ecx, void* edx, Vector* eyePos)
return result;
}

void* Hooks::dCWeaponPortalgun_FirePortal(void* ecx, void* edx, bool bPortal2, Vector* pVector = 0) {
void* Hooks::dCWeaponPortalgun_FirePortal(void* ecx, void* edx, bool bPortal2, Vector* pVector) {
bool wasTrue = m_VR->m_OverrideEyeAngles;

m_VR->m_OverrideEyeAngles = true;
Expand All @@ -876,8 +794,6 @@ bool __fastcall Hooks::dTraceFirePortal(void* ecx, void* edx, const Vector& vTra
if (iPlacedBy == 2) {
int localIndex = m_Game->m_EngineClient->GetLocalPlayer();

std::cout << "dTraceFirePortal: " << ecx << "\n";

auto owner = GetOwner(ecx);

if (owner) {
Expand Down
3 changes: 3 additions & 0 deletions L4D2VR/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ struct Hook {

int enableHook()
{
if (!pTarget)
throw std::invalid_argument("pTarget is empty, did you miss a call to createHook?");

MH_STATUS status = MH_EnableHook(pTarget);
if (status != MH_OK)
{
Expand Down
4 changes: 2 additions & 2 deletions L4D2VR/offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ class Offsets
Offset VGui_GetPanelBounds = { "client.dll", 0x1CC350, "55 8B EC 8B 45 08 8B C8 83 E1 1F BA ? ? ? ?" };
Offset VGUI_UpdateScreenSpaceBounds = { "client.dll", 0x1CC8C0, "55 8B EC 83 EC 14 8B 45 0C 8B 4D 10 53 8B 5D 18 56 A3 ? ? ? ? 33 C0" };
Offset VGui_GetTrueScreenSize = { "client.dll", 0x1CBCF0, "55 8B EC 8B 45 08 8B 0D ? ? ? ? 8B 55 0C 89 08 A1 ? ? ? ? 89 02 5D C3" };
Offset VGui_GetTrueScreenSize = { "client.dll", 0x1CBCF0, "55 8B EC 8B 45 08 8B 0D ? ? ? ? 8B 55 0C 89 08 A1 ? ? ? ? 89 02 5D C3" };*/

Offset VGui_GetClientDLLRootPanel = { "client.dll", 0x26EDF0, "8B 0D ? ? ? ? 8B 01 8B 90 ? ? ? ? FF D2 8B 04 85 ? ? ? ? 8B 48 04" };
Offset g_pFullscreenRootPanel = { "client.dll", 0x26EE20, "A1 ? ? ? ? C3", 2 };*/
Offset g_pFullscreenRootPanel = { "client.dll", 0x26EE20, "A1 ? ? ? ? C3", 2 };

// Pointer laser
Offset CreatePingPointer = { "client.dll", 0x280660, "55 8B EC 83 EC 14 53 56 8B F1 8B 8E ? ? ? ? 57 85 C9 74 30" };
Expand Down
4 changes: 2 additions & 2 deletions L4D2VR/sdk/sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -2137,8 +2137,8 @@ class C_Portal_Player
public:
inline CWeaponPortalBase* GetActivePortalWeapon() {
typedef CWeaponPortalBase* (__thiscall* tGetActivePortalWeapon)(void* thisptr);
static tGetActivePortalWeapon oGetActivePortalWeapon = (tGetActivePortalWeapon)(g_Game->m_Offsets->GetActivePortalWeapon.address);

//static tGetActivePortalWeapon oGetActivePortalWeapon = (tGetActivePortalWeapon)(g_Game->m_Offsets->GetActivePortalWeapon.address);
static tGetActivePortalWeapon oGetActivePortalWeapon = (tGetActivePortalWeapon)(*(uintptr_t*)this + 968);
return oGetActivePortalWeapon(this);
};

Expand Down
6 changes: 3 additions & 3 deletions L4D2VR/vr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1429,10 +1429,10 @@ void VR::ParseConfigFile()
parseOrDefault("LeftHanded", m_LeftHanded, false);
parseOrDefault("VRScale", m_VRScale, 43.2f);
parseOrDefault("IPDScale", m_IpdScale, 1.0f);
parseOrDefault("6DOF", m_6DOF, false);
parseOrDefault("HudDistance", m_HudDistance, 1.3f);
parseOrDefault("6DOF", m_6DOF, true);
/*parseOrDefault("HudDistance", m_HudDistance, 1.3f);
parseOrDefault("HudSize", m_HudSize, 4.0f);
parseOrDefault("HudAlwaysVisible", m_HudAlwaysVisible, false);
parseOrDefault("HudAlwaysVisible", m_HudAlwaysVisible, false);*/
parseOrDefault("AimMode", m_AimMode, 2);
parseOrDefault("AntiAliasing", m_AntiAliasing, 0);
parseXYZOrDefaultZero("ViewmodelPosCustomOffset", m_ViewmodelPosCustomOffset);
Expand Down

0 comments on commit f7e003c

Please sign in to comment.