This commit is contained in:
Sku-111 2023-11-01 16:56:57 +01:00
commit 24f04a940a
12 changed files with 119 additions and 30 deletions

View File

@ -398,6 +398,11 @@ void Scr_AddString(scrContext_t* scrContext, const char* value) {
func(scrContext, value); func(scrContext, value);
} }
int SL_GetString(const char* value) {
auto func = reinterpret_cast<int(*)(const char*)>(0x14131AE30_g);
return func(value);
}
unsigned int GScr_ExecEntThread(gentity_s* ent, int handle, unsigned int paramcount) { unsigned int GScr_ExecEntThread(gentity_s* ent, int handle, unsigned int paramcount) {
auto func = reinterpret_cast<unsigned int(*)(gentity_s*, int, unsigned int)>(0x141257D70_g); auto func = reinterpret_cast<unsigned int(*)(gentity_s*, int, unsigned int)>(0x141257D70_g);
return func(ent, handle, paramcount); return func(ent, handle, paramcount);
@ -461,12 +466,22 @@ short* SV_ClientMP_AddTestClient()
return SV_ClientMP_AddTestClient_func(); return SV_ClientMP_AddTestClient_func();
} }
short* SV_ClientMP_AddBot()
{
auto func = reinterpret_cast<short*(*)(const char* bot_name, unsigned int head, unsigned int body, unsigned int helmet)>(0x14136E210_g);
return func("DONETSK", 0,0,0);
}
void GScr_AddEntity(short* entity) void GScr_AddEntity(short* entity)
{ {
auto GScr_AddEntity_func = reinterpret_cast<void(*)(short* ent)>(0x1412578a0_g); auto GScr_AddEntity_func = reinterpret_cast<void(*)(short* ent)>(0x1412578a0_g);
GScr_AddEntity_func(entity); GScr_AddEntity_func(entity);
} }
void GScr_Notify(short* ent, unsigned int stringValue, unsigned int paramcount) {
reinterpret_cast<void(*)(short*, unsigned int, unsigned int)>(0x141259B30_g)(ent, stringValue, paramcount);
}
void SV_ClientMP_SpawnBotOrTestClient(short* entity) void SV_ClientMP_SpawnBotOrTestClient(short* entity)
{ {
auto SV_ClientMP_SpawnBotOrTestClient_func = reinterpret_cast<void(*)(short* ent)>(0x141373640_g); auto SV_ClientMP_SpawnBotOrTestClient_func = reinterpret_cast<void(*)(short* ent)>(0x141373640_g);
@ -513,6 +528,7 @@ cmd_function_s set_pointer_f_VAR;
cmd_function_s quit_f_VAR; cmd_function_s quit_f_VAR;
cmd_function_s openmenu_f_VAR; cmd_function_s openmenu_f_VAR;
cmd_function_s addbot_f_VAR; cmd_function_s addbot_f_VAR;
cmd_function_s addTestClient_f_VAR;
cmd_function_s ddldump_f_VAR; cmd_function_s ddldump_f_VAR;
cmd_function_s weapondefdump_f_VAR; cmd_function_s weapondefdump_f_VAR;
cmd_function_s view_vehicle_ents_f_VAR; cmd_function_s view_vehicle_ents_f_VAR;

View File

@ -122,6 +122,7 @@ extern cmd_function_s set_pointer_f_VAR;
extern cmd_function_s quit_f_VAR; extern cmd_function_s quit_f_VAR;
extern cmd_function_s openmenu_f_VAR; extern cmd_function_s openmenu_f_VAR;
extern cmd_function_s addbot_f_VAR; extern cmd_function_s addbot_f_VAR;
extern cmd_function_s addTestClient_f_VAR;
extern cmd_function_s ddldump_f_VAR; extern cmd_function_s ddldump_f_VAR;
extern cmd_function_s weapondefdump_f_VAR; extern cmd_function_s weapondefdump_f_VAR;
extern cmd_function_s view_vehicle_ents_f_VAR; extern cmd_function_s view_vehicle_ents_f_VAR;
@ -240,6 +241,9 @@ void Com_SetErrorMessage(const char* errorMessage);
void GamerProfile_SetDataByName(unsigned int controllerIndex, const char* settingName, float settingValue); void GamerProfile_SetDataByName(unsigned int controllerIndex, const char* settingName, float settingValue);
short* SV_ClientMP_AddTestClient(); short* SV_ClientMP_AddTestClient();
short* SV_ClientMP_AddBot();
void GScr_Notify(short* ent, unsigned int stringValue, unsigned int paramcount);
int SL_GetString(const char* value);
void GScr_AddEntity(short* entity); void GScr_AddEntity(short* entity);

View File

@ -11,6 +11,7 @@ void addCustomCmds()
Cmd_AddCommandInternal("quit", Cmd_Quit_f, &quit_f_VAR); Cmd_AddCommandInternal("quit", Cmd_Quit_f, &quit_f_VAR);
Cmd_AddCommandInternal("openmenu", Cmd_OpenMenu_f, &openmenu_f_VAR); Cmd_AddCommandInternal("openmenu", Cmd_OpenMenu_f, &openmenu_f_VAR);
Cmd_AddCommandInternal("addbot", Cmd_AddBot_f, &addbot_f_VAR); Cmd_AddCommandInternal("addbot", Cmd_AddBot_f, &addbot_f_VAR);
Cmd_AddCommandInternal("addtestclient", Cmd_AddTestClient_f, &addTestClient_f_VAR);
Cmd_AddCommandInternal("ddldump", Cmd_DDLDump_f, &ddldump_f_VAR); Cmd_AddCommandInternal("ddldump", Cmd_DDLDump_f, &ddldump_f_VAR);
Cmd_AddCommandInternal("weapondefdump", Cmd_WeaponDefDump_f, &weapondefdump_f_VAR); Cmd_AddCommandInternal("weapondefdump", Cmd_WeaponDefDump_f, &weapondefdump_f_VAR);
//Cmd_AddCommandInternal("view_vehicle_ents", Cmd_ViewVehicleEnts_f, &view_vehicle_ents_f_VAR); //Cmd_AddCommandInternal("view_vehicle_ents", Cmd_ViewVehicleEnts_f, &view_vehicle_ents_f_VAR);
@ -283,11 +284,76 @@ void Cmd_OpenMenu_f()
} }
} }
void Cmd_AddBot_f() void Cmd_AddTestClient_f()
{ {
auto max_clients = *(int*)0x14EEB0CE0_g;
auto client_count = *(int*)0x14E195070_g;
auto spawnable_bots = max_clients - client_count;
if (spawnable_bots <= 0)
return;
int spawn_number = 1;
if (Cmd_Argc() == 2)
{
char command[100]{ 0 };
Cmd_ArgvBuffer(1, command, sizeof(command));
spawn_number = atoll(command);
}
if (spawn_number > spawnable_bots)
spawn_number = spawnable_bots;
std::vector<short*> ents{};
for (int i{}; i < spawn_number; ++i)
{
auto ent = SV_ClientMP_AddTestClient(); auto ent = SV_ClientMP_AddTestClient();
if (!ent)
continue;
GScr_AddEntity(ent); GScr_AddEntity(ent);
SV_ClientMP_SpawnBotOrTestClient(ent); SV_ClientMP_SpawnBotOrTestClient(ent);
ents.push_back(ent);
}
Sleep(100);
for (auto& ent : ents) {
auto scrContext = ScriptContext_Server();
Scr_AddString(scrContext, "class1");
Scr_AddString(scrContext, "class_select");
GScr_Notify(ent, SL_GetString("loadout_class_selected"), 2);
}
}
void Cmd_AddBot_f()
{
auto max_clients = *(int*)0x14EEB0CE0_g;
auto client_count = *(int*)0x14E195070_g;
auto spawnable_bots = max_clients - client_count;
if (spawnable_bots <= 0)
return;
int spawn_number = 1;
if (Cmd_Argc() == 2)
{
char command[100]{ 0 };
Cmd_ArgvBuffer(1, command, sizeof(command));
spawn_number = atoll(command);
}
if (spawn_number > spawnable_bots)
spawn_number = spawnable_bots;
for (int i{}; i < spawn_number; ++i)
{
auto ent = SV_ClientMP_AddBot();
if (!ent)
return;
GScr_AddEntity(ent);
SV_ClientMP_SpawnBotOrTestClient(ent);
//Sleep(20);
}
} }
void SV_CmdsMP_MapRestart_f() void SV_CmdsMP_MapRestart_f()

