Fix some stuff
This commit is contained in:
parent
a33aafcff9
commit
d739b1c6f9
@ -69,9 +69,8 @@ workspace "open-iw5"
|
|||||||
filter {}
|
filter {}
|
||||||
|
|
||||||
filter "configurations:Release"
|
filter "configurations:Release"
|
||||||
optimize "Size"
|
optimize "Full"
|
||||||
buildoptions { "/GL" }
|
buildoptions { "/Os" }
|
||||||
linkoptions { "/IGNORE:4702", "/LTCG" }
|
|
||||||
defines { "NDEBUG" }
|
defines { "NDEBUG" }
|
||||||
flags { "FatalCompileWarnings" }
|
flags { "FatalCompileWarnings" }
|
||||||
filter {}
|
filter {}
|
||||||
|
@ -45,6 +45,8 @@ namespace game
|
|||||||
|
|
||||||
SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString;
|
SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString;
|
||||||
|
|
||||||
|
XUIDToString_t XUIDToString;
|
||||||
|
|
||||||
decltype(longjmp)* _longjmp;
|
decltype(longjmp)* _longjmp;
|
||||||
|
|
||||||
CmdArgs* sv_cmd_args;
|
CmdArgs* sv_cmd_args;
|
||||||
@ -183,6 +185,31 @@ 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* dvarName)
|
||||||
|
{
|
||||||
|
static DWORD func = 0x531320;
|
||||||
|
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov edi, dvarName
|
||||||
|
call func
|
||||||
|
retn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dvar_t* Dvar_FindVar(const char* dvarName)
|
||||||
|
{
|
||||||
|
if (is_dedi())
|
||||||
|
{
|
||||||
|
return dvar_find_malleable_var(dvarName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return reinterpret_cast<dvar_t*(*)(const char*)>
|
||||||
|
(SELECT_VALUE(0x539550, 0x5BDCC0, 0x0))(dvarName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const float* Scr_AllocVector(const float* v)
|
const float* Scr_AllocVector(const float* v)
|
||||||
{
|
{
|
||||||
const auto mem = static_cast<DWORD*>(MT_Alloc(16, 2));
|
const auto mem = static_cast<DWORD*>(MT_Alloc(16, 2));
|
||||||
@ -309,7 +336,7 @@ namespace game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scr_add_string_dedi(const char* value)
|
__declspec(naked) void scr_add_string_dedi(const char* value)
|
||||||
{
|
{
|
||||||
static DWORD func = 0x4F1010;
|
static DWORD func = 0x4F1010;
|
||||||
|
|
||||||
@ -399,7 +426,7 @@ namespace game
|
|||||||
if (mp::svs_clients[i].header.state != CS_FREE
|
if (mp::svs_clients[i].header.state != CS_FREE
|
||||||
&& mp::svs_clients[i].header.netchan.remoteAddress.type == NA_BOT)
|
&& mp::svs_clients[i].header.netchan.remoteAddress.type == NA_BOT)
|
||||||
{
|
{
|
||||||
SV_DropClient(&mp::svs_clients[i], "EXE_TIMEDOUT", 1);
|
SV_DropClient(&mp::svs_clients[i], "EXE_TIMEDOUT", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,6 +438,11 @@ namespace game
|
|||||||
sv_drop_all_bots_mp();
|
sv_drop_all_bots_mp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetProtocolVersion()
|
||||||
|
{
|
||||||
|
return 0x507C;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
launcher::mode mode = launcher::mode::none;
|
launcher::mode mode = launcher::mode::none;
|
||||||
@ -487,6 +519,8 @@ namespace game
|
|||||||
|
|
||||||
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, 0x0));
|
||||||
|
|
||||||
|
native::XUIDToString = native::XUIDToString_t(SELECT_VALUE(0x4FAA30, 0x55CC20, 0x0));
|
||||||
|
|
||||||
native::_longjmp = reinterpret_cast<decltype(longjmp)*>(SELECT_VALUE(0x73AC20, 0x7363BC, 0x655558));
|
native::_longjmp = reinterpret_cast<decltype(longjmp)*>(SELECT_VALUE(0x73AC20, 0x7363BC, 0x655558));
|
||||||
|
|
||||||
native::sv_cmd_args = reinterpret_cast<native::CmdArgs*>(SELECT_VALUE(0x0, 0x1CAA998, 0x1B5E7D8));
|
native::sv_cmd_args = reinterpret_cast<native::CmdArgs*>(SELECT_VALUE(0x0, 0x1CAA998, 0x1B5E7D8));
|
||||||
|
@ -71,6 +71,9 @@ namespace game
|
|||||||
typedef void (*SV_Cmd_EndTokenizedString_t)();
|
typedef void (*SV_Cmd_EndTokenizedString_t)();
|
||||||
extern SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString;
|
extern SV_Cmd_EndTokenizedString_t SV_Cmd_EndTokenizedString;
|
||||||
|
|
||||||
|
typedef void (*XUIDToString_t)(const unsigned __int64* xuid, char* str);
|
||||||
|
extern XUIDToString_t XUIDToString;
|
||||||
|
|
||||||
extern decltype(longjmp)* _longjmp;
|
extern decltype(longjmp)* _longjmp;
|
||||||
|
|
||||||
extern CmdArgs* sv_cmd_args;
|
extern CmdArgs* sv_cmd_args;
|
||||||
@ -114,6 +117,8 @@ namespace game
|
|||||||
|
|
||||||
void* MT_Alloc(int numBytes, int type);
|
void* MT_Alloc(int numBytes, int type);
|
||||||
|
|
||||||
|
dvar_t* Dvar_FindVar(const char* dvarName);
|
||||||
|
|
||||||
const float* Scr_AllocVector(const float* v);
|
const float* Scr_AllocVector(const float* v);
|
||||||
void Scr_ClearOutParams();
|
void Scr_ClearOutParams();
|
||||||
scr_entref_t Scr_GetEntityIdRef(unsigned int id);
|
scr_entref_t Scr_GetEntityIdRef(unsigned int id);
|
||||||
@ -129,6 +134,8 @@ namespace game
|
|||||||
int SV_IsTestClient(int clientNum);
|
int SV_IsTestClient(int clientNum);
|
||||||
void SV_DropClient(mp::client_t* drop, const char* reason, bool tellThem);
|
void SV_DropClient(mp::client_t* drop, const char* reason, bool tellThem);
|
||||||
void SV_DropAllBots();
|
void SV_DropAllBots();
|
||||||
|
|
||||||
|
int GetProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_mp();
|
bool is_mp();
|
||||||
|
@ -30,13 +30,20 @@ game::native::gentity_s* test_clients::sv_add_test_client()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(game::native::Dvar_FindVar("sv_running")->current.enabled);
|
||||||
|
assert(game::native::Dvar_FindVar("sv_maxclients")->current.integer <= *game::native::svs_clientCount);
|
||||||
|
|
||||||
static auto bot_port = 0;
|
static auto bot_port = 0;
|
||||||
char user_info[1024] = {0};
|
char user_info[1024] = {0};
|
||||||
|
char xuid[32] = {0};
|
||||||
|
|
||||||
// Most basic string the game will accept. Xuid and Xnaddr can be empty
|
const std::uint64_t random_xuid = std::rand();
|
||||||
|
game::native::XUIDToString(&random_xuid, xuid);
|
||||||
|
|
||||||
|
// Most basic string the game will accept.
|
||||||
_snprintf_s(user_info, _TRUNCATE,
|
_snprintf_s(user_info, _TRUNCATE,
|
||||||
"connect bot%d \"\\invited\\0\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\bot%d\\xuid\\%s\\xnaddr\\%s\\natType\\2\\protocol\\%d\\checksum\\%u\\statver\\%d %u\"",
|
"connect bot%d \"\\invited\\0\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\bot%d\\xuid\\%s\\xnaddr\\%s\\natType\\2\\protocol\\%d\\checksum\\%u\\statver\\%d %u\"",
|
||||||
bot_port, bot_port, "", "", 0x507C, game::native::BG_NetDataChecksum(),
|
bot_port, bot_port, xuid, "", game::native::GetProtocolVersion(), game::native::BG_NetDataChecksum(),
|
||||||
game::native::LiveStorage_GetPersistentDataDefVersion(), game::native::LiveStorage_GetPersistentDataDefFormatChecksum());
|
game::native::LiveStorage_GetPersistentDataDefVersion(), game::native::LiveStorage_GetPersistentDataDefFormatChecksum());
|
||||||
|
|
||||||
game::native::netadr_s adr;
|
game::native::netadr_s adr;
|
||||||
@ -50,8 +57,8 @@ game::native::gentity_s* test_clients::sv_add_test_client()
|
|||||||
game::native::SV_Cmd_EndTokenizedString();
|
game::native::SV_Cmd_EndTokenizedString();
|
||||||
|
|
||||||
// Find the bot
|
// Find the bot
|
||||||
auto idx = 0;
|
auto idx = 1;
|
||||||
while (idx < *game::native::svs_clientCount)
|
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::clientState_t::CS_FREE)
|
||||||
continue;
|
continue;
|
||||||
@ -121,7 +128,6 @@ __declspec(naked) void test_clients::reset_reliable_mp()
|
|||||||
cmp [esi + 0x41CB4], 1 // bIsTestClient
|
cmp [esi + 0x41CB4], 1 // bIsTestClient
|
||||||
jnz resume
|
jnz resume
|
||||||
|
|
||||||
push eax
|
|
||||||
mov eax, [esi + 0x20E70] // Move reliableSequence to eax
|
mov eax, [esi + 0x20E70] // Move reliableSequence to eax
|
||||||
mov [esi + 0x20E74], eax // Move eax to reliableAcknowledge
|
mov [esi + 0x20E74], eax // Move eax to reliableAcknowledge
|
||||||
|
|
||||||
@ -165,7 +171,7 @@ 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/dedi bots for now :(
|
||||||
|
|
||||||
command::add("spawnBot", [](const std::vector<std::string>& params)
|
command::add("spawnBot", []([[maybe_unused]] const std::vector<std::string>& params)
|
||||||
{
|
{
|
||||||
// Because I am unable to expand the scheduler at the moment
|
// Because I am unable to expand the scheduler at the moment
|
||||||
// we only get one bot at the time
|
// we only get one bot at the time
|
||||||
|
@ -34,6 +34,7 @@ namespace utils::flags
|
|||||||
if (!parsed)
|
if (!parsed)
|
||||||
{
|
{
|
||||||
parse_flags(enabled_flags);
|
parse_flags(enabled_flags);
|
||||||
|
parsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& entry : enabled_flags)
|
for (const auto& entry : enabled_flags)
|
||||||
|
Loading…
Reference in New Issue
Block a user