maint: remove is_dedi since nothing dedi related works

This commit is contained in:
Diavolo 2022-12-09 14:50:13 +01:00
parent 902c15aeef
commit 3620facbdf
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
36 changed files with 299 additions and 785 deletions

View File

@ -19,6 +19,8 @@ function libtomcrypt.includes()
"LTC_NO_FAST", "LTC_NO_FAST",
"LTC_NO_PROTOTYPES", "LTC_NO_PROTOTYPES",
"LTC_NO_RSA_BLINDING", "LTC_NO_RSA_BLINDING",
"LTC_NO_FILE",
"ARGTYPE=4",
} }
end end
@ -34,6 +36,7 @@ function libtomcrypt.project()
} }
removefiles { removefiles {
path.join(libtomcrypt.source, "src/**/*_test.c"),
path.join(libtomcrypt.source, "src/**/*tab.c"), path.join(libtomcrypt.source, "src/**/*tab.c"),
path.join(libtomcrypt.source, "src/encauth/ocb3/**.c"), path.join(libtomcrypt.source, "src/encauth/ocb3/**.c"),
} }

View File

@ -104,8 +104,6 @@ namespace game
gentity_s* g_entities; gentity_s* g_entities;
level_locals_t* level;
DeferredQueue* deferredQueue; DeferredQueue* deferredQueue;
float* com_codeTimeScale; float* com_codeTimeScale;
@ -140,11 +138,8 @@ namespace game
SV_GameSendServerCommand_t SV_GameSendServerCommand; SV_GameSendServerCommand_t SV_GameSendServerCommand;
client_t* svs_clients; client_t* svs_clients;
}
namespace dedi level_locals_t* level;
{
client_t* svs_clients;
} }
namespace sp namespace sp
@ -168,8 +163,7 @@ namespace game
else if ((value->type & ~1) == SCRIPT_STRING) else if ((value->type & ~1) == SCRIPT_STRING)
{ {
static const auto size = is_sp() ? 16 : 12; static const auto size = is_sp() ? 16 : 12;
const auto ref_count = reinterpret_cast<unsigned volatile *>(*scrMemTreePub + size * value const auto ref_count = reinterpret_cast<unsigned volatile *>(*scrMemTreePub + size * value->u.stringValue);
->u.stringValue);
InterlockedIncrement(ref_count); InterlockedIncrement(ref_count);
} }
else if (value->type == SCRIPT_VECTOR) else if (value->type == SCRIPT_VECTOR)
@ -181,78 +175,19 @@ namespace game
} }
} }
__declspec(naked) unsigned int conbuf_append_text_dedicated(const char* message)
{
static DWORD func = 0x53C790;
__asm
{
mov ecx, message
call func
retn
}
}
void Conbuf_AppendText(const char* message) void Conbuf_AppendText(const char* message)
{ {
if (is_dedi()) reinterpret_cast<void(*)(const char*)>(SELECT_VALUE(0x4C84E0, 0x5CF610))(message);
{
conbuf_append_text_dedicated(message);
}
else
{
reinterpret_cast<void(*)(const char*)>(SELECT_VALUE(0x4C84E0, 0x5CF610, 0))(message);
}
}
__declspec(naked) unsigned int find_variable_dedicated(unsigned int parentId, unsigned int name)
{
static DWORD func = 0x4E7ED0;
__asm
{
mov eax, name
mov ecx, parentId
call func
retn
}
} }
unsigned int FindVariable(const unsigned int parentId, const unsigned int name) unsigned int FindVariable(const unsigned int parentId, const unsigned int name)
{ {
if (is_dedi()) return reinterpret_cast<unsigned int(*)(unsigned int, unsigned int)>(SELECT_VALUE(0x4C4E70, 0x5651F0))(parentId, name);
{
return find_variable_dedicated(parentId, name);
}
return reinterpret_cast<unsigned int(*)(unsigned int, unsigned int)> //
(SELECT_VALUE(0x4C4E70, 0x5651F0, 0x0))(parentId, name);
}
__declspec(naked) VariableValue get_entity_field_value_dedicated(unsigned int classnum, int entnum, int _offset)
{
static DWORD func = 0x4F1400;
__asm
{
push _offset
push entnum
mov ecx, classnum
call func
add esp, 8h
retn
}
} }
VariableValue GetEntityFieldValue(const unsigned int classnum, const int entnum, const int offset) VariableValue GetEntityFieldValue(const unsigned int classnum, const int entnum, const int offset)
{ {
if (is_dedi()) return reinterpret_cast<VariableValue(*)(unsigned int, int, int)>(SELECT_VALUE(0x530E30, 0x56AF20))(classnum, entnum, offset);
{
return get_entity_field_value_dedicated(classnum, entnum, offset);
}
return reinterpret_cast<VariableValue(*)(unsigned int, int, int)> //
(SELECT_VALUE(0x530E30, 0x56AF20, 0x0))(classnum, entnum, offset);
} }
void* MT_Alloc(const int numBytes, const int type) void* MT_Alloc(const int numBytes, const int type)
@ -260,104 +195,23 @@ namespace game
return scrMemTreeGlob + 12 * size_t(MT_AllocIndex(numBytes, type)); return scrMemTreeGlob + 12 * size_t(MT_AllocIndex(numBytes, type));
} }
__declspec(naked) dvar_t* dvar_find_malleable_var(const char* dvar_name)
{
static DWORD func = 0x531320;
__asm
{
mov edi, dvar_name
call func
retn
}
}
dvar_t* Dvar_FindVar(const char* dvarName) dvar_t* Dvar_FindVar(const char* dvarName)
{ {
if (is_dedi()) return reinterpret_cast<dvar_t*(*)(const char*)>(SELECT_VALUE(0x539550, 0x5BDCC0))(dvarName);
{
return dvar_find_malleable_var(dvarName);
}
return reinterpret_cast<dvar_t*(*)(const char*)>
(SELECT_VALUE(0x539550, 0x5BDCC0, 0x0))(dvarName);
}
__declspec(naked) const dvar_t* dvar_register_variant_dedicated(const char* dvar_name, unsigned char type,
unsigned __int16 flags, DvarValue value, DvarLimits domain, const char* description)
{
static DWORD func = 0x531F70;
__asm
{
push eax
pushad
mov edi, [esp + 0x24 + 0x28] // description
mov eax, [esp + 0x24 + 0x4] // dvarName
push [esp + 0x24 + 0x24] // domain
push [esp + 0x24 + 0x24] // domain
push [esp + 0x24 + 0x24] // value
push [esp + 0x24 + 0x24] // value
push [esp + 0x24 + 0x24] // value
push [esp + 0x24 + 0x24] // value
push [esp + 0x24 + 0x24] // flags
push [esp + 0x24 + 0x24] // type
call func
add esp, 0x20
mov [esp + 0x20], eax // result
popad
pop eax
retn
}
} }
const dvar_t* Dvar_RegisterFloat(const char* dvarName, float value, const dvar_t* Dvar_RegisterFloat(const char* dvarName, float value,
float min, float max, unsigned __int16 flags, const char* description) float min, float max, unsigned __int16 flags, const char* description)
{ {
if (!is_dedi()) return reinterpret_cast<const dvar_t*(*)(const char*, float, float, float, unsigned __int16, const char*)> //
{ (SELECT_VALUE(0x4F9CC0, 0x5BEA80))(dvarName, value, min, max, flags, description);
return reinterpret_cast<const dvar_t*(*)(const char*, float, float, float, unsigned __int16, const char*)>
(SELECT_VALUE(0x4F9CC0, 0x5BEA80, 0x0))(dvarName, value, min, max, flags, description);
}
DvarLimits domain;
DvarValue dvar_value;
domain.value.min = min;
domain.value.max = max;
dvar_value.value = value;
return dvar_register_variant_dedicated(dvarName, DVAR_TYPE_FLOAT,
flags, dvar_value, domain, description);
} }
const dvar_t* Dvar_RegisterInt(const char* dvarName, int value, const dvar_t* Dvar_RegisterInt(const char* dvarName, int value,
int min, int max, unsigned __int16 flags, const char* description) int min, int max, unsigned __int16 flags, const char* description)
{ {
if (!is_dedi()) return reinterpret_cast<const dvar_t*(*)(const char*, int, int, int, unsigned __int16, const char*)> //
{ (SELECT_VALUE(0x48CD40, 0x5BEA40))(dvarName, value, min, max, flags, description);
return reinterpret_cast<const dvar_t*(*)(const char*, int, int, int, unsigned __int16, const char*)>
(SELECT_VALUE(0x48CD40, 0x5BEA40, 0x0))(dvarName, value, min, max, flags, description);
}
DvarLimits domain;
DvarValue dvar_value;
domain.integer.min = min;
domain.integer.max = max;
dvar_value.integer = value;
return dvar_register_variant_dedicated(dvarName, DVAR_TYPE_INT,
flags, dvar_value, domain, description);
} }
void IncInParam() void IncInParam()
@ -400,18 +254,17 @@ namespace game
scr_entref_t Scr_GetEntityIdRef(const unsigned int id) scr_entref_t Scr_GetEntityIdRef(const unsigned int id)
{ {
static auto class_array = reinterpret_cast<DWORD*>(SELECT_VALUE(0x19AFC84, 0x1E72184, 0x1D3C804)); static auto class_array = reinterpret_cast<DWORD*>(SELECT_VALUE(0x19AFC84, 0x1E72184));
static auto ent_array = reinterpret_cast<WORD*>(SELECT_VALUE(0x19AFC82, 0x1E72182, 0x1D3C802)); static auto ent_array = reinterpret_cast<WORD*>(SELECT_VALUE(0x19AFC82, 0x1E72182));
scr_entref_t result{}; scr_entref_t result;
result.raw.classnum = static_cast<unsigned short>(class_array[2 * id]) >> 8; result.raw.classnum = static_cast<unsigned short>(class_array[2 * id]) >> 8;
result.raw.entnum = ent_array[4 * id]; result.raw.entnum = ent_array[4 * id];
return result; return result;
} }
__declspec(naked) void scr_notify_id_multiplayer(unsigned int id, unsigned int string_value, __declspec(naked) void scr_notify_id_multiplayer(unsigned int id, unsigned int string_value, unsigned int paramcount)
unsigned int paramcount)
{ {
static DWORD func = 0x56B5E0; static DWORD func = 0x56B5E0;
@ -426,8 +279,7 @@ namespace game
} }
} }
__declspec(naked) void scr_notify_id_singleplayer(unsigned int id, unsigned int string_value, __declspec(naked) void scr_notify_id_singleplayer(unsigned int id, unsigned int string_value, unsigned int paramcount)
unsigned int paramcount)
{ {
static DWORD func = 0x610980; static DWORD func = 0x610980;
@ -448,66 +300,21 @@ namespace game
{ {
scr_notify_id_multiplayer(id, stringValue, paramcount); scr_notify_id_multiplayer(id, stringValue, paramcount);
} }
else if (is_sp())
{
scr_notify_id_singleplayer(id, stringValue, paramcount);
}
else else
{ {
reinterpret_cast<void(*)(unsigned int, unsigned int, unsigned int)>(0x4EFAA0) scr_notify_id_singleplayer(id, stringValue, paramcount);
(id, stringValue, paramcount);
}
}
__declspec(naked) int scr_set_object_field_dedicated(unsigned int classnum, int entnum, int _offset)
{
static DWORD func = 0x4B15C0;
__asm
{
mov ecx, _offset
mov eax, entnum
push classnum
call func
add esp, 4h
retn
} }
} }
int Scr_SetObjectField(const unsigned int classnum, const int entnum, const int offset) int Scr_SetObjectField(const unsigned int classnum, const int entnum, const int offset)
{ {
if (is_dedi())
{
return scr_set_object_field_dedicated(classnum, entnum, offset);
}
return reinterpret_cast<int(*)(unsigned int, int, int)> // return reinterpret_cast<int(*)(unsigned int, int, int)> //
(SELECT_VALUE(0x42CAD0, 0x52BCC0, 0x0))(classnum, entnum, offset); (SELECT_VALUE(0x42CAD0, 0x52BCC0))(classnum, entnum, offset);
}
__declspec(naked) void scr_add_string_dedicated(const char* value)
{
static DWORD func = 0x4F1010;
__asm
{
mov edi, value
call func
retn
}
} }
void Scr_AddString(const char* value) void Scr_AddString(const char* value)
{ {
if (is_dedi()) reinterpret_cast<void(*)(const char*)> (SELECT_VALUE(0x4A5600, 0x56AC00))(value);
{
scr_add_string_dedicated(value);
}
else
{
reinterpret_cast<void(*)(const char*)>
(SELECT_VALUE(0x4A5600, 0x56AC00, 0x0))(value);
}
} }
void Scr_AddInt(int value) void Scr_AddInt(int value)
@ -533,7 +340,7 @@ namespace game
unsigned int sl_get_canonical_string(const char* string) unsigned int sl_get_canonical_string(const char* string)
{ {
static DWORD func = SELECT_VALUE(0x610750, 0x56B040, 0x0); static DWORD func = SELECT_VALUE(0x610750, 0x56B040);
unsigned int result{}; unsigned int result{};
__asm __asm
@ -548,33 +355,11 @@ namespace game
return result; return result;
} }
unsigned int sl_get_canonical_dedicated(const char* string)
{
static DWORD func = 0x4F1620;
unsigned int result{};
__asm
{
pushad
mov esi, string
call func
mov result, eax
popad
}
return result;
}
unsigned int SL_GetCanonicalString(const char* str) unsigned int SL_GetCanonicalString(const char* str)
{
if (!is_dedi())
{ {
return sl_get_canonical_string(str); return sl_get_canonical_string(str);
} }
return sl_get_canonical_dedicated(str);
}
__declspec(naked) void sv_send_client_game_state_mp(mp::client_t* /*client*/) __declspec(naked) void sv_send_client_game_state_mp(mp::client_t* /*client*/)
{ {
static DWORD func = 0x570FC0; static DWORD func = 0x570FC0;
@ -601,12 +386,7 @@ namespace game
int SV_IsTestClient(int clientNum) int SV_IsTestClient(int clientNum)
{ {
assert(clientNum < *svs_clientCount); assert(clientNum < MAX_CLIENTS);
if (is_dedi())
{
return dedi::svs_clients[clientNum].bIsTestClient;
}
if (is_mp()) if (is_mp())
{ {
@ -620,8 +400,7 @@ namespace game
{ {
if (is_mp()) if (is_mp())
{ {
reinterpret_cast<void(*)(mp::client_t*, const char*, bool)> reinterpret_cast<void(*)(mp::client_t*, const char*, bool)>(0x570980)(drop, reason, tellThem);
(0x570980)(drop, reason, tellThem);
} }
} }
@ -645,25 +424,9 @@ namespace game
} }
} }
__declspec(naked) void client_command_dedicated(int client_num)
{
static DWORD func = 0x47EA40;
__asm
{
mov edi, client_num
call func
retn
}
}
void ClientCommand(int clientNum) void ClientCommand(int clientNum)
{ {
if (is_dedi()) if (is_mp())
{
client_command_dedicated(clientNum);
}
else if (is_mp())
{ {
reinterpret_cast<void(*)(int)>(0x502CB0)(clientNum); reinterpret_cast<void(*)(int)>(0x502CB0)(clientNum);
} }
@ -679,61 +442,17 @@ namespace game
addr->type = type; addr->type = type;
} }
__declspec(naked) void cbuf_add_text_dedicated(LocalClientNum_t local_client_num, const char* text)
{
static DWORD func = 0x4CB5D0;
__asm
{
mov eax, text
push local_client_num
call func
add esp, 4h
retn
}
}
void Cbuf_AddText(LocalClientNum_t localClientNum, const char* text) void Cbuf_AddText(LocalClientNum_t localClientNum, const char* text)
{ {
if (is_dedi()) reinterpret_cast<void(*)(LocalClientNum_t, const char*)> //
{ (SELECT_VALUE(0x457C90, 0x545680))(localClientNum, text);
cbuf_add_text_dedicated(localClientNum, text);
}
else
{
reinterpret_cast<void(*)(LocalClientNum_t, const char*)>
(SELECT_VALUE(0x457C90, 0x545680, 0x0))(localClientNum, text);
}
}
void teleport_player_dedicated(gentity_s* player, float* origin, float* angles)
{
static DWORD func = 0x48B840;
__asm
{
pushad
mov eax, player
mov ecx, origin
push angles
call func
add esp, 4h
popad
}
} }
void TeleportPlayer(gentity_s* player, float* origin, float* angles) void TeleportPlayer(gentity_s* player, float* origin, float* angles)
{ {
if (is_dedi()) if (is_mp())
{ {
teleport_player_dedicated(player, origin, angles); reinterpret_cast<void(*)(gentity_s*, float*, float*)>(0x50D840)(player, origin, angles);
}
else if (is_mp())
{
reinterpret_cast<void(*)(gentity_s*, float*, float*)>
(0x50D840)(player, origin, angles);
} }
} }
@ -744,7 +463,7 @@ namespace game
{ {
reinterpret_cast<void(*)(LocalClientNum_t, const char*)>(0x456DC0)(localClientNum, msg); reinterpret_cast<void(*)(LocalClientNum_t, const char*)>(0x456DC0)(localClientNum, msg);
} }
else if (is_sp()) else
{ {
reinterpret_cast<void(*)(LocalClientNum_t, const char*, int)>(0x4228A0)(localClientNum, msg, flags); reinterpret_cast<void(*)(LocalClientNum_t, const char*, int)>(0x4228A0)(localClientNum, msg, flags);
} }
@ -752,7 +471,7 @@ namespace game
void Sys_EnterCriticalSection(CriticalSection critSect) void Sys_EnterCriticalSection(CriticalSection critSect)
{ {
assert(static_cast<unsigned int>(critSect) < assert(static_cast<unsigned int>(critSect) < //
static_cast<unsigned int>(CRITSECT_COUNT)); static_cast<unsigned int>(CRITSECT_COUNT));
EnterCriticalSection(&s_criticalSection[critSect]); EnterCriticalSection(&s_criticalSection[critSect]);
@ -760,7 +479,7 @@ namespace game
void Sys_LeaveCriticalSection(CriticalSection critSect) void Sys_LeaveCriticalSection(CriticalSection critSect)
{ {
assert(static_cast<unsigned int>(critSect) < assert(static_cast<unsigned int>(critSect) < //
static_cast<unsigned int>(CRITSECT_COUNT)); static_cast<unsigned int>(CRITSECT_COUNT));
LeaveCriticalSection(&s_criticalSection[critSect]); LeaveCriticalSection(&s_criticalSection[critSect]);
@ -768,7 +487,7 @@ namespace game
bool Sys_TryEnterCriticalSection(CriticalSection critSect) bool Sys_TryEnterCriticalSection(CriticalSection critSect)
{ {
assert(static_cast<unsigned int>(critSect) < assert(static_cast<unsigned int>(critSect) < //
static_cast<unsigned int>(CRITSECT_COUNT)); static_cast<unsigned int>(CRITSECT_COUNT));
return TryEnterCriticalSection(&s_criticalSection[critSect]) != FALSE; return TryEnterCriticalSection(&s_criticalSection[critSect]) != FALSE;
@ -809,30 +528,9 @@ namespace game
return id == *threadId[THREAD_CONTEXT_SERVER]; return id == *threadId[THREAD_CONTEXT_SERVER];
} }
void fs_fclose_file_dedicated(int h)
{
static DWORD func = 0x524910;
__asm
{
pushad
mov eax, h
call func
popad
}
}
void FS_FCloseFile(int h) void FS_FCloseFile(int h)
{ {
if (is_dedi()) reinterpret_cast<void(*)(int)>(SELECT_VALUE(0x415160, 0x5AF170))(h);
{
fs_fclose_file_dedicated(h);
}
else
{
reinterpret_cast<void(*)(int)>
(SELECT_VALUE(0x415160, 0x5AF170, 0x0))(h);
}
} }
bool FS_Initialized() bool FS_Initialized()
@ -840,38 +538,15 @@ namespace game
return (*fs_searchpaths != nullptr); return (*fs_searchpaths != nullptr);
} }
int fs_handle_for_file_dedicated(FsThread thread)
{
static DWORD func = 0x5245F0;
auto result = 0;
__asm
{
pushad
mov edi, thread
call func
mov result, eax
popad
}
return result;
}
int FS_HandleForFile(FsThread thread) int FS_HandleForFile(FsThread thread)
{ {
if (is_dedi()) return reinterpret_cast<int(*)(FsThread)>(SELECT_VALUE(0x46B1C0, 0x5AEE50))(thread);
{
return fs_handle_for_file_dedicated(thread);
}
return reinterpret_cast<int(*)(FsThread)>
(SELECT_VALUE(0x46B1C0, 0x5AEE50, 0x0))(thread);
} }
int fs_fopen_file_read_for_thread_singleplayer(const char* filename, int* file, FsThread thread) int fs_fopen_file_read_for_thread_singleplayer(const char* filename, int* file, FsThread thread)
{ {
static DWORD func = 0x627F20; static DWORD func = 0x627F20;
auto result = 0; int result{};
__asm __asm
{ {
@ -893,29 +568,7 @@ namespace game
int fs_fopen_file_read_for_thread_multiplayer(const char* filename, int* file, FsThread thread) int fs_fopen_file_read_for_thread_multiplayer(const char* filename, int* file, FsThread thread)
{ {
static DWORD func = 0x5B1990; static DWORD func = 0x5B1990;
auto result = 0; int result{};
__asm
{
pushad
mov edx, filename
push thread
push file
call func
add esp, 0x8
mov result, eax
popad
}
return result;
}
int fs_fopen_file_read_for_thread_dedicated(const char* filename, int* file, FsThread thread)
{
static DWORD func = 0x524E30;
auto result = 0;
__asm __asm
{ {
@ -941,40 +594,12 @@ namespace game
return fs_fopen_file_read_for_thread_singleplayer(filename, file, thread); return fs_fopen_file_read_for_thread_singleplayer(filename, file, thread);
} }
if (is_mp())
{
return fs_fopen_file_read_for_thread_multiplayer(filename, file, thread); return fs_fopen_file_read_for_thread_multiplayer(filename, file, thread);
} }
return fs_fopen_file_read_for_thread_dedicated(filename, file, thread);
}
int fs_create_path_directory(char* OSPath)
{
static DWORD func = 0x5247D0;
auto result = 0;
__asm
{
pushad
mov edi, OSPath
call func
mov result, eax
popad
}
return result;
}
int FS_CreatePath(char* OSPath) int FS_CreatePath(char* OSPath)
{ {
if (is_dedi()) return reinterpret_cast<int(*)(char*)>(SELECT_VALUE(0x4F5AB0, 0x5AF060))(OSPath);
{
return fs_create_path_directory(OSPath);
}
return reinterpret_cast<int(*)(char*)>
(SELECT_VALUE(0x4F5AB0, 0x5AF060, 0x0))(OSPath);
} }
void FS_CheckFileSystemStarted() void FS_CheckFileSystemStarted()
@ -1005,73 +630,65 @@ namespace game
return get_mode() == launcher::mode::singleplayer; return get_mode() == launcher::mode::singleplayer;
} }
bool is_dedi()
{
return get_mode() == launcher::mode::server;
}
void initialize(const launcher::mode _mode) void initialize(const launcher::mode _mode)
{ {
mode = _mode; mode = _mode;
native::Cmd_AddCommand = native::Cmd_AddCommand_t(SELECT_VALUE(0x558820, 0x545DF0, 0)); native::Cmd_AddCommand = native::Cmd_AddCommand_t(SELECT_VALUE(0x558820, 0x545DF0));
native::Cmd_RemoveCommand = native::Cmd_RemoveCommand_t(SELECT_VALUE(0x443A30, 0x545E20, 0x4CC060)); native::Cmd_RemoveCommand = native::Cmd_RemoveCommand_t(SELECT_VALUE(0x443A30, 0x545E20));
native::Com_Error = native::Com_Error_t(SELECT_VALUE(0x425540, 0x555450, 0x4D93F0)); native::Com_Error = native::Com_Error_t(SELECT_VALUE(0x425540, 0x555450));
native::Com_Filter = native::Com_Filter_t(SELECT_VALUE(0x44EFF0, 0x5B7C30, 0x0)); native::Com_Filter = native::Com_Filter_t(SELECT_VALUE(0x44EFF0, 0x5B7C30));
native::DB_LoadXAssets = native::DB_LoadXAssets_t(SELECT_VALUE(0x48A8E0, 0x4CD020, 0x44F770)); native::DB_LoadXAssets = native::DB_LoadXAssets_t(SELECT_VALUE(0x48A8E0, 0x4CD020));
native::DB_FindXAssetHeader = native::DB_FindXAssetHeader_t(SELECT_VALUE(0x4FF000, 0x4CA620, 0x44E7A0)); native::DB_FindXAssetHeader = native::DB_FindXAssetHeader_t(SELECT_VALUE(0x4FF000, 0x4CA620));
native::Dvar_RegisterBool = native::Dvar_RegisterBool_t(SELECT_VALUE(0x4914D0, 0x5BE9F0, 0x0)); native::Dvar_RegisterBool = native::Dvar_RegisterBool_t(SELECT_VALUE(0x4914D0, 0x5BE9F0));
native::Dvar_RegisterString = native::Dvar_RegisterString_t(SELECT_VALUE(0x5197F0, 0x5BEC90, 0x0)); native::Dvar_RegisterString = native::Dvar_RegisterString_t(SELECT_VALUE(0x5197F0, 0x5BEC90));
native::Dvar_SetIntByName = native::Dvar_SetIntByName_t(SELECT_VALUE(0x5396B0, 0x5BF560, 0x0)); native::Dvar_SetIntByName = native::Dvar_SetIntByName_t(SELECT_VALUE(0x5396B0, 0x5BF560));
native::Dvar_SetFromStringByName = native::Dvar_SetFromStringByName_t( native::Dvar_SetFromStringByName = native::Dvar_SetFromStringByName_t(SELECT_VALUE(0x4DD090, 0x5BF740));
SELECT_VALUE(0x4DD090, 0x5BF740, 0x518DF0)); native::Dvar_SetString = native::Dvar_SetString_t(SELECT_VALUE(0x540570, 0x5BF3E0));
native::Dvar_SetString = native::Dvar_SetString_t(SELECT_VALUE(0x540570, 0x5BF3E0, 0x0));
native::Dvar_ForEach = native::Dvar_ForEach_t(SELECT_VALUE(0x536720, 0x5BFFB0, 0x0)); native::Dvar_ForEach = native::Dvar_ForEach_t(SELECT_VALUE(0x536720, 0x5BFFB0));
native::Dvar_DisplayableValue = native::Dvar_DisplayableValue_t(SELECT_VALUE(0x4AB1D0, 0x5BD260, 0x0)); native::Dvar_DisplayableValue = native::Dvar_DisplayableValue_t(SELECT_VALUE(0x4AB1D0, 0x5BD260));
native::Dvar_DisplayableLatchedValue = native::Dvar_DisplayableLatchedValue_t(SELECT_VALUE(0x464F50, 0x5BD290, 0x0)); native::Dvar_DisplayableLatchedValue = native::Dvar_DisplayableLatchedValue_t(SELECT_VALUE(0x464F50, 0x5BD290));
native::G_RunFrame = native::G_RunFrame_t(SELECT_VALUE(0x52EAA0, 0x50CB70, 0x48AD60)); native::G_RunFrame = native::G_RunFrame_t(SELECT_VALUE(0x52EAA0, 0x50CB70));
native::G_GetWeaponForName = native::G_GetWeaponForName_t(SELECT_VALUE(0x495E40, 0x531070, 0x0)); native::G_GetWeaponForName = native::G_GetWeaponForName_t(SELECT_VALUE(0x495E40, 0x531070));
native::MSG_ReadData = native::MSG_ReadData_t(SELECT_VALUE(0, 0x5592A0, 0)); native::MSG_ReadData = native::MSG_ReadData_t(SELECT_VALUE(0, 0x5592A0));
native::MT_AllocIndex = native::MT_AllocIndex_t(SELECT_VALUE(0x4B9610, 0x562080, 0x4E6C30)); native::MT_AllocIndex = native::MT_AllocIndex_t(SELECT_VALUE(0x4B9610, 0x562080));
native::RemoveRefToValue = native::RemoveRefToValue_t(SELECT_VALUE(0x477EA0, 0x565730, 0x4E8A40)); native::RemoveRefToValue = native::RemoveRefToValue_t(SELECT_VALUE(0x477EA0, 0x565730));
native::SL_GetStringOfSize = native::SL_GetStringOfSize_t(SELECT_VALUE(0x4E13F0, 0x564650, 0x4E7490)); native::SL_GetStringOfSize = native::SL_GetStringOfSize_t(SELECT_VALUE(0x4E13F0, 0x564650));
native::Scr_AddEntityNum = native::Scr_AddEntityNum_t(SELECT_VALUE(0x0, 0x56ABC0, 0x4EA2F0)); native::Scr_AddEntityNum = native::Scr_AddEntityNum_t(SELECT_VALUE(0x0, 0x56ABC0));
native::Scr_Notify = native::Scr_Notify_t(SELECT_VALUE(0x4895B0, 0x52B190, 0x0)); native::Scr_Notify = native::Scr_Notify_t(SELECT_VALUE(0x4895B0, 0x52B190));
native::Scr_NotifyLevel = native::Scr_NotifyLevel_t(SELECT_VALUE(0x445E10, 0x56B6B0, 0x0)); native::Scr_NotifyLevel = native::Scr_NotifyLevel_t(SELECT_VALUE(0x445E10, 0x56B6B0));
native::Scr_GetNumParam = native::Scr_GetNumParam_t(SELECT_VALUE(0x4C6FE0, 0x56AA10, 0x0)); native::Scr_GetNumParam = native::Scr_GetNumParam_t(SELECT_VALUE(0x4C6FE0, 0x56AA10));
native::Scr_GetString = native::Scr_GetString_t(SELECT_VALUE(0x497530, 0x56A3D0, 0x0)); native::Scr_GetString = native::Scr_GetString_t(SELECT_VALUE(0x497530, 0x56A3D0));
native::Sys_ShowConsole = native::Sys_ShowConsole_t(SELECT_VALUE(0x470AF0, 0x5CF590, 0)); native::Sys_ShowConsole = native::Sys_ShowConsole_t(SELECT_VALUE(0x470AF0, 0x5CF590));
native::Sys_Error = native::Sys_Error_t(SELECT_VALUE(0x490D90, 0x5CC3B0, 0x539590)); native::Sys_Error = native::Sys_Error_t(SELECT_VALUE(0x490D90, 0x5CC3B0));
native::Sys_Milliseconds = native::Sys_Milliseconds_t(SELECT_VALUE(0x4A1610, 0x5CE740, 0x53B900)); native::Sys_Milliseconds = native::Sys_Milliseconds_t(SELECT_VALUE(0x4A1610, 0x5CE740));
native::VM_Notify = native::VM_Notify_t(SELECT_VALUE(0x610200, 0x569720, 0x4EF450)); native::VM_Notify = native::VM_Notify_t(SELECT_VALUE(0x610200, 0x569720));
native::BG_NetDataChecksum = native::BG_NetDataChecksum_t(SELECT_VALUE(0x0, 0x41BB20, 0x0)); native::BG_NetDataChecksum = native::BG_NetDataChecksum_t(SELECT_VALUE(0x0, 0x41BB20));
native::LiveStorage_GetPersistentDataDefVersion = native::LiveStorage_GetPersistentDataDefVersion_t( native::LiveStorage_GetPersistentDataDefVersion = native::LiveStorage_GetPersistentDataDefVersion_t(SELECT_VALUE(0x0, 0x548D60));
SELECT_VALUE(0x0, 0x548D60, 0x4D0390));
native::LiveStorage_GetPersistentDataDefFormatChecksum = native::LiveStorage_GetPersistentDataDefFormatChecksum_t( native::LiveStorage_GetPersistentDataDefFormatChecksum = native::LiveStorage_GetPersistentDataDefFormatChecksum_t(SELECT_VALUE(0x0, 0x548D80));
SELECT_VALUE(0x0, 0x548D80, 0x4D03D0));
native::SV_DirectConnect = native::SV_DirectConnect_t(SELECT_VALUE(0x0, 0x572750, 0x4F74C0)); native::SV_DirectConnect = native::SV_DirectConnect_t(SELECT_VALUE(0x0, 0x572750));
native::SV_ClientEnterWorld = native::SV_ClientEnterWorld_t(SELECT_VALUE(0x0, 0x571100, 0x0)); native::SV_ClientEnterWorld = native::SV_ClientEnterWorld_t(SELECT_VALUE(0x0, 0x571100));
native::SV_Cmd_TokenizeString = native::SV_Cmd_TokenizeString_t(SELECT_VALUE(0x0, 0x545D40, 0x0)); native::SV_Cmd_TokenizeString = native::SV_Cmd_TokenizeString_t(SELECT_VALUE(0x0, 0x545D40));
native::SV_Cmd_EndTokenizedString = native::SV_Cmd_EndTokenizedString_t(SELECT_VALUE(0x0, 0x545D70, 0x0)); native::SV_Cmd_EndTokenizedString = native::SV_Cmd_EndTokenizedString_t(SELECT_VALUE(0x0, 0x545D70));
native::mp::SV_GameSendServerCommand = native::mp::SV_GameSendServerCommand_t(0x573220); native::mp::SV_GameSendServerCommand = native::mp::SV_GameSendServerCommand_t(0x573220);
native::mp::SV_GetGuid = native::mp::SV_GetGuid_t(0x573990); native::mp::SV_GetGuid = native::mp::SV_GetGuid_t(0x573990);
@ -1080,82 +697,78 @@ namespace game
native::sp::TeleportPlayer = native::sp::TeleportPlayer_t(0x4CCEE0); native::sp::TeleportPlayer = native::sp::TeleportPlayer_t(0x4CCEE0);
native::XUIDToString = native::XUIDToString_t(SELECT_VALUE(0x4FAA30, 0x55CC20, 0x0)); native::XUIDToString = native::XUIDToString_t(SELECT_VALUE(0x4FAA30, 0x55CC20));
native::SEH_LocalizeTextMessage = native::SEH_LocalizeTextMessage_t( native::SEH_LocalizeTextMessage = native::SEH_LocalizeTextMessage_t(SELECT_VALUE(0x41EA20, 0x57E240));
SELECT_VALUE(0x41EA20, 0x57E240, 0x0));
native::CM_TransformedCapsuleTrace = native::CM_TransformedCapsuleTrace_t( native::CM_TransformedCapsuleTrace = native::CM_TransformedCapsuleTrace_t(SELECT_VALUE(0x4F9B80, 0x541340));
SELECT_VALUE(0x4F9B80, 0x541340, 0x0));
native::PM_WeaponUseAmmo = native::PM_WeaponUseAmmo_t(SELECT_VALUE(0x463F80, 0x42E930, 0x0)); native::PM_WeaponUseAmmo = native::PM_WeaponUseAmmo_t(SELECT_VALUE(0x463F80, 0x42E930));
native::PM_playerTrace = native::PM_playerTrace_t(SELECT_VALUE(0x4CE600, 0x421F00, 0x0)); native::PM_playerTrace = native::PM_playerTrace_t(SELECT_VALUE(0x4CE600, 0x421F00));
native::PM_trace = native::PM_trace_t(SELECT_VALUE(0x544BF0, 0x41CEB0, 0x0)); native::PM_trace = native::PM_trace_t(SELECT_VALUE(0x544BF0, 0x41CEB0));
native::Jump_ClearState = native::Jump_ClearState_t(SELECT_VALUE(0x514CE0, 0x4160F0, 0x0)); native::Jump_ClearState = native::Jump_ClearState_t(SELECT_VALUE(0x514CE0, 0x4160F0));
native::Vec3Normalize = native::Vec3Normalize_t(SELECT_VALUE(0x536A20, 0x415EE0, 0x0)); native::Vec3Normalize = native::Vec3Normalize_t(SELECT_VALUE(0x536A20, 0x415EE0));
native::Cmd_ExecuteSingleCommand = native::Cmd_ExecuteSingleCommand_t( native::Cmd_ExecuteSingleCommand = native::Cmd_ExecuteSingleCommand_t(SELECT_VALUE(0x4D6960, 0x5462B0));
SELECT_VALUE(0x4D6960, 0x5462B0, 0x4CC360));
native::Com_Quit_f = native::Com_Quit_f_t(SELECT_VALUE(0x4F48B0, 0x5556B0, 0x4D95B0)); native::Com_Quit_f = native::Com_Quit_f_t(SELECT_VALUE(0x4F48B0, 0x5556B0));
native::FS_Printf = native::FS_Printf_t(SELECT_VALUE(0x421E90, 0x5AF7C0, 0x5255A0)); native::FS_Printf = native::FS_Printf_t(SELECT_VALUE(0x421E90, 0x5AF7C0));
native::player_die = native::player_die_t(SELECT_VALUE(0x0, 0x503460, 0x47F4D0)); native::player_die = native::player_die_t(SELECT_VALUE(0x0, 0x503460));
native::_longjmp = reinterpret_cast<decltype(longjmp)*>(SELECT_VALUE(0x73AC20, 0x7363BC, 0x655558)); native::_longjmp = reinterpret_cast<decltype(longjmp)*>(SELECT_VALUE(0x73AC20, 0x7363BC));
native::sv_cmd_args = reinterpret_cast<native::CmdArgs*>(SELECT_VALUE(0x1757218, 0x1CAA998, 0x1B5E7D8)); native::sv_cmd_args = reinterpret_cast<native::CmdArgs*>(SELECT_VALUE(0x1757218, 0x1CAA998));
native::cmd_args = reinterpret_cast<native::CmdArgs*>(SELECT_VALUE(0x1750750, 0x1C978D0, 0x1B455F8)); native::cmd_args = reinterpret_cast<native::CmdArgs*>(SELECT_VALUE(0x1750750, 0x1C978D0));
native::scrVarGlob = reinterpret_cast<short*>(SELECT_VALUE(0x19AFC80, 0x1E72180, 0x1D3C800)); native::scrVarGlob = reinterpret_cast<short*>(SELECT_VALUE(0x19AFC80, 0x1E72180));
native::scrMemTreePub = reinterpret_cast<char**>(SELECT_VALUE(0x196FB00, 0x1E32000, 0x1C152A4)); native::scrMemTreePub = reinterpret_cast<char**>(SELECT_VALUE(0x196FB00, 0x1E32000));
native::scrMemTreeGlob = reinterpret_cast<char*>(SELECT_VALUE(0x186DA00, 0x1D6FF00, 0x1C16600)); native::scrMemTreeGlob = reinterpret_cast<char*>(SELECT_VALUE(0x186DA00, 0x1D6FF00));
native::scr_VarPub = reinterpret_cast<native::scrVarPub_t*>(SELECT_VALUE(0x0, 0x208E188, 0x1CD8720)); native::scr_VarPub = reinterpret_cast<native::scrVarPub_t*>(SELECT_VALUE(0x0, 0x208E188));
native::scr_VmPub = reinterpret_cast<native::scrVmPub_t*>(SELECT_VALUE(0x1BF2580, 0x20B4A80, 0x1F5B080)); native::scr_VmPub = reinterpret_cast<native::scrVmPub_t*>(SELECT_VALUE(0x1BF2580, 0x20B4A80));
native::g_script_error_level = reinterpret_cast<int*>(SELECT_VALUE(0x1BEFCFC, 0x20B21FC, 0x1F5B058)); native::g_script_error_level = reinterpret_cast<int*>(SELECT_VALUE(0x1BEFCFC, 0x20B21FC));
native::g_script_error = reinterpret_cast<jmp_buf*>(SELECT_VALUE(0x1BF1D18, 0x20B4218, 0x1F5A818)); native::g_script_error = reinterpret_cast<jmp_buf*>(SELECT_VALUE(0x1BF1D18, 0x20B4218));
native::g_classMap = reinterpret_cast<native::scr_classStruct_t*>(SELECT_VALUE(0x92D140, 0x8B4300, 0x7C0408)); native::g_classMap = reinterpret_cast<native::scr_classStruct_t*>(SELECT_VALUE(0x92D140, 0x8B4300));
native::svs_clientCount = reinterpret_cast<int*>(SELECT_VALUE(0x0, 0x4B5CF8C, 0x4A12E8C)); native::svs_clientCount = reinterpret_cast<int*>(SELECT_VALUE(0x0, 0x4B5CF8C));
native::levelEntityId = reinterpret_cast<unsigned int*>(SELECT_VALUE(0x1BCBCA4, 0x208E1A4, 0x1CD873C)); native::levelEntityId = reinterpret_cast<unsigned int*>(SELECT_VALUE(0x1BCBCA4, 0x208E1A4));
native::mp::svs_clients = reinterpret_cast<native::mp::client_t*>(0x4B5CF90); native::mp::svs_clients = reinterpret_cast<native::mp::client_t*>(0x4B5CF90);
native::dedi::svs_clients = reinterpret_cast<native::dedi::client_t*>(0x4A12E90);
native::g_entities = reinterpret_cast<native::gentity_s*>(SELECT_VALUE(0, 0x1A66E28, 0x191B900)); native::g_entities = reinterpret_cast<native::gentity_s*>(0x1A66E28);
native::sp::g_entities = reinterpret_cast<native::sp::gentity_s*>(0x1197AD8); native::sp::g_entities = reinterpret_cast<native::sp::gentity_s*>(0x1197AD8);
native::sp::g_clients = reinterpret_cast<native::sp::gclient_s*>(0x1381D48); native::sp::g_clients = reinterpret_cast<native::sp::gclient_s*>(0x1381D48);
native::level = reinterpret_cast<native::level_locals_t*>(SELECT_VALUE(0x0, 0x1C6D4D8, 0x1B21A20)); native::mp::level = reinterpret_cast<native::level_locals_t*>(0x1C6D4D8);
native::deferredQueue = reinterpret_cast<native::DeferredQueue*>(SELECT_VALUE(0x0, 0x1D55438, 0x0)); native::deferredQueue = reinterpret_cast<native::DeferredQueue*>(SELECT_VALUE(0x0, 0x1D55438));
native::com_codeTimeScale = reinterpret_cast<float*>(SELECT_VALUE(0x1769F1C, 0x1CEF554, 0x1B9CEC0)); native::com_codeTimeScale = reinterpret_cast<float*>(SELECT_VALUE(0x1769F1C, 0x1CEF554));
native::s_criticalSection = reinterpret_cast<RTL_CRITICAL_SECTION*>(SELECT_VALUE(0x1CD5638, 0x5A91048, 0x593FF98)); native::s_criticalSection = reinterpret_cast<RTL_CRITICAL_SECTION*>(SELECT_VALUE(0x1CD5638, 0x5A91048));
native::logfile = reinterpret_cast<int*>(SELECT_VALUE(0x176B534, 0x1CF0B78, 0x1B9E4C8)); native::logfile = reinterpret_cast<int*>(SELECT_VALUE(0x176B534, 0x1CF0B78));
native::fs_searchpaths = reinterpret_cast<native::searchpath_s**>(SELECT_VALUE(0x1C2FE78, 0x59BA858, 0x62F4F60)); native::fs_searchpaths = reinterpret_cast<native::searchpath_s**>(SELECT_VALUE(0x1C2FE78, 0x59BA858));
native::fs_gamedir = reinterpret_cast<char*>(SELECT_VALUE(0x1C2B220, 0x59A98F8, 0x585A4D8)); native::fs_gamedir = reinterpret_cast<char*>(SELECT_VALUE(0x1C2B220, 0x59A98F8));
native::fsh = reinterpret_cast<native::fileHandleData_t*>(SELECT_VALUE(0x1C2B540, 0x59B5F20, 0x5866AF8)); native::fsh = reinterpret_cast<native::fileHandleData_t*>(SELECT_VALUE(0x1C2B540, 0x59B5F20));
native::com_fileAccessed = reinterpret_cast<int*>(SELECT_VALUE(0x1C2B328, 0x59A9A04, 0x585A5E0)); native::com_fileAccessed = reinterpret_cast<int*>(SELECT_VALUE(0x1C2B328, 0x59A9A04));
native::threadId = reinterpret_cast<unsigned(*)[native::THREAD_CONTEXT_COUNT]>(SELECT_VALUE(0x18576C8, 0x1D6E448, 0x1C14BDC)); native::threadId = reinterpret_cast<unsigned(*)[native::THREAD_CONTEXT_COUNT]>(SELECT_VALUE(0x18576C8, 0x1D6E448));
native::initialized_0 = reinterpret_cast<int*>(SELECT_VALUE(0x1CE1CA0, 0x5AA3058, 0x62F4F9C)); native::initialized_0 = reinterpret_cast<int*>(SELECT_VALUE(0x1CE1CA0, 0x5AA3058));
native::sys_timeBase = reinterpret_cast<int*>(SELECT_VALUE(0x1CE1C98, 0x5AA3050, 0x5950CE4)); native::sys_timeBase = reinterpret_cast<int*>(SELECT_VALUE(0x1CE1C98, 0x5AA3050));
native::sys_counterBase = reinterpret_cast<unsigned __int64*>(SELECT_VALUE(0x1CE1C90, 0x5AA3048, 0x5950CE8)); native::sys_counterBase = reinterpret_cast<unsigned __int64*>(SELECT_VALUE(0x1CE1C90, 0x5AA3048));
native::dvarCount = reinterpret_cast<int*>(SELECT_VALUE(0x1C42398, 0x59CCDD8, 0x5879644)); native::dvarCount = reinterpret_cast<int*>(SELECT_VALUE(0x1C42398, 0x59CCDD8));
native::sortedDvars = reinterpret_cast<native::dvar_t**>(SELECT_VALUE(0x1C423C0, 0x59CCE00, 0x587C5D8)); native::sortedDvars = reinterpret_cast<native::dvar_t**>(SELECT_VALUE(0x1C423C0, 0x59CCE00));
} }
} }

View File

@ -3,7 +3,7 @@
#include "structs.hpp" #include "structs.hpp"
#include "launcher/launcher.hpp" #include "launcher/launcher.hpp"
#define SELECT_VALUE(sp, mp, dedi) (game::is_sp() ? (sp) : (game::is_mp() ? (mp) : (dedi))) #define SELECT_VALUE(sp, mp) (game::is_sp() ? (sp) : (mp))
#define SERVER_CD_KEY "Open-IW5-CD-Key" #define SERVER_CD_KEY "Open-IW5-CD-Key"
@ -181,14 +181,13 @@ namespace game
extern scr_classStruct_t* g_classMap; extern scr_classStruct_t* g_classMap;
constexpr auto MAX_CLIENTS = 18;
extern int* svs_clientCount; extern int* svs_clientCount;
constexpr auto MAX_GENTITIES = 2048u; constexpr auto MAX_GENTITIES = 2048u;
constexpr auto ENTITYNUM_NONE = MAX_GENTITIES - 1u; constexpr auto ENTITYNUM_NONE = MAX_GENTITIES - 1u;
extern gentity_s* g_entities; extern gentity_s* g_entities;
extern level_locals_t* level;
extern DeferredQueue* deferredQueue; extern DeferredQueue* deferredQueue;
extern float* com_codeTimeScale; extern float* com_codeTimeScale;
@ -232,11 +231,8 @@ namespace game
extern SV_GameSendServerCommand_t SV_GameSendServerCommand; extern SV_GameSendServerCommand_t SV_GameSendServerCommand;
extern client_t* svs_clients; extern client_t* svs_clients;
}
namespace dedi extern level_locals_t* level;
{
extern client_t* svs_clients;
} }
namespace sp namespace sp
@ -317,7 +313,6 @@ namespace game
bool is_mp(); bool is_mp();
bool is_sp(); bool is_sp();
bool is_dedi();
void initialize(launcher::mode mode); void initialize(launcher::mode mode);
} }

