diff --git a/CS2Fixes.vcxproj b/CS2Fixes.vcxproj index cce164ad..68c44003 100644 --- a/CS2Fixes.vcxproj +++ b/CS2Fixes.vcxproj @@ -198,9 +198,9 @@ - - + + diff --git a/src/adminsystem.cpp b/src/adminsystem.cpp index 7b0b2735..30abe87c 100644 --- a/src/adminsystem.cpp +++ b/src/adminsystem.cpp @@ -28,11 +28,12 @@ #include "ctimer.h" #include "detours.h" #include "utils/entity.h" +#include "entity/cgamerules.h" extern IVEngineServer2 *g_pEngineServer2; extern CEntitySystem *g_pEntitySystem; extern CGlobalVars *gpGlobals; -extern CGameRules *g_pGameRules; +extern CCSGameRules *g_pGameRules; CAdminSystem* g_pAdminSystem = nullptr; diff --git a/src/cs2_sdk/entity/cbaseentity.h b/src/cs2_sdk/entity/cbaseentity.h index 9ecc239d..a9257c28 100644 --- a/src/cs2_sdk/entity/cbaseentity.h +++ b/src/cs2_sdk/entity/cbaseentity.h @@ -21,34 +21,13 @@ #include "../schema.h" #include "ccollisionproperty.h" +#include "globaltypes.h" #include "mathlib/vector.h" #include "ehandle.h" #include "../../gameconfig.h" extern CGameConfig *g_GameConfig; -class CNetworkTransmitComponent -{ -public: - DECLARE_SCHEMA_CLASS_INLINE(CNetworkTransmitComponent) -}; - -class CNetworkOriginCellCoordQuantizedVector -{ -public: - DECLARE_SCHEMA_CLASS_INLINE(CNetworkOriginCellCoordQuantizedVector) - - SCHEMA_FIELD(uint16, m_cellX) - SCHEMA_FIELD(uint16, m_cellY) - SCHEMA_FIELD(uint16, m_cellZ) - SCHEMA_FIELD(uint16, m_nOutsideWorld) - - // These are actually CNetworkedQuantizedFloat but we don't have the definition for it... - SCHEMA_FIELD(float, m_vecX) - SCHEMA_FIELD(float, m_vecY) - SCHEMA_FIELD(float, m_vecZ) -}; - class CGameSceneNode { public: @@ -124,6 +103,7 @@ class Z_CBaseEntity : public CBaseEntity SCHEMA_FIELD_POINTER(CNetworkTransmitComponent, m_NetworkTransmitComponent) SCHEMA_FIELD(int, m_iHealth) SCHEMA_FIELD(int, m_iTeamNum) + SCHEMA_FIELD(Vector, m_vecAbsVelocity) SCHEMA_FIELD(Vector, m_vecBaseVelocity) SCHEMA_FIELD(CCollisionProperty*, m_pCollision) SCHEMA_FIELD(MoveType_t, m_MoveType) diff --git a/src/cs2_sdk/entity/cbasemodelentity.h b/src/cs2_sdk/entity/cbasemodelentity.h index de2e1b4b..28a34e8a 100644 --- a/src/cs2_sdk/entity/cbasemodelentity.h +++ b/src/cs2_sdk/entity/cbasemodelentity.h @@ -20,7 +20,7 @@ #pragma once #include "cbaseentity.h" -#include "cglowproperty.h" +#include "globaltypes.h" class CBaseModelEntity : public Z_CBaseEntity { diff --git a/src/cs2_sdk/entity/ccollisionproperty.h b/src/cs2_sdk/entity/ccollisionproperty.h index 5fa4c43e..040c6e9f 100644 --- a/src/cs2_sdk/entity/ccollisionproperty.h +++ b/src/cs2_sdk/entity/ccollisionproperty.h @@ -19,7 +19,7 @@ #pragma once -#include "../schema.h" +#include "cbaseentity.h" struct VPhysicsCollisionAttribute_t { diff --git a/src/cs2_sdk/entity/ccsweaponbase.h b/src/cs2_sdk/entity/ccsweaponbase.h index f61afd1a..1290a5e8 100644 --- a/src/cs2_sdk/entity/ccsweaponbase.h +++ b/src/cs2_sdk/entity/ccsweaponbase.h @@ -19,7 +19,7 @@ #pragma once -#include "schema.h" +#include "cbaseentity.h" class CEconItemView { diff --git a/src/cs2_sdk/entity/centityidentity.h b/src/cs2_sdk/entity/centityidentity.h deleted file mode 100644 index 992afa32..00000000 --- a/src/cs2_sdk/entity/centityidentity.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * ============================================================================= - * CS2Fixes - * Copyright (C) 2023 Source2ZE - * ============================================================================= - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 3.0, as published by the - * Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#pragma once -#include - -class IHandleEntity; -class CEntityClass; - -class CEntityIdentity -{ -public: - IHandleEntity* m_pInstance; - CEntityClass* m_pClass; - CHandle m_EHandle; -}; \ No newline at end of file diff --git a/src/cs2_sdk/entity/cglowproperty.h b/src/cs2_sdk/entity/cgamerules.h similarity index 61% rename from src/cs2_sdk/entity/cglowproperty.h rename to src/cs2_sdk/entity/cgamerules.h index c6d20d1a..aedbc4ab 100644 --- a/src/cs2_sdk/entity/cglowproperty.h +++ b/src/cs2_sdk/entity/cgamerules.h @@ -18,17 +18,32 @@ */ #pragma once +#include +#include "globaltypes.h" #include "cbaseentity.h" -class CGlowProperty +class CGameRules { public: - DECLARE_SCHEMA_CLASS_INLINE(CGlowProperty) + DECLARE_SCHEMA_CLASS(CGameRules) +}; - SCHEMA_FIELD(Vector, m_fGlowColor) - SCHEMA_FIELD(int, m_iGlowType) - SCHEMA_FIELD(int, m_nGlowRange) - SCHEMA_FIELD(Color, m_glowColorOverride) - SCHEMA_FIELD(bool, m_bFlashing) - SCHEMA_FIELD(bool, m_bGlowing) +class CCSGameRules : public CGameRules +{ +public: + DECLARE_SCHEMA_CLASS(CCSGameRules) + + SCHEMA_FIELD(float, m_fMatchStartTime) + SCHEMA_FIELD(float, m_flGameStartTime) + SCHEMA_FIELD(int, m_totalRoundsPlayed) + SCHEMA_FIELD(GameTime_t, m_fRoundStartTime) + SCHEMA_FIELD(GameTime_t, m_flRestartRoundTime) +}; + +class CCSGameRulesProxy : public Z_CBaseEntity +{ +public: + DECLARE_SCHEMA_CLASS(CCSGameRulesProxy) + + SCHEMA_FIELD(CCSGameRules*, m_pGameRules) }; \ No newline at end of file diff --git a/src/cs2_sdk/entity/globaltypes.h b/src/cs2_sdk/entity/globaltypes.h new file mode 100644 index 00000000..d45ea574 --- /dev/null +++ b/src/cs2_sdk/entity/globaltypes.h @@ -0,0 +1,84 @@ +/** + * ============================================================================= + * CS2Fixes + * Copyright (C) 2023 Source2ZE + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#pragma once +#include +#include "schema.h" + +struct GameTime_t +{ +public: + DECLARE_SCHEMA_CLASS_INLINE(GameTime_t) + + SCHEMA_FIELD(float, m_Value) +}; + +class CNetworkTransmitComponent +{ +public: + DECLARE_SCHEMA_CLASS_INLINE(CNetworkTransmitComponent) +}; + +class CNetworkVelocityVector +{ +public: + DECLARE_SCHEMA_CLASS_INLINE(CNetworkVelocityVector) + + SCHEMA_FIELD(float, m_vecX) + SCHEMA_FIELD(float, m_vecY) + SCHEMA_FIELD(float, m_vecZ) +}; + +class CNetworkOriginCellCoordQuantizedVector +{ +public: + DECLARE_SCHEMA_CLASS_INLINE(CNetworkOriginCellCoordQuantizedVector) + + SCHEMA_FIELD(uint16, m_cellX) + SCHEMA_FIELD(uint16, m_cellY) + SCHEMA_FIELD(uint16, m_cellZ) + SCHEMA_FIELD(uint16, m_nOutsideWorld) + + // These are actually CNetworkedQuantizedFloat but we don't have the definition for it... + SCHEMA_FIELD(float, m_vecX) + SCHEMA_FIELD(float, m_vecY) + SCHEMA_FIELD(float, m_vecZ) +}; + +class CInButtonState +{ +public: + DECLARE_SCHEMA_CLASS_INLINE(CInButtonState) + + // m_pButtonStates[3] + SCHEMA_FIELD_POINTER(uint64_t, m_pButtonStates) +}; + +class CGlowProperty +{ +public: + DECLARE_SCHEMA_CLASS_INLINE(CGlowProperty) + + SCHEMA_FIELD(Vector, m_fGlowColor) + SCHEMA_FIELD(int, m_iGlowType) + SCHEMA_FIELD(int, m_nGlowRange) + SCHEMA_FIELD(Color, m_glowColorOverride) + SCHEMA_FIELD(bool, m_bFlashing) + SCHEMA_FIELD(bool, m_bGlowing) +}; \ No newline at end of file diff --git a/src/cs2_sdk/entity/services.h b/src/cs2_sdk/entity/services.h index 203afb68..5545c375 100644 --- a/src/cs2_sdk/entity/services.h +++ b/src/cs2_sdk/entity/services.h @@ -19,8 +19,7 @@ #pragma once #include - -#include "../schema.h" +#include "globaltypes.h" class CBaseEntity; @@ -53,6 +52,29 @@ class CPlayer_MovementServices { public: DECLARE_SCHEMA_CLASS(CPlayer_MovementServices); + + SCHEMA_FIELD(CInButtonState, m_nButtons) + SCHEMA_FIELD(uint64_t, m_nQueuedButtonDownMask) + SCHEMA_FIELD(uint64_t, m_nQueuedButtonChangeMask) + SCHEMA_FIELD(uint64_t, m_nButtonDoublePressed) + + // m_pButtonPressedCmdNumber[64] + SCHEMA_FIELD_POINTER(uint32_t, m_pButtonPressedCmdNumber) + SCHEMA_FIELD(uint32_t, m_nLastCommandNumberProcessed) + SCHEMA_FIELD(uint64_t, m_nToggleButtonDownMask) + SCHEMA_FIELD(float, m_flMaxspeed) +}; + +class CPlayer_MovementServices_Humanoid : CPlayer_MovementServices +{ +public: + DECLARE_SCHEMA_CLASS(CPlayer_MovementServices_Humanoid); +}; + +class CCSPlayer_MovementServices : CPlayer_MovementServices_Humanoid +{ +public: + DECLARE_SCHEMA_CLASS(CCSPlayer_MovementServices); }; class CCSPlayerController_InGameMoneyServices diff --git a/src/cs2fixes.cpp b/src/cs2fixes.cpp index 4cb1b46f..336b8f50 100644 --- a/src/cs2fixes.cpp +++ b/src/cs2fixes.cpp @@ -46,6 +46,7 @@ #include "eventlistener.h" #include "gameconfig.h" #include "httpmanager.h" +#include "entity/cgamerules.h" #define VPROF_ENABLED #include "tier0/vprof.h" @@ -132,7 +133,7 @@ IVEngineServer2* g_pEngineServer2; CGameConfig *g_GameConfig = nullptr; ISteamHTTP* g_http = nullptr; CSteamGameServerAPIContext g_steamAPI; -CGameRules *g_pGameRules = nullptr; +CCSGameRules *g_pGameRules = nullptr; PLUGIN_EXPOSE(CS2Fixes, g_CS2Fixes); bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late) diff --git a/src/detours.cpp b/src/detours.cpp index 05588d5a..2864ac9a 100644 --- a/src/detours.cpp +++ b/src/detours.cpp @@ -31,6 +31,7 @@ #include "entity/cbasemodelentity.h" #include "entity/ccsweaponbase.h" #include "entity/ctriggerpush.h" +#include "entity/cgamerules.h" #include "playermanager.h" #include "igameevents.h" #include "gameconfig.h" @@ -43,7 +44,7 @@ extern CGlobalVars *gpGlobals; extern CEntitySystem *g_pEntitySystem; extern IGameEventManager2 *g_gameEventManager; -extern CGameRules *g_pGameRules; +extern CCSGameRules *g_pGameRules; DECLARE_DETOUR(Host_Say, Detour_Host_Say); DECLARE_DETOUR(UTIL_SayTextFilter, Detour_UTIL_SayTextFilter); @@ -56,7 +57,7 @@ DECLARE_DETOUR(CGameRules_Constructor, Detour_CGameRules_Constructor); void FASTCALL Detour_CGameRules_Constructor(CGameRules *pThis) { - g_pGameRules = pThis; + g_pGameRules = (CCSGameRules*)pThis; CGameRules_Constructor(pThis); } diff --git a/src/utils/entity.cpp b/src/utils/entity.cpp index cce382e3..37348b47 100644 --- a/src/utils/entity.cpp +++ b/src/utils/entity.cpp @@ -25,12 +25,13 @@ #include "../utils/virtual.h" #include "entitysystem.h" #include "platform.h" +#include "entity/cgamerules.h" #include "tier0/memdbgon.h" extern CEntitySystem *g_pEntitySystem; extern CGameConfig *g_GameConfig; -extern CGameRules *g_pGameRules; +extern CCSGameRules *g_pGameRules; class Z_CBaseEntity; diff --git a/src/utils/entity.h b/src/utils/entity.h index 676c940f..807a3de4 100644 --- a/src/utils/entity.h +++ b/src/utils/entity.h @@ -23,7 +23,6 @@ #include "datamap.h" #include "string_t.h" -class CGameRules; class CEntityInstance; class Z_CBaseEntity; class CBasePlayerController;