Skip to content

Commit f7e003c

Browse files
committed
Small cleanup, 6DoF on by deafault, support for comments in config
1 parent 7c26ca0 commit f7e003c

File tree

6 files changed

+22
-106
lines changed

6 files changed

+22
-106
lines changed

L4D2VR/config.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ TurnSpeed=0.15
22
SnapTurning=false
33
SnapTurnAngle=45.0
44
LeftHanded=false
5-
VRScale=43.2
6-
IPDScale=1.0
7-
6DOF=false
8-
HudDistance=1.3
9-
HudSize=4.0
10-
HudAlwaysVisible=false
11-
AimMode=2
12-
AntiAliasing=0
5+
VRScale=43.2 # Real word units to source units scale
6+
IPDScale=1.0 # Scale of interpupillary distance
7+
6DOF=true
8+
AimMode=2 # 0 = None, 1 = Crosshair (does not work properly), 2 = Laser sight/beam
9+
AntiAliasing=0 # 0, 2, 4 8
1310
ViewmodelPosCustomOffsetX=0.0
1411
ViewmodelPosCustomOffsetY=0.0
1512
ViewmodelPosCustomOffsetZ=0.0

L4D2VR/hooks.cpp

Lines changed: 7 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,18 @@ Hooks::Hooks(Game *game)
3131
//hkWriteUsercmdDeltaToBuffer.enableHook();
3232
hkWriteUsercmd.enableHook();
3333

34-
//hkAdjustEngineViewport.enableHook();
35-
//hkViewport.enableHook();
36-
//hkGetViewport.enableHook();
37-
3834
hkCreateMove.enableHook();
39-
4035
hkEyePosition.enableHook();
41-
42-
//hkDrawModelExecute.enableHook();
4336
hkRenderView.enableHook();
4437

45-
/*hkPushRenderTargetAndViewport.enableHook();
46-
hkPopRenderTargetAndViewport.enableHook();*/
47-
//hkVgui_Paint.enableHook();
48-
/*hkIsSplitScreen.enableHook();
49-
hkPrePushRenderTarget.enableHook();*/
50-
//hkGetFullScreenTexture.enableHook();
5138

5239
hkWeapon_ShootPosition.enableHook();
5340
hkTraceFirePortal.enableHook();
41+
hkCWeaponPortalgun_FirePortal.enableHook();
42+
5443
hkDrawSelf.enableHook();
5544
hkPlayerPortalled.enableHook();
5645

57-
//hkGetModeHeight.enableHook();
58-
/*hkVGui_GetHudBounds.enableHook();
59-
hkVGui_GetPanelBounds.enableHook();
60-
hkVGUI_UpdateScreenSpaceBounds.enableHook();
61-
hkSetBounds.enableHook();
62-
hkSetSize.enableHook();
63-
hkGetScreenSize.enableHook();
64-
hkGetHudSize.enableHook();*/
65-
66-
//hkPush2DView.enableHook();
67-
//hkRender.enableHook();
68-
69-
//hkGetClipRect.enableHook();
70-
7146
//hkComputeError.enableHook();
7247
hkUpdateObject.enableHook();
7348
hkUpdateObjectVM.enableHook();
@@ -79,7 +54,7 @@ Hooks::Hooks(Game *game)
7954
hkGetViewModelFOV.enableHook();
8055

8156
hkSetDrawOnlyForSplitScreenUser.enableHook();
82-
hkClientThink.enableHook();
57+
//kClientThink.enableHook();
8358
hkPrecache.enableHook();
8459
hkCHudCrosshair_ShouldDraw.enableHook();
8560
}
@@ -155,6 +130,8 @@ int Hooks::initSourceHooks()
155130
LPVOID TraceFirePortalAddr = (LPVOID)(m_Game->m_Offsets->TraceFirePortalServer.address);
156131
hkTraceFirePortal.createHook(TraceFirePortalAddr, &dTraceFirePortal);
157132

133+
hkCWeaponPortalgun_FirePortal.createHook((LPVOID)m_Game->m_Offsets->CWeaponPortalgun_FirePortal.address, &dCWeaponPortalgun_FirePortal);
134+
158135
LPVOID DrawSelfAddr = (LPVOID)(m_Game->m_Offsets->DrawSelf.address);
159136
hkDrawSelf.createHook(DrawSelfAddr, &dDrawSelf);
160137

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

