Skip to content

Commit

Permalink
Merge pull request #5 from M-archand/main
Browse files Browse the repository at this point in the history
Replace StateChanged signatures
  • Loading branch information
Interesting-exe authored Aug 14, 2024
2 parents 94c14fe + 7475b7f commit af3b436
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
13 changes: 0 additions & 13 deletions gamedata/cs2fixes.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@
"windows" "\x48\x85\xC9\x0F\x84\x2A\x2A\x2A\x2A\x48\x89\x5C\x24\x2A\x55"
"linux" "\x55\x48\x89\xE5\x41\x57\x49\x89\xCF\x41\x56\x49\x89\xD6\x41\x55\x41\x89\xF5\x41\x54\x4C\x8D\xA5\xA0\xFE\xFF\xFF"
}
"NetworkStateChanged"
{
"library" "server"
"windows" "\x4C\x8B\xC9\x48\x8B\x09\x48\x85\xC9\x74\x2A\x48\x8B\x41\x10"
"linux" "\x4C\x8B\x07\x4D\x85\xC0\x74\x2A\x49\x8B\x40\x10"
}
// String : "SV: %d/%s ignored %d FL_FULL_EDICT_CH"
"StateChanged"
{
"library" "server"
"windows" "\x40\x55\x53\x56\x41\x55\x41\x57\x48\x8D\x6C\x24\xB0"
"linux" "\x55\x48\x89\xE5\x41\x57\x41\x56\x41\x55\x41\x54\x53\x89\xD3"
}
// String: "Noise removal", there should be 3 customermachine checks
"HammerNoCustomerMachine"
{
Expand Down
2 changes: 0 additions & 2 deletions src/addresses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ bool addresses::Initialize(CGameConfig *g_GameConfig)
modules::hammer = new CModule(ROOTBIN, "tools/hammer");
#endif

RESOLVE_SIG(g_GameConfig, "NetworkStateChanged", addresses::NetworkStateChanged);
RESOLVE_SIG(g_GameConfig, "StateChanged", addresses::StateChanged);
RESOLVE_SIG(g_GameConfig, "CBasePlayerController_SetPawn", addresses::CBasePlayerController_SetPawn);
RESOLVE_SIG(g_GameConfig, "InitPlayerMovementTraceFilter", addresses::InitPlayerMovementTraceFilter);
RESOLVE_SIG(g_GameConfig, "TracePlayerBBox", addresses::TracePlayerBBox);
Expand Down
2 changes: 0 additions & 2 deletions src/addresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ namespace addresses
{
bool Initialize(CGameConfig *g_GameConfig);

inline void(FASTCALL *NetworkStateChanged)(int64 chainEntity, int64 offset, int64 a3);
inline void(FASTCALL *StateChanged)(void *networkTransmitComponent, CEntityInstance *ent, int64 offset, int16 a4, int16 a5);
inline void(FASTCALL *CBasePlayerController_SetPawn)(CBasePlayerController *pController, CCSPlayerPawn *pPawn, bool a3, bool a4);

// typedef void InitPlayerMovementTraceFilter_t(CTraceFilterPlayerMovementCS &pFilter, CEntityInstance *pHandleEntity, uint64_t interactWith, int collisionGroup);
Expand Down
18 changes: 12 additions & 6 deletions src/cs2_sdk/schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,16 @@ SchemaKey schema::GetOffset(const char* className, uint32_t classKey, const char
return tableMap->Element(memberIndex);
}

void SetStateChanged(Z_CBaseEntity* pEntity, int offset)
void EntityNetworkStateChanged(uintptr_t entityInstance, uint nOffset)
{
addresses::StateChanged(pEntity->m_NetworkTransmitComponent(), pEntity, offset, -1, -1);

pEntity->m_lastNetworkChange = gpGlobals->curtime;
pEntity->m_isSteadyState().ClearAll();
};
reinterpret_cast<CEntityInstance*>(entityInstance)->NetworkStateChanged(nOffset);
}

void ChainNetworkStateChanged(uintptr_t networkVarChainer, uint nLocalOffset)
{
CEntityInstance* pEntity = *reinterpret_cast<CEntityInstance**>(networkVarChainer);
if (pEntity && (pEntity->m_pEntity->m_flags & EF_IS_CONSTRUCTION_IN_PROGRESS) == 0)
{
pEntity->NetworkStateChanged(nLocalOffset, -1, *reinterpret_cast<ChangeAccessorFieldPathIndex_t*>(networkVarChainer + 32));
}
}
8 changes: 4 additions & 4 deletions src/cs2_sdk/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ struct SchemaKey
bool networked;
};

class Z_CBaseEntity;
void SetStateChanged(Z_CBaseEntity* pEntity, int offset);
void EntityNetworkStateChanged(uintptr_t entityInstance, uint nOffset);
void ChainNetworkStateChanged(uintptr_t networkVarChainer, uint nLocalOffset);

constexpr uint32_t val_32_const = 0x811c9dc5;
constexpr uint32_t prime_32_const = 0x1000193;
Expand Down Expand Up @@ -96,15 +96,15 @@ inline constexpr uint64_t hash_64_fnv1a_const(const char *const str, const uint6
if (m_chain != 0 && m_key.networked) \
{ \
DevMsg("Found chain offset %d for %s::%s\n", m_chain, ThisClassName, #varName); \
addresses::NetworkStateChanged((uintptr_t)(pThisClass) + m_chain, m_key.offset + extra_offset, 0xFFFFFFFF); \
ChainNetworkStateChanged((uintptr_t)(pThisClass) + m_chain, m_key.offset + extra_offset); \
} \
else if(m_key.networked) \
{ \
/* WIP: Works fine for most props, but inlined classes in the middle of a class will
need to have their this pointer corrected by the offset .*/ \
DevMsg("Attempting to call SetStateChanged on on %s::%s\n", ThisClassName, #varName); \
if (!IsStruct) \
SetStateChanged((Z_CBaseEntity*)pThisClass, m_key.offset + extra_offset); \
EntityNetworkStateChanged((uintptr_t)pThisClass, m_key.offset + extra_offset); \
else \
CALL_VIRTUAL(void, 1, pThisClass, m_key.offset + extra_offset, 0xFFFFFFFF, 0xFFFF); \
} \
Expand Down

0 comments on commit af3b436

Please sign in to comment.