From a4cb9f5fec2fee68817a828a62919c3d291b777f Mon Sep 17 00:00:00 2001 From: arthurdead Date: Sun, 5 Mar 2023 02:42:08 -0300 Subject: [PATCH] i merged the pr wrong --- extension.cpp | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/extension.cpp b/extension.cpp index b04a28a..6a9340d 100644 --- a/extension.cpp +++ b/extension.cpp @@ -762,13 +762,13 @@ private: pack_entity_params_t &operator=(pack_entity_params_t &&) = delete; }; -static thread_var in_compute_packs; -static thread_var do_calc_delta; -static thread_var do_writedelta_entities; -static thread_var writedeltaentities_client; -static thread_var sendproxy_client_slot; +static thread_var in_compute_packs{}; +static thread_var do_calc_delta{}; +static thread_var do_writedelta_entities{}; +static thread_var writedeltaentities_client{}; +static thread_var sendproxy_client_slot{}; -static std::unique_ptr packentity_params; +static std::unique_ptr packentity_params{}; static void Host_Error(const char *error, ...) noexcept { @@ -1395,7 +1395,7 @@ DETOUR_DECL_STATIC6(SendTable_Encode, bool, const SendTable *, pTable, const voi const std::vector &entities{packentity_params->entities}; if(std::find(entities.cbegin(), entities.cend(), ref) != entities.cend()) { const std::size_t slots_size{packentity_params->slots.size()}; - for(int i{0}; i < slots_size; ++i) { + for(std::size_t i{0}; i < slots_size; ++i) { std::vector &vec{packentity_params->entity_data[i]}; vec.emplace_back(); packed_entity_data_t &packedData{vec.back()}; @@ -1429,14 +1429,14 @@ DETOUR_DECL_STATIC8(SendTable_CalcDelta, int, const SendTable *, pTable, const v int total_nChanges{global_nChanges}; if(total_nChanges < nMaxDeltaProps) { - int *client_deltaProps{new int[nMaxDeltaProps]}; + int *client_deltaProps{new int[nMaxDeltaProps]{}}; int new_nChanges{total_nChanges}; unsigned long ref = ::IndexToReference(objectID); const std::size_t slots_size{packentity_params->slots.size()}; - for(int i{0}; i < slots_size; ++i) { + for(std::size_t i{0}; i < slots_size; ++i) { using entity_data_t = std::vector; entity_data_t &entity_data{packentity_params->entity_data[i]}; @@ -1540,7 +1540,7 @@ DETOUR_DECL_MEMBER2(CFrameSnapshotManager_GetPackedEntity, PackedEntity *, CFram const packed_entity_data_t *packedData{nullptr}; const std::size_t slots_size{packentity_params->slots.size()}; - for(int i{0}; i < slots_size; ++i) { + for(std::size_t i{0}; i < slots_size; ++i) { if(packentity_params->slots[i] == slot) { const std::vector &entity_data{packentity_params->entity_data[i]}; for(const packed_entity_data_t &it : entity_data) { @@ -1834,7 +1834,29 @@ static void game_frame(bool simulating) noexcept return; } - + // dumb nonsense so clients are fully aware that our hooked edicts are changing. + // this looks hacky, and it is, but there is not a better way i could find + // after tearing my hair out for 3 days of research + // sappho.io + for (auto& hook : hooks) + { + unsigned long ref = hook.first; // hook.second.ref; + //for (auto& cb : hook.second.callbacks) + //{ + // cb.second.change_edict_state(); + //} + CBaseEntity* pEntity = ::ReferenceToEntity(ref); + if (!pEntity) + { + continue; + } + edict_t* edict = pEntity->GetNetworkable()->GetEdict(); + if (!edict) + { + continue; + } + gamehelpers->SetEdictStateChanged(edict, 0); + } } DETOUR_DECL_MEMBER1(CGameServer_SendClientMessages, void, bool, bSendSnapshots)