172-
/*void *clientMode = nullptr;
173-
while (!clientMode)
174-
{
175-
Sleep(10);
176-
clientMode = **(void ***)(m_Game->m_Offsets->g_pClientMode.address);
177-
}
178-
179-
hkCreateMove.createHook( (*(void ***)clientMode)[23], dCreateMove );*/
180-
181149
LPVOID CreateMoveAddr = (LPVOID)(m_Game->m_Offsets->CreateMove.address);
182150
hkCreateMove.createHook(CreateMoveAddr, &dCreateMove);
183-
184-
LPVOID VGui_GetHudBoundsAddr = (LPVOID)(m_Game->m_Offsets->VGui_GetHudBounds.address);
185-
hkVGui_GetHudBounds.createHook(VGui_GetHudBoundsAddr, &dVGui_GetHudBounds);
186-
187-
hkVGui_GetPanelBounds.createHook((LPVOID)(m_Game->m_Offsets->VGui_GetPanelBounds.address), &dVGui_GetPanelBounds);
188-
189-
hkVGUI_UpdateScreenSpaceBounds.createHook((LPVOID)(m_Game->m_Offsets->VGUI_UpdateScreenSpaceBounds.address), &dVGUI_UpdateScreenSpaceBounds);
190-
hkVGui_GetTrueScreenSize.createHook((LPVOID)(m_Game->m_Offsets->VGui_GetTrueScreenSize.address), &dVGui_GetTrueScreenSize);
191-
192-
//hkSetBounds.createHook((LPVOID)m_Game->m_Offsets->SetBoundsC.address, &dSetBounds);
193-
hkSetBounds.createHook((LPVOID)m_Game->m_Offsets->SetBoundsE.address, &dSetBounds);
194-
195-
//hkSetSize.createHook((LPVOID)(m_Game->m_Offsets->SetSizeC.address), &dSetSize);
196-
//hkSetSize.createHook((LPVOID)(m_Game->m_Offsets->SetSizeE.address), &dSetSize);
197-
hkSetSize.createHook((LPVOID)(m_Game->m_Offsets->SetSizeV.address), &dSetSize);
198-
199-
hkGetScreenSize.createHook((LPVOID)(m_Game->m_Offsets->GetScreenSize.address), &dGetScreenSize);
200-
hkGetHudSize.createHook((LPVOID)(m_Game->m_Offsets->GetHudSize.address), &dGetHudSize);
201-
202-
LPVOID Push2DViewAddr = (LPVOID)(m_Game->m_Offsets->Push2DView.address);
203-
hkPush2DView.createHook(Push2DViewAddr, &dPush2DView);
204-
205-
LPVOID RenderAddr = (LPVOID)(m_Game->m_Offsets->Render.address);
206-
hkRender.createHook(RenderAddr, &dRender);
207-
208-
hkGetClipRect.createHook((LPVOID)(m_Game->m_Offsets->GetClipRect.address), &dGetClipRect);
209-
210-
hkGetModeHeight.createHook((LPVOID)(m_Game->m_Offsets->GetModeHeight.address), &dGetModeHeight);
211151

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

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

239-
hkCWeaponPortalgun_FirePortal.createHook((LPVOID)m_Game->m_Offsets->CWeaponPortalgun_FirePortal.address, &dCWeaponPortalgun_FirePortal);
240-
241178
return 1;
242179
}
243180

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

301-
VPanel* g_pFullscreenRootPanel = *(VPanel**)(m_Game->m_Offsets->g_pFullscreenRootPanel.address);
302-
303-
/*int w, h;
304-
g_pFullscreenRootPanel->GetSize(w, h);*/
238+
//VPanel* g_pFullscreenRootPanel = *(VPanel**)(m_Game->m_Offsets->g_pFullscreenRootPanel.address);
305239

306240
IMaterialSystem* matSystem = m_Game->m_MaterialSystem;
307241

308-
/*int windowWidth, windowHeight;
309-
m_Game->m_MaterialSystem->GetRenderContext()->GetWindowSize(windowWidth, windowHeight);*/
310-
311-
/*hudViewSetup.x = m_VR->m_RenderWidth - windowWidth;
312-
hudViewSetup.y = m_VR->m_RenderHeight - windowHeight;*/
313-
314-
/*hudViewSetup.x = 500;
315-
hudViewSetup.y = 250;*/
316-
317242
hudViewSetup.width = m_VR->m_RenderWidth;
318243
hudViewSetup.height = m_VR->m_RenderHeight;
319244
hudViewSetup.fov = m_VR->m_Fov;
@@ -329,8 +254,6 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie
329254
Vector vec = position - m_VR->m_SetupOrigin;
330255
float distance = sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z);
331256