View File

@ -22,6 +22,8 @@ void Cmd_OpenMenu_f();
void Cmd_AddBot_f(); void Cmd_AddBot_f();
void Cmd_AddTestClient_f();
void SV_CmdsMP_MapRestart_f(); void SV_CmdsMP_MapRestart_f();
void SV_CmdsMP_FastRestart_f(); void SV_CmdsMP_FastRestart_f();

View File

@ -12,7 +12,7 @@
#include "dvar.h" #include "dvar.h"
#include "stringed.h" #include "stringed.h"
#include "fastfile.h" #include "fastfile.h"
#include "party.h" #include "mp_init.h"
#include "ddl.h" #include "ddl.h"
#include "gamemode.h" #include "gamemode.h"
#include "sv_main.h" #include "sv_main.h"

View File

@ -176,7 +176,7 @@
<ClCompile Include="Main.cpp" /> <ClCompile Include="Main.cpp" />
<ClCompile Include="net_chan.cpp" /> <ClCompile Include="net_chan.cpp" />
<ClCompile Include="omnvars.cpp" /> <ClCompile Include="omnvars.cpp" />
<ClCompile Include="party.cpp" /> <ClCompile Include="mp_init.cpp" />
<ClCompile Include="patch.cpp" /> <ClCompile Include="patch.cpp" />
<ClCompile Include="screen.cpp" /> <ClCompile Include="screen.cpp" />
<ClCompile Include="script.cpp" /> <ClCompile Include="script.cpp" />
@ -221,7 +221,7 @@
<ClInclude Include="MinHook.hpp" /> <ClInclude Include="MinHook.hpp" />
<ClInclude Include="net_chan.h" /> <ClInclude Include="net_chan.h" />
<ClInclude Include="omnvars.h" /> <ClInclude Include="omnvars.h" />
<ClInclude Include="party.h" /> <ClInclude Include="mp_init.h" />
<ClInclude Include="patch.h" /> <ClInclude Include="patch.h" />
<ClInclude Include="screen.h" /> <ClInclude Include="screen.h" />
<ClInclude Include="script.h" /> <ClInclude Include="script.h" />

