Skip to content

Commit

Permalink
Add gamerules header and cleanup some headers
Browse files Browse the repository at this point in the history
Also use CCSGameRules
  • Loading branch information
xen-000 committed Oct 28, 2023
1 parent 7b7b8c8 commit 47be731
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 75 deletions.
4 changes: 2 additions & 2 deletions CS2Fixes.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@
<ClInclude Include="src\cs2_sdk\entity\ccollisionproperty.h" />
<ClInclude Include="src\cs2_sdk\entity\ccsplayercontroller.h" />
<ClInclude Include="src\cs2_sdk\entity\ccsplayerpawn.h" />
<ClInclude Include="src\cs2_sdk\entity\centityidentity.h" />
<ClInclude Include="src\cs2_sdk\entity\cglowproperty.h" />
<ClInclude Include="src\cs2_sdk\entity\ccsweaponbase.h" />
<ClInclude Include="src\cs2_sdk\entity\cgamerules.h" />
<ClInclude Include="src\cs2_sdk\entity\globaltypes.h" />
<ClInclude Include="src\cs2_sdk\entity\services.h" />
<ClInclude Include="src\cs2_sdk\interfaces\cgameresourceserviceserver.h" />
<ClInclude Include="src\cs2_sdk\interfaces\cschemasystem.h" />
Expand Down
3 changes: 2 additions & 1 deletion src/adminsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
24 changes: 2 additions & 22 deletions src/cs2_sdk/entity/cbaseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/cs2_sdk/entity/cbasemodelentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#pragma once

#include "cbaseentity.h"
#include "cglowproperty.h"
#include "globaltypes.h"

class CBaseModelEntity : public Z_CBaseEntity
{
Expand Down
2 changes: 1 addition & 1 deletion src/cs2_sdk/entity/ccollisionproperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

#include "../schema.h"
#include "cbaseentity.h"

struct VPhysicsCollisionAttribute_t
{
Expand Down
2 changes: 1 addition & 1 deletion src/cs2_sdk/entity/ccsweaponbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

#include "schema.h"
#include "cbaseentity.h"

class CEconItemView
{
Expand Down
32 changes: 0 additions & 32 deletions src/cs2_sdk/entity/centityidentity.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,32 @@
*/

#pragma once
#include <platform.h>
#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)
};
84 changes: 84 additions & 0 deletions src/cs2_sdk/entity/globaltypes.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

#pragma once
#include <platform.h>
#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)
};
26 changes: 24 additions & 2 deletions src/cs2_sdk/entity/services.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

#pragma once
#include <platform.h>

#include "../schema.h"
#include "globaltypes.h"

class CBaseEntity;

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/cs2fixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "eventlistener.h"
#include "gameconfig.h"
#include "httpmanager.h"
#include "entity/cgamerules.h"

#define VPROF_ENABLED
#include "tier0/vprof.h"
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
Expand All @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/utils/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "datamap.h"
#include "string_t.h"

class CGameRules;
class CEntityInstance;
class Z_CBaseEntity;
class CBasePlayerController;
Expand Down

0 comments on commit 47be731

Please sign in to comment.