332-
//std::cout << "dRenderView: " << distance << "\n";
333-
334257
// Rudimentary portalling detection
335258
if (distance > 35) {
336259
//m_VR->m_RotationOffset.x += m_VR->m_PortalRotationOffset.x;
@@ -379,10 +302,6 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie
379302
rndrContext->Release();
380303
hkRenderView.fOriginal(ecx, leftEyeView, hudViewSetup, nClearFlags, whatToDraw);
381304

382-
//m_VR->m_HUDTexture
383-
384-
//std::cout << "dRenderView - Left End\n";
385-
386305
// Right eye CViewSetup
387306
tempAngle = QAngle(setup.angles.x, setup.angles.y, setup.angles.z);
388307
rightEyeView.origin = m_VR->TraceEye((uint32_t*)localPlayer, position, m_VR->GetViewOriginRight(position), tempAngle);
@@ -393,7 +312,6 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie
393312
rndrContext->SetRenderTarget(m_VR->m_RightEyeTexture);
394313
rndrContext->Release();
395314
hkRenderView.fOriginal(ecx, rightEyeView, hudViewSetup, nClearFlags, whatToDraw);
396-
//std::cout << "dRenderView - Right End\n";
397315

398316
m_PushedHud = false;
399317

@@ -855,7 +773,7 @@ Vector* Hooks::dWeapon_ShootPosition(void* ecx, void* edx, Vector* eyePos)
855773
return result;
856774
}
857775

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

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

879-
std::cout << "dTraceFirePortal: " << ecx << "\n";
880-
881797
auto owner = GetOwner(ecx);
882798

883799
if (owner) {

L4D2VR/hooks.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ struct Hook {
3737

3838
int enableHook()
3939
{
40+
if (!pTarget)
41+
throw std::invalid_argument("pTarget is empty, did you miss a call to createHook?");
42+
4043
MH_STATUS status = MH_EnableHook(pTarget);
4144
if (status != MH_OK)
4245
{

L4D2VR/offsets.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ class Offsets
7979
Offset VGui_GetPanelBounds = { "client.dll", 0x1CC350, "55 8B EC 8B 45 08 8B C8 83 E1 1F BA ? ? ? ?" };
8080
8181
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" };
82-
Offset VGui_GetTrueScreenSize = { "client.dll", 0x1CBCF0, "55 8B EC 8B 45 08 8B 0D ? ? ? ? 8B 55 0C 89 08 A1 ? ? ? ? 89 02 5D C3" };
82+
Offset VGui_GetTrueScreenSize = { "client.dll", 0x1CBCF0, "55 8B EC 8B 45 08 8B 0D ? ? ? ? 8B 55 0C 89 08 A1 ? ? ? ? 89 02 5D C3" };*/
8383

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

8787
// Pointer laser
8888
Offset CreatePingPointer = { "client.dll", 0x280660, "55 8B EC 83 EC 14 53 56 8B F1 8B 8E ? ? ? ? 57 85 C9 74 30" };

L4D2VR/sdk/sdk.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,8 +2137,8 @@ class C_Portal_Player
21372137
public:
21382138
inline CWeaponPortalBase* GetActivePortalWeapon() {
21392139
typedef CWeaponPortalBase* (__thiscall* tGetActivePortalWeapon)(void* thisptr);
2140-
static tGetActivePortalWeapon oGetActivePortalWeapon = (tGetActivePortalWeapon)(g_Game->m_Offsets->GetActivePortalWeapon.address);
2141-
2140+
//static tGetActivePortalWeapon oGetActivePortalWeapon = (tGetActivePortalWeapon)(g_Game->m_Offsets->GetActivePortalWeapon.address);
2141+
static tGetActivePortalWeapon oGetActivePortalWeapon = (tGetActivePortalWeapon)(*(uintptr_t*)this + 968);
21422142
return oGetActivePortalWeapon(this);
21432143
};
21442144

L4D2VR/vr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,10 +1429,10 @@ void VR::ParseConfigFile()
14291429
parseOrDefault("LeftHanded", m_LeftHanded, false);
14301430
parseOrDefault("VRScale", m_VRScale, 43.2f);
14311431
parseOrDefault("IPDScale", m_IpdScale, 1.0f);
1432-
parseOrDefault("6DOF", m_6DOF, false);
1433-
parseOrDefault("HudDistance", m_HudDistance, 1.3f);
1432+
parseOrDefault("6DOF", m_6DOF, true);
1433+
/*parseOrDefault("HudDistance", m_HudDistance, 1.3f);
14341434
parseOrDefault("HudSize", m_HudSize, 4.0f);
1435-
parseOrDefault("HudAlwaysVisible", m_HudAlwaysVisible, false);
1435+
parseOrDefault("HudAlwaysVisible", m_HudAlwaysVisible, false);*/
14361436
parseOrDefault("AimMode", m_AimMode, 2);
14371437
parseOrDefault("AntiAliasing", m_AntiAliasing, 0);
14381438
parseXYZOrDefaultZero("ViewmodelPosCustomOffset", m_ViewmodelPosCustomOffset);

0 commit comments

Comments
 (0)