View File

@ -106,7 +106,7 @@
<ClCompile Include="omnvars.cpp"> <ClCompile Include="omnvars.cpp">
<Filter>hook_lib\game</Filter> <Filter>hook_lib\game</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="party.cpp"> <ClCompile Include="mp_init.cpp">
<Filter>hook_lib\game</Filter> <Filter>hook_lib\game</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="patch.cpp"> <ClCompile Include="patch.cpp">
@ -237,7 +237,7 @@
<ClInclude Include="omnvars.h"> <ClInclude Include="omnvars.h">
<Filter>hook_lib\game</Filter> <Filter>hook_lib\game</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="party.h"> <ClInclude Include="mp_init.h">
<Filter>hook_lib\game</Filter> <Filter>hook_lib\game</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="patch.h"> <ClInclude Include="patch.h">

13
hook_lib/mp_init.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "mp_init.h"
#include "game_inc.h"
void CG_MainMP_Init_Detour(int localClientNum, int serverMessageNum, int serverCommandSequence, int clientNum, void* hunkUser)
{
cg_mainmp_init.stub<void>(localClientNum, serverMessageNum, serverCommandSequence, clientNum, hunkUser);
Cbuf_AddText("exec autoexec.cfg");
LoadInventory();
Cbuf_AddText("set cl_textChatEnabled 1");
}

5
hook_lib/mp_init.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include "Main.hpp"
inline utils::hook::detour cg_mainmp_init;
void CG_MainMP_Init_Detour(int localClientNum, int serverMessageNum, int serverCommandSequence, int clientNum, void* hunkUser);

View File

@ -1,13 +0,0 @@
#include "party.h"
#include "game_inc.h"
void PartyHost_StartPrivateParty_Detour(int localClientNum, int localControllerIndex, bool currentlyActive, int hostType)
{
Cbuf_AddText("exec autoexec.cfg");
partyhost_startprivateparty.stub<void>(localClientNum, localControllerIndex, currentlyActive, hostType);
LoadInventory();
Cbuf_AddText("set cl_textChatEnabled 1");
}

View File

@ -1,5 +0,0 @@
#pragma once
#include "Main.hpp"
inline utils::hook::detour partyhost_startprivateparty;
void PartyHost_StartPrivateParty_Detour(int localClientNum, int localControllerIndex, bool currentlyActive, int hostType);

View File

@ -94,9 +94,9 @@ int LiveStorage_GetActiveStatsSource_Detour()
return 1; return 1;
} }
void Donetsk() bool ProfanityFilter_IsBadWord_Detour()
{ {
// set_splashscreen(); return false;
} }
void hooks() void hooks()
@ -141,7 +141,7 @@ void hooks()
seh_stringed_getstring.create(0x1413CC2A0_g, SEH_StringEd_GetString_Detour); seh_stringed_getstring.create(0x1413CC2A0_g, SEH_StringEd_GetString_Detour);
cl_createdevgui.create(0x1415B2080_g, CL_CreateDevGui_Detour); cl_createdevgui.create(0x1415B2080_g, CL_CreateDevGui_Detour);
partyhost_startprivateparty.create(0x14119F0D0_g, PartyHost_StartPrivateParty_Detour); cg_mainmp_init.create(0x141792E60_g, CG_MainMP_Init_Detour);
PM_WeaponUseAmmo.create(0x141155AF0_g, PM_WeaponUseAmmo_Detour); PM_WeaponUseAmmo.create(0x141155AF0_g, PM_WeaponUseAmmo_Detour);
@ -149,6 +149,8 @@ void hooks()
lui_cod_luacall_enginenotifyserver_detour_impl.create(0x1419F7160_g, LUI_CoD_LuaCall_EngineNotifyServer_Detour); lui_cod_luacall_enginenotifyserver_detour_impl.create(0x1419F7160_g, LUI_CoD_LuaCall_EngineNotifyServer_Detour);
utils::hook::jump(0x141609140_g, ProfanityFilter_IsBadWord_Detour);
// remove FF Header version check // remove FF Header version check
// db_checkxfileversion.create(0x1411A7840_g, DB_CheckXFileVersion_Detour); // db_checkxfileversion.create(0x1411A7840_g, DB_CheckXFileVersion_Detour);
} }
@ -156,7 +158,6 @@ void hooks()
void patchGame() void patchGame()
{ {
hooks(); hooks();
Donetsk();
// patch ui_maxclients limit // patch ui_maxclients limit
utils::hook::nop(0x140F30210_g, 5); utils::hook::nop(0x140F30210_g, 5);