Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
update sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
huoji120 committed Oct 8, 2023
1 parent e5f2541 commit 4bfd7fb
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 49 deletions.
8 changes: 4 additions & 4 deletions csgo2/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ auto OnPlayerHurtEvent(IGameEvent* event) -> void {
*/
UnkGameEventStruct_t userIdNameParams{"userid"};
UnkGameEventStruct_t attackerNameParams{"attacker"};
UnkGameEventStruct_t healthNameParams{"health"};
UnkGameEventStruct_t healthNameParams{0};
UnkGameEventStruct_t armorNameParams{0};
UnkGameEventStruct_t weaponNameParams{0};
UnkGameEventStruct_t dmg_healthNameParams{0};
Expand All @@ -23,9 +23,9 @@ auto OnPlayerHurtEvent(IGameEvent* event) -> void {
static const auto dmg_armorStr = "dmg_armor";
static const auto hitgroupStr = "hitgroup";

// healthNameParams.m_Unk = Offset::FnServerHashFunction(
// healthStr, sizeof healthStr, SERVER_HASH_FUCNTION_KEY);
// healthNameParams.m_Key = healthStr;
healthNameParams.m_Unk = Offset::FnServerHashFunction(
healthStr, sizeof healthStr, SERVER_HASH_FUCNTION_KEY);
healthNameParams.m_Key = healthStr;

armorNameParams.m_Unk = Offset::FnServerHashFunction(
armorStr, sizeof armorStr, SERVER_HASH_FUCNTION_KEY);
Expand Down
3 changes: 1 addition & 2 deletions csgo2/native_sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t* tableMap,

for (int i = 0; i < fieldsSize; ++i) {
SchemaClassFieldData_t& field = pFields[i];
// LOG("%s::%s found at -> 0x%X - %llx\n", className, field.m_name,
// field.m_offset, &field);
LOG("%s::%s found at -> 0x%X - %llx\n", className, field.m_name, field.m_offset, &field);

keyValueMap->Insert(hash_32_fnv1a_const(field.m_name),
{field.m_offset, IsFieldNetworked(field)});
Expand Down
20 changes: 10 additions & 10 deletions csgo2/native_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extern auto SetStateChanged(Z_CBaseEntity* pEntity, int offset) -> void;
static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
\
static const auto m_key = \
schema::GetOffset(ThisClass, datatable_hash, #varName, prop_hash); \
schema::GetOffset(datatableName, datatable_hash, #varName, prop_hash); \
\
return *reinterpret_cast<std::add_pointer_t<type>>( \
(uintptr_t)(this) + m_key.offset + extra_offset); \
Expand All @@ -96,7 +96,7 @@ extern auto SetStateChanged(Z_CBaseEntity* pEntity, int offset) -> void;
static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
\
static const auto m_key = \
schema::GetOffset(ThisClass, datatable_hash, #varName, prop_hash); \
schema::GetOffset(datatableName, datatable_hash, #varName, prop_hash); \
\
static const auto m_chain = schema::FindChainOffset(ThisClass); \
\
Expand All @@ -111,7 +111,7 @@ extern auto SetStateChanged(Z_CBaseEntity* pEntity, int offset) -> void;
middle of a class will need to have their this pointer \
corrected by the offset .*/ \
LOG("Attempting to call SetStateChanged on on %s::%s\n", \
ThisClass, #varName); \
datatableName, #varName); \
if (!OffsetIsStruct) \
SetStateChanged((Z_CBaseEntity*)this, \
m_key.offset + extra_offset); \
Expand Down Expand Up @@ -380,13 +380,7 @@ class CGlowProperty {
SCHEMA_FIELD(bool, m_bFlashing)
SCHEMA_FIELD(bool, m_bGlowing)
};
class CBaseModelEntity {
public:
DECLARE_CLASS(CBaseModelEntity);

SCHEMA_FIELD(CCollisionProperty, m_Collision)
SCHEMA_FIELD(CGlowProperty, m_Glow)
};
class CBaseEntity : public CEntityInstance {
public:
DECLARE_CLASS(CBaseEntity);
Expand All @@ -396,11 +390,17 @@ class CBaseEntity : public CEntityInstance {
// SCHEMA_FIELD(Vector, m_vecBaseVelocity)
SCHEMA_FIELD(CCollisionProperty*, m_pCollision)
SCHEMA_FIELD(Vector, m_vecBaseVelocity)
SCHEMA_FIELD_EX(CGlowProperty, "CBaseModelEntity", m_Glow);
//SCHEMA_FIELD_EX(CGlowProperty, "CBaseModelEntity", m_Glow);
auto IsBasePlayerController() -> bool;
auto SpawnClientEntity() -> void;
};
class CBaseModelEntity : public CBaseEntity {
public:
DECLARE_CLASS(CBaseModelEntity);

SCHEMA_FIELD(CCollisionProperty, m_Collision)
SCHEMA_FIELD(CGlowProperty, m_Glow)
};
class CBasePlayerController : public CBaseEntity {
public:
DECLARE_CLASS(CBasePlayerController);
Expand Down
24 changes: 18 additions & 6 deletions csgo2/script_apis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ auto luaApi_SetPlayerGlowColor(lua_State* luaVm) -> int {
const auto b = lua_tonumber(luaVm, 4);
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
playerController->m_hPawn()
.Get<CCSPlayerPawn>()
.Get<CBaseModelEntity>()
->m_Glow()
.m_glowColorOverride(Color(r, g, b, 230));
});
Expand All @@ -672,14 +672,24 @@ auto luaApi_SetPlayerGlowEnable(lua_State* luaVm) -> int {
const auto playerIndex = lua_tointeger(luaVm, 1);
const auto isEnable = lua_toboolean(luaVm, 2);
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
playerController->m_hPawn().Get<CCSPlayerPawn>()->m_Glow().m_bGlowing(
LOG("glow set %d to %d \n", playerController->m_hPawn().Get<CBaseModelEntity>()->m_Glow().m_bGlowing(), isEnable);
playerController->m_hPawn().Get<CBaseModelEntity>()->m_Glow().m_bGlowing(
isEnable);
playerController->m_hPawn().Get<CCSPlayerPawn>()->m_Glow().m_iGlowType(
3);
playerController->m_hPawn().Get<CBaseModelEntity>()->m_Glow().m_iGlowType(3);
playerController->m_hPawn()
.Get<CBaseModelEntity>()
->m_Glow()
.m_glowColorOverride(Color(201, 0, 118, 230));
});
lua_pop(luaVm, 2);
return 0;
}
auto luaApi_RunServerCommand(lua_State* luaVm) -> int {
const auto command = lua_tostring(luaVm, 1);
Offset::InterFaces::IVEngineServer->ServerCommand(command);
lua_pop(luaVm, 1);
return 0;
}
auto luaApi_GetAllPlayerIndex(lua_State* luaVm) -> int {
// param: playerIndex:int, style:int
lua_newtable(luaVm);
Expand All @@ -693,17 +703,18 @@ auto luaApi_GetAllPlayerIndex(lua_State* luaVm) -> int {
auto player = EntitySystem->GetBaseEntity(i);

if (player == nullptr) {
break;
continue;
}
if (player->IsBasePlayerController() == false) {
break;
continue;
}
lua_pushinteger(luaVm, player->GetRefEHandle().GetEntryIndex());
lua_rawseti(luaVm, -2, index++);
}
} while (false);
return 1;
}

auto initFunciton(lua_State* luaVm) -> void {
lua_register(luaVm, "ListenToGameEvent", luaApi_ListenToGameEvent);
lua_register(luaVm, "luaApi_SetPlayerCurrentWeaponAmmo",
Expand Down Expand Up @@ -745,6 +756,7 @@ auto initFunciton(lua_State* luaVm) -> void {
luaApi_SetPlayerGlowEnable);
lua_register(luaVm, "luaApi_SetPlayerGlowColor", luaApi_SetPlayerGlowColor);
lua_register(luaVm, "luaApi_GetAllPlayerIndex", luaApi_GetAllPlayerIndex);
lua_register(luaVm, "luaApi_RunServerCommand", luaApi_RunServerCommand);

luabridge::getGlobalNamespace(luaVm)
.beginClass<_luaApi_WeaponInfo>("WeaponInfo")
Expand Down
4 changes: 2 additions & 2 deletions csgo2/sdk/gameevent/IGameEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class IGameEvent {
bool defaultValue = false) = 0;
virtual int GetInt(UnkGameEventStruct_t* keyName = NULL,
int defaultValue = 0) = 0;
virtual uint64_t GetUint64(const char* keyName = NULL,
virtual uint64_t GetUint64(UnkGameEventStruct_t* keyName = NULL,
uint64_t defaultValue = 0) = 0;
virtual float GetFloat(const char* keyName = NULL,
virtual float GetFloat(UnkGameEventStruct_t* keyName = NULL,
float defaultValue = 0.0f) = 0;
virtual const char* GetString(UnkGameEventStruct_t* keyName = NULL,
const char* defaultValue = "") = 0;
Expand Down
64 changes: 39 additions & 25 deletions csgo2/sdk/public/eiface.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ class ISource2Server : public IAppSystem

virtual void ServerConVarChanged(const char* pVarName, const char* pValue) = 0;
};

//-----------------------------------------------------------------------------
// Purpose: Interface the engine exposes to the game DLL
//-----------------------------------------------------------------------------
Expand All @@ -326,6 +327,7 @@ class IVEngineServer2 : public ISource2Engine
virtual void unk003() = 0;
virtual void unk004() = 0;
virtual void unk005() = 0;
virtual void unk006() = 0;


// Tell engine to change level ( "changelevel s1\n" or "changelevel2 s1 s2\n" )
Expand Down Expand Up @@ -417,7 +419,7 @@ class IVEngineServer2 : public ISource2Engine

virtual void SetTimescale(float flTimescale) = 0;

virtual uint32_t GetAppID() = 0;
virtual uint32 GetAppID() = 0;

// Returns the SteamID of the specified player. It'll be NULL if the player hasn't authenticated yet.
virtual const CSteamID* GetClientSteamID(CPlayerSlot clientIndex) = 0;
Expand Down Expand Up @@ -451,7 +453,7 @@ class IVEngineServer2 : public ISource2Engine
virtual bool GetPlayerInfo(CPlayerSlot clientIndex, google::protobuf::Message& info) = 0;

// Returns the XUID of the specified player. It'll be NULL if the player hasn't connected yet.
virtual uint64_t GetClientXUID(CPlayerSlot clientIndex) = 0;
virtual uint64 GetClientXUID(CPlayerSlot clientIndex) = 0;

virtual void* GetPVSForSpawnGroup(SpawnGroupHandle_t spawnGroup) = 0;
virtual SpawnGroupHandle_t FindSpawnGroupByName(const char* szName) = 0;
Expand All @@ -463,45 +465,57 @@ class IVEngineServer2 : public ISource2Engine

virtual bool IsClientLowViolence(CEntityIndex clientIndex) = 0;

#if 0 // Don't really match the binary
// Kicks the slot with the specified NetworkDisconnectionReason
virtual void DisconnectClient(CEntityIndex clientIndex, /* ENetworkDisconnectionReason */ int reason) = 0;

#if 0 // Don't really match the binary
virtual void GetAllSpawnGroupsWithPVS(CUtlVector<SpawnGroupHandle_t>* spawnGroups, CUtlVector<IPVS*>* pOut) = 0;

virtual void P2PGroupChanged() = 0;
#endif

virtual void unk006() = 0;
virtual void unk007() = 0;
virtual void unk008() = 0;
virtual void unk009() = 0;
virtual void unk010() = 0;
virtual void unk011() = 0;
virtual void unk012() = 0;
virtual void unk013() = 0;
virtual void unk101() = 0;
virtual void unk102() = 0;
virtual void unk103() = 0;
virtual void unk104() = 0;
virtual void unk105() = 0;
virtual void unk106() = 0;
virtual void unk107() = 0;

virtual void OnKickClient(const CCommandContext& context, const CCommand& cmd) = 0;

// Kicks the slot with the specified NetworkDisconnectionReason.
// Kicks and bans the slot.
// Note that the internal reason is never displayed to the user.
// ENetworkDisconnectionReason reason is ignored, client is always kicked with ENetworkDisconnectionReason::NETWORK_DISCONNECT_KICKBANADDED
//
// AM TODO: add header ref for ENetworkDisconnectReason from proto header
virtual void KickClient(CPlayerSlot slot, const char* szInternalReason, /*ENetworkDisconnectionReason*/ char reason) = 0;

virtual void unk015() = 0;
virtual void unk016() = 0;
virtual void unk017() = 0;
virtual void unk018() = 0;
virtual void unk019() = 0;
virtual void unk020() = 0;
virtual void unk021() = 0;
virtual void unk022() = 0;
virtual void unk023() = 0;
virtual void BanClient(CPlayerSlot slot, const char* szInternalReason, /*ENetworkDisconnectionReason*/ char reason) = 0;

virtual void unk200() = 0;
virtual void unk201() = 0;
virtual void unk202() = 0;
virtual void unk203() = 0;
virtual void unk204() = 0;
virtual void unk205() = 0;
virtual void unk206() = 0;
virtual void unk207() = 0;
virtual void unk208() = 0;

virtual void SetClientUpdateRate(CEntityIndex clientIndex, float flUpdateRate) = 0;

virtual void unk024() = 0;
virtual void unk025() = 0;
virtual void unk300() = 0;
virtual void unk301() = 0;
};

class IServerGCLobby
{
public:
virtual bool HasLobby() const = 0;
virtual bool SteamIDAllowedToConnect(const CSteamID& steamId) const = 0;
virtual void UpdateServerDetails(void) = 0;
virtual bool ShouldHibernate() = 0;
virtual bool SteamIDAllowedToP2PConnect(const CSteamID& steamId) const = 0;
virtual bool LobbyAllowsCheats(void) const = 0;
};
//-----------------------------------------------------------------------------
// Purpose: Player / Client related functions
Expand Down

0 comments on commit 4bfd7fb

Please sign in to comment.