party: add short version to getInfoPackeResponse (#491)

This commit is contained in:
Edo 2022-10-23 11:53:24 +01:00 committed by GitHub
parent b2a47bf2b7
commit 63b0dfcf09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 41 deletions

View File

@ -10,6 +10,7 @@
#include "console.hpp"
#include "game_console.hpp"
#include "scheduler.hpp"
#include "fastfiles.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
@ -258,15 +259,6 @@ namespace command
}
}
void enum_assets(const game::XAssetType type, const std::function<void(game::XAssetHeader)>& callback, const bool includeOverride)
{
game::DB_EnumXAssets_Internal(type, static_cast<void(*)(game::XAssetHeader, void*)>([](game::XAssetHeader header, void* data)
{
const auto& cb = *static_cast<const std::function<void(game::XAssetHeader)>*>(data);
cb(header);
}), &callback, includeOverride);
}
class component final : public component_interface
{
public:
@ -407,7 +399,7 @@ namespace command
console::info("Listing assets in pool %s\n", game::g_assetNames[type]);
const std::string filter = params.get(2);
enum_assets(type, [type, filter](const game::XAssetHeader header)
fastfiles::enum_assets(type, [type, filter](const game::XAssetHeader header)
{
const auto asset = game::XAsset{ type, header };
const auto* const asset_name = game::DB_GetXAssetName(&asset);

View File

@ -14,6 +14,8 @@
#include <utils/cryptography.hpp>
#include <utils/hook.hpp>
#include <version.hpp>
namespace party
{
namespace
@ -80,29 +82,18 @@ namespace party
std::string get_dvar_string(const std::string& dvar)
{
auto* dvar_value = game::Dvar_FindVar(dvar.data());
const auto* dvar_value = game::Dvar_FindVar(dvar.data());
if (dvar_value && dvar_value->current.string)
{
return dvar_value->current.string;
return {dvar_value->current.string};
}
return {};
}
int get_dvar_int(const std::string& dvar)
{
auto* dvar_value = game::Dvar_FindVar(dvar.data());
if (dvar_value && dvar_value->current.integer)
{
return dvar_value->current.integer;
}
return -1;
}
bool get_dvar_bool(const std::string& dvar)
{
auto* dvar_value = game::Dvar_FindVar(dvar.data());
const auto* dvar_value = game::Dvar_FindVar(dvar.data());
if (dvar_value && dvar_value->current.enabled)
{
return dvar_value->current.enabled;
@ -128,22 +119,20 @@ namespace party
{
if (game::CL_IsCgameInitialized())
{
// CL_ForwardCommandToServer
reinterpret_cast<void (*)(int, const char*)>(0x14020B310)(0, "disconnect");
// CL_WritePacket
reinterpret_cast<void (*)(int)>(0x1402058F0)(0);
game::CL_ForwardCommandToServer(0, "disconnect");
game::CL_WritePacket(0);
}
// CL_Disconnect
reinterpret_cast<void (*)(int)>(0x140209EC0)(0);
game::CL_Disconnect(0);
}
}
utils::hook::detour cldisconnect_hook;
utils::hook::detour cl_disconnect_hook;
void cldisconnect_stub(int a1)
void cl_disconnect_stub(int a1)
{
clear_sv_motd();
cldisconnect_hook.invoke<void>(a1);
cl_disconnect_hook.invoke<void>(a1);
}
const auto drop_reason_stub = utils::hook::assemble([](utils::hook::assembler& a)
@ -156,7 +145,7 @@ namespace party
void clear_sv_motd()
{
party::sv_motd.clear();
sv_motd.clear();
}
int get_client_num_by_name(const std::string& name)
@ -305,7 +294,7 @@ namespace party
utils::hook::jump(0x14020A010, disconnect_stub);
// detour CL_Disconnect to clear motd
cldisconnect_hook.create(0x140209EC0, cldisconnect_stub);
cl_disconnect_hook.create(0x140209EC0, cl_disconnect_stub);
if (game::environment::is_mp())
{
@ -548,6 +537,7 @@ namespace party
info.set("playmode", utils::string::va("%i", game::Com_GetCurrentCoDPlayMode()));
info.set("sv_running", utils::string::va("%i", get_dvar_bool("sv_running")));
info.set("dedicated", utils::string::va("%i", get_dvar_bool("dedicated")));
info.set("shortversion", SHORTVERSION);
network::send(target, "infoResponse", info.build(), '\n');
});

View File

@ -24,12 +24,8 @@ namespace game
WEAK symbol<void(float, float, int)> Com_SetSlowMotion{0, 0x1403D19B0};
WEAK symbol<void()> Com_Quit_f{0x1402F9390, 0x1403D08C0};
WEAK symbol<void(const char* cmdName, void (), cmd_function_s* allocedCmd)> Cmd_AddCommandInternal{
0x1402EDDB0, 0x1403AF2C0
};
WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)> Cmd_ExecuteSingleCommand{
0x1402EE350, 0x1403AF900
};
WEAK symbol<void(const char* cmdName, void (), cmd_function_s* allocedCmd)> Cmd_AddCommandInternal{0x1402EDDB0, 0x1403AF2C0};
WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)> Cmd_ExecuteSingleCommand{0x1402EE350, 0x1403AF900};
WEAK symbol<void(const char*)> Cmd_RemoveCommand{0x1402EE910, 0x1403AFEF0};
WEAK symbol<void(const char* text_in)> Cmd_TokenizeString{0x1402EEA30, 0x1403B0020};
WEAK symbol<void()> Cmd_EndTokenizeString{0x1402EE000, 0x1403AF5B0};
@ -44,6 +40,9 @@ namespace game
void (int, int, const char*))> Cbuf_ExecuteBufferInternal{0x1402ED9A0, 0x1403AEE80};
WEAK symbol<bool()> CL_IsCgameInitialized{0x140136560, 0x1401FD510};
WEAK symbol<void(int localClientNum, const char* string)> CL_ForwardCommandToServer{0x0, 0x14020B310};
WEAK symbol<void(int localClientNum)> CL_WritePacket{0x0, 0x1402058F0};
WEAK symbol<void(int localClientNum)> CL_Disconnect{0x0, 0x140209EC0};
WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessage{0x1400EE500, 0x1401A3050};
WEAK symbol<void(int localClientNum, /*mp::cg_s**/void* cg, const char* dvar, const char* value)> CG_SetClientDvarFromServer{0, 0x1401BF0A0};