mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
changed paint hook for logsystem and fixed some issue (#58)
* changed paint hook * Update gameclasses.cpp * fixed vector issue with logsystem (i think)
This commit is contained in:
parent
cb3aaa7640
commit
7f86722116
@ -127,10 +127,16 @@ namespace Hooks
|
||||
extern FrameUpdateFn originalFrameUpdate;
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CEngineVGui
|
||||
int CEngineVGui_Paint(void* thisptr, int mode);
|
||||
|
||||
using CEngineVGui_PaintFn = int(*)(void*, int);
|
||||
extern CEngineVGui_PaintFn originalCEngineVGui_Paint;
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Other
|
||||
int MSG_EngineError(char* fmt, va_list args);
|
||||
bool LoadPlaylist(const char* playlist);
|
||||
void CFPSPanel_Paint(void* thisptr);
|
||||
|
||||
using MSG_EngineErrorFn = int(*)(char*, va_list);
|
||||
extern MSG_EngineErrorFn originalMSG_EngineError;
|
||||
@ -138,8 +144,6 @@ namespace Hooks
|
||||
using LoadPlaylistFn = bool(*)(const char*);
|
||||
extern LoadPlaylistFn originalLoadPlaylist;
|
||||
|
||||
using CFPSPanel_PaintFn = void(*)(void*);
|
||||
extern CFPSPanel_PaintFn originalCFPSPanel_Paint;
|
||||
#pragma endregion
|
||||
|
||||
void InstallHooks();
|
||||
|
@ -150,9 +150,9 @@ namespace
|
||||
FUNC_AT_ADDRESS(addr_KeyValues_FindKey, void*(*)(void*, const char*, bool), r5_patterns.PatternSearch("40 56 57 41 57 48 81 EC ?? ?? ?? ?? 45").GetPtr());
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CFPSPanel
|
||||
/*0x14074A230*/
|
||||
FUNC_AT_ADDRESS(addr_CFPSPanel_Paint, void(*)(void*), r5_patterns.PatternSearch("48 8B C4 55 56 41 55 48 8D A8 ? ? ? ?").GetPtr());
|
||||
#pragma region CEngineVGui
|
||||
/*0x140283FD0*/
|
||||
FUNC_AT_ADDRESS(addr_CEngineVGui_Paint, int(*)(void*, int), r5_patterns.PatternSearch("41 55 41 56 48 83 EC 78 44 8B EA").GetPtr());
|
||||
#pragma endregion
|
||||
|
||||
|
||||
|
@ -372,7 +372,7 @@ if not EXIST $(SolutionDir)r5net\lib\$(Configuration)\r5net.lib (
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\shared\utility.cpp" />
|
||||
<ClCompile Include="src\CCompanion.cpp" />
|
||||
<ClCompile Include="src\cfpspanel.cpp" />
|
||||
<ClCompile Include="src\cenginevgui.cpp" />
|
||||
<ClCompile Include="src\console.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">pch.h</PrecompiledHeaderFile>
|
||||
|
@ -112,7 +112,7 @@
|
||||
<Filter Include="hooks\src\cmatsystemsurface">
|
||||
<UniqueIdentifier>{a2663195-c4f2-4d5f-8d65-cfed54976e4c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="hooks\src\cfpspanel">
|
||||
<Filter Include="hooks\src\cenginevgui">
|
||||
<UniqueIdentifier>{10a22c13-763e-4054-bf6a-8f4b61697520}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
@ -219,8 +219,8 @@
|
||||
<ClCompile Include="src\hooks\lockcursor.cpp">
|
||||
<Filter>hooks\src\cmatsystemsurface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cfpspanel.cpp">
|
||||
<Filter>hooks\src\cfpspanel</Filter>
|
||||
<ClCompile Include="src\cenginevgui.cpp">
|
||||
<Filter>hooks\src\cenginevgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\logsystem.cpp">
|
||||
<Filter>r5-sdk\src</Filter>
|
||||
|
29
r5dev/src/cenginevgui.cpp
Normal file
29
r5dev/src/cenginevgui.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "pch.h"
|
||||
#include "hooks.h"
|
||||
#include "logsystem.h"
|
||||
|
||||
namespace Hooks
|
||||
{
|
||||
CEngineVGui_PaintFn originalCEngineVGui_Paint = nullptr;
|
||||
}
|
||||
|
||||
int Hooks::CEngineVGui_Paint(void* thisptr, int mode)
|
||||
{
|
||||
int result = originalCEngineVGui_Paint(thisptr, mode);
|
||||
|
||||
static void* g_pMatSystemSurface = MemoryAddress(0x14D40B3B0).RCast<void* (*)()>();
|
||||
static auto RenderStart = MemoryAddress(0x14053EFC0).RCast<void(*)(void*)>();
|
||||
static auto RenderEnd = MemoryAddress(0x14053F1B0).RCast<void*(*)()>();
|
||||
|
||||
if (mode == 1 || mode == 2)
|
||||
{
|
||||
RenderStart(g_pMatSystemSurface);
|
||||
|
||||
g_LogSystem.Update();
|
||||
|
||||
RenderEnd();
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
#include "pch.h"
|
||||
#include "hooks.h"
|
||||
#include "logsystem.h"
|
||||
|
||||
namespace Hooks
|
||||
{
|
||||
CFPSPanel_PaintFn originalCFPSPanel_Paint = nullptr;
|
||||
}
|
||||
|
||||
void Hooks::CFPSPanel_Paint(void* thisptr)
|
||||
{
|
||||
originalCFPSPanel_Paint(thisptr);
|
||||
|
||||
g_LogSystem.Update();
|
||||
}
|
@ -414,6 +414,7 @@ namespace GameGlobals
|
||||
void* BanIDConCommand = CreateCustomConCommand("banid", "Bans a client from the Server via originID, userID or IP | Usage: banid (originID/ipAddress/userID)", 0, CustomCommandVariations::BanID_Callback, nullptr);
|
||||
|
||||
ConVar* DrawConsoleOverlayConVar = CreateCustomConVar("cl_drawconsoleoverlay", "0", 0, "Draw the console overlay at the top of the screen", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
ConVar* ConsoleOverlayLinesConVar = CreateCustomConVar("cl_consoleoverlay_lines", "3", 0, "Number of lines of console output to draw", false, 1.f, false, 50.f, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void* CreateCustomConCommand(const char* name, const char* helpString, int flags, void* callback, void* callbackAfterExecution)
|
||||
@ -528,4 +529,4 @@ const char* KeyValues::GetName()
|
||||
{
|
||||
return GameGlobals::KeyValuesSystem->GetStringForSymbol(MAKE_3_BYTES_FROM_1_AND_2(m_iKeyNameCaseSensitive, m_iKeyNameCaseSensitive2));
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
@ -59,7 +59,7 @@ void Hooks::InstallHooks()
|
||||
// Hook Utility functions
|
||||
MH_CreateHook(addr_MSG_EngineError, &Hooks::MSG_EngineError, reinterpret_cast<void**>(&originalMSG_EngineError));
|
||||
MH_CreateHook(addr_LoadPlaylist, &Hooks::LoadPlaylist, reinterpret_cast<void**>(&originalLoadPlaylist));
|
||||
MH_CreateHook(addr_CFPSPanel_Paint, &Hooks::CFPSPanel_Paint, reinterpret_cast<void**>(&originalCFPSPanel_Paint));
|
||||
MH_CreateHook(addr_CEngineVGui_Paint, &Hooks::CEngineVGui_Paint, reinterpret_cast<void**>(&originalCEngineVGui_Paint));
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Hook WinAPI
|
||||
@ -122,7 +122,7 @@ void Hooks::InstallHooks()
|
||||
// Enabled Utility hooks
|
||||
MH_EnableHook(addr_MSG_EngineError);
|
||||
MH_EnableHook(addr_LoadPlaylist);
|
||||
MH_EnableHook(addr_CFPSPanel_Paint);
|
||||
MH_EnableHook(addr_CEngineVGui_Paint);
|
||||
}
|
||||
|
||||
void Hooks::RemoveHooks()
|
||||
@ -176,7 +176,7 @@ void Hooks::RemoveHooks()
|
||||
// Unhook Utility functions
|
||||
MH_RemoveHook(addr_MSG_EngineError);
|
||||
MH_RemoveHook(addr_LoadPlaylist);
|
||||
MH_RemoveHook(addr_CFPSPanel_Paint);
|
||||
MH_RemoveHook(addr_CEngineVGui_Paint);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Unhook CBaseFileSystem functions.
|
||||
|
@ -19,8 +19,13 @@ void LogSystem::Update()
|
||||
if (GameGlobals::Cvar->FindVar("cl_drawconsoleoverlay")->m_iValue < 1)
|
||||
return;
|
||||
|
||||
if (i < LOGSYSTEM_LINES_TO_SHOW) {
|
||||
if (i < GameGlobals::Cvar->FindVar("cl_consoleoverlay_lines")->m_iValue)
|
||||
{
|
||||
|
||||
if (i >= m_vLogs.size())
|
||||
{
|
||||
break;
|
||||
}
|
||||
float fadepct = fminf(float(m_vLogs[i].Ticks) / 64.f, 1.0);
|
||||
|
||||
float ptc = (int)ceilf( fadepct * 255.f);
|
||||
@ -32,6 +37,10 @@ void LogSystem::Update()
|
||||
|
||||
MemoryAddress(0x140547900).RCast<void(*)(void*, QWORD, __int64, QWORD, int, int, DWORD, DWORD, DWORD, const char*, ...)>()(g_pMatSystemSurface, 0x13, fontHeight, 10, y, color[0], color[1], color[2], alpha, m_vLogs[i].Message.c_str());
|
||||
}
|
||||
else {
|
||||
m_vLogs.erase(m_vLogs.begin());
|
||||
continue;
|
||||
}
|
||||
|
||||
m_vLogs[i].Ticks--;
|
||||
}
|
||||
@ -48,9 +57,6 @@ void LogSystem::AddLog(LogType_t type, std::string message)
|
||||
log.Message = message;
|
||||
log.Type = type;
|
||||
log.Ticks = 1024;
|
||||
if (m_vLogs.size() > LOGSYSTEM_LINES_TO_SHOW-1) {
|
||||
m_vLogs.erase(m_vLogs.begin());
|
||||
}
|
||||
m_vLogs.push_back(log);
|
||||
}
|
||||
|
||||
@ -64,5 +70,7 @@ std::array<int, 3> LogSystem::GetLogColorForType(LogType_t type) {
|
||||
return { 117, 116, 139 };
|
||||
case LogType_t::SCRIPT_UI:
|
||||
return { 197, 160, 177 };
|
||||
default:
|
||||
return { 255, 255, 255 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user