View File

@ -1354,23 +1354,6 @@ namespace game
static_assert(sizeof(client_t) == 0x78698); static_assert(sizeof(client_t) == 0x78698);
} }
namespace dedi
{
struct client_t
{
clientHeader_t header;
const char* dropReason;
char userinfo[1024];
unsigned char __pad0[0x4123E];
unsigned __int16 scriptId;
int bIsTestClient; // 0x41CB0
int serverId;
unsigned char __pad1[0x369D8];
};
static_assert(sizeof(dedi::client_t) == 0x78690);
}
namespace sp namespace sp
{ {
struct usercmd_s struct usercmd_s

View File

@ -9,7 +9,6 @@ public:
none, none,
singleplayer, singleplayer,
multiplayer, multiplayer,
server,
}; };
launcher(); launcher();

View File

@ -132,7 +132,7 @@ namespace binary_loader
long)); long));
std::string binary; std::string binary;
binary.resize(size_t(*size)); binary.resize(static_cast<size_t>(*size));
const auto new_data = reinterpret_cast<unsigned char*>(binary.data()); const auto new_data = reinterpret_cast<unsigned char*>(binary.data());
const auto old_data = reinterpret_cast<const unsigned char*>(base.data()); const auto old_data = reinterpret_cast<const unsigned char*>(base.data());
@ -149,12 +149,7 @@ namespace binary_loader
std::string load(const launcher::mode mode) std::string load(const launcher::mode mode)
{ {
auto base = load_base(); const auto base = load_base();
if (mode == launcher::mode::server)
{
return base;
}
auto delta = load_delta(mode); auto delta = load_delta(mode);
delta = utils::compression::zstd::decompress(delta); delta = utils::compression::zstd::decompress(delta);
return build_binary(base, delta); return build_binary(base, delta);

View File

@ -38,11 +38,6 @@ void verify_tls()
launcher::mode detect_mode_from_arguments() launcher::mode detect_mode_from_arguments()
{ {
if (utils::flags::has_flag("dedicated"))
{
return launcher::mode::server;
}
if (utils::flags::has_flag("multiplayer")) if (utils::flags::has_flag("multiplayer"))
{ {
return launcher::mode::multiplayer; return launcher::mode::multiplayer;

View File

@ -9,38 +9,27 @@ static char* com_get_build_version_stub()
{ {
static char buf[128]; static char buf[128];
const auto version_number = SELECT_VALUE(0x1CD, 0x5EC0E, 0x5EC0E); const auto version_number = SELECT_VALUE(0x1CD, 0x5EC0E);
_snprintf_s(buf, _TRUNCATE, "%d %s", version_number, __DATE__); _snprintf_s(buf, _TRUNCATE, "%d %s", version_number, __DATE__);
return buf; return buf;
} }
static int com_get_build_version_dedi_stub(char* buf, const char* fmt, int version_number, const char* /*date*/)
{
return _snprintf_s(buf, 0x80, _TRUNCATE, fmt, version_number, __DATE__);
}
class branding final : public module class branding final : public module
{ {
public: public:
void post_load() override void post_load() override
{ {
if (game::is_dedi()) this->patch_dedi(); add_branding();
else this->add_branding();
// gamedate dvar // gamedate dvar
utils::hook::set<const char*>(SELECT_VALUE(0x5C223B, 0x50B0F4, 0x48844F), __DATE__); utils::hook::set<const char*>(SELECT_VALUE(0x5C223B, 0x50B0F4), __DATE__);
}
static void patch_dedi()
{
utils::hook(0x4DAB99, com_get_build_version_dedi_stub, HOOK_CALL).install()->quick();
} }
static void add_branding() static void add_branding()
{ {
utils::hook(SELECT_VALUE(0x50BBD0, 0x53B4B0, 0x0), com_get_build_version_stub, HOOK_JUMP).install()->quick(); utils::hook(SELECT_VALUE(0x50BBD0, 0x53B4B0), com_get_build_version_stub, HOOK_JUMP).install()->quick();
} }
}; };

View File

@ -47,10 +47,10 @@ void bullet::post_load()
0.0f, std::numeric_limits<float>::max(), game::native::DVAR_CODINFO, 0.0f, std::numeric_limits<float>::max(), game::native::DVAR_CODINFO,
"Set to a value greater than 0 to override the surface penetration depth"); "Set to a value greater than 0 to override the surface penetration depth");
bullet_fire_addr = SELECT_VALUE(0x5B6442, 0x4F6C5C, 0x46CFFA); bullet_fire_addr = SELECT_VALUE(0x5B6442, 0x4F6C5C);
utils::hook(SELECT_VALUE(0x5B643C, 0x4F6C56, 0x46CFF4), &bullet_fire_stub, HOOK_JUMP).install()->quick(); utils::hook(SELECT_VALUE(0x5B643C, 0x4F6C56), &bullet_fire_stub, HOOK_JUMP).install()->quick();
bg_get_surface_penetration_depth_hook.create(SELECT_VALUE(0x43BDE0, 0x42F4D0, 0x421610), &bg_get_surface_penetration_depth_stub); bg_get_surface_penetration_depth_hook.create(SELECT_VALUE(0x43BDE0, 0x42F4D0), &bg_get_surface_penetration_depth_stub);
} }
REGISTER_MODULE(bullet) REGISTER_MODULE(bullet)

View File

@ -1,12 +1,11 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include "game/game.hpp" #include "game/game.hpp"
#include <utils/hook.hpp>
#include "game_log.hpp" #include "game_log.hpp"
#include <utils/hook.hpp>
static void notify_on_say(game::native::gentity_s* ent, int mode, const char* message) static void notify_on_say(game::native::gentity_s* ent, int mode, const char* message)
{ {
const auto ent_num = ent->s.number; const auto ent_num = ent->s.number;

View File

@ -1,11 +1,12 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include <utils/string.hpp>
#include "game/game.hpp" #include "game/game.hpp"
#include "command.hpp" #include "command.hpp"
#include "scheduler.hpp" #include "scheduler.hpp"
#include <utils/string.hpp>
static const game::native::dvar_t* g_cheats; static const game::native::dvar_t* g_cheats;
class client_command final : public module class client_command final : public module

View File

@ -4,12 +4,12 @@
#include <utils/string.hpp> #include <utils/string.hpp>
#include <utils/hook.hpp> #include <utils/hook.hpp>
#include <utils/io.hpp>
#include "command.hpp" #include "command.hpp"
utils::memory::allocator command::allocator_; static utils::memory::allocator allocator;
std::unordered_map<std::string, std::function<void(const command::params&)>> command::handlers; std::unordered_map<std::string, std::function<void(const command::params&)>> command::handlers;
std::unordered_map<std::string, std::function<void(game::native::gentity_s*, command::params_sv&)>> command::handlers_sv; std::unordered_map<std::string, std::function<void(game::native::gentity_s*, command::params_sv&)>> command::handlers_sv;
std::unordered_map<std::string, std::function<void(game::native::sp::gentity_s*, command::params_sv&)>> command::handlers_sp_sv; std::unordered_map<std::string, std::function<void(game::native::sp::gentity_s*, command::params_sv&)>> command::handlers_sp_sv;
@ -84,7 +84,7 @@ std::string command::params_sv::join(const int index) const
void command::add_raw(const char* name, void (*callback)()) void command::add_raw(const char* name, void (*callback)())
{ {
game::native::Cmd_AddCommand(name, callback, command::allocator_.allocate<game::native::cmd_function_t>()); game::native::Cmd_AddCommand(name, callback, allocator.allocate<game::native::cmd_function_t>());
} }
void command::add(const char* name, const std::function<void(const command::params&)>& callback) void command::add(const char* name, const std::function<void(const command::params&)>& callback)
@ -148,7 +148,7 @@ void command::main_handler()
const auto command = utils::string::to_lower(params[0]); const auto command = utils::string::to_lower(params[0]);
if (const auto itr = command::handlers.find(command); itr != handlers.end()) if (const auto itr = handlers.find(command); itr != handlers.end())
{ {
itr->second(params); itr->second(params);
} }
@ -158,7 +158,7 @@ void command::client_command_stub(int client_num)
{ {
const auto entity = &game::native::g_entities[client_num]; const auto entity = &game::native::g_entities[client_num];
if (entity->client == nullptr) if (!entity->client)
{ {
return; return;
} }
@ -167,7 +167,7 @@ void command::client_command_stub(int client_num)
const auto command = utils::string::to_lower(params[0]); const auto command = utils::string::to_lower(params[0]);
if (const auto itr = command::handlers_sv.find(command); itr != handlers_sv.end()) if (const auto itr = handlers_sv.find(command); itr != handlers_sv.end())
{ {
itr->second(entity, params); itr->second(entity, params);
return; return;
@ -186,7 +186,7 @@ void command::client_command_sp(int client_num, const char* s)
const auto command = utils::string::to_lower(params[0]); const auto command = utils::string::to_lower(params[0]);
if (const auto itr = command::handlers_sp_sv.find(command); itr != handlers_sp_sv.end()) if (const auto itr = handlers_sp_sv.find(command); itr != handlers_sp_sv.end())
{ {
itr->second(entity, params); itr->second(entity, params);
} }
@ -200,7 +200,7 @@ __declspec(naked) void command::client_command_sp_stub()
push [esp + 0x20 + 0x8] push [esp + 0x20 + 0x8]
push [esp + 0x20 + 0x8] push [esp + 0x20 + 0x8]
call command::client_command_sp call client_command_sp
add esp, 0x8 add esp, 0x8
popad popad
@ -214,21 +214,6 @@ __declspec(naked) void command::client_command_sp_stub()
} }
} }
__declspec(naked) void command::client_command_dedi_stub()
{
__asm
{
pushad
push edi
call client_command_stub
add esp, 4h
popad
retn
}
}
// Between ufo/noclip functions and their mp counterpart is that I reversed the 'CG' type // Between ufo/noclip functions and their mp counterpart is that I reversed the 'CG' type
void command::add_sp_commands() void command::add_sp_commands()
{ {
@ -358,21 +343,15 @@ void command::add_sp_commands()
void command::post_load() void command::post_load()
{ {
if (game::is_dedi())
{
utils::hook(0x4F96B5, &command::client_command_dedi_stub, HOOK_CALL).install()->quick(); // SV_ExecuteClientCommand
return;
}
add("quit", game::native::Com_Quit_f); add("quit", game::native::Com_Quit_f);
if (game::is_mp()) if (game::is_mp())
{ {
utils::hook(0x57192A, &command::client_command_stub, HOOK_CALL).install()->quick(); // SV_ExecuteClientCommand utils::hook(0x57192A, &client_command_stub, HOOK_CALL).install()->quick(); // SV_ExecuteClientCommand
} }
else else
{ {
utils::hook(0x44BB50, &command::client_command_sp_stub, HOOK_JUMP).install()->quick(); utils::hook(0x44BB50, &client_command_sp_stub, HOOK_JUMP).install()->quick();
utils::hook::nop(0x44BB55, 5); // Nop skipped instructions utils::hook::nop(0x44BB55, 5); // Nop skipped instructions
add_sp_commands(); add_sp_commands();
} }

View File

@ -1,5 +1,4 @@
#pragma once #pragma once
#include <utils/memory.hpp>
class command final : public module class command final : public module
{ {
@ -51,8 +50,6 @@ public:
void post_load() override; void post_load() override;
private: private:
static utils::memory::allocator allocator_;
static std::unordered_map<std::string, std::function<void(const params&)>> handlers; static std::unordered_map<std::string, std::function<void(const params&)>> handlers;
static std::unordered_map<std::string, std::function<void(game::native::gentity_s*, params_sv&)>> handlers_sv; static std::unordered_map<std::string, std::function<void(game::native::gentity_s*, params_sv&)>> handlers_sv;
static std::unordered_map<std::string, std::function<void(game::native::sp::gentity_s*, params_sv&)>> handlers_sp_sv; static std::unordered_map<std::string, std::function<void(game::native::sp::gentity_s*, params_sv&)>> handlers_sp_sv;

View File

@ -1,6 +1,5 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include "game/game.hpp" #include "game/game.hpp"
#include "scheduler.hpp" #include "scheduler.hpp"
@ -45,11 +44,8 @@ public:
} }
void post_load() override void post_load() override
{
if (!game::is_dedi())
{ {
game::native::Sys_ShowConsole(); game::native::Sys_ShowConsole();
}
std::lock_guard _(this->mutex_); std::lock_guard _(this->mutex_);
this->console_initialized_ = true; this->console_initialized_ = true;

View File

@ -1,18 +1,17 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include "game/game.hpp"
#include "scheduler.hpp"
#include "log_file.hpp"
#include <discord_rpc.h> #include <discord_rpc.h>
#include "game/game.hpp"
#include "scheduler.hpp"
class discord final : public module class discord final : public module
{ {
public: public:
void post_load() override void post_load() override
{ {
if (game::is_dedi()) return;
DiscordEventHandlers handlers; DiscordEventHandlers handlers;
ZeroMemory(&handlers, sizeof(handlers)); ZeroMemory(&handlers, sizeof(handlers));
handlers.ready = ready; handlers.ready = ready;
@ -45,7 +44,7 @@ private:
static void errored(const int error_code, const char* message) static void errored(const int error_code, const char* message)
{ {
printf("Discord: (%i) %s", error_code, message); log_file::info("Discord: (%i) %s", error_code, message);
} }
}; };

View File

@ -193,11 +193,6 @@ void dvar::list_f(const command::params& params)
void dvar::post_load() void dvar::post_load()
{ {
if (game::is_dedi())
{
return;
}
command::add("dvardump", dump_f); command::add("dvardump", dump_f);
command::add("dvarlist", list_f); command::add("dvarlist", list_f);
} }

View File

@ -1,4 +1,6 @@
#include <std_include.hpp> #include <std_include.hpp>
#include "game/game.hpp"
#include <utils/hook.hpp> #include <utils/hook.hpp>
#include <utils/nt.hpp> #include <utils/nt.hpp>
#include <utils/cryptography.hpp> #include <utils/cryptography.hpp>
@ -11,15 +13,13 @@
#include "game/demonware/services/bdDediRSAAuth.hpp" // 26 #include "game/demonware/services/bdDediRSAAuth.hpp" // 26
#include "game/demonware/services/bdSteamAuth.hpp" // 28 #include "game/demonware/services/bdSteamAuth.hpp" // 28
#include "game/game.hpp"
#include "dw.hpp" #include "dw.hpp"
namespace demonware namespace demonware
{ {
namespace io namespace io
{ {
int __stdcall send_to(const SOCKET s, const char* buf, const int len, const int flags, const sockaddr* to, int WINAPI send_to(const SOCKET s, const char* buf, const int len, const int flags, const sockaddr* to, const int tolen)
const int tolen)
{ {
if (tolen == sizeof(sockaddr_in)) if (tolen == sizeof(sockaddr_in))
{ {
@ -31,7 +31,7 @@ namespace demonware
return sendto(s, buf, len, flags, to, tolen); return sendto(s, buf, len, flags, to, tolen);
} }
int __stdcall recv_from(const SOCKET s, char* buf, const int len, const int flags, sockaddr* from, int* fromlen) int WINAPI recv_from(const SOCKET s, char* buf, const int len, const int flags, sockaddr* from, int* fromlen)
{ {
auto res = dw::recv_datagam_packet(s, buf, len, from, fromlen); auto res = dw::recv_datagam_packet(s, buf, len, from, fromlen);
if (res != 0) return res; if (res != 0) return res;
@ -41,7 +41,7 @@ namespace demonware
return res; return res;
} }
int __stdcall send(const SOCKET s, const char* buf, const int len, const int flags) int WINAPI send(const SOCKET s, const char* buf, const int len, const int flags)
{ {
auto server = dw::find_server_by_socket(s); auto server = dw::find_server_by_socket(s);
if (server) return server->send(buf, len); if (server) return server->send(buf, len);
@ -49,7 +49,7 @@ namespace demonware
return ::send(s, buf, len, flags); return ::send(s, buf, len, flags);
} }
int __stdcall recv(const SOCKET s, char* buf, const int len, const int flags) int WINAPI recv(const SOCKET s, char* buf, const int len, const int flags)
{ {
auto server = dw::find_server_by_socket(s); auto server = dw::find_server_by_socket(s);
if (server) if (server)
@ -75,7 +75,7 @@ namespace demonware
return ::recv(s, buf, len, flags); return ::recv(s, buf, len, flags);
} }
int __stdcall connect(const SOCKET s, const sockaddr* addr, const int len) int WINAPI connect(const SOCKET s, const sockaddr* addr, const int len)
{ {
if (len == sizeof(sockaddr_in)) if (len == sizeof(sockaddr_in))
{ {
@ -86,14 +86,14 @@ namespace demonware
return ::connect(s, addr, len); return ::connect(s, addr, len);
} }
int __stdcall close_socket(const SOCKET s) int WINAPI close_socket(const SOCKET s)
{ {
dw::remove_blocking_socket(s); dw::remove_blocking_socket(s);
dw::unlink_socket(s); dw::unlink_socket(s);
return closesocket(s); return closesocket(s);
} }
int __stdcall ioctl_socket(const SOCKET s, const long cmd, u_long* argp) int WINAPI ioctl_socket(const SOCKET s, const long cmd, u_long* argp)
{ {
if (static_cast<unsigned long>(cmd) == (FIONBIO)) if (static_cast<unsigned long>(cmd) == (FIONBIO))
{ {
@ -103,7 +103,7 @@ namespace demonware
return ioctlsocket(s, cmd, argp); return ioctlsocket(s, cmd, argp);
} }
hostent* __stdcall get_host_by_name(char* name) hostent* WINAPI get_host_by_name(char* name)
{ {
static std::mutex mutex; static std::mutex mutex;
std::lock_guard<std::mutex> _(mutex); std::lock_guard<std::mutex> _(mutex);
@ -185,7 +185,7 @@ namespace demonware
return server->second; return server->second;
} }
return std::shared_ptr<service_server>(); return {};
} }
std::shared_ptr<stun_server> dw::find_stun_server_by_name(const std::string& name) std::shared_ptr<stun_server> dw::find_stun_server_by_name(const std::string& name)
@ -204,7 +204,7 @@ namespace demonware
return server->second; return server->second;
} }
return std::shared_ptr<stun_server>(); return {};
} }
std::shared_ptr<service_server> dw::find_server_by_socket(const SOCKET s) std::shared_ptr<service_server> dw::find_server_by_socket(const SOCKET s)
@ -217,7 +217,7 @@ namespace demonware
return server->second; return server->second;
} }
return std::shared_ptr<service_server>(); return {};
} }
bool dw::link_socket(const SOCKET s, const unsigned long address) bool dw::link_socket(const SOCKET s, const unsigned long address)
@ -406,7 +406,7 @@ namespace demonware
io::register_hook("ioctlsocket", io::ioctl_socket); io::register_hook("ioctlsocket", io::ioctl_socket);
io::register_hook("gethostbyname", io::get_host_by_name); io::register_hook("gethostbyname", io::get_host_by_name);
utils::hook(SELECT_VALUE(0x6F40A0, 0x6EE1C0, 0x611310), bd_logger_stub, HOOK_JUMP).install()->quick(); utils::hook(SELECT_VALUE(0x6F40A0, 0x6EE1C0), bd_logger_stub, HOOK_JUMP).install()->quick();
} }
void dw::bd_logger_stub(int /*type*/, const char* const /*channelName*/, const char*, const char* const /*file*/, void dw::bd_logger_stub(int /*type*/, const char* const /*channelName*/, const char*, const char* const /*file*/,
@ -417,11 +417,11 @@ namespace demonware
va_list ap; va_list ap;
va_start(ap, msg); va_start(ap, msg);
_vsnprintf_s(buffer, _TRUNCATE, msg, ap); vsnprintf_s(buffer, _TRUNCATE, msg, ap);
printf("%s: %s\n", function, buffer); printf("%s: %s\n", function, buffer);
va_end(ap); va_end(ap);
} }
REGISTER_MODULE(dw)
} }
REGISTER_MODULE(demonware::dw)

View File

@ -1,9 +1,9 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include <utils/hook.hpp>
#include "game/game.hpp" #include "game/game.hpp"
#include <utils/hook.hpp>
static __declspec(naked) void db_load_stub_client(game::native::XZoneInfo*, unsigned int, int) static __declspec(naked) void db_load_stub_client(game::native::XZoneInfo*, unsigned int, int)
{ {
__asm __asm
@ -18,20 +18,6 @@ static __declspec(naked) void db_load_stub_client(game::native::XZoneInfo*, unsi
} }
} }
static __declspec(naked) void db_load_stub_server(game::native::XZoneInfo*, unsigned int, int)
{
__asm
{
sub esp, 10h
mov eax, [esp + 1Ch]
mov ecx, game::native::DB_LoadXAssets
add ecx, 7h
push ecx
retn
}
}
class fastfiles final : public module class fastfiles final : public module
{ {
public: public:
@ -47,13 +33,11 @@ private:
{ {
if (zone_info[i].name) if (zone_info[i].name)
{ {
printf("Loading FastFile: %s (0x%X | 0x%X)\n", zone_info[i].name, zone_info[i].allocFlags, printf("Loading FastFile: %s (0x%X | 0x%X)\n", zone_info[i].name, zone_info[i].allocFlags, zone_info[i].freeFlags);
zone_info[i].freeFlags);
} }
} }
if (game::is_dedi()) return db_load_stub_server(zone_info, zone_count, sync); return db_load_stub_client(zone_info, zone_count, sync);
else return db_load_stub_client(zone_info, zone_count, sync);
} }
}; };

View File

@ -1,11 +1,13 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include "game/game.hpp"
#include <utils/hook.hpp> #include <utils/hook.hpp>
#include "game/game.hpp"
#include "file_system.hpp" #include "file_system.hpp"
#include "log_file.hpp"
#define _CRT_SECURE_NO_WARNINGS
static utils::hook::detour sys_default_install_path_hook; static utils::hook::detour sys_default_install_path_hook;
@ -34,7 +36,7 @@ static FILE* file_open_append_text(const char* filename)
return file; return file;
} }
printf("Couldn't open file: %s %s\n", filename, std::strerror(errno)); log_file::info("Couldn't open file: %s %s\n", filename, std::strerror(errno));
return nullptr; return nullptr;
} }
@ -47,7 +49,7 @@ static FILE* file_open_write_binary(const char* filename)
return file; return file;
} }
printf("Couldn't open file: %s %s\n", filename, std::strerror(errno)); log_file::info("Couldn't open file: %s %s\n", filename, std::strerror(errno));
return nullptr; return nullptr;
} }
@ -154,7 +156,7 @@ static int open_file_append(const char* filename)
build_os_path_for_thread(basepath, game::native::fs_gamedir, filename, ospath, game::native::FS_THREAD_MAIN); build_os_path_for_thread(basepath, game::native::fs_gamedir, filename, ospath, game::native::FS_THREAD_MAIN);
if ((*fs_debug)->current.integer) if ((*fs_debug)->current.integer)
{ {
printf("FS_FOpenFileAppend: %s\n", ospath); log_file::info("FS_FOpenFileAppend: %s\n", ospath);
} }
if (game::native::FS_CreatePath(ospath)) if (game::native::FS_CreatePath(ospath))
@ -212,7 +214,7 @@ static int open_file_write_to_dir_for_thread(const char* filename, const char* d
if ((*fs_debug)->current.integer) if ((*fs_debug)->current.integer)
{ {
printf("FS_FOpenFileWriteToDirForThread: %s\n", ospath); log_file::info("FS_FOpenFileWriteToDirForThread: %s\n", ospath);
} }
if (game::native::FS_CreatePath(ospath)) if (game::native::FS_CreatePath(ospath))
@ -297,8 +299,8 @@ int file_system::write(const char* buffer, int len, int h)
auto tries = 0; auto tries = 0;
while (remaining) while (remaining)
{ {
auto block = remaining; const auto block = remaining;
auto written = static_cast<int>(file_write(buf, block, f)); const auto written = static_cast<int>(file_write(buf, block, f));
if (!written) if (!written)
{ {
if (tries) if (tries)
@ -327,16 +329,14 @@ int file_system::write(const char* buffer, int len, int h)
void file_system::post_load() void file_system::post_load()
{ {
fs_homepath = reinterpret_cast<const game::native::dvar_t**>( fs_homepath = reinterpret_cast<const game::native::dvar_t**>(SELECT_VALUE(0x1C2B538, 0x59ADD18));
SELECT_VALUE(0x1C2B538, 0x59ADD18, 0x585E8F0)); fs_debug = reinterpret_cast<const game::native::dvar_t**>(SELECT_VALUE(0x1C2B32C, 0x59A9A08));
fs_debug = reinterpret_cast<const game::native::dvar_t**>(
SELECT_VALUE(0x1C2B32C, 0x59A9A08, 0x585A5E4));
// Make open-iw5 work outside of the game directory // Make open-iw5 work outside of the game directory
sys_default_install_path_hook.create(SELECT_VALUE(0x487E50, 0x5C4A80, 0x535F80), &sys_default_install_path_stub); sys_default_install_path_hook.create(SELECT_VALUE(0x487E50, 0x5C4A80), &sys_default_install_path_stub);
// fs_basegame // fs_basegame
utils::hook::set<const char*>(SELECT_VALUE(0x629031, 0x5B0FD1, 0x526F5C), "userraw"); utils::hook::set<const char*>(SELECT_VALUE(0x629031, 0x5B0FD1), "userraw");
} }
REGISTER_MODULE(file_system) REGISTER_MODULE(file_system)

View File

@ -3,6 +3,8 @@
class file_system final : public module class file_system final : public module
{ {
public: public:
static_assert(sizeof(game::native::fileHandleData_t) == 0x11C);
void post_load() override; void post_load() override;
static int open_file_by_mode(const char* qpath, int* f, game::native::fsMode_t mode); static int open_file_by_mode(const char* qpath, int* f, game::native::fsMode_t mode);

View File

@ -1,18 +1,18 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include <utils/hook.hpp>
#include "game/game.hpp" #include "game/game.hpp"
#include "log_file.hpp"
#include <utils/hook.hpp>
class fov final : public module class fov final : public module
{ {
public: public:
void post_load() override void post_load() override
{ {
if (game::is_dedi()) return;
// Set dvar flag // Set dvar flag
utils::hook::set<BYTE>(SELECT_VALUE(0x4302C5, 0x455155, 0), game::native::DVAR_ARCHIVE | (game::is_mp() ? game::native::DVAR_SAVED : 0)); utils::hook::set<BYTE>(SELECT_VALUE(0x4302C5, 0x455155), game::native::DVAR_ARCHIVE | (game::is_mp() ? game::native::DVAR_SAVED : 0));
if (game::is_mp()) if (game::is_mp())
{ {
@ -31,7 +31,7 @@ private:
const auto* dvar = game::native::Dvar_FindVar(dvar_name); const auto* dvar = game::native::Dvar_FindVar(dvar_name);
if (dvar != nullptr && ((dvar->flags & game::native::DVAR_ARCHIVE) != 0)) if (dvar != nullptr && ((dvar->flags & game::native::DVAR_ARCHIVE) != 0))
{ {
printf("Not allowing server to override archive dvar '%s'\n", dvar_name); log_file::info("Not allowing server to override archive dvar '%s'\n", dvar_name);
return; return;
} }

View File

@ -17,7 +17,7 @@ public:
} }
private: private:
static HINSTANCE __stdcall shell_execute_a(const HWND hwnd, const LPCSTR lp_operation, const LPCSTR lp_file, static HINSTANCE WINAPI shell_execute_a(const HWND hwnd, const LPCSTR lp_operation, const LPCSTR lp_file,
const LPCSTR lp_parameters, const LPCSTR lp_directory, const LPCSTR lp_parameters, const LPCSTR lp_directory,
const INT n_show_cmd) const INT n_show_cmd)
{ {

View File

@ -29,7 +29,7 @@ void game_log::g_log_printf(const char* fmt, ...)
return; return;
} }
const auto time = game::native::level->time / 1000; const auto time = game::native::mp::level->time / 1000;
const auto len = sprintf_s(out, "%3i:%i%i %s", time / 60, time % 60 / 10, time % 60 % 10, buf); const auto len = sprintf_s(out, "%3i:%i%i %s", time / 60, time % 60 / 10, time % 60 % 10, buf);
file_system::write(out, len, log_file); file_system::write(out, len, log_file);

View File

@ -1,9 +1,9 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include <utils/hook.hpp>
#include "game/game.hpp" #include "game/game.hpp"
#include <utils/hook.hpp>
static const game::native::dvar_t** com_fixedtime = nullptr; static const game::native::dvar_t** com_fixedtime = nullptr;
static const game::native::dvar_t* com_timescale = nullptr; static const game::native::dvar_t* com_timescale = nullptr;
@ -42,7 +42,7 @@ static float com_get_timescale_for_snd()
static float com_get_timescale_for_sv() static float com_get_timescale_for_sv()
{ {
assert(com_timescale != nullptr); assert(com_timescale);
if (dev_timescale->current.value == 1.0f && com_timescale->current.value == 1.0f if (dev_timescale->current.value == 1.0f && com_timescale->current.value == 1.0f
&& *game::native::com_codeTimeScale == 1.0f) && *game::native::com_codeTimeScale == 1.0f)

View File

@ -73,7 +73,7 @@ namespace gsc
unsigned int find_variable_stub(unsigned int parent_id, unsigned int thread_name) unsigned int find_variable_stub(unsigned int parent_id, unsigned int thread_name)
{ {
const auto res = utils::hook::invoke<unsigned int>(SELECT_VALUE(0x4C4E70, 0x5651F0, 0x0), parent_id, thread_name); const auto res = utils::hook::invoke<unsigned int>(SELECT_VALUE(0x4C4E70, 0x5651F0), parent_id, thread_name);
if (!res) if (!res)
{ {
get_unknown_function_error(thread_name); get_unknown_function_error(thread_name);
@ -106,16 +106,11 @@ namespace gsc
public: public:
void post_load() override void post_load() override
{ {
if (game::is_dedi()) scr_emit_function_hook.create(SELECT_VALUE(0x40DCB0, 0x561400), &scr_emit_function_stub);
{
return;
}
scr_emit_function_hook.create(SELECT_VALUE(0x40DCB0, 0x561400, 0x0), &scr_emit_function_stub); utils::hook(SELECT_VALUE(0x60DABA, 0x5615FA), &compile_error_stub, HOOK_CALL).install()->quick();
utils::hook(SELECT_VALUE(0x60DAD1, 0x561611), &compile_error_stub, HOOK_CALL).install()->quick();
utils::hook(SELECT_VALUE(0x60DABA, 0x5615FA, 0x0), &compile_error_stub, HOOK_CALL).install()->quick(); utils::hook(SELECT_VALUE(0x40DCFA, 0x56144A), &find_variable_stub, HOOK_CALL).install()->quick();
utils::hook(SELECT_VALUE(0x60DAD1, 0x561611, 0x0), &compile_error_stub, HOOK_CALL).install()->quick();
utils::hook(SELECT_VALUE(0x40DCFA, 0x56144A, 0x0), &find_variable_stub, HOOK_CALL).install()->quick();
} }
void pre_destroy() override void pre_destroy() override

View File

@ -88,7 +88,7 @@ void log_file::post_load()
com_logfile = game::native::Dvar_RegisterInt("logfile", 1, com_logfile = game::native::Dvar_RegisterInt("logfile", 1,
0, 2, 0, "Write to log file - 0 = disabled, 1 = async file write, 2 = Sync every write"); 0, 2, 0, "Write to log file - 0 = disabled, 1 = async file write, 2 = Sync every write");
log_file_name = SELECT_VALUE("console_sp.log", "console_mp.log", "console_mp_dedicated.log"); log_file_name = SELECT_VALUE("console_sp.log", "console_mp.log");
} }
REGISTER_MODULE(log_file) REGISTER_MODULE(log_file)

View File

@ -1,19 +1,18 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include <utils/hook.hpp>
#include "game/game.hpp" #include "game/game.hpp"
#include <utils/hook.hpp>
class patches final : public module class patches final : public module
{ {
public: public:
void post_load() override void post_load() override
{ {
if (!game::is_dedi()) this->patch_clients(); this->patch_clients();
if (game::is_sp()) this->patch_sp(); if (game::is_sp()) this->patch_sp();
else if (game::is_mp()) this->patch_mp(); else if (game::is_mp()) this->patch_mp();
else if (game::is_dedi()) this->patch_dedi();
utils::hook(game::native::_longjmp, long_jump_stub, HOOK_JUMP).install()->quick(); utils::hook(game::native::_longjmp, long_jump_stub, HOOK_JUMP).install()->quick();
} }
@ -22,10 +21,10 @@ private:
void patch_clients() const void patch_clients() const
{ {
// Remove improper quit check // Remove improper quit check
utils::hook::nop(SELECT_VALUE(0x53444A, 0x5CCDC0, 0), 9); utils::hook::nop(SELECT_VALUE(0x53444A, 0x5CCDC0), 9);
// Ignore sdm files // Ignore sdm files
utils::hook::nop(SELECT_VALUE(0x4438BA, 0x6371EA, 0), 2); utils::hook::nop(SELECT_VALUE(0x4438BA, 0x6371EA), 2);
} }
void patch_sp() const void patch_sp() const
@ -35,8 +34,8 @@ private:
WSAStartup(MAKEWORD(2, 2), &wsa_data); WSAStartup(MAKEWORD(2, 2), &wsa_data);
// Disable remote storage // Disable remote storage
utils::hook::set<BYTE>(0x663B5A, 0xEB); utils::hook::set<std::uint8_t>(0x663B5A, 0xEB);
utils::hook::set<BYTE>(0x663C54, 0xEB); utils::hook::set<std::uint8_t>(0x663C54, 0xEB);
utils::hook(0x44C640, &live_get_local_client_name_stub, HOOK_JUMP).install()->quick(); utils::hook(0x44C640, &live_get_local_client_name_stub, HOOK_JUMP).install()->quick();
} }

View File

@ -26,6 +26,7 @@ const game::native::dvar_t* player_movement::g_speed;
DWORD player_movement::bounce_addr; DWORD player_movement::bounce_addr;
DWORD player_movement::dont_bounce_addr; DWORD player_movement::dont_bounce_addr;
DWORD player_movement::pm_project_velocity_addr;
DWORD player_movement::push_off_ladder_addr; DWORD player_movement::push_off_ladder_addr;
DWORD player_movement::jump_start_addr; DWORD player_movement::jump_start_addr;
DWORD player_movement::jump_get_step_height_addr; DWORD player_movement::jump_get_step_height_addr;
@ -310,28 +311,24 @@ __declspec(naked) void player_movement::jump_start_stub()
} }
} }
void player_movement::pm_project_velocity_stub(const float* vel_in, const float* normal, float* vel_out) __declspec(naked) void player_movement::pm_project_velocity_stub()
{ {
const auto length_squared_2d = vel_in[0] * vel_in[0] + vel_in[1] * vel_in[1]; __asm
if (std::fabsf(normal[2]) < 0.001f || length_squared_2d == 0.0f)
{ {
std::memcpy(vel_out, vel_in, sizeof(std::float_t[3])); push eax
return; mov eax, pm_bouncesAllAngles
} cmp byte ptr [eax + 0xC], 1
pop eax
auto new_z = vel_in[0] * normal[0] + vel_in[1] * normal[1]; je bounce
new_z = -new_z / normal[2];
const auto length_scale = std::sqrtf((vel_in[2] * vel_in[2] + length_squared_2d) / fstp ST(0)
(new_z * new_z + length_squared_2d)); pop esi
add esp, 0x10
retn
if (pm_bouncesAllAngles->current.enabled == true bounce:
|| (length_scale < 1.f || new_z < 0.f || vel_in[2] > 0.f)) jmp dont_bounce_addr
{
vel_out[0] = vel_in[0] * length_scale;
vel_out[1] = vel_in[1] * length_scale;
vel_out[2] = new_z * length_scale;
} }
} }
@ -525,7 +522,7 @@ void player_movement::patch_mp()
utils::hook(0x4166F0, jump_start_stub, HOOK_JUMP).install()->quick(); utils::hook(0x4166F0, jump_start_stub, HOOK_JUMP).install()->quick();
utils::hook::nop(0x4166F5, 1); // Nop skipped opcode utils::hook::nop(0x4166F5, 1); // Nop skipped opcode
utils::hook(0x424E0A, pm_project_velocity_stub, HOOK_CALL).install()->quick(); // PM_StepSlideMove utils::hook(0x41D196, pm_project_velocity_stub, HOOK_JUMP).install()->quick(); // PM_StepSlideMove
utils::hook(0x4F9BB3, bg_gravity_stub, HOOK_JUMP).install()->quick(); // ClientEndFrame utils::hook(0x4F9BB3, bg_gravity_stub, HOOK_JUMP).install()->quick(); // ClientEndFrame
utils::hook::nop(0x4F9BB8, 2); // Nop skipped opcode utils::hook::nop(0x4F9BB8, 2); // Nop skipped opcode
@ -579,7 +576,7 @@ void player_movement::patch_sp()
utils::hook(0x63E90A, jump_start_stub, HOOK_JUMP).install()->quick(); utils::hook(0x63E90A, jump_start_stub, HOOK_JUMP).install()->quick();
utils::hook::nop(0x63E90F, 1); // Nop skipped opcode utils::hook::nop(0x63E90F, 1); // Nop skipped opcode
utils::hook(0x43D9D1, pm_project_velocity_stub, HOOK_CALL).install()->quick(); // PM_StepSlideMove utils::hook(0x4A57E6, pm_project_velocity_stub, HOOK_JUMP).install()->quick(); // PM_StepSlideMove
utils::hook(0x64384F, pm_cmd_scale_crawl_speed_stub, HOOK_JUMP).install()->quick(); // PM_CmdScaleForStance utils::hook(0x64384F, pm_cmd_scale_crawl_speed_stub, HOOK_JUMP).install()->quick(); // PM_CmdScaleForStance
utils::hook(0x643859, pm_cmd_scale_ducked_speed_stub, HOOK_JUMP).install()->quick(); // PM_CmdScaleForStance utils::hook(0x643859, pm_cmd_scale_ducked_speed_stub, HOOK_JUMP).install()->quick(); // PM_CmdScaleForStance
@ -616,18 +613,14 @@ void player_movement::register_common_dvars()
void player_movement::post_load() void player_movement::post_load()
{ {
// Un-cheat missileMacross. It seems it retained its functionality // Un-cheat missileMacross. It seems it retained its functionality
utils::hook::set<BYTE>(SELECT_VALUE(0x44DFED, 0x50DDDD, 0x48C16F), 0x0); utils::hook::set<BYTE>(SELECT_VALUE(0x44DFED, 0x50DDDD), 0x0);
if (game::is_dedi()) bounce_addr = SELECT_VALUE(0x43D91F, 0x424D58);
{ dont_bounce_addr = SELECT_VALUE(0x43D933, 0x424D6C);
return; pm_project_velocity_addr = SELECT_VALUE(0x4A57Ef, 0x41D19F);
} push_off_ladder_addr = SELECT_VALUE(0x63EA4C, 0x41686C);
jump_start_addr = SELECT_VALUE(0x63E910, 0x4166F6);
bounce_addr = SELECT_VALUE(0x43D91F, 0x424D58, 0x0); jump_get_step_height_addr = SELECT_VALUE(0x48C1E2, 0x416145);
dont_bounce_addr = SELECT_VALUE(0x43D933, 0x424D6C, 0x0);
push_off_ladder_addr = SELECT_VALUE(0x63EA4C, 0x41686C, 0x0);
jump_start_addr = SELECT_VALUE(0x63E910, 0x4166F6, 0x0);
jump_get_step_height_addr = SELECT_VALUE(0x48C1E2, 0x416145, 0x0);
this->register_common_dvars(); this->register_common_dvars();

View File

@ -31,6 +31,7 @@ private:
static DWORD bounce_addr; static DWORD bounce_addr;
static DWORD dont_bounce_addr; static DWORD dont_bounce_addr;
static DWORD pm_project_velocity_addr;
static DWORD push_off_ladder_addr; static DWORD push_off_ladder_addr;
static DWORD jump_start_addr; static DWORD jump_start_addr;
static DWORD jump_get_step_height_addr; static DWORD jump_get_step_height_addr;
@ -59,11 +60,11 @@ private:
int contents, const float* origin, const float* angles); int contents, const float* origin, const float* angles);
static game::native::gentity_s* weapon_rocket_launcher_fire_mp_stub(game::native::gentity_s* ent, static game::native::gentity_s* weapon_rocket_launcher_fire_mp_stub(game::native::gentity_s* ent,
const game::native::Weapon weapon, float spread, game::native::weaponParms* wp, game::native::Weapon weapon, float spread, game::native::weaponParms* wp,
const float* gun_vel, game::native::missileFireParms* fire_parms, game::native::missileFireParms* magic_bullet); const float* gun_vel, game::native::missileFireParms* fire_parms, game::native::missileFireParms* magic_bullet);
static game::native::sp::gentity_s* weapon_rocket_launcher_fire_sp_stub(game::native::sp::gentity_s* ent, static game::native::sp::gentity_s* weapon_rocket_launcher_fire_sp_stub(game::native::sp::gentity_s* ent,
const game::native::Weapon weapon, float spread, game::native::weaponParms* wp, game::native::Weapon weapon, float spread, game::native::weaponParms* wp,
const float* gun_vel, game::native::missileFireParms* fire_parms, game::native::missileFireParms* magic_bullet); const float* gun_vel, game::native::missileFireParms* fire_parms, game::native::missileFireParms* magic_bullet);
static void pm_player_trace_stub(game::native::pmove_t* pm, game::native::trace_t* results, static void pm_player_trace_stub(game::native::pmove_t* pm, game::native::trace_t* results,
@ -88,7 +89,7 @@ private:
static void jump_start_stub(); static void jump_start_stub();
static void pm_project_velocity_stub(const float* vel_in, const float* normal, float* vel_out); static void pm_project_velocity_stub();
// On SP these are already implemented // On SP these are already implemented
static void bg_gravity_stub(); static void bg_gravity_stub();

View File

@ -1,11 +1,11 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include "game/game.hpp"
#include <utils/hook.hpp> #include <utils/hook.hpp>
#include <utils/thread.hpp> #include <utils/thread.hpp>
#include <utils/concurrency.hpp> #include <utils/concurrency.hpp>
#include "game/game.hpp"
#include "scheduler.hpp" #include "scheduler.hpp"
namespace namespace
@ -95,19 +95,19 @@ void scheduler::execute(const pipeline type)
void scheduler::r_end_frame_stub() void scheduler::r_end_frame_stub()
{ {
utils::hook::invoke<void>(SELECT_VALUE(0x4193D0, 0x67F840, 0x0)); utils::hook::invoke<void>(SELECT_VALUE(0x4193D0, 0x67F840));
execute(pipeline::renderer); execute(pipeline::renderer);
} }
void scheduler::g_glass_update_stub() void scheduler::g_glass_update_stub()
{ {
utils::hook::invoke<void>(SELECT_VALUE(0x4E3730, 0x505BB0, 0x481EA0)); utils::hook::invoke<void>(SELECT_VALUE(0x4E3730, 0x505BB0));
execute(pipeline::server); execute(pipeline::server);
} }
void scheduler::main_frame_stub() void scheduler::main_frame_stub()
{ {
utils::hook::invoke<void>(SELECT_VALUE(0x458600, 0x556470, 0x4DB070)); utils::hook::invoke<void>(SELECT_VALUE(0x458600, 0x556470));
execute(pipeline::main); execute(pipeline::main);
} }
@ -137,7 +137,7 @@ void scheduler::loop(const std::function<void()>& callback, const pipeline type,
void scheduler::once(const std::function<void()>& callback, const pipeline type, void scheduler::once(const std::function<void()>& callback, const pipeline type,
const std::chrono::milliseconds delay) const std::chrono::milliseconds delay)
{ {
schedule([callback]() schedule([callback]
{ {
callback(); callback();
return cond_end; return cond_end;
@ -158,15 +158,12 @@ void scheduler::post_start()
void scheduler::post_load() void scheduler::post_load()
{ {
utils::hook(SELECT_VALUE(0x44C7DB, 0x55688E, 0x4DB324), main_frame_stub, HOOK_CALL).install()->quick(); utils::hook(SELECT_VALUE(0x44C7DB, 0x55688E), main_frame_stub, HOOK_CALL).install()->quick();
if (!game::is_dedi()) utils::hook(SELECT_VALUE(0x57F7F8, 0x4978E2), r_end_frame_stub, HOOK_CALL).install()->quick();
{
utils::hook(SELECT_VALUE(0x57F7F8, 0x4978E2, 0x0), r_end_frame_stub, HOOK_CALL).install()->quick();
}
// Hook a function inside G_RunFrame. Fixes TLS issues // Hook a function inside G_RunFrame. Fixes TLS issues
utils::hook(SELECT_VALUE(0x52EFBC, 0x50CEC6, 0x48B277), g_glass_update_stub, HOOK_CALL).install()->quick(); utils::hook(SELECT_VALUE(0x52EFBC, 0x50CEC6), g_glass_update_stub, HOOK_CALL).install()->quick();
} }
void scheduler::pre_destroy() void scheduler::pre_destroy()

View File

@ -105,20 +105,20 @@ namespace scripting
public: public:
void post_load() override void post_load() override
{ {
start_hook_.initialize(SELECT_VALUE(0x50C575, 0x50D4F2, 0x48A026), &start_execution_stub, HOOK_CALL) // start_hook_.initialize(SELECT_VALUE(0x50C575, 0x50D4F2), &start_execution_stub, HOOK_CALL) //
->install() // ->install() //
->quick(); ->quick();
stop_hook_.initialize(SELECT_VALUE(0x528B04, 0x569E46, 0x4F03FA), &stop_execution_stub, HOOK_CALL) // stop_hook_.initialize(SELECT_VALUE(0x528B04, 0x569E46), &stop_execution_stub, HOOK_CALL) //
->install() // ->install() //
->quick(); ->quick();
utils::hook(SELECT_VALUE(0x4F9706, 0x5772A0, 0x4FAB88), &frame_stub, HOOK_CALL).install()->quick(); utils::hook(SELECT_VALUE(0x4F9706, 0x5772A0), &frame_stub, HOOK_CALL).install()->quick();
utils::hook(SELECT_VALUE(0x4FFA48, 0x5774AB, 0x4FEFD7), &frame_stub, HOOK_CALL).install()->quick(); utils::hook(SELECT_VALUE(0x4FFA48, 0x5774AB), &frame_stub, HOOK_CALL).install()->quick();
// Only relevant one? // Only relevant one?
utils::hook(SELECT_VALUE(0x6109F3, 0x56B637, 0x4EDFF7), &vm_notify_stub, HOOK_CALL).install()->quick(); utils::hook(SELECT_VALUE(0x6109F3, 0x56B637), &vm_notify_stub, HOOK_CALL).install()->quick();
utils::hook(SELECT_VALUE(0x6128BE, 0x56D541, 0x4EFAF9), &vm_notify_stub, HOOK_CALL).install()->quick(); utils::hook(SELECT_VALUE(0x6128BE, 0x56D541), &vm_notify_stub, HOOK_CALL).install()->quick();
if (game::is_sp()) if (game::is_sp())
{ {
@ -129,10 +129,8 @@ namespace scripting
utils::hook(0x610970, &vm_notify_stub, HOOK_JUMP).install()->quick(); utils::hook(0x610970, &vm_notify_stub, HOOK_JUMP).install()->quick();
} }
if (game::is_dedi()) return; utils::hook(SELECT_VALUE(0x44690A, 0x56B1EA), &scr_set_thread_position, HOOK_CALL).install()->quick();
utils::hook(SELECT_VALUE(0x4232A8, 0x561748), &process_script, HOOK_CALL).install()->quick();
utils::hook(SELECT_VALUE(0x44690A, 0x56B1EA, 0x0), &scr_set_thread_position, HOOK_CALL).install()->quick();
utils::hook(SELECT_VALUE(0x4232A8, 0x561748, 0x0), &process_script, HOOK_CALL).install()->quick();
} }
void pre_destroy() override void pre_destroy() override
@ -145,7 +143,7 @@ namespace scripting
void load_scripts() void load_scripts()
{ {
const auto script_dir = "open-iw5/scripts/"s; const auto script_dir = "userraw/scripts/"s;
if (!utils::io::directory_exists(script_dir)) if (!utils::io::directory_exists(script_dir))
{ {

View File

@ -1,9 +1,9 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include <utils/hook.hpp>
#include "game/game.hpp" #include "game/game.hpp"
#include <utils/hook.hpp>
class security final : public module class security final : public module
{ {
public: public:
@ -15,7 +15,7 @@ public:
utils::hook(0x57680C, net_defer_packet_to_client, HOOK_CALL).install()->quick(); // SV_ConnectionlessPacket utils::hook(0x57680C, net_defer_packet_to_client, HOOK_CALL).install()->quick(); // SV_ConnectionlessPacket
} }
else if (game::is_sp()) else
{ {
// Disable CL_ShellExecute_URL_f // Disable CL_ShellExecute_URL_f
utils::hook::nop(0x4298F6, 5); utils::hook::nop(0x4298F6, 5);
@ -38,8 +38,7 @@ private:
return; return;
} }
auto* msg = &game::native::deferredQueue->msgs[game::native::deferredQueue->send auto* msg = &game::native::deferredQueue->msgs[game::native::deferredQueue->send % std::extent_v<decltype(game::native::DeferredQueue::msgs)>];
% std::extent_v<decltype(game::native::DeferredQueue::msgs)>];
std::memcpy(msg->data, net_message->data, net_message->cursize); std::memcpy(msg->data, net_message->data, net_message->cursize);
msg->datalen = net_message->cursize; msg->datalen = net_message->cursize;

View File

@ -19,8 +19,6 @@ public:
void post_load() override void post_load() override
{ {
if (game::is_dedi()) return;
this->load_client(); this->load_client();
this->clean_up_on_error(); this->clean_up_on_error();

View File

@ -1,19 +1,21 @@
#include <std_include.hpp> #include <std_include.hpp>
#include <loader/module_loader.hpp> #include <loader/module_loader.hpp>
#include "game/game.hpp"
#include <utils/hook.hpp> #include <utils/hook.hpp>
#include <utils/string.hpp> #include <utils/string.hpp>
#include "game/game.hpp"
#include "test_clients.hpp" #include "test_clients.hpp"
#include "command.hpp" #include "command.hpp"
#include "scheduler.hpp" #include "scheduler.hpp"
#include "log_file.hpp"
bool test_clients::can_add() bool test_clients::can_add()
{ {
auto i = 0; auto i = 0;
while (i < *game::native::svs_clientCount) while (i < *game::native::svs_clientCount)
{ {
if (game::native::mp::svs_clients[i].header.state == game::native::clientState_t::CS_FREE) if (game::native::mp::svs_clients[i].header.state == game::native::CS_FREE)
{ {
// Free slot was found // Free slot was found
break; break;
@ -27,7 +29,7 @@ bool test_clients::can_add()
game::native::gentity_s* test_clients::sv_add_test_client() game::native::gentity_s* test_clients::sv_add_test_client()
{ {
if (!test_clients::can_add()) if (!can_add())
{ {
return nullptr; return nullptr;
} }
@ -54,7 +56,7 @@ game::native::gentity_s* test_clients::sv_add_test_client()
game::native::SV_Cmd_TokenizeString(user_info); game::native::SV_Cmd_TokenizeString(user_info);
adr.port = static_cast<std::uint16_t>(bot_port++); adr.port = static_cast<std::uint16_t>(bot_port++);
game::native::NetAdr_SetType(&adr, game::native::netadrtype_t::NA_BOT); game::native::NetAdr_SetType(&adr, game::native::NA_BOT);
game::native::SV_DirectConnect(adr); game::native::SV_DirectConnect(adr);
@ -64,7 +66,7 @@ game::native::gentity_s* test_clients::sv_add_test_client()
int idx; int idx;
for (idx = 0; idx < *game::native::svs_clientCount; idx++) for (idx = 0; idx < *game::native::svs_clientCount; idx++)
{ {
if (game::native::mp::svs_clients[idx].header.state == game::native::clientState_t::CS_FREE) if (game::native::mp::svs_clients[idx].header.state == game::native::CS_FREE)
continue; continue;
if (game::native::mp::svs_clients[idx].header.netchan.remoteAddress.type == adr.type if (game::native::mp::svs_clients[idx].header.netchan.remoteAddress.type == adr.type
@ -84,7 +86,7 @@ game::native::gentity_s* test_clients::sv_add_test_client()
game::native::SV_SendClientGameState(client); game::native::SV_SendClientGameState(client);
game::native::usercmd_s cmd; game::native::usercmd_s cmd;
std::memset(&cmd, 0, sizeof(game::native::usercmd_s)); ZeroMemory(&cmd, sizeof(game::native::usercmd_s));
game::native::SV_ClientEnterWorld(client, &cmd); game::native::SV_ClientEnterWorld(client, &cmd);
@ -95,7 +97,7 @@ game::native::gentity_s* test_clients::sv_add_test_client()
void test_clients::gscr_add_test_client() void test_clients::gscr_add_test_client()
{ {
const auto* ent = test_clients::sv_add_test_client(); const auto* ent = sv_add_test_client();
if (ent != nullptr) if (ent != nullptr)
{ {
@ -107,19 +109,19 @@ void test_clients::spawn(const int count)
{ {
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {
scheduler::once([]() scheduler::once([]
{ {
auto* ent = sv_add_test_client(); auto* ent = sv_add_test_client();
if (ent == nullptr) return; if (ent == nullptr) return;
game::native::Scr_AddEntityNum(ent->s.number, 0); game::native::Scr_AddEntityNum(ent->s.number, 0);
scheduler::once([ent]() scheduler::once([ent]
{ {
game::native::Scr_AddString("autoassign"); game::native::Scr_AddString("autoassign");
game::native::Scr_AddString("team_marinesopfor"); game::native::Scr_AddString("team_marinesopfor");
game::native::Scr_Notify(ent, static_cast<std::uint16_t>(game::native::SL_GetString("menuresponse", 0)), 2); game::native::Scr_Notify(ent, static_cast<std::uint16_t>(game::native::SL_GetString("menuresponse", 0)), 2);
scheduler::once([ent]() scheduler::once([ent]
{ {
game::native::Scr_AddString(utils::string::va("class%i", std::rand() % 5)); game::native::Scr_AddString(utils::string::va("class%i", std::rand() % 5));
game::native::Scr_AddString("changeclass"); game::native::Scr_AddString("changeclass");
@ -157,8 +159,8 @@ __declspec(naked) void test_clients::reset_reliable_mp()
bool test_clients::check_timeouts(const game::native::mp::client_t* client) bool test_clients::check_timeouts(const game::native::mp::client_t* client)
{ {
return (!client->bIsTestClient || client->header.state == game::native::clientState_t::CS_ZOMBIE) return (!client->bIsTestClient || client->header.state == game::native::clientState_t::CS_ZOMBIE) &&
&& client->header.netchan.remoteAddress.type != game::native::netadrtype_t::NA_LOOPBACK; client->header.netchan.remoteAddress.type != game::native::netadrtype_t::NA_LOOPBACK;
} }
__declspec(naked) void test_clients::check_timeouts_stub_mp() __declspec(naked) void test_clients::check_timeouts_stub_mp()
@ -170,7 +172,7 @@ __declspec(naked) void test_clients::check_timeouts_stub_mp()
lea esi, [ebx - 0x2146C] lea esi, [ebx - 0x2146C]
push esi push esi
call test_clients::check_timeouts call check_timeouts
add esp, 4 add esp, 4
mov [esp + 0x20], eax mov [esp + 0x20], eax
@ -187,17 +189,26 @@ __declspec(naked) void test_clients::check_timeouts_stub_mp()
void test_clients::post_load() void test_clients::post_load()
{ {
if (game::is_mp()) this->patch_mp(); if (game::is_mp()) this->patch_mp();
else return; // No sp/dedi bots for now :( else return; // No sp bots for now :(
command::add("spawnBot", [](const command::params& params) command::add("spawnBot", [](const command::params& params)
{ {
char* end;
if (params.size() < 2) if (params.size() < 2)
{ {
return; return;
} }
const auto count = std::atoi(params.get(1)); const auto* input = params.get(1);
test_clients::spawn(count); const auto count = std::strtol(input, &end, 10);
if (input == end)
{
log_file::info("%s is not a valid input\nUsage: %s <number of bots>\n", input, params.get(0));
return;
}
spawn(count);
}); });
} }
@ -206,16 +217,16 @@ void test_clients::patch_mp()
utils::hook::nop(0x639803, 5); // LiveSteamServer_RunFrame utils::hook::nop(0x639803, 5); // LiveSteamServer_RunFrame
utils::hook::nop(0x5CD65A, 5); // Do not crash for silly fatal error utils::hook::nop(0x5CD65A, 5); // Do not crash for silly fatal error
utils::hook::set<BYTE>(0x572879, 0xEB); // Skip checks in SV_DirectConnect utils::hook::set<std::uint8_t>(0x572879, 0xEB); // Skip checks in SV_DirectConnect
utils::hook::set<BYTE>(0x5728D4, 0xEB); utils::hook::set<std::uint8_t>(0x5728D4, 0xEB);
utils::hook::set<BYTE>(0x57293D, 0xEB); utils::hook::set<std::uint8_t>(0x57293D, 0xEB);
utils::hook(0x50C147, &test_clients::scr_shutdown_system_mp_stub, HOOK_CALL).install()->quick(); // G_ShutdownGame utils::hook(0x50C147, &scr_shutdown_system_mp_stub, HOOK_CALL).install()->quick(); // G_ShutdownGame
utils::hook(0x57BBF9, &test_clients::reset_reliable_mp, HOOK_CALL).install()->quick(); // SV_SendMessageToClient utils::hook(0x57BBF9, &reset_reliable_mp, HOOK_CALL).install()->quick(); // SV_SendMessageToClient
utils::hook(0x576DCC, &test_clients::check_timeouts_stub_mp, HOOK_JUMP).install()->quick(); // SV_CheckTimeouts utils::hook(0x576DCC, &check_timeouts_stub_mp, HOOK_JUMP).install()->quick(); // SV_CheckTimeouts
// Replace nullsubbed gsc func "GScr_AddTestClient" with our spawn // Replace nullsubbed gsc func "GScr_AddTestClient" with our spawn
utils::hook::set<void(*)()>(0x8AC8DC, test_clients::gscr_add_test_client); utils::hook::set<void(*)()>(0x8AC8DC, gscr_add_test_client);
} }
REGISTER_MODULE(test_clients); REGISTER_MODULE(test_clients);

View File

@ -17,7 +17,6 @@
#pragma warning(disable: 28020) #pragma warning(disable: 28020)
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h> #include <Windows.h>
#include <MsHTML.h> #include <MsHTML.h>
@ -39,17 +38,17 @@
#undef min #undef min
#endif #endif
#include <map>
#include <atomic> #include <atomic>
#include <vector> #include <chrono>
#include <filesystem>
#include <fstream>
#include <map>
#include <mutex> #include <mutex>
#include <queue> #include <queue>
#include <regex> #include <regex>
#include <chrono>
#include <thread> #include <thread>
#include <fstream>
#include <utility> #include <utility>
#include <filesystem> #include <vector>
#include <zlib.h> #include <zlib.h>
#include <zstd.h> #include <zstd.h>

View File

@ -206,7 +206,7 @@ namespace utils::cryptography
cbc_start(des3, reinterpret_cast<const uint8_t*>(iv.data()), reinterpret_cast<const uint8_t*>(key.data()), cbc_start(des3, reinterpret_cast<const uint8_t*>(iv.data()), reinterpret_cast<const uint8_t*>(key.data()),
key.size(), 0, &cbc); key.size(), 0, &cbc);
cbc_decrypt(reinterpret_cast<const uint8_t*>(data.data()), cbc_decrypt(reinterpret_cast<const uint8_t*>(data.data()),
reinterpret_cast<uint8_t*>(const_cast<char*>(dec_data.data())), data.size(), &cbc); reinterpret_cast<uint8_t*>(dec_data.data()), data.size(), &cbc);
cbc_done(&cbc); cbc_done(&cbc);
return dec_data; return dec_data;