diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 5e712f61..cc61b462 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -16,6 +16,7 @@ #include "sourcemm_api.h" CHalfLife2 g_HL2; +bool g_IsOriginalEngine = false; namespace SourceHook { @@ -69,7 +70,7 @@ CSharedEdictChangeInfo *g_pSharedChangeInfo = NULL; void CHalfLife2::OnSourceModStartup(bool late) { - if (!g_pSharedChangeInfo) + if (!g_IsOriginalEngine && !g_pSharedChangeInfo) { g_pSharedChangeInfo = engine->GetSharedEdictChangeInfo(); } @@ -80,12 +81,6 @@ IChangeInfoAccessor *CBaseEdict::GetChangeAccessor() return engine->GetChangeAccessor( (const edict_t *)this ); } -#if 0 -void CHalfLife2::OnSourceModAllShutdown() -{ -} -#endif - SendProp *UTIL_FindInSendTable(SendTable *pTable, const char *name) { const char *pname; @@ -217,3 +212,18 @@ typedescription_t *CHalfLife2::FindInDataMap(datamap_t *pMap, const char *offset return td; } + +void CHalfLife2::SetEdictStateChanged(edict_t *pEdict, unsigned short offset) +{ + if (!g_IsOriginalEngine) + { + if (offset) + { + pEdict->StateChanged(offset); + } else { + pEdict->StateChanged(); + } + } else { + pEdict->m_fStateFlags |= FL_EDICT_CHANGED; + } +} diff --git a/core/HalfLife2.h b/core/HalfLife2.h index 0f7df3b2..bdf8de22 100644 --- a/core/HalfLife2.h +++ b/core/HalfLife2.h @@ -22,6 +22,7 @@ #include "dt_send.h" #include "server_class.h" #include "datamap.h" +#include "edict.h" using namespace SourceHook; @@ -49,6 +50,7 @@ public: SendProp *FindInSendTable(const char *classname, const char *offset); ServerClass *FindServerClass(const char *classname); typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset); + void SetEdictStateChanged(edict_t *pEdict, unsigned short offset); private: DataTableInfo *_FindServerClass(const char *classname); private: @@ -58,5 +60,6 @@ private: }; extern CHalfLife2 g_HL2; +extern bool g_IsOriginalEngine; #endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_ diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index e4208eda..26311228 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -298,7 +298,7 @@ static cell_t SetEntData(IPluginContext *pContext, const cell_t *params) if (params[5]) { - pEdict->StateChanged(offset); + g_HL2.SetEdictStateChanged(pEdict, offset); } switch (params[4]) @@ -366,7 +366,7 @@ static cell_t SetEntDataFloat(IPluginContext *pContext, const cell_t *params) if (params[4]) { - pEdict->StateChanged(offset); + g_HL2.SetEdictStateChanged(pEdict, offset); } return 1; @@ -427,7 +427,7 @@ static cell_t SetEntDataVector(IPluginContext *pContext, const cell_t *params) if (params[4]) { - pEdict->StateChanged(offset); + g_HL2.SetEdictStateChanged(pEdict, offset); } return 1; @@ -494,7 +494,7 @@ static cell_t SetEntDataEnt(IPluginContext *pContext, const cell_t *params) if (params[4]) { - pEdict->StateChanged(offset); + g_HL2.SetEdictStateChanged(pEdict, offset); } return 1; @@ -509,12 +509,7 @@ static cell_t ChangeEdictState(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Edict %d is invalid", params[1]); } - if (params[2]) - { - pEdict->StateChanged(params[2]); - } else { - pEdict->StateChanged(); - } + g_HL2.SetEdictStateChanged(pEdict, params[2]); return 1; } diff --git a/core/sourcemod.h b/core/sourcemod.h index f7a80ac3..5c282ec5 100644 --- a/core/sourcemod.h +++ b/core/sourcemod.h @@ -116,7 +116,7 @@ private: }; extern SourceModBase g_SourceMod; -extern HandleType_t g_WrBitBufType; -extern HandleType_t g_RdBitBufType; +extern HandleType_t g_WrBitBufType; //:TODO: find a better place for this +extern HandleType_t g_RdBitBufType; //:TODO: find a better place for this #endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_