comment sv_parallel_sendsnapshot, detect string_t, mark edict as changed after hooking/unhooking

This commit is contained in:
arthurdead 2023-02-15 22:50:16 -03:00
parent ea36957b1e
commit 5c1f39064b
3 changed files with 61 additions and 5 deletions

View File

@ -214,6 +214,10 @@ private:
using restores_t = std::unordered_map<SendProp *, std::unique_ptr<proxyrestore_t>>;
static restores_t restores;
static SendVarProxyFn SendProxy_StringT_To_String_ptr{nullptr};
static SendVarProxyFn SendProxy_Color32ToInt_ptr{nullptr};
static SendVarProxyFn SendProxy_EHandleToInt_ptr{nullptr};
static prop_types guess_prop_type(const SendProp *pProp, const SendTable *pTable) noexcept
{
#if defined _DEBUG
@ -278,6 +282,12 @@ static prop_types guess_prop_type(const SendProp *pProp, const SendTable *pTable
#endif
return prop_types::unsigned_int;
} else {
if(SendProxy_Color32ToInt_ptr && pRealProxy == SendProxy_Color32ToInt_ptr) {
return prop_types::color32_;
} else if(SendProxy_EHandleToInt_ptr && pRealProxy == SendProxy_EHandleToInt_ptr) {
return prop_types::ehandle;
}
{
if(pProp->m_nBits == 32) {
struct dummy_t {
@ -368,8 +378,12 @@ static prop_types guess_prop_type(const SendProp *pProp, const SendTable *pTable
case DPT_VectorXY:
return prop_types::vector;
case DPT_String: {
if(SendProxy_StringT_To_String_ptr && pRealProxy == SendProxy_StringT_To_String_ptr) {
return prop_types::tstring;
} else {
return prop_types::cstring;
}
}
case DPT_Array:
return prop_types::unknown;
case DPT_DataTable:
@ -1667,7 +1681,7 @@ DETOUR_DECL_STATIC3(SV_ComputeClientPacks, void, int, clientCount, CGameClient *
g_Sample.is_parallel_pack_allowed()
};
sv_parallel_sendsnapshot->SetValue(true);
//sv_parallel_sendsnapshot->SetValue(false);
sv_parallel_packentities->SetValue(parallel_pack);
in_compute_packs = true;
@ -1924,21 +1938,34 @@ static cell_t proxysend_hook(IPluginContext *pContext, const cell_t *params) noe
it_hook = hooks.emplace(std::pair<int, proxyhook_t>{ref, proxyhook_t{ref}}).first;
}
edict_t *edict{pEntity->GetNetworkable()->GetEdict()};
if(pProp->GetType() == DPT_DataTable) {
SendTable *pPropTable{pProp->GetDataTable()};
int NumProps{pPropTable->GetNumProps()};
for(int i = 0; i < NumProps; ++i) {
SendProp *pChildProp{pPropTable->GetProp(i)};
std::string tmp_name{prop_name};
cell_t ret{proxysend_handle_hook(pContext, it_hook, ref, info.actual_offset + pChildProp->GetOffset(), pChildProp, std::move(tmp_name), i, pTable, callback, per_client)};
int offset{info.actual_offset + pChildProp->GetOffset()};
cell_t ret{proxysend_handle_hook(pContext, it_hook, ref, offset, pChildProp, std::move(tmp_name), i, pTable, callback, per_client)};
if(ret != 0) {
return ret;
}
if(edict) {
gamehelpers->SetEdictStateChanged(edict, offset);
}
}
return 0;
}
return proxysend_handle_hook(pContext, it_hook, ref, info.actual_offset, pProp, std::move(prop_name), 0, pTable, callback, per_client);
cell_t ret{proxysend_handle_hook(pContext, it_hook, ref, info.actual_offset, pProp, std::move(prop_name), 0, pTable, callback, per_client)};
if(ret == 0) {
if(edict) {
gamehelpers->SetEdictStateChanged(edict, info.actual_offset);
}
}
return ret;
}
static void proxysend_handle_unhook(hooks_t::iterator it_hook, int ref, const SendProp *pProp, const char *name, IPluginFunction *callback)
@ -1999,6 +2026,11 @@ static cell_t proxysend_unhook(IPluginContext *pContext, const cell_t *params) n
}
}
edict_t *edict{pEntity->GetNetworkable()->GetEdict()};
if(edict) {
gamehelpers->SetEdictStateChanged(edict, 0);
}
return 0;
}
@ -2047,6 +2079,15 @@ bool Sample::SDK_OnLoad(char *error, size_t maxlen, bool late) noexcept
return false;
}
gameconf->GetMemSig("SendProxy_StringT_To_String", (void **)&SendProxy_StringT_To_String_ptr);
if(SendProxy_StringT_To_String_ptr == nullptr) {
snprintf(error, maxlen, "could not get SendProxy_StringT_To_String address");
return false;
}
gameconf->GetMemSig("SendProxy_Color32ToInt", (void **)&SendProxy_Color32ToInt_ptr);
gameconf->GetMemSig("SendProxy_EHandleToInt", (void **)&SendProxy_EHandleToInt_ptr);
CDetourManager::Init(smutils->GetScriptingEngine(), gameconf);
SendTable_CalcDelta_detour = DETOUR_CREATE_STATIC(SendTable_CalcDelta, "SendTable_CalcDelta");

View File

@ -40,7 +40,7 @@
/* Basic information exposed publicly */
#define SMEXT_CONF_NAME "proxysend"
#define SMEXT_CONF_DESCRIPTION "proxysend"
#define SMEXT_CONF_VERSION "0.1.0.6"
#define SMEXT_CONF_VERSION "0.1.0.7"
#define SMEXT_CONF_AUTHOR "Arthurdead"
#define SMEXT_CONF_URL ""
#define SMEXT_CONF_LOGTAG "PROXYSEND"

View File

@ -60,6 +60,21 @@
"library" "engine"
"linux" "@_ZN10PackWork_t7ProcessERS_"
}
"SendProxy_StringT_To_String"
{
"library" "server"
"linux" "@_Z27SendProxy_StringT_To_StringPK8SendPropPKvS3_P8DVariantii"
}
"SendProxy_Color32ToInt"
{
"library" "server"
"linux" "@_Z22SendProxy_Color32ToIntPK8SendPropPKvS3_P8DVariantii"
}
"SendProxy_EHandleToInt"
{
"library" "server"
"linux" "@_Z22SendProxy_EHandleToIntPK8SendPropPKvS3_P8DVariantii"
}
}
}
}