cleaned up some more
This commit is contained in:
@@ -14,8 +14,6 @@ public sealed class SendProxyNative : IDisposable
|
|||||||
private readonly RemoveOverrideDelegate _removeOverride;
|
private readonly RemoveOverrideDelegate _removeOverride;
|
||||||
private readonly ClearOverridesDelegate _clearOverrides;
|
private readonly ClearOverridesDelegate _clearOverrides;
|
||||||
private readonly MarkDirtyDelegate _markDirty;
|
private readonly MarkDirtyDelegate _markDirty;
|
||||||
private readonly DumpSchemaDelegate _dumpSchema;
|
|
||||||
private readonly DumpEnumDelegate _dumpEnum;
|
|
||||||
|
|
||||||
public SendProxyNative(string libraryPath)
|
public SendProxyNative(string libraryPath)
|
||||||
{
|
{
|
||||||
@@ -25,8 +23,6 @@ public sealed class SendProxyNative : IDisposable
|
|||||||
_removeOverride = GetExport<RemoveOverrideDelegate>("SendProxy_RemoveOverride");
|
_removeOverride = GetExport<RemoveOverrideDelegate>("SendProxy_RemoveOverride");
|
||||||
_clearOverrides = GetExport<ClearOverridesDelegate>("SendProxy_ClearOverrides");
|
_clearOverrides = GetExport<ClearOverridesDelegate>("SendProxy_ClearOverrides");
|
||||||
_markDirty = GetExport<MarkDirtyDelegate>("SendProxy_MarkDirty");
|
_markDirty = GetExport<MarkDirtyDelegate>("SendProxy_MarkDirty");
|
||||||
_dumpSchema = GetExport<DumpSchemaDelegate>("SendProxy_DumpSchema");
|
|
||||||
_dumpEnum = GetExport<DumpEnumDelegate>("SendProxy_DumpEnum");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SendProxyNative FromGameDirectory(string gameDirectory)
|
public static SendProxyNative FromGameDirectory(string gameDirectory)
|
||||||
@@ -102,16 +98,6 @@ public sealed class SendProxyNative : IDisposable
|
|||||||
return _markDirty(entityIndex, className, fieldPath);
|
return _markDirty(entityIndex, className, fieldPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DumpSchema(string className, string contains)
|
|
||||||
{
|
|
||||||
_dumpSchema(className, contains);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DumpEnum(string enumName)
|
|
||||||
{
|
|
||||||
_dumpEnum(enumName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
NativeLibrary.Free(_library);
|
NativeLibrary.Free(_library);
|
||||||
@@ -139,9 +125,4 @@ public sealed class SendProxyNative : IDisposable
|
|||||||
[return: MarshalAs(UnmanagedType.I1)]
|
[return: MarshalAs(UnmanagedType.I1)]
|
||||||
private delegate bool MarkDirtyDelegate(int entityIndex, string className, string fieldPath);
|
private delegate bool MarkDirtyDelegate(int entityIndex, string className, string fieldPath);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
||||||
private delegate void DumpSchemaDelegate(string className, string contains);
|
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
||||||
private delegate void DumpEnumDelegate(string enumName);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,10 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "gameconfig.h"
|
#include "gameconfig.h"
|
||||||
#include "networksystem/inetworkserializer.h"
|
|
||||||
#include "overrides.h"
|
#include "overrides.h"
|
||||||
#include "playerslot.h"
|
#include "playerslot.h"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
extern CGameConfig* g_gameConfig;
|
extern CGameConfig* g_gameConfig;
|
||||||
extern bool g_enabled;
|
|
||||||
extern bool g_armed;
|
extern bool g_armed;
|
||||||
|
|
||||||
using SendSnapshotFn = void (*)(void*, void*);
|
using SendSnapshotFn = void (*)(void*, void*);
|
||||||
@@ -85,7 +81,7 @@ static void Detour_PackEntity(void* self, void* arg1, int entityIndex, void* ent
|
|||||||
{
|
{
|
||||||
++g_packEntityCalls;
|
++g_packEntityCalls;
|
||||||
|
|
||||||
if (!g_enabled || !g_armed || !entityData || !g_overrides.HasPackedOverrides())
|
if (!g_armed || !entityData || !g_overrides.HasPackedOverrides())
|
||||||
{
|
{
|
||||||
g_packEntity(self, arg1, entityIndex, entityData, arg4, arg5, arg6, arg7, arg8, arg9);
|
g_packEntity(self, arg1, entityIndex, entityData, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||||
return;
|
return;
|
||||||
@@ -191,20 +187,3 @@ void ShutdownSnapshotDetour()
|
|||||||
g_packEntities = nullptr;
|
g_packEntities = nullptr;
|
||||||
g_packEntity = nullptr;
|
g_packEntity = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpDetourStats()
|
|
||||||
{
|
|
||||||
SPMessage("hooks: snapshot calls=%llu; pack calls=%llu; pack_entity calls=%llu generic_spoofs=%llu; fullupdate writes=%llu budget=%d\n",
|
|
||||||
static_cast<unsigned long long>(g_snapshotCalls),
|
|
||||||
static_cast<unsigned long long>(g_packCalls),
|
|
||||||
static_cast<unsigned long long>(g_packEntityCalls),
|
|
||||||
static_cast<unsigned long long>(g_packEntityGenericSpoofs),
|
|
||||||
static_cast<unsigned long long>(g_fullUpdateWrites),
|
|
||||||
g_fullUpdateBudget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RequestSnapshotFullUpdates(int budget)
|
|
||||||
{
|
|
||||||
if (budget > g_fullUpdateBudget)
|
|
||||||
g_fullUpdateBudget = budget;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,5 +6,3 @@ class CGameConfig;
|
|||||||
|
|
||||||
bool InitSnapshotDetour(CGameConfig* config);
|
bool InitSnapshotDetour(CGameConfig* config);
|
||||||
void ShutdownSnapshotDetour();
|
void ShutdownSnapshotDetour();
|
||||||
void DumpDetourStats();
|
|
||||||
void RequestSnapshotFullUpdates(int budget = 512);
|
|
||||||
|
|||||||
@@ -80,8 +80,6 @@ CModule::CModule(const char* relativePath, const char* module) : m_name(module)
|
|||||||
|
|
||||||
if (!GetModuleInformation(m_handle, &m_base, &m_size, m_sections))
|
if (!GetModuleInformation(m_handle, &m_base, &m_size, m_sections))
|
||||||
Error("[SendProxy] Could not inspect %s\n", path);
|
Error("[SendProxy] Could not inspect %s\n", path);
|
||||||
|
|
||||||
SPMessage("module %s base=%p size=%zu\n", module, m_base, m_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* CModule::FindSignature(const uint8_t* pattern, size_t length, int& error) const
|
void* CModule::FindSignature(const uint8_t* pattern, size_t length, int& error) const
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ public:
|
|||||||
int AddRuleVectorFirstFromField(int recipientSlot, int entityIndex, const char* className, const char* vectorFieldPath, const char* sourceFieldPath, std::string& error);
|
int AddRuleVectorFirstFromField(int recipientSlot, int entityIndex, const char* className, const char* vectorFieldPath, const char* sourceFieldPath, std::string& error);
|
||||||
bool RemoveRule(int id);
|
bool RemoveRule(int id);
|
||||||
bool MarkEntityFieldDirty(int entityIndex, const char* className, const char* fieldPath, std::string& error);
|
bool MarkEntityFieldDirty(int entityIndex, const char* className, const char* fieldPath, std::string& error);
|
||||||
bool Empty() const { return m_rules.empty(); }
|
|
||||||
bool HasPackedOverrides() const { return !m_rulesByEntity.empty(); }
|
bool HasPackedOverrides() const { return !m_rulesByEntity.empty(); }
|
||||||
bool HasRulesForEntity(int entityIndex) const { return m_rulesByEntity.find(entityIndex) != m_rulesByEntity.end(); }
|
|
||||||
|
|
||||||
std::vector<AppliedOverride> ApplyForPackedEntity(CPlayerSlot recipient, int entityIndex, void* entityData);
|
std::vector<AppliedOverride> ApplyForPackedEntity(CPlayerSlot recipient, int entityIndex, void* entityData);
|
||||||
void Restore(const std::vector<AppliedOverride>& applied);
|
void Restore(const std::vector<AppliedOverride>& applied);
|
||||||
|
|||||||
@@ -9,21 +9,17 @@
|
|||||||
#include "schema.h"
|
#include "schema.h"
|
||||||
#include "schemasystem/schemasystem.h"
|
#include "schemasystem/schemasystem.h"
|
||||||
#include "interfaces/interfaces.h"
|
#include "interfaces/interfaces.h"
|
||||||
#include "entity2/entityclass.h"
|
|
||||||
#include "entity2/entitysystem.h"
|
#include "entity2/entitysystem.h"
|
||||||
|
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
SendProxyPlugin g_SendProxy;
|
SendProxyPlugin g_SendProxy;
|
||||||
IVEngineServer2* g_engine = nullptr;
|
IVEngineServer2* g_engine = nullptr;
|
||||||
INetworkServerService* g_networkServerService = nullptr;
|
|
||||||
IServerGameClients* g_gameClients = nullptr;
|
|
||||||
ISchemaSystem* g_schemaSystem = nullptr;
|
ISchemaSystem* g_schemaSystem = nullptr;
|
||||||
IFileSystem* g_fileSystem = nullptr;
|
IFileSystem* g_fileSystem = nullptr;
|
||||||
IGameResourceService* g_gameResourceService = nullptr;
|
IGameResourceService* g_gameResourceService = nullptr;
|
||||||
CGameConfig* g_gameConfig = nullptr;
|
CGameConfig* g_gameConfig = nullptr;
|
||||||
CGameEntitySystem* g_entitySystem = nullptr;
|
CGameEntitySystem* g_entitySystem = nullptr;
|
||||||
bool g_enabled = true;
|
|
||||||
bool g_armed = false;
|
bool g_armed = false;
|
||||||
|
|
||||||
void SPMessage(const char* msg, ...)
|
void SPMessage(const char* msg, ...)
|
||||||
@@ -69,7 +65,6 @@ extern "C" __attribute__((visibility("default"))) int SendProxy_SetOverride(int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_enabled = true;
|
|
||||||
g_armed = true;
|
g_armed = true;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -84,7 +79,6 @@ extern "C" __attribute__((visibility("default"))) int SendProxy_SetVectorFirstFr
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_enabled = true;
|
|
||||||
g_armed = true;
|
g_armed = true;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -111,16 +105,6 @@ extern "C" __attribute__((visibility("default"))) bool SendProxy_MarkDirty(int e
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" __attribute__((visibility("default"))) void SendProxy_DumpSchema(const char* className, const char* contains)
|
|
||||||
{
|
|
||||||
schema::DumpFields(className, contains);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __attribute__((visibility("default"))) void SendProxy_DumpEnum(const char* enumName)
|
|
||||||
{
|
|
||||||
schema::DumpEnum(enumName);
|
|
||||||
}
|
|
||||||
|
|
||||||
PLUGIN_EXPOSE(SendProxyPlugin, g_SendProxy);
|
PLUGIN_EXPOSE(SendProxyPlugin, g_SendProxy);
|
||||||
|
|
||||||
bool SendProxyPlugin::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool late)
|
bool SendProxyPlugin::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool late)
|
||||||
@@ -128,8 +112,6 @@ bool SendProxyPlugin::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxle
|
|||||||
PLUGIN_SAVEVARS();
|
PLUGIN_SAVEVARS();
|
||||||
|
|
||||||
GET_V_IFACE_CURRENT(GetEngineFactory, g_engine, IVEngineServer2, SOURCE2ENGINETOSERVER_INTERFACE_VERSION);
|
GET_V_IFACE_CURRENT(GetEngineFactory, g_engine, IVEngineServer2, SOURCE2ENGINETOSERVER_INTERFACE_VERSION);
|
||||||
GET_V_IFACE_ANY(GetEngineFactory, g_networkServerService, INetworkServerService, NETWORKSERVERSERVICE_INTERFACE_VERSION);
|
|
||||||
GET_V_IFACE_ANY(GetServerFactory, g_gameClients, IServerGameClients, SOURCE2GAMECLIENTS_INTERFACE_VERSION);
|
|
||||||
GET_V_IFACE_CURRENT(GetEngineFactory, g_schemaSystem, ISchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
|
GET_V_IFACE_CURRENT(GetEngineFactory, g_schemaSystem, ISchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
|
||||||
GET_V_IFACE_CURRENT(GetEngineFactory, g_gameResourceService, IGameResourceService, GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
|
GET_V_IFACE_CURRENT(GetEngineFactory, g_gameResourceService, IGameResourceService, GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
|
||||||
GET_V_IFACE_ANY(GetFileSystemFactory, g_fileSystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION);
|
GET_V_IFACE_ANY(GetFileSystemFactory, g_fileSystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION);
|
||||||
|
|||||||
@@ -61,39 +61,6 @@ static bool FindFieldRecursive(SchemaClassInfoData_t* info, const char* fieldNam
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DumpFieldsRecursive(const char* rootClassName, SchemaClassInfoData_t* info, const char* contains, uint32_t baseOffset, int& printed, std::set<const SchemaClassInfoData_t*>& visited)
|
|
||||||
{
|
|
||||||
if (!info || visited.find(info) != visited.end())
|
|
||||||
return;
|
|
||||||
visited.insert(info);
|
|
||||||
|
|
||||||
for (int i = 0; i < info->m_nFieldCount; ++i)
|
|
||||||
{
|
|
||||||
const auto& field = info->m_pFields[i];
|
|
||||||
if (contains && contains[0] && !V_stristr(field.m_pszName, contains))
|
|
||||||
continue;
|
|
||||||
const char* typeName = field.m_pType ? field.m_pType->m_sTypeName.String() : "";
|
|
||||||
int size = 0;
|
|
||||||
uint8 alignment = 0;
|
|
||||||
if (field.m_pType)
|
|
||||||
field.m_pType->GetSizeAndAlignment(size, alignment);
|
|
||||||
SPMessage("%s/%s::%s offset=%d size=%d type=%s networked=%d\n",
|
|
||||||
rootClassName,
|
|
||||||
info->m_pszName ? info->m_pszName : "<unknown>",
|
|
||||||
field.m_pszName,
|
|
||||||
static_cast<int>(baseOffset + field.m_nSingleInheritanceOffset),
|
|
||||||
size,
|
|
||||||
typeName ? typeName : "",
|
|
||||||
IsNetworked(field) ? 1 : 0);
|
|
||||||
++printed;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < info->m_nBaseClassCount; ++i)
|
|
||||||
{
|
|
||||||
DumpFieldsRecursive(rootClassName, info->m_pBaseClasses[i].m_pClass, contains, baseOffset + info->m_pBaseClasses[i].m_nOffset, printed, visited);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void schema::Init(ISchemaSystem* system)
|
void schema::Init(ISchemaSystem* system)
|
||||||
{
|
{
|
||||||
g_schema = system;
|
g_schema = system;
|
||||||
@@ -135,48 +102,3 @@ SchemaField schema::FindField(const char* className, const char* fieldName)
|
|||||||
g_cache[key] = result;
|
g_cache[key] = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void schema::DumpFields(const char* className, const char* contains)
|
|
||||||
{
|
|
||||||
auto* typeScope = g_schema ? g_schema->FindTypeScopeForModule("libserver.so") : nullptr;
|
|
||||||
if (!typeScope)
|
|
||||||
{
|
|
||||||
SPWarning("schema type scope for libserver.so is unavailable\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SchemaClassInfoData_t* info = typeScope->FindDeclaredClass(className).Get();
|
|
||||||
if (!info)
|
|
||||||
{
|
|
||||||
SPWarning("schema class %s not found\n", className);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int printed = 0;
|
|
||||||
std::set<const SchemaClassInfoData_t*> visited;
|
|
||||||
DumpFieldsRecursive(className, info, contains, 0, printed, visited);
|
|
||||||
SPMessage("%s fields printed=%d filter=%s\n", className, printed, contains && contains[0] ? contains : "<none>");
|
|
||||||
}
|
|
||||||
|
|
||||||
void schema::DumpEnum(const char* enumName)
|
|
||||||
{
|
|
||||||
auto* typeScope = g_schema ? g_schema->FindTypeScopeForModule("libserver.so") : nullptr;
|
|
||||||
if (!typeScope)
|
|
||||||
{
|
|
||||||
SPWarning("schema type scope for libserver.so is unavailable\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* info = typeScope->FindDeclaredEnum(enumName).Get();
|
|
||||||
if (!info)
|
|
||||||
{
|
|
||||||
SPWarning("schema enum %s not found\n", enumName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < info->m_nEnumeratorCount; ++i)
|
|
||||||
{
|
|
||||||
const auto& enumerator = info->m_pEnumerators[i];
|
|
||||||
SPMessage("%s::%s = %lld\n", enumName, enumerator.m_pszName ? enumerator.m_pszName : "<unknown>", static_cast<long long>(enumerator.m_nValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,6 +18,4 @@ namespace schema
|
|||||||
{
|
{
|
||||||
void Init(ISchemaSystem* system);
|
void Init(ISchemaSystem* system);
|
||||||
SchemaField FindField(const char* className, const char* fieldName);
|
SchemaField FindField(const char* className, const char* fieldName);
|
||||||
void DumpFields(const char* className, const char* contains);
|
|
||||||
void DumpEnum(const char* enumName);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user