add back warning

This commit is contained in:
FutureRave 2023-02-03 01:13:35 +00:00
parent ce63647cd4
commit 2360a29bcf
No known key found for this signature in database
GPG Key ID: 22F9079C86CFAB31
5 changed files with 76 additions and 24 deletions

View File

@ -145,6 +145,8 @@ namespace game
float* com_codeTimeScale; float* com_codeTimeScale;
int* com_frameTime;
RTL_CRITICAL_SECTION* s_criticalSection; RTL_CRITICAL_SECTION* s_criticalSection;
int* logfile; int* logfile;
@ -873,6 +875,8 @@ namespace game
native::com_codeTimeScale = reinterpret_cast<float*>(SELECT_VALUE(0x1769F1C, 0x1CEF554)); native::com_codeTimeScale = reinterpret_cast<float*>(SELECT_VALUE(0x1769F1C, 0x1CEF554));
native::com_frameTime = reinterpret_cast<int*>(SELECT_VALUE(0x0, 0x1CF0B88));
native::s_criticalSection = reinterpret_cast<RTL_CRITICAL_SECTION*>(SELECT_VALUE(0x1CD5638, 0x5A91048)); native::s_criticalSection = reinterpret_cast<RTL_CRITICAL_SECTION*>(SELECT_VALUE(0x1CD5638, 0x5A91048));
native::logfile = reinterpret_cast<int*>(SELECT_VALUE(0x176B534, 0x1CF0B78)); native::logfile = reinterpret_cast<int*>(SELECT_VALUE(0x176B534, 0x1CF0B78));

View File

@ -278,6 +278,8 @@ namespace game
extern float* com_codeTimeScale; extern float* com_codeTimeScale;
extern int* com_frameTime;
extern RTL_CRITICAL_SECTION* s_criticalSection; extern RTL_CRITICAL_SECTION* s_criticalSection;
extern int* logfile; extern int* logfile;

View File

@ -90,7 +90,7 @@ int main()
FARPROC entry_point; FARPROC entry_point;
enable_dpi_awareness(); enable_dpi_awareness();
std::srand(uint32_t(time(nullptr))); std::srand(static_cast<std::uint32_t>(time(nullptr)) ^ ~(GetTickCount() * GetCurrentProcessId()));
{ {
auto premature_shutdown = true; auto premature_shutdown = true;

View File

@ -29,7 +29,7 @@ namespace
void dump_gsc_script(const std::string& name, game::native::XAssetHeader header) void dump_gsc_script(const std::string& name, game::native::XAssetHeader header)
{ {
if (g_dump_scripts->current.enabled) if (!g_dump_scripts->current.enabled)
{ {
return; return;
} }

View File

@ -4,6 +4,70 @@
#include <utils/hook.hpp> #include <utils/hook.hpp>
#include "console.hpp"
namespace
{
__declspec(noreturn) void long_jump_stub(jmp_buf buf, const int value) noexcept(false)
{
#ifdef _DEBUG
{
printf("Unwinding the stack...\n");
}
#endif
longjmp(buf, value);
}
const game::native::dvar_t* dvar_register_com_max_fps(const char* dvarName, int value,
int min, int /*max*/, unsigned __int16 /*flags*/, const char* description)
{
return game::native::Dvar_RegisterInt(dvarName, value, min, 1000, game::native::DVAR_ARCHIVE, description);
}
const char* live_get_local_client_name_stub()
{
return game::native::Dvar_FindVar("name")->current.string;
}
void com_clamp_msec(const int msec)
{
if (msec > 500 && msec < 500000)
{
console::warn("Hitch warning: %i msec frame time\n", msec);
}
}
__declspec(naked) void com_clamp_msec_stub()
{
using namespace game::native;
__asm
{
pushad
push esi
call com_clamp_msec
add esp, 0x4
popad
// Game's code
cmp esi, eax
jle label_5565DA
mov esi, eax
push 0x5565D6
ret
label_5565DA:
push 0x5565DA
ret
}
}
}
class patches final : public module class patches final : public module
{ {
public: public:
@ -56,6 +120,10 @@ private:
utils::hook(0x5C9980, &live_get_local_client_name_stub, HOOK_JUMP).install()->quick(); utils::hook(0x5C9980, &live_get_local_client_name_stub, HOOK_JUMP).install()->quick();
// Add back warning
utils::hook(0x5565D0, &com_clamp_msec_stub, HOOK_JUMP).install()->quick(); // Com_Frame_Try_Block_Function
utils::hook::nop(0x5565D0 + 5, 1);
// Unpure client detected // Unpure client detected
utils::hook::set<std::uint8_t>(0x57228C, 0xEB); utils::hook::set<std::uint8_t>(0x57228C, 0xEB);
@ -76,28 +144,6 @@ private:
utils::hook::nop(0x47EB9D, 5); utils::hook::nop(0x47EB9D, 5);
utils::hook::nop(0x47EBC9, 5); utils::hook::nop(0x47EBC9, 5);
} }
static __declspec(noreturn) void long_jump_stub(jmp_buf buf, const int value) noexcept(false)
{
#ifdef _DEBUG
{
printf("Unwinding the stack...\n");
}
#endif
longjmp(buf, value);
}
static const game::native::dvar_t* dvar_register_com_max_fps(const char* dvarName, int value,
int min, int /*max*/, unsigned __int16 /*flags*/, const char* description)
{
return game::native::Dvar_RegisterInt(dvarName, value, min, 1000, game::native::DVAR_ARCHIVE, description);
}
static const char* live_get_local_client_name_stub()
{
return game::native::Dvar_FindVar("name")->current.string;
}
}; };
REGISTER_MODULE(patches) REGISTER_MODULE(patches)