Skip to content

Commit

Permalink
Add camera position to debug overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Nov 11, 2023
1 parent 031c974 commit c00ff86
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 4 deletions.
62 changes: 61 additions & 1 deletion Patches/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ DWORD *SpecializedLight1Addr = nullptr;
DWORD *SpecializedLight2Addr = nullptr;
DWORD *TransitionStateAddr = nullptr;
BYTE *FullscreenImageEventAddr = nullptr;
float *InGameCameraPosYAddr = nullptr;
float* InGameCameraPosXAddr = nullptr;
float* InGameCameraPosYAddr = nullptr;
float* InGameCameraPosZAddr = nullptr;
BYTE *InventoryStatusAddr = nullptr;
DWORD *LoadingScreenAddr = nullptr;
BYTE *PauseMenuButtonIndexAddr = nullptr;
Expand Down Expand Up @@ -659,6 +661,35 @@ BYTE *GetFullscreenImageEventPointer()
return FullscreenImageEventAddr;
}

float GetInGameCameraPosX()
{
float* pInGameCameraPosX = GetInGameCameraPosXPointer();

return (pInGameCameraPosX) ? *pInGameCameraPosX : 0.0f;
}

// Get Camera in-game position X
float* GetInGameCameraPosXPointer()
{
if (InGameCameraPosXAddr)
{
return InGameCameraPosXAddr;
}

// Get Camera Pos Y address
void* CameraPosYAddr = GetInGameCameraPosYPointer();

// Checking address pointer
if (!CameraPosYAddr)
{
Logging::Log() << __FUNCTION__ << " Error: failed to find Camera Pos Y address!";
return nullptr;
}
InGameCameraPosXAddr = (float*)((DWORD)CameraPosYAddr - 0x04);

return InGameCameraPosXAddr;
}

float GetInGameCameraPosY()
{
float *pInGameCameraPosY = GetInGameCameraPosYPointer();
Expand Down Expand Up @@ -688,6 +719,35 @@ float *GetInGameCameraPosYPointer()
return InGameCameraPosYAddr;
}

float GetInGameCameraPosZ()
{
float* pInGameCameraPosZ = GetInGameCameraPosZPointer();

return (pInGameCameraPosZ) ? *pInGameCameraPosZ : 0.0f;
}

// Get Camera in-game position Z
float* GetInGameCameraPosZPointer()
{
if (InGameCameraPosZAddr)
{
return InGameCameraPosZAddr;
}

// Get Camera Pos Y address
void* CameraPosYAddr = GetInGameCameraPosYPointer();

// Checking address pointer
if (!CameraPosYAddr)
{
Logging::Log() << __FUNCTION__ << " Error: failed to find Camera Pos Y address!";
return nullptr;
}
InGameCameraPosZAddr = (float*)((DWORD)CameraPosYAddr + 0x04);

return InGameCameraPosZAddr;
}

BYTE GetInventoryStatus()
{
BYTE *pInventoryStatus = GetInventoryStatusPointer();
Expand Down
10 changes: 8 additions & 2 deletions Patches/Patches.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ BYTE GetEventIndex();
BYTE GetMenuEvent();
DWORD GetTransitionState();
BYTE GetFullscreenImageEvent();
float GetInGameCameraPosX();
float GetInGameCameraPosY();
float GetInGameCameraPosZ();
BYTE GetInventoryStatus();
DWORD GetLoadingScreen();
BYTE GetPauseMenuButtonIndex();
Expand Down Expand Up @@ -101,7 +103,9 @@ BYTE *GetEventIndexPointer();
BYTE *GetMenuEventPointer();
DWORD *GetTransitionStatePointer();
BYTE *GetFullscreenImageEventPointer();
float *GetInGameCameraPosYPointer();
float* GetInGameCameraPosXPointer();
float* GetInGameCameraPosYPointer();
float* GetInGameCameraPosZPointer();
BYTE *GetInventoryStatusPointer();
DWORD *GetLoadingScreenPointer();
BYTE *GetPauseMenuButtonIndexPointer();
Expand Down Expand Up @@ -366,7 +370,9 @@ extern DWORD *TransitionStateAddr; /* 1 = fades the game image to black
3 = fades from black back to the in game screen */

extern BYTE *FullscreenImageEventAddr;
extern float *InGameCameraPosYAddr;
extern float* InGameCameraPosXAddr;
extern float* InGameCameraPosYAddr;
extern float* InGameCameraPosZAddr;
extern BYTE *InventoryStatusAddr;
extern DWORD *LoadingScreenAddr;
extern int SpecularFlag;
Expand Down
2 changes: 1 addition & 1 deletion Resources/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 2088
#define BUILD_NUMBER 2089
9 changes: 9 additions & 0 deletions Wrappers/d3d8/Overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ void Overlay::DrawDebugOverlay(LPDIRECT3DDEVICE8 ProxyInterface)
OvlString.append("\rChar Z Position: ");
OvlString.append(FloatToStr(GetJamesPosZ(), FloatPrecision));

OvlString.append("\rCamera X Position: ");
OvlString.append(FloatToStr(GetInGameCameraPosX(), FloatPrecision));

OvlString.append("\rCamera Y Position: ");
OvlString.append(FloatToStr(GetInGameCameraPosY(), FloatPrecision));

OvlString.append("\rCamera Z Position: ");
OvlString.append(FloatToStr(GetInGameCameraPosZ(), FloatPrecision));

OvlString.append("\rRight Click Function: ");
OvlString.append(InputTweaksRef.GetRightClickState());

Expand Down

0 comments on commit c00ff86

Please sign in to comment.