From c8c2334bcce60bba38f8f499b4ef471d5a81d7ca Mon Sep 17 00:00:00 2001 From: ericek111 Date: Mon, 10 Aug 2026 17:31:33 +0200 Subject: [PATCH] cleaned up some more --- .../CounterStrikeSharp/SendProxyNative.cs | 19 ----- src/detour.cpp | 23 +----- src/detour.h | 2 - src/module.cpp | 2 - src/overrides.h | 2 - src/plugin.cpp | 18 ----- src/schema.cpp | 78 ------------------- src/schema.h | 2 - 8 files changed, 1 insertion(+), 145 deletions(-) diff --git a/examples/CounterStrikeSharp/SendProxyNative.cs b/examples/CounterStrikeSharp/SendProxyNative.cs index 2627bc6..586992f 100644 --- a/examples/CounterStrikeSharp/SendProxyNative.cs +++ b/examples/CounterStrikeSharp/SendProxyNative.cs @@ -14,8 +14,6 @@ public sealed class SendProxyNative : IDisposable private readonly RemoveOverrideDelegate _removeOverride; private readonly ClearOverridesDelegate _clearOverrides; private readonly MarkDirtyDelegate _markDirty; - private readonly DumpSchemaDelegate _dumpSchema; - private readonly DumpEnumDelegate _dumpEnum; public SendProxyNative(string libraryPath) { @@ -25,8 +23,6 @@ public sealed class SendProxyNative : IDisposable _removeOverride = GetExport("SendProxy_RemoveOverride"); _clearOverrides = GetExport("SendProxy_ClearOverrides"); _markDirty = GetExport("SendProxy_MarkDirty"); - _dumpSchema = GetExport("SendProxy_DumpSchema"); - _dumpEnum = GetExport("SendProxy_DumpEnum"); } public static SendProxyNative FromGameDirectory(string gameDirectory) @@ -102,16 +98,6 @@ public sealed class SendProxyNative : IDisposable 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() { NativeLibrary.Free(_library); @@ -139,9 +125,4 @@ public sealed class SendProxyNative : IDisposable [return: MarshalAs(UnmanagedType.I1)] 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); } diff --git a/src/detour.cpp b/src/detour.cpp index 1988ac1..c7a0df7 100644 --- a/src/detour.cpp +++ b/src/detour.cpp @@ -2,14 +2,10 @@ #include "common.h" #include "gameconfig.h" -#include "networksystem/inetworkserializer.h" #include "overrides.h" #include "playerslot.h" -#include - extern CGameConfig* g_gameConfig; -extern bool g_enabled; extern bool g_armed; using SendSnapshotFn = void (*)(void*, void*); @@ -85,7 +81,7 @@ static void Detour_PackEntity(void* self, void* arg1, int entityIndex, void* ent { ++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); return; @@ -191,20 +187,3 @@ void ShutdownSnapshotDetour() g_packEntities = 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(g_snapshotCalls), - static_cast(g_packCalls), - static_cast(g_packEntityCalls), - static_cast(g_packEntityGenericSpoofs), - static_cast(g_fullUpdateWrites), - g_fullUpdateBudget); -} - -void RequestSnapshotFullUpdates(int budget) -{ - if (budget > g_fullUpdateBudget) - g_fullUpdateBudget = budget; -} diff --git a/src/detour.h b/src/detour.h index ad27104..763b98c 100644 --- a/src/detour.h +++ b/src/detour.h @@ -6,5 +6,3 @@ class CGameConfig; bool InitSnapshotDetour(CGameConfig* config); void ShutdownSnapshotDetour(); -void DumpDetourStats(); -void RequestSnapshotFullUpdates(int budget = 512); diff --git a/src/module.cpp b/src/module.cpp index 402e724..638c99f 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -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)) 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 diff --git a/src/overrides.h b/src/overrides.h index da48739..19be33b 100644 --- a/src/overrides.h +++ b/src/overrides.h @@ -52,9 +52,7 @@ public: int AddRuleVectorFirstFromField(int recipientSlot, int entityIndex, const char* className, const char* vectorFieldPath, const char* sourceFieldPath, std::string& error); bool RemoveRule(int id); 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 HasRulesForEntity(int entityIndex) const { return m_rulesByEntity.find(entityIndex) != m_rulesByEntity.end(); } std::vector ApplyForPackedEntity(CPlayerSlot recipient, int entityIndex, void* entityData); void Restore(const std::vector& applied); diff --git a/src/plugin.cpp b/src/plugin.cpp index 0ef10b0..012bf78 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -9,21 +9,17 @@ #include "schema.h" #include "schemasystem/schemasystem.h" #include "interfaces/interfaces.h" -#include "entity2/entityclass.h" #include "entity2/entitysystem.h" #include "tier0/memdbgon.h" SendProxyPlugin g_SendProxy; IVEngineServer2* g_engine = nullptr; -INetworkServerService* g_networkServerService = nullptr; -IServerGameClients* g_gameClients = nullptr; ISchemaSystem* g_schemaSystem = nullptr; IFileSystem* g_fileSystem = nullptr; IGameResourceService* g_gameResourceService = nullptr; CGameConfig* g_gameConfig = nullptr; CGameEntitySystem* g_entitySystem = nullptr; -bool g_enabled = true; bool g_armed = false; void SPMessage(const char* msg, ...) @@ -69,7 +65,6 @@ extern "C" __attribute__((visibility("default"))) int SendProxy_SetOverride(int return 0; } - g_enabled = true; g_armed = true; return id; } @@ -84,7 +79,6 @@ extern "C" __attribute__((visibility("default"))) int SendProxy_SetVectorFirstFr return 0; } - g_enabled = true; g_armed = true; return id; } @@ -111,16 +105,6 @@ extern "C" __attribute__((visibility("default"))) bool SendProxy_MarkDirty(int e 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); 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(); 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_gameResourceService, IGameResourceService, GAMERESOURCESERVICESERVER_INTERFACE_VERSION); GET_V_IFACE_ANY(GetFileSystemFactory, g_fileSystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION); diff --git a/src/schema.cpp b/src/schema.cpp index 5dbde8a..d61e2ce 100644 --- a/src/schema.cpp +++ b/src/schema.cpp @@ -61,39 +61,6 @@ static bool FindFieldRecursive(SchemaClassInfoData_t* info, const char* fieldNam return false; } -static void DumpFieldsRecursive(const char* rootClassName, SchemaClassInfoData_t* info, const char* contains, uint32_t baseOffset, int& printed, std::set& 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 : "", - field.m_pszName, - static_cast(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) { g_schema = system; @@ -135,48 +102,3 @@ SchemaField schema::FindField(const char* className, const char* fieldName) g_cache[key] = 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 visited; - DumpFieldsRecursive(className, info, contains, 0, printed, visited); - SPMessage("%s fields printed=%d filter=%s\n", className, printed, contains && contains[0] ? contains : ""); -} - -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 : "", static_cast(enumerator.m_nValue)); - } -} diff --git a/src/schema.h b/src/schema.h index 55c677f..3fbd3ea 100644 --- a/src/schema.h +++ b/src/schema.h @@ -18,6 +18,4 @@ namespace schema { void Init(ISchemaSystem* system); SchemaField FindField(const char* className, const char* fieldName); - void DumpFields(const char* className, const char* contains); - void DumpEnum(const char* enumName); }