Skip to content

Commit 14c3448

Browse files
committed
Disable instant back to gameplay camera after disabling free cam
1 parent bb9e512 commit 14c3448

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

Camera.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void __cdecl GAMELOOP_Process(int a1)
9393
{
9494
origGAMELOOP_Process(a1);
9595

96-
if (Hooking::GetInstance().GetMenu()->IsFreecam())
96+
if (Hooking::GetInstance().GetMenu()->GetFreeCamMode() == FreeCameraMode::enabled)
9797
{
9898
auto speed = IsActionPressed(34);
9999
auto camera = *reinterpret_cast<int*>(0xE80534);

Hooking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Hooking::Hooking()
4545
InsertTerrainDrawableHooks();
4646

4747
#if TRAE // TODO
48-
InstallSoundHooks();
48+
//InstallSoundHooks();
4949

5050
MH_CreateHook((void*)0x467E60, MakePeHandle, nullptr);
5151
#elif TR7

Menu.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,27 @@ void Menu::Process(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
391391
auto cameraMode = (int*)0x850984;
392392
*cameraMode = *cameraMode == 7 ? 2 : 7;
393393
#elif TR8
394-
m_freecam = !m_freecam;
395-
if (m_freecam)
394+
if (m_freeCamMode == FreeCameraMode::disabled)
396395
{
396+
// enable free camera
397+
m_freeCamMode = FreeCameraMode::enabled;
398+
399+
// switch to camera
397400
CAMERA_SetMode(11);
398401

399402
auto camera = *(int*)0xE80534;
400403
*(cdc::Vector*)(camera + 0x40) = (*(Instance**)PLAYERINSTANCE)->position;
401404
}
402-
else
405+
else if (m_freeCamMode == FreeCameraMode::enabled)
403406
{
407+
// disable free camera but keep camera active
408+
m_freeCamMode = FreeCameraMode::nocontrol;
409+
}
410+
else if (m_freeCamMode == FreeCameraMode::nocontrol)
411+
{
412+
m_freeCamMode = FreeCameraMode::disabled;
413+
414+
// switch back to gameplay camera
404415
_setToGameplayCamera(0xE804F0 /* AVCameraManager */);
405416
}
406417
#endif
@@ -1078,9 +1089,9 @@ bool Menu::IsFocus() const noexcept
10781089
return m_focus;
10791090
}
10801091

1081-
bool Menu::IsFreecam() const noexcept
1092+
FreeCameraMode Menu::GetFreeCamMode() const noexcept
10821093
{
1083-
return m_freecam;
1094+
return m_freeCamMode;
10841095
}
10851096

10861097
void Menu::SetFocus(bool value) noexcept

Menu.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
#include "Game.hpp"
1010

11+
enum class FreeCameraMode
12+
{
13+
enabled,
14+
nocontrol,
15+
disabled,
16+
};
17+
1118
struct DrawSettings
1219
{
1320
bool draw = false;
@@ -42,7 +49,7 @@ class Menu
4249
void SetDevice(LPDIRECT3DDEVICE9 pd3dDevice);
4350
void Log(const char* fmt, ...);
4451

45-
bool IsFreecam() const noexcept;
52+
FreeCameraMode GetFreeCamMode() const noexcept;
4653
bool IsFocus() const noexcept;
4754
bool IsVisible() const noexcept;
4855
void SetFocus(bool value) noexcept;
@@ -70,7 +77,7 @@ class Menu
7077
bool m_visible = true;
7178
bool m_isAzertyLayout = false;
7279

73-
bool m_freecam = false;
80+
FreeCameraMode m_freeCamMode = FreeCameraMode::disabled;
7481

7582
ImGuiTextBuffer logBuffer;
7683

0 commit comments

Comments
 (0)