diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..4c5c3574
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,148 @@
+# for more, see: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+
+Language: Cpp
+
+AccessModifierOffset: -4
+
+AlignAfterOpenBracket: Align
+
+AlignArrayOfStructures: Left
+
+AlignConsecutiveAssignments: false
+
+AlignConsecutiveDeclarations: false
+
+AlignEscapedNewlines: Right
+
+AlignOperands: true
+
+AlignTrailingComments: true
+
+AllowAllParametersOfDeclarationOnNextLine: false
+
+AllowShortBlocksOnASingleLine: true
+
+AllowShortCaseLabelsOnASingleLine: true
+
+AllowShortFunctionsOnASingleLine: InlineOnly
+
+AllowShortIfStatementsOnASingleLine: true
+
+AllowShortLoopsOnASingleLine: true
+
+AlwaysBreakAfterReturnType: None
+
+AlwaysBreakBeforeMultilineStrings: false
+
+AlwaysBreakTemplateDeclarations: true
+
+BinPackArguments: true
+
+BinPackParameters: true
+
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterStruct: true
+ AfterUnion: true
+ AfterExternBlock: true
+ BeforeCatch: true
+ BeforeElse: true
+ AfterCaseLabel: true
+ IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
+
+BreakBeforeBinaryOperators: NonAssignment
+
+BreakBeforeBraces: Custom
+
+BreakBeforeTernaryOperators: false
+
+BreakConstructorInitializers: AfterColon
+
+#BreakInheritanceList: AfterColon
+
+BreakStringLiterals: false
+
+ColumnLimit: 0
+
+CompactNamespaces: true
+
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+
+ConstructorInitializerIndentWidth: 4
+
+ContinuationIndentWidth: 4
+
+Cpp11BracedListStyle: true
+
+DerivePointerAlignment: false
+
+FixNamespaceComments: true
+
+IndentCaseLabels: true
+
+IndentWidth: 4
+
+IndentWrappedFunctionNames: false
+
+KeepEmptyLinesAtTheStartOfBlocks: false
+
+MaxEmptyLinesToKeep: 1
+
+NamespaceIndentation: All
+
+PointerAlignment: Left
+
+ReflowComments: true
+
+SortUsingDeclarations: false
+
+SpaceAfterCStyleCast: false
+
+SpaceAfterTemplateKeyword: true
+
+SpaceBeforeAssignmentOperators: true
+
+# SpaceBeforeCpp11BracedList: true
+
+# SpaceBeforeCtorInitializerColon: true
+
+# SpaceBeforeInheritanceColon: true
+
+SpaceBeforeParens: ControlStatements
+
+# SpaceBeforeRangeBasedForLoopColon: true
+
+SpaceInEmptyParentheses: false
+
+SpacesBeforeTrailingComments: 1
+
+SpacesInAngles: false
+
+SpacesInCStyleCastParentheses: false
+
+SpacesInContainerLiterals: true
+
+SpacesInParentheses: false
+
+SpacesInSquareBrackets: false
+
+Standard: Auto
+
+TabWidth: 4
+
+UseTab: Always
+
+SortIncludes: true
+
+IndentPPDirectives: BeforeHash
+
+PPIndentWidth: -1
+
+RemoveBracesLLVM: true
\ No newline at end of file
diff --git a/clang-format.sh b/clang-format.sh
new file mode 100644
index 00000000..df4d0397
--- /dev/null
+++ b/clang-format.sh
@@ -0,0 +1 @@
+find src/ -iname '*.h' -o -iname '*.cpp' | xargs clang-format -i
\ No newline at end of file
diff --git a/src/addresses.cpp b/src/addresses.cpp
index 7cd60f7c..d7ed939f 100644
--- a/src/addresses.cpp
+++ b/src/addresses.cpp
@@ -18,20 +18,20 @@
*/
#include "addresses.h"
-#include "utils/module.h"
#include "gameconfig.h"
+#include "utils/module.h"
#include "tier0/memdbgon.h"
-extern CGameConfig *g_GameConfig;
+extern CGameConfig* g_GameConfig;
-#define RESOLVE_SIG(gameConfig, name, variable) \
- variable = (decltype(variable))gameConfig->ResolveSignature(name); \
- if (!variable) \
- return false; \
+#define RESOLVE_SIG(gameConfig, name, variable) \
+ variable = (decltype(variable))gameConfig->ResolveSignature(name); \
+ if (!variable) \
+ return false; \
Message("Found %s at 0x%p\n", name, variable);
-bool addresses::Initialize(CGameConfig *g_GameConfig)
+bool addresses::Initialize(CGameConfig* g_GameConfig)
{
modules::engine = new CModule(ROOTBIN, "engine2");
modules::tier0 = new CModule(ROOTBIN, "tier0");
diff --git a/src/addresses.h b/src/addresses.h
index f752fc1f..b848e01c 100644
--- a/src/addresses.h
+++ b/src/addresses.h
@@ -26,17 +26,17 @@
namespace modules
{
- inline CModule *engine;
- inline CModule *tier0;
- inline CModule *server;
- inline CModule *schemasystem;
- inline CModule *vscript;
- inline CModule *client;
+ inline CModule* engine;
+ inline CModule* tier0;
+ inline CModule* server;
+ inline CModule* schemasystem;
+ inline CModule* vscript;
+ inline CModule* client;
inline CModule* networksystem;
inline CModule* vphysics2;
inline CModule* matchmaking;
#ifdef _WIN32
- inline CModule *hammer;
+ inline CModule* hammer;
#endif
} // namespace modules
@@ -61,36 +61,36 @@ struct SndOpEventGuid_t;
namespace addresses
{
- bool Initialize(CGameConfig *g_GameConfig);
+ bool Initialize(CGameConfig* g_GameConfig);
- inline void(FASTCALL *SetGroundEntity)(CBaseEntity *ent, CBaseEntity *ground, CBaseEntity* unk3);
- inline void(FASTCALL *CCSPlayerController_SwitchTeam)(CCSPlayerController *pController, uint32 team);
- inline void(FASTCALL *CBasePlayerController_SetPawn)(CBasePlayerController *pController, CCSPlayerPawn *pPawn, bool a3, bool a4, bool a5);
- inline void(FASTCALL *CBaseModelEntity_SetModel)(CBaseModelEntity *pModel, const char *szModel);
- inline void(FASTCALL *UTIL_Remove)(CEntityInstance*);
+ inline void(FASTCALL* SetGroundEntity)(CBaseEntity* ent, CBaseEntity* ground, CBaseEntity* unk3);
+ inline void(FASTCALL* CCSPlayerController_SwitchTeam)(CCSPlayerController* pController, uint32 team);
+ inline void(FASTCALL* CBasePlayerController_SetPawn)(CBasePlayerController* pController, CCSPlayerPawn* pPawn, bool a3, bool a4, bool a5);
+ inline void(FASTCALL* CBaseModelEntity_SetModel)(CBaseModelEntity* pModel, const char* szModel);
+ inline void(FASTCALL* UTIL_Remove)(CEntityInstance*);
- inline void(FASTCALL *CEntitySystem_AddEntityIOEvent)(CEntitySystem *pEntitySystem, CEntityInstance *pTarget, const char *pszInput,
- CEntityInstance *pActivator, CEntityInstance *pCaller, variant_t *value, float flDelay, int outputID);
+ inline void(FASTCALL* CEntitySystem_AddEntityIOEvent)(CEntitySystem* pEntitySystem, CEntityInstance* pTarget, const char* pszInput,
+ CEntityInstance* pActivator, CEntityInstance* pCaller, variant_t* value, float flDelay, int outputID);
- inline void(FASTCALL *CEntityInstance_AcceptInput)(CEntityInstance *pThis, const char *pInputName,
- CEntityInstance *pActivator, CEntityInstance *pCaller, variant_t *value, int nOutputID);
+ inline void(FASTCALL* CEntityInstance_AcceptInput)(CEntityInstance* pThis, const char* pInputName,
+ CEntityInstance* pActivator, CEntityInstance* pCaller, variant_t* value, int nOutputID);
- inline CBaseEntity *(FASTCALL *CGameEntitySystem_FindEntityByClassName)(CEntitySystem *pEntitySystem, CEntityInstance *pStartEntity, const char *szName);
+ inline CBaseEntity*(FASTCALL* CGameEntitySystem_FindEntityByClassName)(CEntitySystem* pEntitySystem, CEntityInstance* pStartEntity, const char* szName);
- inline CBaseEntity *(FASTCALL *CGameEntitySystem_FindEntityByName)(CEntitySystem *pEntitySystem, CEntityInstance *pStartEntity, const char *szName,
- CEntityInstance *pSearchingEntity, CEntityInstance *pActivator, CEntityInstance *pCaller,
- IEntityFindFilter *pFilter);
- inline void(FASTCALL *CGameRules_TerminateRound)(CGameRules* pGameRules, float delay, unsigned int reason, int64 a4, unsigned int a5);
- inline CBaseEntity *(FASTCALL* CreateEntityByName)(const char* className, int iForceEdictIndex);
- inline void(FASTCALL *DispatchSpawn)(CBaseEntity* pEntity, CEntityKeyValues *pEntityKeyValues);
- inline void(FASTCALL *CEntityIdentity_SetEntityName)(CEntityIdentity *pEntity, const char *pName);
- inline void(FASTCALL *CBaseEntity_EmitSoundParams)(CBaseEntity *pEntity, const char *pszSound, int nPitch, float flVolume, float flDelay);
- inline void(FASTCALL *CBaseEntity_SetParent)(CBaseEntity *pEntity, CBaseEntity *pNewParent, CUtlStringToken nBoneOrAttachName, matrix3x4a_t *pOffsetTransform);
- inline int(FASTCALL *DispatchParticleEffect)(const char *pszParticleName, int iAttachType, CBaseEntity *pEntity,
- char iAttachmentPoint, CUtlSymbolLarge iAttachmentName, bool bResetAllParticlesOnEntity, int nSplitScreenPlayerSlot, IRecipientFilter *a7, byte *a8);
- inline SndOpEventGuid_t(FASTCALL *CBaseEntity_EmitSoundFilter)(IRecipientFilter &filter, CEntityIndex ent, const EmitSound_t ¶ms);
- inline void(FASTCALL *CBaseEntity_SetMoveType)(CBaseEntity *pThis, MoveType_t nMoveType, MoveCollide_t nMoveCollide);
- inline void(FASTCALL *CTakeDamageInfo_Constructor)(CTakeDamageInfo *pThis, CBaseEntity *pInflictor, CBaseEntity *pAttacker, CBaseEntity *pAbility,
- const Vector *vecDamageForce, const Vector *vecDamagePosition, float flDamage, int bitsDamageType, int iCustomDamage, void *a10);
- inline void(FASTCALL *CNetworkStringTable_DeleteAllStrings)(INetworkStringTable *pThis);
-}
\ No newline at end of file
+ inline CBaseEntity*(FASTCALL* CGameEntitySystem_FindEntityByName)(CEntitySystem* pEntitySystem, CEntityInstance* pStartEntity, const char* szName,
+ CEntityInstance* pSearchingEntity, CEntityInstance* pActivator, CEntityInstance* pCaller,
+ IEntityFindFilter* pFilter);
+ inline void(FASTCALL* CGameRules_TerminateRound)(CGameRules* pGameRules, float delay, unsigned int reason, int64 a4, unsigned int a5);
+ inline CBaseEntity*(FASTCALL* CreateEntityByName)(const char* className, int iForceEdictIndex);
+ inline void(FASTCALL* DispatchSpawn)(CBaseEntity* pEntity, CEntityKeyValues* pEntityKeyValues);
+ inline void(FASTCALL* CEntityIdentity_SetEntityName)(CEntityIdentity* pEntity, const char* pName);
+ inline void(FASTCALL* CBaseEntity_EmitSoundParams)(CBaseEntity* pEntity, const char* pszSound, int nPitch, float flVolume, float flDelay);
+ inline void(FASTCALL* CBaseEntity_SetParent)(CBaseEntity* pEntity, CBaseEntity* pNewParent, CUtlStringToken nBoneOrAttachName, matrix3x4a_t* pOffsetTransform);
+ inline int(FASTCALL* DispatchParticleEffect)(const char* pszParticleName, int iAttachType, CBaseEntity* pEntity,
+ char iAttachmentPoint, CUtlSymbolLarge iAttachmentName, bool bResetAllParticlesOnEntity, int nSplitScreenPlayerSlot, IRecipientFilter* a7, byte* a8);
+ inline SndOpEventGuid_t(FASTCALL* CBaseEntity_EmitSoundFilter)(IRecipientFilter& filter, CEntityIndex ent, const EmitSound_t& params);
+ inline void(FASTCALL* CBaseEntity_SetMoveType)(CBaseEntity* pThis, MoveType_t nMoveType, MoveCollide_t nMoveCollide);
+ inline void(FASTCALL* CTakeDamageInfo_Constructor)(CTakeDamageInfo* pThis, CBaseEntity* pInflictor, CBaseEntity* pAttacker, CBaseEntity* pAbility,
+ const Vector* vecDamageForce, const Vector* vecDamagePosition, float flDamage, int bitsDamageType, int iCustomDamage, void* a10);
+ inline void(FASTCALL* CNetworkStringTable_DeleteAllStrings)(INetworkStringTable* pThis);
+} // namespace addresses
\ No newline at end of file
diff --git a/src/adminsystem.cpp b/src/adminsystem.cpp
index 96c02d04..982c5568 100644
--- a/src/adminsystem.cpp
+++ b/src/adminsystem.cpp
@@ -17,36 +17,35 @@
* this program. If not, see .
*/
-
#include "adminsystem.h"
#include "KeyValues.h"
-#include "interfaces/interfaces.h"
-#include "filesystem.h"
-#include "icvar.h"
-#include "playermanager.h"
#include "commands.h"
#include "ctimer.h"
#include "detours.h"
#include "discord.h"
-#include "utils/entity.h"
#include "entity/cbaseentity.h"
-#include "entity/cparticlesystem.h"
#include "entity/cgamerules.h"
+#include "entity/cparticlesystem.h"
+#include "filesystem.h"
#include "gamesystem.h"
-#include "votemanager.h"
+#include "icvar.h"
+#include "interfaces/interfaces.h"
#include "map_votes.h"
+#include "playermanager.h"
+#include "utils/entity.h"
+#include "votemanager.h"
#include
-extern IVEngineServer2 *g_pEngineServer2;
-extern CGameEntitySystem *g_pEntitySystem;
-extern CGlobalVars *gpGlobals;
-extern CCSGameRules *g_pGameRules;
+extern IVEngineServer2* g_pEngineServer2;
+extern CGameEntitySystem* g_pEntitySystem;
+extern CGlobalVars* gpGlobals;
+extern CCSGameRules* g_pGameRules;
CAdminSystem* g_pAdminSystem = nullptr;
-CUtlMap g_CommandList(0, 0, DefLessFunc(uint32));
+CUtlMap g_CommandList(0, 0, DefLessFunc(uint32));
-void ParseInfraction(const CCommand &args, CCSPlayerController* pAdmin, bool bAdding, CInfractionBase::EInfractionType infType);
+void ParseInfraction(const CCommand& args, CCSPlayerController* pAdmin, bool bAdding, CInfractionBase::EInfractionType infType);
const char* GetActionPhrase(CInfractionBase::EInfractionType infType, GrammarTense iTense, bool bAdding);
void PrintSingleAdminAction(const char* pszAdminName, const char* pszTargetName, const char* pszAction, const char* pszAction2 = "", const char* prefix = CHAT_PREFIX)
@@ -58,57 +57,57 @@ void PrintMultiAdminAction(ETargetType nType, const char* pszAdminName, const ch
{
switch (nType)
{
- case ETargetType::ALL:
- PrintSingleAdminAction(pszAdminName, "everyone", pszAction, pszAction2, prefix);
- break;
- case ETargetType::SPECTATOR:
- PrintSingleAdminAction(pszAdminName, "spectators", pszAction, pszAction2, prefix);
- break;
- case ETargetType::T:
- PrintSingleAdminAction(pszAdminName, "terrorists", pszAction, pszAction2, prefix);
- break;
- case ETargetType::CT:
- PrintSingleAdminAction(pszAdminName, "counter-terrorists", pszAction, pszAction2, prefix);
- break;
- case ETargetType::DEAD:
- PrintSingleAdminAction(pszAdminName, "dead players", pszAction, pszAction2, prefix);
- break;
- case ETargetType::ALIVE:
- PrintSingleAdminAction(pszAdminName, "alive players", pszAction, pszAction2, prefix);
- break;
- case ETargetType::BOT:
- PrintSingleAdminAction(pszAdminName, "bots", pszAction, pszAction2, prefix);
- break;
- case ETargetType::HUMAN:
- PrintSingleAdminAction(pszAdminName, "humans", pszAction, pszAction2, prefix);
- break;
- case ETargetType::ALL_BUT_SELF:
- ClientPrintAll(HUD_PRINTTALK, "%s" ADMIN_PREFIX "%s everyone except %s%s.", prefix, pszAdminName, pszAction, pszAdminName, pszAction2);
- break;
- case ETargetType::ALL_BUT_RANDOM:
- PrintSingleAdminAction(pszAdminName, "everyone except a random player", pszAction, pszAction2, prefix);
- break;
- case ETargetType::ALL_BUT_RANDOM_T:
- PrintSingleAdminAction(pszAdminName, "everyone except a random terrorist", pszAction, pszAction2, prefix);
- break;
- case ETargetType::ALL_BUT_RANDOM_CT:
- PrintSingleAdminAction(pszAdminName, "everyone except a random counter-terrorist", pszAction, pszAction2, prefix);
- break;
- case ETargetType::ALL_BUT_RANDOM_SPEC:
- PrintSingleAdminAction(pszAdminName, "everyone except a random spectator", pszAction, pszAction2, prefix);
- break;
- case ETargetType::ALL_BUT_AIM:
- PrintSingleAdminAction(pszAdminName, "everyone except a targetted player", pszAction, pszAction2, prefix);
- break;
- case ETargetType::ALL_BUT_SPECTATOR:
- PrintSingleAdminAction(pszAdminName, "non-spectators", pszAction, pszAction2, prefix);
- break;
- case ETargetType::ALL_BUT_T:
- PrintSingleAdminAction(pszAdminName, "non-terrorists", pszAction, pszAction2, prefix);
- break;
- case ETargetType::ALL_BUT_CT:
- PrintSingleAdminAction(pszAdminName, "non-counter-terrorists", pszAction, pszAction2, prefix);
- break;
+ case ETargetType::ALL:
+ PrintSingleAdminAction(pszAdminName, "everyone", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::SPECTATOR:
+ PrintSingleAdminAction(pszAdminName, "spectators", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::T:
+ PrintSingleAdminAction(pszAdminName, "terrorists", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::CT:
+ PrintSingleAdminAction(pszAdminName, "counter-terrorists", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::DEAD:
+ PrintSingleAdminAction(pszAdminName, "dead players", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::ALIVE:
+ PrintSingleAdminAction(pszAdminName, "alive players", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::BOT:
+ PrintSingleAdminAction(pszAdminName, "bots", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::HUMAN:
+ PrintSingleAdminAction(pszAdminName, "humans", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::ALL_BUT_SELF:
+ ClientPrintAll(HUD_PRINTTALK, "%s" ADMIN_PREFIX "%s everyone except %s%s.", prefix, pszAdminName, pszAction, pszAdminName, pszAction2);
+ break;
+ case ETargetType::ALL_BUT_RANDOM:
+ PrintSingleAdminAction(pszAdminName, "everyone except a random player", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::ALL_BUT_RANDOM_T:
+ PrintSingleAdminAction(pszAdminName, "everyone except a random terrorist", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::ALL_BUT_RANDOM_CT:
+ PrintSingleAdminAction(pszAdminName, "everyone except a random counter-terrorist", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::ALL_BUT_RANDOM_SPEC:
+ PrintSingleAdminAction(pszAdminName, "everyone except a random spectator", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::ALL_BUT_AIM:
+ PrintSingleAdminAction(pszAdminName, "everyone except a targetted player", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::ALL_BUT_SPECTATOR:
+ PrintSingleAdminAction(pszAdminName, "non-spectators", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::ALL_BUT_T:
+ PrintSingleAdminAction(pszAdminName, "non-terrorists", pszAction, pszAction2, prefix);
+ break;
+ case ETargetType::ALL_BUT_CT:
+ PrintSingleAdminAction(pszAdminName, "non-counter-terrorists", pszAction, pszAction2, prefix);
+ break;
}
}
@@ -168,7 +167,7 @@ CON_COMMAND_CHAT_FLAGS(unban, " - Unban a player. Takes decimal STEAM
if (!bResult)
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Couldn't find user with STEAMID64 <%llu> in ban infractions.", iTargetSteamId64);
- return;
+ return;
}
g_pAdminSystem->SaveInfractions();
@@ -212,13 +211,13 @@ CON_COMMAND_CHAT_FLAGS(kick, " - Kick a player", ADMFLAG_KICK)
if (!g_playerManager->CanTargetPlayers(player, args[1], iNumClients, pSlots, NO_TARGET_BLOCKS, nType))
return;
- const char *pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
+ const char* pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
for (int i = 0; i < iNumClients; i++)
{
CCSPlayerController* pTarget = CCSPlayerController::FromSlot(pSlots[i]);
ZEPlayer* pTargetPlayer = pTarget->GetZEPlayer();
-
+
g_pEngineServer2->DisconnectClient(pTargetPlayer->GetPlayerSlot(), NETWORK_DISCONNECT_KICKED);
if (iNumClients == 1)
@@ -243,7 +242,7 @@ CON_COMMAND_CHAT_FLAGS(slay, " - Slay a player", ADMFLAG_SLAY)
if (!g_playerManager->CanTargetPlayers(player, args[1], iNumClients, pSlots, NO_DEAD, nType))
return;
- const char *pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
+ const char* pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
for (int i = 0; i < iNumClients; i++)
{
@@ -273,12 +272,12 @@ CON_COMMAND_CHAT_FLAGS(slap, " [damage] - Slap a player", ADMFLAG_SLAY)
if (!g_playerManager->CanTargetPlayers(player, args[1], iNumClients, pSlots, NO_DEAD, nType))
return;
- const char *pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
+ const char* pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
for (int i = 0; i < iNumClients; i++)
{
- CBasePlayerController *pTarget = (CBasePlayerController *)g_pEntitySystem->GetEntityInstance((CEntityIndex)(pSlots[i] + 1));
- CBasePlayerPawn *pPawn = pTarget->m_hPawn();
+ CBasePlayerController* pTarget = (CBasePlayerController*)g_pEntitySystem->GetEntityInstance((CEntityIndex)(pSlots[i] + 1));
+ CBasePlayerPawn* pPawn = pTarget->m_hPawn();
if (!pPawn)
continue;
@@ -290,12 +289,12 @@ CON_COMMAND_CHAT_FLAGS(slap, " [damage] - Slap a player", ADMFLAG_SLAY)
velocity.z += rand() % 200 + 100;
pPawn->SetAbsVelocity(velocity);
- float flDamage = V_StringToFloat32 (args[2], 0);
-
+ float flDamage = V_StringToFloat32(args[2], 0);
+
if (flDamage > 0)
{
// Default to the world
- CBaseEntity *pAttacker = (CBaseEntity*)g_pEntitySystem->GetEntityInstance(CEntityIndex(0));
+ CBaseEntity* pAttacker = (CBaseEntity*)g_pEntitySystem->GetEntityInstance(CEntityIndex(0));
if (player)
pAttacker = player->GetPlayerPawn();
@@ -402,9 +401,9 @@ CON_COMMAND_CHAT_FLAGS(setteam, " - Set a player's team", ADM
if (!g_playerManager->CanTargetPlayers(player, args[1], iNumClients, pSlots, NO_TARGET_BLOCKS, nType))
return;
- const char *pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
+ const char* pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
- constexpr const char *teams[] = {"none", "spectators", "terrorists", "counter-terrorists"};
+ constexpr const char* teams[] = {"none", "spectators", "terrorists", "counter-terrorists"};
char szAction[64];
V_snprintf(szAction, sizeof(szAction), " to %s", teams[iTeam]);
@@ -435,7 +434,7 @@ CON_COMMAND_CHAT_FLAGS(noclip, "[name] - Toggle noclip on a player", ADMFLAG_CHE
return;
CCSPlayerController* pTarget = CCSPlayerController::FromSlot(pSlots[0]);
- CBasePlayerPawn *pPawn = pTarget->m_hPawn();
+ CBasePlayerPawn* pPawn = pTarget->m_hPawn();
const char* pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
if (!pPawn)
@@ -469,7 +468,7 @@ CON_COMMAND_CHAT_FLAGS(entfire, " [parameter] - Fire outputs at en
int iFoundEnts = 0;
- CBaseEntity *pTarget = nullptr;
+ CBaseEntity* pTarget = nullptr;
// The idea here is to only use one of the targeting modes at once, prioritizing !picker then targetname/!self then classname
// Try picker first, FindEntityByName can also take !picker but it always uses player 0 so we have to do this ourselves
@@ -495,7 +494,7 @@ CON_COMMAND_CHAT_FLAGS(entfire, " [parameter] - Fire outputs at en
iFoundEnts++;
}
}
-
+
if (!iFoundEnts)
{
while ((pTarget = UTIL_FindEntityByName(pTarget, args[1], player)))
@@ -539,7 +538,7 @@ CON_COMMAND_CHAT_FLAGS(entfirepawn, " [parameter] - Fire outputs at
for (int i = 0; i < iNumClients; i++)
{
- CCSPlayerController *pTarget = CCSPlayerController::FromSlot(pSlots[i]);
+ CCSPlayerController* pTarget = CCSPlayerController::FromSlot(pSlots[i]);
if (!pTarget->GetPawn())
continue;
@@ -570,7 +569,7 @@ CON_COMMAND_CHAT_FLAGS(entfirecontroller, " [parameter] - Fire out
for (int i = 0; i < iNumClients; i++)
{
- CCSPlayerController *pTarget = CCSPlayerController::FromSlot(pSlots[i]);
+ CCSPlayerController* pTarget = CCSPlayerController::FromSlot(pSlots[i]);
pTarget->AcceptInput(args[2], args[3], player, player);
iFoundEnts++;
}
@@ -632,8 +631,7 @@ CON_COMMAND_CHAT_FLAGS(map, " - Change map", ADMFLAG_CHANGEMAP)
ClientPrintAll(HUD_PRINTTALK, CHAT_PREFIX "Changing map to %s...", pszMapName);
- new CTimer(5.0f, false, true, [sCommand]()
- {
+ new CTimer(5.0f, false, true, [sCommand]() {
g_pEngineServer2->ServerCommand(sCommand.c_str());
return -1.0f;
});
@@ -643,8 +641,7 @@ CON_COMMAND_CHAT_FLAGS(map, " - Change map", ADMFLAG_CHANGEMAP)
ClientPrintAll(HUD_PRINTTALK, CHAT_PREFIX "Changing map to %s...", pszMapName);
- new CTimer(5.0f, false, true, [sMapName]()
- {
+ new CTimer(5.0f, false, true, [sMapName]() {
g_pEngineServer2->ChangeLevel(sMapName.c_str(), nullptr);
return -1.0f;
});
@@ -735,7 +732,7 @@ CON_COMMAND_CHAT_FLAGS(pm, " - Private message a player. This wi
if (player == pTarget)
{
- //Player is PMing themselves (bind to display message in chat probably), so no need to echo to all admins
+ // Player is PMing themselves (bind to display message in chat probably), so no need to echo to all admins
ClientPrint(player, HUD_PRINTTALK, "\x0A[SELF]\x0C %s\1: \x0B%s", pszName, strMessage.c_str());
return;
}
@@ -865,7 +862,6 @@ CON_COMMAND_CHAT_FLAGS(who, "- List the flags of all online players", ADMFLAG_GE
ClientPrint(player, HUD_PRINTCONSOLE, "|----------------------|----------------------------------------------------|-------------------|");
for (auto [strPlayerName, strFlags, iSteamID] : rgNameSlotID)
{
-
if (strPlayerName.length() % 2 == 1)
strPlayerName = strPlayerName + ' ';
if (strPlayerName.length() < 20)
@@ -936,7 +932,7 @@ CON_COMMAND_CHAT(status, " - Checks a player's active punishments. Non-adm
CCSPlayerController* pTarget = CCSPlayerController::FromSlot(pSlots[0]);
pTargetPlayer = pTarget->GetZEPlayer();
-
+
if (!pTargetPlayer->IsMuted() && !pTargetPlayer->IsGagged())
{
if (pTarget == player)
@@ -1134,7 +1130,7 @@ bool CAdminSystem::LoadAdmins()
KeyValues* pKV = new KeyValues("admins");
KeyValues::AutoDelete autoDelete(pKV);
- const char *pszPath = "addons/cs2fixes/configs/admins.cfg";
+ const char* pszPath = "addons/cs2fixes/configs/admins.cfg";
if (!pKV->LoadFromFile(g_pFullFileSystem, pszPath))
{
@@ -1143,9 +1139,9 @@ bool CAdminSystem::LoadAdmins()
}
for (KeyValues* pKey = pKV->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey())
{
- const char *pszName = pKey->GetName();
- const char *pszSteamID = pKey->GetString("steamid", nullptr);
- const char *pszFlags = pKey->GetString("flags", nullptr);
+ const char* pszName = pKey->GetName();
+ const char* pszSteamID = pKey->GetString("steamid", nullptr);
+ const char* pszFlags = pKey->GetString("flags", nullptr);
int iImmunityLevel = pKey->GetInt("immunity", -1);
if (!pszSteamID)
@@ -1186,7 +1182,7 @@ bool CAdminSystem::LoadInfractions()
KeyValues* pKV = new KeyValues("infractions");
KeyValues::AutoDelete autoDelete(pKV);
- const char *pszPath = "addons/cs2fixes/data/infractions.txt";
+ const char* pszPath = "addons/cs2fixes/data/infractions.txt";
if (!pKV->LoadFromFile(g_pFullFileSystem, pszPath))
{
@@ -1220,17 +1216,17 @@ bool CAdminSystem::LoadInfractions()
switch (iType)
{
- case CInfractionBase::Ban:
- AddInfraction(new CBanInfraction(iEndTime, iSteamId, true));
- break;
- case CInfractionBase::Mute:
- AddInfraction(new CMuteInfraction(iEndTime, iSteamId, true));
- break;
- case CInfractionBase::Gag:
- AddInfraction(new CGagInfraction(iEndTime, iSteamId, true));
- break;
- default:
- Warning("Invalid infraction type %d\n", iType);
+ case CInfractionBase::Ban:
+ AddInfraction(new CBanInfraction(iEndTime, iSteamId, true));
+ break;
+ case CInfractionBase::Mute:
+ AddInfraction(new CMuteInfraction(iEndTime, iSteamId, true));
+ break;
+ case CInfractionBase::Gag:
+ AddInfraction(new CGagInfraction(iEndTime, iSteamId, true));
+ break;
+ default:
+ Warning("Invalid infraction type %d\n", iType);
}
}
@@ -1274,11 +1270,10 @@ void CAdminSystem::AddInfraction(CInfractionBase* infraction)
m_vecInfractions.AddToTail(infraction);
}
-
// This function can run at least twice when a player connects: Immediately upon client connection, and also upon getting authenticated by steam.
// It's also run when we're periodically checking for infraction expiry in the case of mutes/gags.
// This returns false only when called from ClientConnect and the player is banned in order to reject them.
-bool CAdminSystem::ApplyInfractions(ZEPlayer *player)
+bool CAdminSystem::ApplyInfractions(ZEPlayer* player)
{
FOR_EACH_VEC(m_vecInfractions, i)
{
@@ -1303,14 +1298,14 @@ bool CAdminSystem::ApplyInfractions(ZEPlayer *player)
// We are called from ClientConnect and the player is banned, immediately reject them
if (!player->IsConnected() && m_vecInfractions[i]->GetType() == CInfractionBase::EInfractionType::Ban)
return false;
-
+
m_vecInfractions[i]->ApplyInfraction(player);
}
return true;
}
-bool CAdminSystem::FindAndRemoveInfraction(ZEPlayer *player, CInfractionBase::EInfractionType type)
+bool CAdminSystem::FindAndRemoveInfraction(ZEPlayer* player, CInfractionBase::EInfractionType type)
{
FOR_EACH_VEC_BACK(m_vecInfractions, i)
{
@@ -1318,7 +1313,7 @@ bool CAdminSystem::FindAndRemoveInfraction(ZEPlayer *player, CInfractionBase::EI
{
m_vecInfractions[i]->UndoInfraction(player);
m_vecInfractions.Remove(i);
-
+
return true;
}
}
@@ -1333,7 +1328,7 @@ bool CAdminSystem::FindAndRemoveInfractionSteamId64(uint64 steamid64, CInfractio
if (m_vecInfractions[i]->GetSteamId64() == steamid64 && m_vecInfractions[i]->GetType() == type)
{
m_vecInfractions.Remove(i);
-
+
return true;
}
}
@@ -1341,7 +1336,7 @@ bool CAdminSystem::FindAndRemoveInfractionSteamId64(uint64 steamid64, CInfractio
return false;
}
-CAdmin *CAdminSystem::FindAdmin(uint64 iSteamID)
+CAdmin* CAdminSystem::FindAdmin(uint64 iSteamID)
{
FOR_EACH_VEC(m_vecAdmins, i)
{
@@ -1376,10 +1371,8 @@ void CAdminSystem::AddDisconnectedPlayer(const char* pszName, uint64 xuid, const
{
auto plyInfo = std::make_tuple(pszName, xuid, pszIP);
for (auto& dcPlyInfo : m_rgDCPly)
- {
if (std::get<1>(dcPlyInfo) == std::get<1>(plyInfo))
return;
- }
m_rgDCPly[m_iDCPlyIndex] = plyInfo;
m_iDCPlyIndex = (m_iDCPlyIndex + 1) % 20;
}
@@ -1411,7 +1404,7 @@ void CAdminSystem::ShowDisconnectedPlayers(CCSPlayerController* const pAdmin)
ClientPrint(pAdmin, HUD_PRINTTALK, CHAT_PREFIX "No players have disconnected yet.");
}
-void CBanInfraction::ApplyInfraction(ZEPlayer *player)
+void CBanInfraction::ApplyInfraction(ZEPlayer* player)
{
g_pEngineServer2->DisconnectClient(player->GetPlayerSlot(), NETWORK_DISCONNECT_KICKBANADDED); // "Kicked and banned"
}
@@ -1421,17 +1414,17 @@ void CMuteInfraction::ApplyInfraction(ZEPlayer* player)
player->SetMuted(true);
}
-void CMuteInfraction::UndoInfraction(ZEPlayer *player)
+void CMuteInfraction::UndoInfraction(ZEPlayer* player)
{
player->SetMuted(false);
}
-void CGagInfraction::ApplyInfraction(ZEPlayer *player)
+void CGagInfraction::ApplyInfraction(ZEPlayer* player)
{
player->SetGagged(true);
}
-void CGagInfraction::UndoInfraction(ZEPlayer *player)
+void CGagInfraction::UndoInfraction(ZEPlayer* player)
{
player->SetGagged(false);
}
@@ -1475,7 +1468,7 @@ int ParseTimeInput(std::string strTime)
if (strNumbers.length() == 0)
return -1;
else if (strNumbers.length() > 9)
- // Really high number, just return perma
+ // Really high number, just return perma
return 0;
// stoi should be exception safe here due to above checks
@@ -1524,7 +1517,7 @@ std::string GetReason(const CCommand& args, int iArgsBefore, bool bStripUnicode)
std::string strOutput = "";
if (bStripUnicode)
- std::copy_if(strReason.cbegin(), strReason.cend(), std::back_inserter(strOutput), [](unsigned char c) {return c < 128; });
+ std::copy_if(strReason.cbegin(), strReason.cend(), std::back_inserter(strOutput), [](unsigned char c) { return c < 128; });
else
strOutput = strReason;
@@ -1537,7 +1530,7 @@ std::string GetReason(const CCommand& args, int iArgsBefore, bool bStripUnicode)
return strOutput;
}
-void ParseInfraction(const CCommand &args, CCSPlayerController* pAdmin, bool bAdding, CInfractionBase::EInfractionType infType)
+void ParseInfraction(const CCommand& args, CCSPlayerController* pAdmin, bool bAdding, CInfractionBase::EInfractionType infType)
{
if (args.ArgC() < 2 || (bAdding && args.ArgC() < 3))
{
@@ -1547,7 +1540,8 @@ void ParseInfraction(const CCommand &args, CCSPlayerController* pAdmin, bool bAd
}
int iDuration = bAdding ? ParseTimeInput(args[2]) : 0;
- if (bAdding && iDuration < 0) {
+ if (bAdding && iDuration < 0)
+ {
ClientPrint(pAdmin, HUD_PRINTTALK, CHAT_PREFIX "Invalid duration.");
return;
}
@@ -1576,7 +1570,7 @@ void ParseInfraction(const CCommand &args, CCSPlayerController* pAdmin, bool bAd
return;
}
- const char *pszCommandPlayerName = pAdmin ? pAdmin->GetPlayerName() : CONSOLE_NAME;
+ const char* pszCommandPlayerName = pAdmin ? pAdmin->GetPlayerName() : CONSOLE_NAME;
for (int i = 0; i < iNumClients; i++)
{
@@ -1627,10 +1621,8 @@ void ParseInfraction(const CCommand &args, CCSPlayerController* pAdmin, bool bAd
}
if (iNumClients > 1)
- {
PrintMultiAdminAction(nType, pszCommandPlayerName, GetActionPhrase(infType, GrammarTense::Past, bAdding),
bAdding ? (" for " + FormatTime(iDuration, false)).c_str() : "");
- }
g_pAdminSystem->SaveInfractions();
}
diff --git a/src/adminsystem.h b/src/adminsystem.h
index 481d5a2f..abbc2389 100644
--- a/src/adminsystem.h
+++ b/src/adminsystem.h
@@ -19,10 +19,11 @@
#pragma once
#include "platform.h"
-#include "utlvector.h"
#include "playermanager.h"
+#include "utlvector.h"
#include
+// clang-format off
#define ADMFLAG_NONE (0)
#define ADMFLAG_RESERVATION (1 << 0) // a
#define ADMFLAG_GENERIC (1 << 1) // b
@@ -50,6 +51,7 @@
#define ADMFLAG_CUSTOM10 (1 << 23) // x
#define ADMFLAG_CUSTOM11 (1 << 24) // y
#define ADMFLAG_ROOT (1 << 25) // z
+// clang-format on
#define ADMIN_PREFIX "Admin %s has "
#define CONSOLE_NAME "\2CONSOLE\1" // color it to indicate that it isnt a regular player using the command
@@ -67,7 +69,8 @@ enum GrammarTense
class CInfractionBase
{
public:
- CInfractionBase(time_t duration, uint64 steamId, bool bEndTime = false) : m_iSteamID(steamId)
+ CInfractionBase(time_t duration, uint64 steamId, bool bEndTime = false) :
+ m_iSteamID(steamId)
{
// The duration is in minutes here
if (!bEndTime)
@@ -84,7 +87,7 @@ class CInfractionBase
virtual EInfractionType GetType() = 0;
virtual void ApplyInfraction(ZEPlayer*) = 0;
- virtual void UndoInfraction(ZEPlayer *) = 0;
+ virtual void UndoInfraction(ZEPlayer*) = 0;
time_t GetTimestamp() { return m_iTimestamp; }
uint64 GetSteamId64() { return m_iSteamID; }
@@ -97,22 +100,22 @@ class CBanInfraction : public CInfractionBase
{
public:
using CInfractionBase::CInfractionBase;
-
+
EInfractionType GetType() override { return Ban; }
void ApplyInfraction(ZEPlayer*) override;
// This isn't needed as we'll just not kick the player when checking infractions upon joining
- void UndoInfraction(ZEPlayer *) override {}
+ void UndoInfraction(ZEPlayer*) override {}
};
-class CMuteInfraction :public CInfractionBase
+class CMuteInfraction : public CInfractionBase
{
public:
using CInfractionBase::CInfractionBase;
-
+
EInfractionType GetType() override { return Mute; }
void ApplyInfraction(ZEPlayer*) override;
- void UndoInfraction(ZEPlayer *) override;
+ void UndoInfraction(ZEPlayer*) override;
};
class CGagInfraction : public CInfractionBase
@@ -121,14 +124,14 @@ class CGagInfraction : public CInfractionBase
using CInfractionBase::CInfractionBase;
EInfractionType GetType() override { return Gag; }
- void ApplyInfraction(ZEPlayer *) override;
- void UndoInfraction(ZEPlayer *) override;
+ void ApplyInfraction(ZEPlayer*) override;
+ void UndoInfraction(ZEPlayer*) override;
};
class CAdmin
{
public:
- CAdmin(const char* pszName, uint64 iSteamID, uint64 iFlags, int iAdminImmunity) :
+ CAdmin(const char* pszName, uint64 iSteamID, uint64 iFlags, int iAdminImmunity) :
m_pszName(pszName), m_iSteamID(iSteamID), m_iFlags(iFlags), m_iAdminImmunity(iAdminImmunity)
{}
@@ -152,10 +155,10 @@ class CAdminSystem
bool LoadInfractions();
void AddInfraction(CInfractionBase*);
void SaveInfractions();
- bool ApplyInfractions(ZEPlayer *player);
- bool FindAndRemoveInfraction(ZEPlayer *player, CInfractionBase::EInfractionType type);
+ bool ApplyInfractions(ZEPlayer* player);
+ bool FindAndRemoveInfraction(ZEPlayer* player, CInfractionBase::EInfractionType type);
bool FindAndRemoveInfractionSteamId64(uint64 steamid64, CInfractionBase::EInfractionType type);
- CAdmin *FindAdmin(uint64 iSteamID);
+ CAdmin* FindAdmin(uint64 iSteamID);
uint64 ParseFlags(const char* pszFlags);
void AddDisconnectedPlayer(const char* pszName, uint64 xuid, const char* pszIP);
void ShowDisconnectedPlayers(CCSPlayerController* const pAdmin);
@@ -163,13 +166,13 @@ class CAdminSystem
private:
CUtlVector m_vecAdmins;
CUtlVector m_vecInfractions;
-
+
// Implemented as a circular buffer.
std::tuple m_rgDCPly[20];
int m_iDCPlyIndex;
};
-extern CAdminSystem *g_pAdminSystem;
+extern CAdminSystem* g_pAdminSystem;
// Given a formatted time entered by an admin, return the minutes
int ParseTimeInput(std::string strTime);
diff --git a/src/buttonwatch.cpp b/src/buttonwatch.cpp
index 922d16ce..7c98c9a6 100644
--- a/src/buttonwatch.cpp
+++ b/src/buttonwatch.cpp
@@ -1,25 +1,28 @@
/**
-* =============================================================================
-* CS2Fixes
-* Copyright (C) 2023-2024 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 .
-*/
+ * =============================================================================
+ * CS2Fixes
+ * Copyright (C) 2023-2024 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 .
+ */
#include "buttonwatch.h"
+#include "commands.h"
+#include "cs2fixes.h"
#include "ctimer.h"
+#include "detours.h"
#include "entity.h"
#include "entity/cbaseplayercontroller.h"
#include "entity/ccsplayercontroller.h"
@@ -28,120 +31,113 @@
#include "entity/cgamerules.h"
#include "entity/clogiccase.h"
#include "entity/cpointviewcontrol.h"
-#include "detours.h"
-#include "cs2fixes.h"
-#include "commands.h"
CON_COMMAND_F(cs2f_enable_button_watch, "INCOMPATIBLE WITH CS#. Whether to enable button watch or not.", FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY | FCVAR_PROTECTED)
{
- if (args.ArgC() < 2)
- {
- Msg("%s %i\n", args[0], IsButtonWatchEnabled());
- return;
- }
-
- if (!V_StringToBool(args[1], false) || !SetupFireOutputInternalDetour())
- mapIOFunctions.erase("buttonwatch");
- else if (!IsButtonWatchEnabled())
- mapIOFunctions["buttonwatch"] = ButtonWatch;
+ if (args.ArgC() < 2)
+ {
+ Msg("%s %i\n", args[0], IsButtonWatchEnabled());
+ return;
+ }
+
+ if (!V_StringToBool(args[1], false) || !SetupFireOutputInternalDetour())
+ mapIOFunctions.erase("buttonwatch");
+ else if (!IsButtonWatchEnabled())
+ mapIOFunctions["buttonwatch"] = ButtonWatch;
}
CON_COMMAND_CHAT_FLAGS(bw, "- Toggle button watch display", ADMFLAG_GENERIC)
{
- if (!IsButtonWatchEnabled())
- {
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Button watch is disabled on this server.");
- return;
- }
-
- if (!player)
- {
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You cannot use this command from the server console.");
- return;
- }
-
- ZEPlayer* zpPlayer = player->GetZEPlayer();
- if (!zpPlayer)
- {
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Something went wrong, please wait a moment before trying this command again.");
- return;
- }
-
- zpPlayer->CycleButtonWatch();
-
- switch (zpPlayer->GetButtonWatchMode())
- {
- case 0:
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x02 disabled\1 button watch.");
- break;
- case 1:
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in chat.");
- break;
- case 2:
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in console.");
- break;
- case 3:
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in chat and console.");
- break;
- }
+ if (!IsButtonWatchEnabled())
+ {
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Button watch is disabled on this server.");
+ return;
+ }
+
+ if (!player)
+ {
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You cannot use this command from the server console.");
+ return;
+ }
+
+ ZEPlayer* zpPlayer = player->GetZEPlayer();
+ if (!zpPlayer)
+ {
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Something went wrong, please wait a moment before trying this command again.");
+ return;
+ }
+
+ zpPlayer->CycleButtonWatch();
+
+ switch (zpPlayer->GetButtonWatchMode())
+ {
+ case 0:
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x02 disabled\1 button watch.");
+ break;
+ case 1:
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in chat.");
+ break;
+ case 2:
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in console.");
+ break;
+ case 3:
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in chat and console.");
+ break;
+ }
}
bool IsButtonWatchEnabled()
{
- return std::any_of(mapIOFunctions.begin(), mapIOFunctions.end(), [](const auto& p) {
- return p.first == "buttonwatch";
- });
+ return std::any_of(mapIOFunctions.begin(), mapIOFunctions.end(), [](const auto& p) {
+ return p.first == "buttonwatch";
+ });
}
-std::map mapRecentEnts;
+std::map mapRecentEnts;
void ButtonWatch(const CEntityIOOutput* pThis, CEntityInstance* pActivator, CEntityInstance* pCaller, const CVariant* value, float flDelay)
{
- if (!IsButtonWatchEnabled() || V_stricmp(pThis->m_pDesc->m_pName, "OnPressed") ||
- !pActivator || !((CBaseEntity*)pActivator)->IsPawn() ||
- !pCaller || mapRecentEnts.contains(pCaller->GetEntityIndex().Get()))
- return;
-
- CCSPlayerController* ccsPlayer = CCSPlayerController::FromPawn(static_cast(pActivator));
- std::string strPlayerName = ccsPlayer->GetPlayerName();
-
- ZEPlayer* zpPlayer = ccsPlayer->GetZEPlayer();
- std::string strPlayerID = "";
- if (zpPlayer && !zpPlayer->IsFakeClient())
- {
- strPlayerID = std::to_string(zpPlayer->IsAuthenticated() ? zpPlayer->GetSteamId64() : zpPlayer->GetUnauthenticatedSteamId64());
- strPlayerID = "(" + strPlayerID + ")";
- }
-
- std::string strButton = std::to_string(pCaller->GetEntityIndex().Get()) + " " +
- std::string(((CBaseEntity*)pCaller)->GetName());
-
- for (int i = 0; i < gpGlobals->maxClients; i++)
- {
- CCSPlayerController* ccsPlayer = CCSPlayerController::FromSlot(i);
- if (!ccsPlayer)
- continue;
-
- ZEPlayer* zpPlayer = ccsPlayer->GetZEPlayer();
- if (!zpPlayer)
- continue;
-
- if (zpPlayer->GetButtonWatchMode() % 2 == 1)
- ClientPrint(ccsPlayer, HUD_PRINTTALK, " \x02[BW]\x0C %s\1 pressed button \x0C%s\1", strPlayerName.c_str(), strButton.c_str());
- if (zpPlayer->GetButtonWatchMode() >= 2)
- {
- ClientPrint(ccsPlayer, HUD_PRINTCONSOLE, "------------------------------------ [ButtonWatch] ------------------------------------");
- ClientPrint(ccsPlayer, HUD_PRINTCONSOLE, "Player: %s %s", strPlayerName.c_str(), strPlayerID.c_str());
- ClientPrint(ccsPlayer, HUD_PRINTCONSOLE, "Button: %s", strButton.c_str());
- ClientPrint(ccsPlayer, HUD_PRINTCONSOLE, "---------------------------------------------------------------------------------------");
- }
- }
-
- // Limit each button to only printing out at most once every 5 seconds
- int iIndex = pCaller->GetEntityIndex().Get();
- mapRecentEnts[iIndex] = true;
- new CTimer(5.0f, true, true, [iIndex]()
- {
- mapRecentEnts.erase(iIndex);
- return -1.0f;
- });
+ if (!IsButtonWatchEnabled() || V_stricmp(pThis->m_pDesc->m_pName, "OnPressed") || !pActivator || !((CBaseEntity*)pActivator)->IsPawn() || !pCaller || mapRecentEnts.contains(pCaller->GetEntityIndex().Get()))
+ return;
+
+ CCSPlayerController* ccsPlayer = CCSPlayerController::FromPawn(static_cast(pActivator));
+ std::string strPlayerName = ccsPlayer->GetPlayerName();
+
+ ZEPlayer* zpPlayer = ccsPlayer->GetZEPlayer();
+ std::string strPlayerID = "";
+ if (zpPlayer && !zpPlayer->IsFakeClient())
+ {
+ strPlayerID = std::to_string(zpPlayer->IsAuthenticated() ? zpPlayer->GetSteamId64() : zpPlayer->GetUnauthenticatedSteamId64());
+ strPlayerID = "(" + strPlayerID + ")";
+ }
+
+ std::string strButton = std::to_string(pCaller->GetEntityIndex().Get()) + " " + std::string(((CBaseEntity*)pCaller)->GetName());
+
+ for (int i = 0; i < gpGlobals->maxClients; i++)
+ {
+ CCSPlayerController* ccsPlayer = CCSPlayerController::FromSlot(i);
+ if (!ccsPlayer)
+ continue;
+
+ ZEPlayer* zpPlayer = ccsPlayer->GetZEPlayer();
+ if (!zpPlayer)
+ continue;
+
+ if (zpPlayer->GetButtonWatchMode() % 2 == 1)
+ ClientPrint(ccsPlayer, HUD_PRINTTALK, " \x02[BW]\x0C %s\1 pressed button \x0C%s\1", strPlayerName.c_str(), strButton.c_str());
+ if (zpPlayer->GetButtonWatchMode() >= 2)
+ {
+ ClientPrint(ccsPlayer, HUD_PRINTCONSOLE, "------------------------------------ [ButtonWatch] ------------------------------------");
+ ClientPrint(ccsPlayer, HUD_PRINTCONSOLE, "Player: %s %s", strPlayerName.c_str(), strPlayerID.c_str());
+ ClientPrint(ccsPlayer, HUD_PRINTCONSOLE, "Button: %s", strButton.c_str());
+ ClientPrint(ccsPlayer, HUD_PRINTCONSOLE, "---------------------------------------------------------------------------------------");
+ }
+ }
+
+ // Limit each button to only printing out at most once every 5 seconds
+ int iIndex = pCaller->GetEntityIndex().Get();
+ mapRecentEnts[iIndex] = true;
+ new CTimer(5.0f, true, true, [iIndex]() {
+ mapRecentEnts.erase(iIndex);
+ return -1.0f;
+ });
}
\ No newline at end of file
diff --git a/src/buttonwatch.h b/src/buttonwatch.h
index f15877e9..f3c7c4aa 100644
--- a/src/buttonwatch.h
+++ b/src/buttonwatch.h
@@ -1,21 +1,21 @@
/**
-* =============================================================================
-* CS2Fixes
-* Copyright (C) 2023-2024 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 .
-*/
+ * =============================================================================
+ * CS2Fixes
+ * Copyright (C) 2023-2024 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 "detours.h"
diff --git a/src/cdetour.h b/src/cdetour.h
index a20573b8..9e1493e7 100644
--- a/src/cdetour.h
+++ b/src/cdetour.h
@@ -18,19 +18,19 @@
*/
#pragma once
-#include
+#include "addresses.h"
#include "funchook.h"
+#include "gameconfig.h"
#include "module.h"
-#include "utlvector.h"
#include "plat.h"
-#include "gameconfig.h"
-#include "addresses.h"
+#include "utlvector.h"
+#include
class CDetourBase
{
public:
virtual const char* GetName() = 0;
- virtual bool CreateDetour(CGameConfig *gameConfig) = 0;
+ virtual bool CreateDetour(CGameConfig* gameConfig) = 0;
virtual void FreeDetour() = 0;
virtual void EnableDetour() = 0;
virtual void DisableDetour() = 0;
@@ -40,23 +40,23 @@ template
class CDetour : public CDetourBase
{
public:
- CDetour(T *pfnDetour, const char *pszName);
+ CDetour(T* pfnDetour, const char* pszName);
~CDetour()
{
FreeDetour();
}
- bool CreateDetour(CGameConfig *gameConfig) override;
+ bool CreateDetour(CGameConfig* gameConfig) override;
void EnableDetour();
void DisableDetour();
void FreeDetour() override;
const char* GetName() override { return m_pszName; }
- T *GetFunc() { return m_pfnFunc; }
+ T* GetFunc() { return m_pfnFunc; }
// Shorthand for calling original.
template
- auto operator()(Args &&...args)
+ auto operator()(Args&&... args)
{
return std::invoke(m_pfnFunc, std::forward(args)...);
}
@@ -75,7 +75,7 @@ class CDetour : public CDetourBase
extern CUtlVector g_vecDetours;
template
-CDetour::CDetour(T *pfnDetour, const char *pszName) :
+CDetour::CDetour(T* pfnDetour, const char* pszName) :
m_pfnDetour(pfnDetour), m_pszName(pszName)
{
m_hook = nullptr;
@@ -88,13 +88,13 @@ CDetour::CDetour(T *pfnDetour, const char *pszName) :
}
template
-bool CDetour::CreateDetour(CGameConfig *gameConfig)
+bool CDetour::CreateDetour(CGameConfig* gameConfig)
{
m_pfnFunc = (T*)gameConfig->ResolveSignature(m_pszName);
if (!m_pfnFunc)
return false;
- T *pFunc = m_pfnFunc;
+ T* pFunc = m_pfnFunc;
m_hook = funchook_create();
funchook_prepare(m_hook, (void**)&m_pfnFunc, (void*)m_pfnDetour);
@@ -120,11 +120,11 @@ void CDetour::EnableDetour()
template
void CDetour::DisableDetour()
{
- if (!m_hook )
+ if (!m_hook)
return;
int error = funchook_uninstall(m_hook, 0);
-
+
if (!error)
m_bInstalled = false;
else
diff --git a/src/clientframe.h b/src/clientframe.h
index 71d58db0..3a7df38f 100644
--- a/src/clientframe.h
+++ b/src/clientframe.h
@@ -1,13 +1,13 @@
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
-// Purpose:
+// Purpose:
//
//=============================================================================//
#ifndef CLIENTFRAME_H
#define CLIENTFRAME_H
#ifdef _WIN32
-#pragma once
+ #pragma once
#endif
#include
@@ -22,24 +22,23 @@ class CClientFrame
virtual ~CClientFrame();
public:
-
// State of entities this frame from the POV of the client.
- int tick_count; // server tick of this snapshot
- int last_entity; // highest entity index
- CClientFrame* m_pNext;
+ int tick_count; // server tick of this snapshot
+ int last_entity; // highest entity index
+ CClientFrame* m_pNext;
// Index of snapshot entry that stores the entities that were active and the serial numbers
// for the frame number this packed entity corresponds to
// m_pSnapshot MUST be private to force using SetSnapshot(), see reference counters
- CFrameSnapshot *m_pSnapshot;
+ CFrameSnapshot* m_pSnapshot;
// Used by server to indicate if the entity was in the player's pvs
- CBitVec transmit_entity; // if bit n is set, entity n will be send to client
- CBitVec unkBitVec2080;
- CBitVec unkBitVec4128;
- CBitVec unkBitVec6176;
- CBitVec *transmit_always; // if bit is set, don't do PVS checks before sending (HLTV only)
-}; // sizeof 8232
+ CBitVec transmit_entity; // if bit n is set, entity n will be send to client
+ CBitVec unkBitVec2080;
+ CBitVec unkBitVec4128;
+ CBitVec unkBitVec6176;
+ CBitVec* transmit_always; // if bit is set, don't do PVS checks before sending (HLTV only)
+}; // sizeof 8232
// TODO substitute CClientFrameManager with an intelligent structure (Tree, hash, cache, etc)
class CClientFrameManager
@@ -49,8 +48,8 @@ class CClientFrameManager
public:
char pad120[120];
- CUtlMemoryPool< CClientFrame > m_ClientFramePool;
- CClientFrame *m_Frames; // updates can be delta'ed from here
+ CUtlMemoryPool m_ClientFramePool;
+ CClientFrame* m_Frames; // updates can be delta'ed from here
}; // sizeof 288
#endif // CLIENTFRAME_H
\ No newline at end of file
diff --git a/src/commands.cpp b/src/commands.cpp
index 6abcb3aa..69be8e1c 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -17,31 +17,30 @@
* this program. If not, see .
*/
-#include "usermessages.pb.h"
-#include "detours.h"
-#include "common.h"
-#include "utlstring.h"
-#include "recipientfilters.h"
#include "commands.h"
-#include "utils/entity.h"
+#include "adminsystem.h"
+#include "common.h"
+#include "ctimer.h"
+#include "detours.h"
+#include "discord.h"
+#include "engine/igameeventsystem.h"
#include "entity/cbaseentity.h"
-#include "entity/ccsweaponbase.h"
+#include "entity/cbasemodelentity.h"
#include "entity/ccsplayercontroller.h"
#include "entity/ccsplayerpawn.h"
-#include "entity/cbasemodelentity.h"
#include "entity/ccsweaponbase.h"
#include "entity/cparticlesystem.h"
#include "entity/lights.h"
-#include "playermanager.h"
-#include "adminsystem.h"
-#include "leader.h"
-#include "ctimer.h"
#include "httpmanager.h"
-#include "discord.h"
-#include "zombiereborn.h"
+#include "leader.h"
#include "networksystem/inetworkmessages.h"
-#include "engine/igameeventsystem.h"
+#include "playermanager.h"
+#include "recipientfilters.h"
#include "tier0/vprof.h"
+#include "usermessages.pb.h"
+#include "utils/entity.h"
+#include "utlstring.h"
+#include "zombiereborn.h"
#undef snprintf
#include "vendor/nlohmann/json.hpp"
@@ -49,8 +48,8 @@
using json = nlohmann::json;
-extern IGameEventSystem *g_gameEventSystem;
-extern CGameEntitySystem *g_pEntitySystem;
+extern IGameEventSystem* g_gameEventSystem;
+extern CGameEntitySystem* g_pEntitySystem;
extern IVEngineServer2* g_pEngineServer2;
extern ISteamHTTP* g_http;
@@ -60,6 +59,7 @@ bool g_bEnableAdminCommands;
FAKE_BOOL_CVAR(cs2f_commands_enable, "Whether to enable chat commands", g_bEnableCommands, false, 0)
FAKE_BOOL_CVAR(cs2f_admin_commands_enable, "Whether to enable admin chat commands", g_bEnableAdminCommands, false, 0)
+// clang-format off
WeaponMapEntry_t WeaponMap[] = {
{{"bizon"}, "weapon_bizon", "PP-Bizon", 1400, 26, GEAR_SLOT_RIFLE},
{{"mac10", "mac"}, "weapon_mac10", "MAC-10", 1050, 27, GEAR_SLOT_RIFLE},
@@ -99,6 +99,7 @@ WeaponMapEntry_t WeaponMap[] = {
{{"molotov"}, "weapon_molotov", "Molotov", 400, 46, GEAR_SLOT_GRENADES, 1},
{{"kevlar"}, "item_kevlar", "Kevlar Vest", 650, 50, GEAR_SLOT_UTILITY},
};
+// clang-format on
bool g_bEnableWeapons = false;
@@ -126,9 +127,9 @@ int GetGrenadeAmmo(CCSPlayer_WeaponServices* pWeaponServices, WeaponMapEntry_t w
int GetGrenadeAmmoTotal(CCSPlayer_WeaponServices* pWeaponServices)
{
- if(!pWeaponServices)
+ if (!pWeaponServices)
return -1;
-
+
int grenadeAmmoOffsets[] = {
AMMO_OFFSET_HEGRENADE,
AMMO_OFFSET_FLASHBANG,
@@ -139,10 +140,8 @@ int GetGrenadeAmmoTotal(CCSPlayer_WeaponServices* pWeaponServices)
int totalGrenades = 0;
for (int i = 0; i < (sizeof(grenadeAmmoOffsets) / sizeof(int)); i++)
- {
totalGrenades += pWeaponServices->m_iAmmo[grenadeAmmoOffsets[i]];
- }
-
+
return totalGrenades;
}
@@ -190,7 +189,7 @@ void ParseWeaponCommand(const CCommand& args, CCSPlayerController* player)
CCSPlayer_ItemServices* pItemServices = pPawn->m_pItemServices;
CCSPlayer_WeaponServices* pWeaponServices = pPawn->m_pWeaponServices;
- // it can sometimes be null when player joined on the very first round?
+ // it can sometimes be null when player joined on the very first round?
if (!pItemServices || !pWeaponServices)
return;
@@ -218,13 +217,13 @@ void ParseWeaponCommand(const CCommand& args, CCSPlayerController* player)
if (iMatchingGrenades >= iGrenadeLimitDefault)
{
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX"You cannot carry any more %ss (Max %i)", weaponEntry.szWeaponName, iGrenadeLimitDefault);
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You cannot carry any more %ss (Max %i)", weaponEntry.szWeaponName, iGrenadeLimitDefault);
return;
}
if (iTotalGrenades >= iGrenadeLimitTotal)
{
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX"You cannot carry any more grenades (Max %i)", iGrenadeLimitTotal);
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You cannot carry any more grenades (Max %i)", iGrenadeLimitTotal);
return;
}
}
@@ -316,7 +315,7 @@ void RegisterWeaponCommands()
}
}
-void ParseChatCommand(const char *pMessage, CCSPlayerController *pController)
+void ParseChatCommand(const char* pMessage, CCSPlayerController* pController)
{
if (!pController || !pController->IsConnected())
return;
@@ -333,20 +332,18 @@ void ParseChatCommand(const char *pMessage, CCSPlayerController *pController)
uint16 index = g_CommandList.Find(hash_32_fnv1a_const(name.c_str()));
if (g_CommandList.IsValidIndex(index))
- {
(*g_CommandList[index])(args, pController);
- }
}
-bool CChatCommand::CheckCommandAccess(CCSPlayerController *pPlayer, uint64 flags)
+bool CChatCommand::CheckCommandAccess(CCSPlayerController* pPlayer, uint64 flags)
{
if (!pPlayer)
return false;
int slot = pPlayer->GetPlayerSlot();
- ZEPlayer *pZEPlayer = g_playerManager->GetPlayer(slot);
-
+ ZEPlayer* pZEPlayer = g_playerManager->GetPlayer(slot);
+
if (!pZEPlayer)
return false;
@@ -377,7 +374,7 @@ bool CChatCommand::CheckCommandAccess(CCSPlayerController *pPlayer, uint64 flags
return true;
}
-void ClientPrintAll(int hud_dest, const char *msg, ...)
+void ClientPrintAll(int hud_dest, const char* msg, ...)
{
va_list args;
va_start(args, msg);
@@ -387,7 +384,7 @@ void ClientPrintAll(int hud_dest, const char *msg, ...)
va_end(args);
- INetworkMessageInternal *pNetMsg = g_pNetworkMessages->FindNetworkMessagePartial("TextMsg");
+ INetworkMessageInternal* pNetMsg = g_pNetworkMessages->FindNetworkMessagePartial("TextMsg");
auto data = pNetMsg->AllocateMessage()->ToPB();
data->set_dest(hud_dest);
@@ -403,7 +400,7 @@ void ClientPrintAll(int hud_dest, const char *msg, ...)
ConMsg("%s\n", buf);
}
-void ClientPrint(CCSPlayerController *player, int hud_dest, const char *msg, ...)
+void ClientPrint(CCSPlayerController* player, int hud_dest, const char* msg, ...)
{
va_list args;
va_start(args, msg);
@@ -419,7 +416,7 @@ void ClientPrint(CCSPlayerController *player, int hud_dest, const char *msg, ...
return;
}
- INetworkMessageInternal *pNetMsg = g_pNetworkMessages->FindNetworkMessagePartial("TextMsg");
+ INetworkMessageInternal* pNetMsg = g_pNetworkMessages->FindNetworkMessagePartial("TextMsg");
auto data = pNetMsg->AllocateMessage()->ToPB();
data->set_dest(hud_dest);
@@ -436,7 +433,6 @@ bool g_bEnableStopSound = false;
FAKE_BOOL_CVAR(cs2f_stopsound_enable, "Whether to enable stopsound", g_bEnableStopSound, false, false)
-
CON_COMMAND_CHAT(stopsound, "- Toggle weapon sounds")
{
if (!g_bEnableStopSound)
@@ -455,7 +451,8 @@ CON_COMMAND_CHAT(stopsound, "- Toggle weapon sounds")
g_playerManager->SetPlayerStopSound(iPlayer, bSilencedSet);
g_playerManager->SetPlayerSilenceSound(iPlayer, !bSilencedSet && !bStopSet);
- ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have %s weapon sounds.", bSilencedSet ? "disabled" : !bSilencedSet && !bStopSet ? "silenced" : "enabled");
+ ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have %s weapon sounds.", bSilencedSet ? "disabled" : !bSilencedSet && !bStopSet ? "silenced" :
+ "enabled");
}
CON_COMMAND_CHAT(toggledecals, "- Toggle world decals, if you're into having 10 fps in ZE")
@@ -529,7 +526,7 @@ CON_COMMAND_CHAT(hide, " - Hide nearby players")
return;
}
- ZEPlayer *pZEPlayer = player->GetZEPlayer();
+ ZEPlayer* pZEPlayer = player->GetZEPlayer();
// Something has to really go wrong for this to happen
if (!pZEPlayer)
@@ -641,7 +638,7 @@ CON_COMMAND_CHAT(spec, "[name] - Spectate another player or join spectators")
// 1 frame delay as observer services will be null on same frame as spectator team switch
CHandle hPlayer = player->GetHandle();
CHandle hTarget = pTarget->GetHandle();
- new CTimer(0.0f, false, false, [hPlayer, hTarget](){
+ new CTimer(0.0f, false, false, [hPlayer, hTarget]() {
CCSPlayerController* pPlayer = hPlayer.Get();
CCSPlayerController* pTargetPlayer = hTarget.Get();
if (!pPlayer || !pTargetPlayer)
@@ -691,7 +688,7 @@ CON_COMMAND_CHAT(info, " - Get a player's information")
{
CCSPlayerController* pTarget = CCSPlayerController::FromSlot(pSlots[i]);
ZEPlayer* zpTarget = pTarget->GetZEPlayer();
-
+
ClientPrint(player, HUD_PRINTCONSOLE, "%s", pTarget->GetPlayerName());
ClientPrint(player, HUD_PRINTCONSOLE, "\tUser ID: %i", g_pEngineServer2->GetPlayerUserId(pTarget->GetPlayerSlot()).Get());
@@ -766,7 +763,7 @@ CON_COMMAND_CHAT(fl, "- Flashlight")
if (!player)
return;
- CCSPlayerPawn *pPawn = (CCSPlayerPawn *)player->GetPawn();
+ CCSPlayerPawn* pPawn = (CCSPlayerPawn*)player->GetPawn();
auto ptr = pPawn->m_pMovementServices->m_nButtons().m_pButtonStates();
@@ -777,7 +774,7 @@ CON_COMMAND_CHAT(fl, "- Flashlight")
origin.z += 64.0f;
origin += forward * 54.0f; // The minimum distance such that an awp wouldn't block the light
- CBarnLight *pLight = CreateEntityByName("light_barn");
+ CBarnLight* pLight = CreateEntityByName("light_barn");
pLight->m_bEnabled = true;
pLight->m_Color->SetColor(255, 255, 255, 255);
@@ -793,7 +790,7 @@ CON_COMMAND_CHAT(fl, "- Flashlight")
pLight->Teleport(&origin, &pPawn->m_angEyeAngles(), nullptr);
// Have to use keyvalues for this since the schema prop is a resource handle
- CEntityKeyValues *pKeyValues = new CEntityKeyValues();
+ CEntityKeyValues* pKeyValues = new CEntityKeyValues();
pKeyValues->SetString("lightcookie", "materials/effects/lightcookies/flashlight.vtex");
pLight->DispatchSpawn(pKeyValues);
@@ -822,7 +819,6 @@ CON_COMMAND_CHAT(test_target, " [blocked flag] [...] - Test string targett
uint64 iBlockedFlags = NO_TARGET_BLOCKS;
for (int i = 1; i < args.ArgC(); i++)
- {
if (!V_stricmp(args[i], "NO_RANDOM"))
iBlockedFlags |= NO_RANDOM;
else if (!V_stricmp(args[i], "NO_MULTIPLE"))
@@ -847,7 +843,6 @@ CON_COMMAND_CHAT(test_target, " [blocked flag] [...] - Test string targett
iBlockedFlags |= NO_SPECTATOR;
else if (!V_stricmp(args[i], "NO_IMMUNITY"))
iBlockedFlags |= NO_IMMUNITY;
- }
int iNumClients = 0;
int pSlots[MAXPLAYERS];
@@ -871,7 +866,7 @@ CON_COMMAND_CHAT(particle, "- Spawn a particle")
Vector vecAbsOrigin = player->GetPawn()->GetAbsOrigin();
vecAbsOrigin.z += 64.0f;
- CParticleSystem *particle = CreateEntityByName("info_particle_system");
+ CParticleSystem* particle = CreateEntityByName("info_particle_system");
particle->m_bStartActive(true);
particle->m_iszEffectName(args[1]);
@@ -891,9 +886,9 @@ CON_COMMAND_CHAT(particle_kv, "- Spawn a particle but using keyvalues to spawn")
Vector vecAbsOrigin = player->GetPawn()->GetAbsOrigin();
vecAbsOrigin.z += 64.0f;
- CParticleSystem *particle = CreateEntityByName("info_particle_system");
+ CParticleSystem* particle = CreateEntityByName("info_particle_system");
- CEntityKeyValues *pKeyValues = new CEntityKeyValues();
+ CEntityKeyValues* pKeyValues = new CEntityKeyValues();
pKeyValues->SetString("effect_name", args[1]);
pKeyValues->SetBool("start_active", true);
@@ -921,7 +916,7 @@ CON_COMMAND_CHAT(emitsound, "- Emit a sound from the entity under crosshair")
if (!player)
return;
- CBaseEntity *pEntity = UTIL_FindPickerEntity(player);
+ CBaseEntity* pEntity = UTIL_FindPickerEntity(player);
if (!pEntity)
{
@@ -940,14 +935,14 @@ CON_COMMAND_CHAT(getstats, "- Get your stats")
if (!player)
return;
- CSMatchStats_t *stats = &player->m_pActionTrackingServices->m_matchStats();
+ CSMatchStats_t* stats = &player->m_pActionTrackingServices->m_matchStats();
- ClientPrint(player, HUD_PRINTCENTER,
- "Kills: %i\n"
- "Deaths: %i\n"
- "Assists: %i\n"
- "Damage: %i"
- , stats->m_iKills.Get(), stats->m_iDeaths.Get(), stats->m_iAssists.Get(), stats->m_iDamage.Get());
+ ClientPrint(player, HUD_PRINTCENTER,
+ "Kills: %i\n"
+ "Deaths: %i\n"
+ "Assists: %i\n"
+ "Damage: %i",
+ stats->m_iKills.Get(), stats->m_iDeaths.Get(), stats->m_iAssists.Get(), stats->m_iDamage.Get());
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Kills: %d", stats->m_iKills.Get());
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Deaths: %d", stats->m_iDeaths.Get());
diff --git a/src/commands.h b/src/commands.h
index d1d80962..1959e750 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -18,19 +18,19 @@
*/
#pragma once
-#include "entity/ccsplayercontroller.h"
-#include "convar.h"
#include "adminsystem.h"
+#include "convar.h"
+#include "entity/ccsplayercontroller.h"
#include "leader.h"
#include
-#define CMDFLAG_NONE (0)
-#define CMDFLAG_NOHELP (1 << 0) // Don't show in !help menu
+#define CMDFLAG_NONE (0)
+#define CMDFLAG_NOHELP (1 << 0) // Don't show in !help menu
#define COMMAND_PREFIX "c_"
-#define CHAT_PREFIX " \7[CS2Fixes]\1 "
+#define CHAT_PREFIX " \7[CS2Fixes]\1 "
-typedef void (*FnChatCommandCallback_t)(const CCommand &args, CCSPlayerController *player);
+typedef void (*FnChatCommandCallback_t)(const CCommand& args, CCSPlayerController* player);
class CChatCommand;
@@ -44,21 +44,20 @@ extern bool g_bEnableStopSound;
extern bool g_bEnableNoShake;
extern float g_flMaxShakeAmp;
-
-void ClientPrintAll(int destination, const char *msg, ...);
-void ClientPrint(CCSPlayerController *player, int destination, const char *msg, ...);
+void ClientPrintAll(int destination, const char* msg, ...);
+void ClientPrint(CCSPlayerController* player, int destination, const char* msg, ...);
// Just a wrapper class so we're able to insert the callback
class CChatCommand
{
public:
- CChatCommand(const char *cmd, FnChatCommandCallback_t callback, const char *description, uint64 adminFlags = ADMFLAG_NONE, uint64 cmdFlags = CMDFLAG_NONE) :
+ CChatCommand(const char* cmd, FnChatCommandCallback_t callback, const char* description, uint64 adminFlags = ADMFLAG_NONE, uint64 cmdFlags = CMDFLAG_NONE) :
m_pfnCallback(callback), m_sName(cmd), m_sDescription(description), m_nAdminFlags(adminFlags), m_nCmdFlags(cmdFlags)
{
g_CommandList.Insert(hash_32_fnv1a_const(cmd), this);
}
- void operator()(const CCommand &args, CCSPlayerController *player)
+ void operator()(const CCommand& args, CCSPlayerController* player)
{
// Server disabled ALL chat commands
if (!g_bEnableCommands)
@@ -79,7 +78,7 @@ class CChatCommand
m_pfnCallback(args, player);
}
- static bool CheckCommandAccess(CCSPlayerController *pPlayer, uint64 flags);
+ static bool CheckCommandAccess(CCSPlayerController* pPlayer, uint64 flags);
const char* GetName() { return m_sName.c_str(); }
const char* GetDescription() { return m_sDescription.c_str(); }
@@ -109,23 +108,23 @@ struct WeaponMapEntry_t
};
void RegisterWeaponCommands();
-void ParseChatCommand(const char *, CCSPlayerController *);
-
-#define CON_COMMAND_CHAT_FLAGS(name, description, flags) \
- void name##_callback(const CCommand &args, CCSPlayerController *player); \
- static CChatCommand name##_chat_command(#name, name##_callback, description, flags); \
- static void name##_con_callback(const CCommandContext &context, const CCommand &args) \
- { \
- CCSPlayerController *pController = nullptr; \
- if (context.GetPlayerSlot().Get() != -1) \
- pController = (CCSPlayerController *)g_pEntitySystem->GetEntityInstance((CEntityIndex)(context.GetPlayerSlot().Get() + 1)); \
- \
- name##_chat_command(args, pController); \
- } \
- static ConCommandRefAbstract name##_ref; \
- static ConCommand name##_command(&name##_ref, COMMAND_PREFIX #name, name##_con_callback, \
- description, FCVAR_CLIENT_CAN_EXECUTE | FCVAR_LINKED_CONCOMMAND); \
- void name##_callback(const CCommand &args, CCSPlayerController *player)
+void ParseChatCommand(const char*, CCSPlayerController*);
+
+#define CON_COMMAND_CHAT_FLAGS(name, description, flags) \
+ void name##_callback(const CCommand& args, CCSPlayerController* player); \
+ static CChatCommand name##_chat_command(#name, name##_callback, description, flags); \
+ static void name##_con_callback(const CCommandContext& context, const CCommand& args) \
+ { \
+ CCSPlayerController* pController = nullptr; \
+ if (context.GetPlayerSlot().Get() != -1) \
+ pController = (CCSPlayerController*)g_pEntitySystem->GetEntityInstance((CEntityIndex)(context.GetPlayerSlot().Get() + 1)); \
+ \
+ name##_chat_command(args, pController); \
+ } \
+ static ConCommandRefAbstract name##_ref; \
+ static ConCommand name##_command(&name##_ref, COMMAND_PREFIX #name, name##_con_callback, \
+ description, FCVAR_CLIENT_CAN_EXECUTE | FCVAR_LINKED_CONCOMMAND); \
+ void name##_callback(const CCommand& args, CCSPlayerController* player)
#define CON_COMMAND_CHAT(name, description) CON_COMMAND_CHAT_FLAGS(name, description, ADMFLAG_NONE)
#define CON_COMMAND_CHAT_LEADER(name, description) CON_COMMAND_CHAT_FLAGS(name, description, FLAG_LEADER)
diff --git a/src/common.h b/src/common.h
index b0206184..9f488713 100644
--- a/src/common.h
+++ b/src/common.h
@@ -23,69 +23,69 @@
#define VPROF_LEVEL 1
-#define CS_TEAM_NONE 0
-#define CS_TEAM_SPECTATOR 1
-#define CS_TEAM_T 2
-#define CS_TEAM_CT 3
+#define CS_TEAM_NONE 0
+#define CS_TEAM_SPECTATOR 1
+#define CS_TEAM_T 2
+#define CS_TEAM_CT 3
-#define HUD_PRINTNOTIFY 1
-#define HUD_PRINTCONSOLE 2
-#define HUD_PRINTTALK 3
-#define HUD_PRINTCENTER 4
+#define HUD_PRINTNOTIFY 1
+#define HUD_PRINTCONSOLE 2
+#define HUD_PRINTTALK 3
+#define HUD_PRINTCENTER 4
#define MAXPLAYERS 64
#ifdef _WIN32
-#define ROOTBIN "/bin/win64/"
-#define GAMEBIN "/csgo/bin/win64/"
+ #define ROOTBIN "/bin/win64/"
+ #define GAMEBIN "/csgo/bin/win64/"
#else
-#define ROOTBIN "/bin/linuxsteamrt64/"
-#define GAMEBIN "/csgo/bin/linuxsteamrt64/"
+ #define ROOTBIN "/bin/linuxsteamrt64/"
+ #define GAMEBIN "/csgo/bin/linuxsteamrt64/"
#endif
void UnlockConVars();
void UnlockConCommands();
-void Message(const char *, ...);
-void Panic(const char *, ...);
+void Message(const char*, ...);
+void Panic(const char*, ...);
// CONVAR_TODO
// Need to replace with actual cvars once available in SDK
-#define FAKE_CVAR(name, description, variable_name, variable_type, variable_type_format, variable_default, protect) \
- CON_COMMAND_F(name, description, FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY | (protect ? FCVAR_PROTECTED : FCVAR_NONE)) \
- { \
- if (args.ArgC() < 2) \
- Msg("%s " #variable_type_format "\n", args[0], variable_name); \
- else \
- variable_name = V_StringTo##variable_type(args[1], variable_default); \
+#define FAKE_CVAR(name, description, variable_name, variable_type, variable_type_format, variable_default, protect) \
+ CON_COMMAND_F(name, description, FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY | (protect ? FCVAR_PROTECTED : FCVAR_NONE)) \
+ { \
+ if (args.ArgC() < 2) \
+ Msg("%s " #variable_type_format "\n", args[0], variable_name); \
+ else \
+ variable_name = V_StringTo##variable_type(args[1], variable_default); \
}
-#define FAKE_INT_CVAR(name, description, variable_name, variable_default, protect) \
- FAKE_CVAR(name, description, variable_name, Int32, %i, variable_default, protect)
+#define FAKE_INT_CVAR(name, description, variable_name, variable_default, protect) \
+ FAKE_CVAR(name, description, variable_name, Int32, % i, variable_default, protect)
-#define FAKE_BOOL_CVAR(name, description, variable_name, variable_default, protect) \
- FAKE_CVAR(name, description, variable_name, Bool, %i, variable_default, protect)
+#define FAKE_BOOL_CVAR(name, description, variable_name, variable_default, protect) \
+ FAKE_CVAR(name, description, variable_name, Bool, % i, variable_default, protect)
-#define FAKE_FLOAT_CVAR(name, description, variable_name, variable_default, protect) \
- FAKE_CVAR(name, description, variable_name, Float32, %f, variable_default, protect)
+#define FAKE_FLOAT_CVAR(name, description, variable_name, variable_default, protect) \
+ FAKE_CVAR(name, description, variable_name, Float32, % f, variable_default, protect)
// assumes std::string variable
-#define FAKE_STRING_CVAR(name, description, variable_name, protect) \
- CON_COMMAND_F(name, description, FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY | (protect ? FCVAR_PROTECTED : FCVAR_NONE)) \
- { \
- if (args.ArgC() < 2) \
- Msg("%s %s\n", args[0], variable_name.c_str()); \
- else \
- variable_name = args[1]; \
+#define FAKE_STRING_CVAR(name, description, variable_name, protect) \
+ CON_COMMAND_F(name, description, FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY | (protect ? FCVAR_PROTECTED : FCVAR_NONE)) \
+ { \
+ if (args.ArgC() < 2) \
+ Msg("%s %s\n", args[0], variable_name.c_str()); \
+ else \
+ variable_name = args[1]; \
}
-#define FAKE_COLOR_CVAR(name, description, variable_name, protect) \
- CON_COMMAND_F(name, description, FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY | (protect ? FCVAR_PROTECTED : FCVAR_NONE)) \
- { \
- if (args.ArgC() < 2) \
- Msg("%s %i %i %i\n", args[0], variable_name[0], variable_name[1], variable_name[2]); \
- else if (args.ArgC() == 2) \
- V_StringToColor(args[1], variable_name); \
- else \
- V_StringToColor(args.ArgS(), variable_name); \
+#define FAKE_COLOR_CVAR(name, description, variable_name, protect) \
+ CON_COMMAND_F(name, description, FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY | (protect ? FCVAR_PROTECTED : FCVAR_NONE)) \
+ { \
+ if (args.ArgC() < 2) \
+ Msg("%s %i %i %i\n", args[0], variable_name[0], variable_name[1], variable_name[2]); \
+ else if (args.ArgC() == 2) \
+ V_StringToColor(args[1], variable_name); \
+ else \
+ V_StringToColor(args.ArgS(), variable_name); \
}
\ No newline at end of file
diff --git a/src/cs2_sdk/entity/cbaseentity.h b/src/cs2_sdk/entity/cbaseentity.h
index 0bb40b39..8faf928d 100644
--- a/src/cs2_sdk/entity/cbaseentity.h
+++ b/src/cs2_sdk/entity/cbaseentity.h
@@ -19,18 +19,18 @@
#pragma once
-#include "schema.h"
+#include "../../gameconfig.h"
+#include "../detours.h"
#include "ccollisionproperty.h"
-#include "globaltypes.h"
#include "ctakedamageinfo.h"
-#include "mathlib/vector.h"
#include "ehandle.h"
-#include "../detours.h"
#include "entitykeyvalues.h"
-#include "../../gameconfig.h"
+#include "globaltypes.h"
+#include "mathlib/vector.h"
+#include "schema.h"
#include "tier1/utlstringtoken.h"
-extern CGameConfig *g_GameConfig;
+extern CGameConfig* g_GameConfig;
class CGameUI;
class CEnvHudHint;
@@ -41,9 +41,9 @@ class CGameSceneNode
public:
DECLARE_SCHEMA_CLASS(CGameSceneNode)
- SCHEMA_FIELD(CEntityInstance *, m_pOwner)
- SCHEMA_FIELD(CGameSceneNode *, m_pParent)
- SCHEMA_FIELD(CGameSceneNode *, m_pChild)
+ SCHEMA_FIELD(CEntityInstance*, m_pOwner)
+ SCHEMA_FIELD(CGameSceneNode*, m_pParent)
+ SCHEMA_FIELD(CGameSceneNode*, m_pChild)
SCHEMA_FIELD(CNetworkOriginCellCoordQuantizedVector, m_vecOrigin)
SCHEMA_FIELD(QAngle, m_angRotation)
SCHEMA_FIELD(float, m_flScale)
@@ -57,7 +57,7 @@ class CGameSceneNode
matrix3x4_t mat;
// issues with this and im tired so hardcoded it
- //AngleMatrix(this->m_angAbsRotation(), this->m_vecAbsOrigin(), mat);
+ // AngleMatrix(this->m_angAbsRotation(), this->m_vecAbsOrigin(), mat);
QAngle angles = this->m_angAbsRotation();
float sr, sp, sy, cr, cp, cy;
@@ -94,7 +94,7 @@ class CBodyComponent
public:
DECLARE_SCHEMA_CLASS(CBodyComponent)
- SCHEMA_FIELD(CGameSceneNode *, m_pSceneNode)
+ SCHEMA_FIELD(CGameSceneNode*, m_pSceneNode)
};
class CModelState
@@ -124,7 +124,7 @@ class CBaseEntity : public CEntityInstance
public:
DECLARE_SCHEMA_CLASS(CBaseEntity)
- SCHEMA_FIELD(CBodyComponent *, m_CBodyComponent)
+ SCHEMA_FIELD(CBodyComponent*, m_CBodyComponent)
SCHEMA_FIELD(CBitVec<64>, m_isSteadyState)
SCHEMA_FIELD(float, m_lastNetworkChange)
SCHEMA_FIELD_POINTER(CNetworkTransmitComponent, m_NetworkTransmitComponent)
@@ -164,17 +164,17 @@ class CBaseEntity : public CEntityInstance
void SetAbsVelocity(Vector vecVelocity) { m_vecAbsVelocity = vecVelocity; }
void SetBaseVelocity(Vector vecVelocity) { m_vecBaseVelocity = vecVelocity; }
- void SetName(const char *pName)
+ void SetName(const char* pName)
{
addresses::CEntityIdentity_SetEntityName(m_pEntity, pName);
}
- void TakeDamage(CTakeDamageInfo &info)
+ void TakeDamage(CTakeDamageInfo& info)
{
Detour_CBaseEntity_TakeDamageOld(this, &info);
}
- void Teleport(const Vector *position, const QAngle *angles, const Vector *velocity)
+ void Teleport(const Vector* position, const QAngle* angles, const Vector* velocity)
{
static int offset = g_GameConfig->GetOffset("Teleport");
CALL_VIRTUAL(void, offset, this, position, angles, velocity);
@@ -207,7 +207,7 @@ class CBaseEntity : public CEntityInstance
return CALL_VIRTUAL(bool, offset, this);
}
- void AcceptInput(const char *pInputName, variant_t value = variant_t(""), CEntityInstance *pActivator = nullptr, CEntityInstance *pCaller = nullptr)
+ void AcceptInput(const char* pInputName, variant_t value = variant_t(""), CEntityInstance* pActivator = nullptr, CEntityInstance* pCaller = nullptr)
{
addresses::CEntityInstance_AcceptInput(this, pInputName, pActivator, pCaller, &value, 0);
}
@@ -219,18 +219,18 @@ class CBaseEntity : public CEntityInstance
// A double pointer to entity VData is available 4 bytes past m_nSubclassID, if applicable
CEntitySubclassVDataBase* GetVData() { return *(CEntitySubclassVDataBase**)((uint8*)(m_nSubclassID()) + 4); }
- void DispatchSpawn(CEntityKeyValues *pEntityKeyValues = nullptr)
+ void DispatchSpawn(CEntityKeyValues* pEntityKeyValues = nullptr)
{
addresses::DispatchSpawn(this, pEntityKeyValues);
}
// Emit a sound event
- void EmitSound(const char *pszSound, int nPitch = 100, float flVolume = 1.0, float flDelay = 0.0)
+ void EmitSound(const char* pszSound, int nPitch = 100, float flVolume = 1.0, float flDelay = 0.0)
{
addresses::CBaseEntity_EmitSoundParams(this, pszSound, nPitch, flVolume, flDelay);
}
- SndOpEventGuid_t EmitSoundFilter(IRecipientFilter &filter, const char *pszSound, float flVolume = 1.0, float flPitch = 1.0)
+ SndOpEventGuid_t EmitSoundFilter(IRecipientFilter& filter, const char* pszSound, float flVolume = 1.0, float flPitch = 1.0)
{
EmitSound_t params;
params.m_pSoundName = pszSound;
@@ -240,14 +240,14 @@ class CBaseEntity : public CEntityInstance
return addresses::CBaseEntity_EmitSoundFilter(filter, entindex(), params);
}
- void DispatchParticle(const char *pszParticleName, IRecipientFilter *pFilter, ParticleAttachment_t nAttachType = PATTACH_POINT_FOLLOW,
- char iAttachmentPoint = 0, CUtlSymbolLarge iAttachmentName = "")
+ void DispatchParticle(const char* pszParticleName, IRecipientFilter* pFilter, ParticleAttachment_t nAttachType = PATTACH_POINT_FOLLOW,
+ char iAttachmentPoint = 0, CUtlSymbolLarge iAttachmentName = "")
{
addresses::DispatchParticleEffect(pszParticleName, nAttachType, this, iAttachmentPoint, iAttachmentName, false, 0, pFilter, 0);
}
// This was needed so we can parent to nameless entities using pointers
- void SetParent(CBaseEntity *pNewParent)
+ void SetParent(CBaseEntity* pNewParent)
{
addresses::CBaseEntity_SetParent(this, pNewParent, MakeStringToken(""), nullptr);
}
@@ -262,7 +262,7 @@ class CBaseEntity : public CEntityInstance
addresses::CBaseEntity_SetMoveType(this, nMoveType, m_MoveCollide);
}
- void SetGroundEntity(CBaseEntity *pGround)
+ void SetGroundEntity(CBaseEntity* pGround)
{
addresses::SetGroundEntity(this, pGround, nullptr);
}
@@ -271,7 +271,7 @@ class CBaseEntity : public CEntityInstance
/* Begin Custom Entities Cast */
- [[nodiscard]] CGameUI *AsGameUI()
+ [[nodiscard]] CGameUI* AsGameUI()
{
if (V_strcasecmp(GetClassname(), "logic_case") != 0)
return nullptr;
@@ -279,20 +279,20 @@ class CBaseEntity : public CEntityInstance
const auto tag = m_iszPrivateVScripts.IsValid() ? m_iszPrivateVScripts.String() : nullptr;
if (tag && V_strcasecmp(tag, "game_ui") == 0)
- return reinterpret_cast(this);
+ return reinterpret_cast(this);
return nullptr;
}
- [[nodiscard]] CEnvHudHint *AsHudHint()
+ [[nodiscard]] CEnvHudHint* AsHudHint()
{
if (V_strcasecmp(GetClassname(), "env_hudhint") == 0)
- return reinterpret_cast(this);
+ return reinterpret_cast(this);
return nullptr;
}
- [[nodiscard]] CPointViewControl *AsPointViewControl()
+ [[nodiscard]] CPointViewControl* AsPointViewControl()
{
if (V_strcasecmp(GetClassname(), "logic_relay") != 0)
return nullptr;
@@ -300,7 +300,7 @@ class CBaseEntity : public CEntityInstance
const auto tag = m_iszPrivateVScripts.IsValid() ? m_iszPrivateVScripts.String() : nullptr;
if (tag && V_strcasecmp(tag, "point_viewcontrol") == 0)
- return reinterpret_cast(this);
+ return reinterpret_cast(this);
return nullptr;
}
diff --git a/src/cs2_sdk/entity/cbasemodelentity.h b/src/cs2_sdk/entity/cbasemodelentity.h
index 74ab7635..1c291e9f 100644
--- a/src/cs2_sdk/entity/cbasemodelentity.h
+++ b/src/cs2_sdk/entity/cbasemodelentity.h
@@ -34,7 +34,7 @@ class CBaseModelEntity : public CBaseEntity
SCHEMA_FIELD(float, m_flDissolveStartTime)
SCHEMA_FIELD(Vector, m_vecViewOffset)
- void SetModel(const char *szModel)
+ void SetModel(const char* szModel)
{
addresses::CBaseModelEntity_SetModel(this, szModel);
}
@@ -44,7 +44,7 @@ class CBaseModelEntity : public CBaseEntity
m_Collision().m_CollisionGroup = static_cast(nCollisionGroup);
CollisionRulesChanged();
}
-
+
const char* GetModelName()
{
return ((CSkeletonInstance*)m_CBodyComponent->m_pSceneNode.Get())->m_modelState().m_ModelName.Get().String();
diff --git a/src/cs2_sdk/entity/cbaseplayercontroller.h b/src/cs2_sdk/entity/cbaseplayercontroller.h
index f8610cfa..d89afdda 100644
--- a/src/cs2_sdk/entity/cbaseplayercontroller.h
+++ b/src/cs2_sdk/entity/cbaseplayercontroller.h
@@ -19,9 +19,9 @@
#pragma once
-#include "ehandle.h"
#include "cbaseentity.h"
#include "ccsplayerpawn.h"
+#include "ehandle.h"
enum class PlayerConnectedState : uint32_t
{
@@ -50,8 +50,8 @@ class CBasePlayerController : public CBaseEntity
// - The player's actual pawn
// - An observer pawn if spectating
// - A bot pawn if controlling one
- CBasePlayerPawn *GetPawn() { return m_hPawn.Get(); }
- const char *GetPlayerName() { return m_iszPlayerName(); }
+ CBasePlayerPawn* GetPawn() { return m_hPawn.Get(); }
+ const char* GetPlayerName() { return m_iszPlayerName(); }
int GetPlayerSlot() { return entindex() - 1; }
bool IsConnected() { return m_iConnected() == PlayerConnectedState::PlayerConnected; }
void SetPawn(CCSPlayerPawn* pawn)
diff --git a/src/cs2_sdk/entity/cbaseplayerpawn.h b/src/cs2_sdk/entity/cbaseplayerpawn.h
index 5341beed..34a50896 100644
--- a/src/cs2_sdk/entity/cbaseplayerpawn.h
+++ b/src/cs2_sdk/entity/cbaseplayerpawn.h
@@ -70,5 +70,5 @@ class CBasePlayerPawn : public CBaseModelEntity
CALL_VIRTUAL(void, offset, this, bExplode, bForce);
}
- CBasePlayerController *GetController() { return m_hController.Get(); }
+ CBasePlayerController* GetController() { return m_hController.Get(); }
};
\ No newline at end of file
diff --git a/src/cs2_sdk/entity/cbasetrigger.h b/src/cs2_sdk/entity/cbasetrigger.h
index de942bff..d9528596 100644
--- a/src/cs2_sdk/entity/cbasetrigger.h
+++ b/src/cs2_sdk/entity/cbasetrigger.h
@@ -19,8 +19,8 @@
#pragma once
+#include "../schema.h"
#include "cbasemodelentity.h"
-#include"../schema.h"
#define SF_TRIG_PUSH_ONCE 0x80
@@ -34,7 +34,7 @@ class CBaseTrigger : public CBaseModelEntity
SCHEMA_FIELD_POINTER(CUtlVector>, m_hTouchingEntities)
SCHEMA_FIELD(bool, m_bClientSidePredicted)
- bool PassesTriggerFilters(CBaseEntity *pOther)
+ bool PassesTriggerFilters(CBaseEntity* pOther)
{
static int offset = g_GameConfig->GetOffset("PassesTriggerFilters");
return CALL_VIRTUAL(bool, offset, this, pOther);
diff --git a/src/cs2_sdk/entity/ccollisionproperty.h b/src/cs2_sdk/entity/ccollisionproperty.h
index a21f5d6c..9e418f1a 100644
--- a/src/cs2_sdk/entity/ccollisionproperty.h
+++ b/src/cs2_sdk/entity/ccollisionproperty.h
@@ -19,7 +19,7 @@
#pragma once
-#include "cbaseentity.h"
+#include "schema.h"
struct VPhysicsCollisionAttribute_t
{
diff --git a/src/cs2_sdk/entity/ccsplayercontroller.h b/src/cs2_sdk/entity/ccsplayercontroller.h
index 93a0f57b..ee01df9d 100644
--- a/src/cs2_sdk/entity/ccsplayercontroller.h
+++ b/src/cs2_sdk/entity/ccsplayercontroller.h
@@ -19,12 +19,12 @@
#pragma once
-#include "cbaseplayercontroller.h"
-#include "services.h"
#include "../playermanager.h"
#include "../serversideclient.h"
+#include "cbaseplayercontroller.h"
+#include "services.h"
-extern CServerSideClient *GetClientBySlot(CPlayerSlot slot);
+extern CServerSideClient* GetClientBySlot(CPlayerSlot slot);
extern CGameEntitySystem* g_pEntitySystem;
@@ -63,7 +63,7 @@ class CCSPlayerController : public CBasePlayerController
}
// Returns the actual player pawn
- CCSPlayerPawn *GetPlayerPawn()
+ CCSPlayerPawn* GetPlayerPawn()
{
return m_hPlayerPawn().Get();
}
@@ -73,7 +73,7 @@ class CCSPlayerController : public CBasePlayerController
return g_playerManager->GetPlayer(GetPlayerSlot());
}
- CServerSideClient *GetServerSideClient()
+ CServerSideClient* GetServerSideClient()
{
return GetClientBySlot(GetPlayerSlot());
}
@@ -95,18 +95,14 @@ class CCSPlayerController : public CBasePlayerController
return;
if (iTeam == CS_TEAM_SPECTATOR)
- {
ChangeTeam(iTeam);
- }
else
- {
addresses::CCSPlayerController_SwitchTeam(this, iTeam);
- }
}
void Respawn()
{
- CCSPlayerPawn *pPawn = GetPlayerPawn();
+ CCSPlayerPawn* pPawn = GetPlayerPawn();
if (!pPawn || pPawn->IsAlive())
return;
@@ -118,7 +114,7 @@ class CCSPlayerController : public CBasePlayerController
CSPlayerState GetPawnState()
{
// All CS2 pawns are derived from this
- CCSPlayerPawnBase *pPawn = (CCSPlayerPawnBase*)GetPawn();
+ CCSPlayerPawnBase* pPawn = (CCSPlayerPawnBase*)GetPawn();
// The player is still joining so their pawn doesn't exist yet, and STATE_WELCOME is what they start with
if (!pPawn)
@@ -129,7 +125,7 @@ class CCSPlayerController : public CBasePlayerController
CSPlayerState GetPlayerPawnState()
{
- CCSPlayerPawn *pPawn = GetPlayerPawn();
+ CCSPlayerPawn* pPawn = GetPlayerPawn();
// The player is still joining so their pawn doesn't exist yet, and STATE_WELCOME is what they start with
if (!pPawn)
@@ -138,7 +134,7 @@ class CCSPlayerController : public CBasePlayerController
return pPawn->m_iPlayerState();
}
- CBaseEntity *GetObserverTarget()
+ CBaseEntity* GetObserverTarget()
{
auto pPawn = GetPawn();
diff --git a/src/cs2_sdk/entity/ccsplayerpawn.h b/src/cs2_sdk/entity/ccsplayerpawn.h
index 6b6b6a0f..88ab8b54 100644
--- a/src/cs2_sdk/entity/ccsplayerpawn.h
+++ b/src/cs2_sdk/entity/ccsplayerpawn.h
@@ -35,7 +35,6 @@ enum CSPlayerState
NUM_PLAYER_STATES = 0x9,
};
-
class CCSPlayerPawnBase : public CBasePlayerPawn
{
public:
@@ -44,7 +43,7 @@ class CCSPlayerPawnBase : public CBasePlayerPawn
SCHEMA_FIELD(CSPlayerState, m_iPlayerState)
SCHEMA_FIELD(CHandle, m_hOriginalController)
- CCSPlayerController *GetOriginalController()
+ CCSPlayerController* GetOriginalController()
{
return m_hOriginalController().Get();
}
diff --git a/src/cs2_sdk/entity/cenventitymaker.h b/src/cs2_sdk/entity/cenventitymaker.h
index 9858ee74..5c96b4f8 100644
--- a/src/cs2_sdk/entity/cenventitymaker.h
+++ b/src/cs2_sdk/entity/cenventitymaker.h
@@ -19,8 +19,8 @@
#pragma once
+#include "../schema.h"
#include "cbaseentity.h"
-#include"../schema.h"
#define SF_TRIG_PUSH_ONCE 0x80
diff --git a/src/cs2_sdk/entity/cenvhudhint.h b/src/cs2_sdk/entity/cenvhudhint.h
index 1993bc0c..0a4f5df7 100644
--- a/src/cs2_sdk/entity/cenvhudhint.h
+++ b/src/cs2_sdk/entity/cenvhudhint.h
@@ -25,7 +25,7 @@
class CEnvHudHint : public CBaseEntity
{
public:
- DECLARE_SCHEMA_CLASS(CEnvHudHint)
+ DECLARE_SCHEMA_CLASS(CEnvHudHint)
- SCHEMA_FIELD(CUtlSymbolLarge, m_iszMessage)
+ SCHEMA_FIELD(CUtlSymbolLarge, m_iszMessage)
};
diff --git a/src/cs2_sdk/entity/cgameplayerequip.h b/src/cs2_sdk/entity/cgameplayerequip.h
index f97ec385..7097a644 100644
--- a/src/cs2_sdk/entity/cgameplayerequip.h
+++ b/src/cs2_sdk/entity/cgameplayerequip.h
@@ -26,13 +26,12 @@ class CGamePlayerEquip : public CBaseEntity
{
DECLARE_SCHEMA_CLASS(CGamePlayerEquip)
public:
+ static constexpr int MAX_EQUIPMENTS_SIZE = 32;
- static constexpr int MAX_EQUIPMENTS_SIZE = 32;
+ static constexpr int SF_PLAYEREQUIP_USEONLY = 0x0001;
+ static constexpr int SF_PLAYEREQUIP_STRIPFIRST = 0x0002;
- static constexpr int SF_PLAYEREQUIP_USEONLY = 0x0001;
- static constexpr int SF_PLAYEREQUIP_STRIPFIRST = 0x0002;
-
- // TODO this flag copied from CSGO, and impl on FyS server. but CS2Fixes not support aws currently.
- // Add it in the future.
- static constexpr int SF_PLAYEREQUIP_ONLYSTRIPSAME = 0x0004;
+ // TODO this flag copied from CSGO, and impl on FyS server. but CS2Fixes not support aws currently.
+ // Add it in the future.
+ static constexpr int SF_PLAYEREQUIP_ONLYSTRIPSAME = 0x0004;
};
\ No newline at end of file
diff --git a/src/cs2_sdk/entity/cgamerules.h b/src/cs2_sdk/entity/cgamerules.h
index 61c25a63..edb40f8e 100644
--- a/src/cs2_sdk/entity/cgamerules.h
+++ b/src/cs2_sdk/entity/cgamerules.h
@@ -18,9 +18,9 @@
*/
#pragma once
-#include
-#include "globaltypes.h"
#include "cbaseentity.h"
+#include "globaltypes.h"
+#include
enum CSRoundEndReason
{
@@ -40,10 +40,10 @@ enum CSRoundEndReason
TerroristsNotEscaped, /**< Terrorists have not escaped! */
VIPNotEscaped, /**< VIP has not escaped! - Doesn't exist on CS:GO */
GameStart, /**< Game Commencing! */
- TerroristsSurrender, /**< Terrorists Surrender */
- CTSurrender, /**< CTs Surrender */
- TerroristsPlanted, /**< Terrorists Planted the bomb */
- CTsReachedHostage, /**< CTs Reached the hostage */
+ TerroristsSurrender, /**< Terrorists Surrender */
+ CTSurrender, /**< CTs Surrender */
+ TerroristsPlanted, /**< Terrorists Planted the bomb */
+ CTsReachedHostage, /**< CTs Reached the hostage */
SurvivalWin,
SurvivalDraw
};
@@ -82,5 +82,5 @@ class CCSGameRulesProxy : public CBaseEntity
public:
DECLARE_SCHEMA_CLASS(CCSGameRulesProxy)
- SCHEMA_FIELD(CCSGameRules *, m_pGameRules)
+ SCHEMA_FIELD(CCSGameRules*, m_pGameRules)
};
\ No newline at end of file
diff --git a/src/cs2_sdk/entity/clogiccase.h b/src/cs2_sdk/entity/clogiccase.h
index 80b60736..c7c20e9d 100644
--- a/src/cs2_sdk/entity/clogiccase.h
+++ b/src/cs2_sdk/entity/clogiccase.h
@@ -25,18 +25,18 @@
class CLogicCase : public CBaseEntity
{
public:
- DECLARE_SCHEMA_CLASS(CLogicCase)
+ DECLARE_SCHEMA_CLASS(CLogicCase)
};
class CGameUI : public CLogicCase
{
public:
- static constexpr int SF_GAMEUI_FREEZE_PLAYER = 32;
- static constexpr int SF_GAMEUI_JUMP_DEACTIVATE = 256;
+ static constexpr int SF_GAMEUI_FREEZE_PLAYER = 32;
+ static constexpr int SF_GAMEUI_JUMP_DEACTIVATE = 256;
- // TODO Hide Weapon requires more RE
- static constexpr int SF_GAMEUI_HIDE_WEAPON = 64;
+ // TODO Hide Weapon requires more RE
+ static constexpr int SF_GAMEUI_HIDE_WEAPON = 64;
- // TODO subtick problem
- static constexpr int SF_GAMEUI_USE_DEACTIVATE = 128;
+ // TODO subtick problem
+ static constexpr int SF_GAMEUI_USE_DEACTIVATE = 128;
};
\ No newline at end of file
diff --git a/src/cs2_sdk/entity/cpointviewcontrol.h b/src/cs2_sdk/entity/cpointviewcontrol.h
index 069d45a8..a5b4b15b 100644
--- a/src/cs2_sdk/entity/cpointviewcontrol.h
+++ b/src/cs2_sdk/entity/cpointviewcontrol.h
@@ -27,43 +27,43 @@
class CPointViewControl : public CBaseEntity
{
- DECLARE_SCHEMA_CLASS(CPointViewControl)
+ DECLARE_SCHEMA_CLASS(CPointViewControl)
- // hello, don't port my garbage code to cssharp :)
+ // hello, don't port my garbage code to cssharp :)
- static constexpr int SF_POINT_VIEWCONTROL_FROZEN = 1 << 5;
- static constexpr int SF_POINT_VIEWCONTROL_FOV = 1 << 6;
- static constexpr int SF_POINT_VIEWCONTROL_DISARM = 1 << 7;
+ static constexpr int SF_POINT_VIEWCONTROL_FROZEN = 1 << 5;
+ static constexpr int SF_POINT_VIEWCONTROL_FOV = 1 << 6;
+ static constexpr int SF_POINT_VIEWCONTROL_DISARM = 1 << 7;
public:
- [[nodiscard]] CBaseEntity* GetTargetCameraEntity()
- {
- const auto pTarget = UTIL_FindEntityByName(nullptr, m_target().String());
- return pTarget && pTarget->m_pCollision() ? pTarget : nullptr;
- }
+ [[nodiscard]] CBaseEntity* GetTargetCameraEntity()
+ {
+ const auto pTarget = UTIL_FindEntityByName(nullptr, m_target().String());
+ return pTarget && pTarget->m_pCollision() ? pTarget : nullptr;
+ }
- [[nodiscard]] bool HasTargetCameraEntity()
- {
- return m_target().IsValid() && strlen(m_target().String()) >= 2;
- }
+ [[nodiscard]] bool HasTargetCameraEntity()
+ {
+ return m_target().IsValid() && strlen(m_target().String()) >= 2;
+ }
- [[nodiscard]] bool HasFrozen()
- {
- return !!(m_spawnflags() & SF_POINT_VIEWCONTROL_FROZEN);
- }
+ [[nodiscard]] bool HasFrozen()
+ {
+ return !!(m_spawnflags() & SF_POINT_VIEWCONTROL_FROZEN);
+ }
- [[nodiscard]] bool HasFOV()
- {
- return !!(m_spawnflags() & SF_POINT_VIEWCONTROL_FOV);
- }
+ [[nodiscard]] bool HasFOV()
+ {
+ return !!(m_spawnflags() & SF_POINT_VIEWCONTROL_FOV);
+ }
- [[nodiscard]] bool HasDisarm()
- {
- return !!(m_spawnflags() & SF_POINT_VIEWCONTROL_DISARM);
- }
+ [[nodiscard]] bool HasDisarm()
+ {
+ return !!(m_spawnflags() & SF_POINT_VIEWCONTROL_DISARM);
+ }
- [[nodiscard]] uint GetFOV()
- {
- return clamp(static_cast(m_iHealth()), 16, 179);
- }
+ [[nodiscard]] uint GetFOV()
+ {
+ return clamp(static_cast(m_iHealth()), 16, 179);
+ }
};
diff --git a/src/cs2_sdk/entity/ctakedamageinfo.h b/src/cs2_sdk/entity/ctakedamageinfo.h
index db348ef0..af1bf53f 100644
--- a/src/cs2_sdk/entity/ctakedamageinfo.h
+++ b/src/cs2_sdk/entity/ctakedamageinfo.h
@@ -18,8 +18,8 @@
*/
#pragma once
-#include
#include "ehandle.h"
+#include
enum DamageTypes_t : uint32_t
{
@@ -81,7 +81,7 @@ struct AttackerInfo_t
// No idea what this is meant to have, but OnTakeDamage_Alive expects this and we only care about pInfo
struct CTakeDamageInfoContainer
{
- CTakeDamageInfo *pInfo;
+ CTakeDamageInfo* pInfo;
};
class CTakeDamageInfo
@@ -95,7 +95,7 @@ class CTakeDamageInfo
addresses::CTakeDamageInfo_Constructor(this, nullptr, nullptr, nullptr, &vec3_origin, &vec3_origin, 0.f, 0, 0, nullptr);
}
- CTakeDamageInfo(CBaseEntity *pInflictor, CBaseEntity *pAttacker, CBaseEntity *pAbility, float flDamage, DamageTypes_t bitsDamageType)
+ CTakeDamageInfo(CBaseEntity* pInflictor, CBaseEntity* pAttacker, CBaseEntity* pAbility, float flDamage, DamageTypes_t bitsDamageType)
{
addresses::CTakeDamageInfo_Constructor(this, pInflictor, pAttacker, pAbility, &vec3_origin, &vec3_origin, flDamage, bitsDamageType, 0, nullptr);
}
diff --git a/src/cs2_sdk/entity/cteam.h b/src/cs2_sdk/entity/cteam.h
index 8b7f955a..49e243f5 100644
--- a/src/cs2_sdk/entity/cteam.h
+++ b/src/cs2_sdk/entity/cteam.h
@@ -17,7 +17,6 @@
* this program. If not, see .
*/
-
#pragma once
#include "cbaseentity.h"
#include "cbaseplayercontroller.h"
diff --git a/src/cs2_sdk/entity/ctriggerpush.h b/src/cs2_sdk/entity/ctriggerpush.h
index 73169bfd..e8a909c7 100644
--- a/src/cs2_sdk/entity/ctriggerpush.h
+++ b/src/cs2_sdk/entity/ctriggerpush.h
@@ -19,8 +19,8 @@
#pragma once
+#include "../schema.h"
#include "cbasetrigger.h"
-#include"../schema.h"
#define SF_TRIG_PUSH_ONCE 0x80
diff --git a/src/cs2_sdk/entity/cvotecontroller.h b/src/cs2_sdk/entity/cvotecontroller.h
index d96a7823..68112cdc 100644
--- a/src/cs2_sdk/entity/cvotecontroller.h
+++ b/src/cs2_sdk/entity/cvotecontroller.h
@@ -20,7 +20,7 @@
#pragma once
#include "cbaseentity.h"
-//#include "util_shared.h"
+// #include "util_shared.h"
class CVoteController : public CBaseEntity
{
@@ -28,11 +28,11 @@ class CVoteController : public CBaseEntity
DECLARE_SCHEMA_CLASS(CVoteController);
SCHEMA_FIELD(int, m_iActiveIssueIndex)
- SCHEMA_FIELD(int, m_iOnlyTeamToVote)
- SCHEMA_FIELD_POINTER(int, m_nVoteOptionCount)
- SCHEMA_FIELD(int, m_nPotentialVotes)
- SCHEMA_FIELD(bool, m_bIsYesNoVote)
- SCHEMA_FIELD_POINTER(int, m_nVotesCast)
- SCHEMA_FIELD(int, m_nHighestCountIndex)
- SCHEMA_FIELD_POINTER(CUtlVector, m_VoteOptions)
+ SCHEMA_FIELD(int, m_iOnlyTeamToVote)
+ SCHEMA_FIELD_POINTER(int, m_nVoteOptionCount)
+ SCHEMA_FIELD(int, m_nPotentialVotes)
+ SCHEMA_FIELD(bool, m_bIsYesNoVote)
+ SCHEMA_FIELD_POINTER(int, m_nVotesCast)
+ SCHEMA_FIELD(int, m_nHighestCountIndex)
+ SCHEMA_FIELD_POINTER(CUtlVector, m_VoteOptions)
};
diff --git a/src/cs2_sdk/entity/globaltypes.h b/src/cs2_sdk/entity/globaltypes.h
index 58561b05..ac72820a 100644
--- a/src/cs2_sdk/entity/globaltypes.h
+++ b/src/cs2_sdk/entity/globaltypes.h
@@ -18,9 +18,9 @@
*/
#pragma once
-#include
#include "schema.h"
#include "soundflags.h"
+#include
enum InputBitMask_t : uint64_t
{
@@ -66,12 +66,12 @@ enum EInButtonState : uint32_t
enum ParticleAttachment_t : uint32_t
{
PATTACH_INVALID = 0xffffffff,
- PATTACH_ABSORIGIN = 0x0, // Spawn at entity origin
- PATTACH_ABSORIGIN_FOLLOW = 0x1, // Spawn at and follow entity origin
+ PATTACH_ABSORIGIN = 0x0, // Spawn at entity origin
+ PATTACH_ABSORIGIN_FOLLOW = 0x1, // Spawn at and follow entity origin
PATTACH_CUSTOMORIGIN = 0x2,
PATTACH_CUSTOMORIGIN_FOLLOW = 0x3,
- PATTACH_POINT = 0x4, // Spawn at attachment point
- PATTACH_POINT_FOLLOW = 0x5, // Spawn at and follow attachment point
+ PATTACH_POINT = 0x4, // Spawn at attachment point
+ PATTACH_POINT_FOLLOW = 0x5, // Spawn at and follow attachment point
PATTACH_EYES_FOLLOW = 0x6,
PATTACH_OVERHEAD_FOLLOW = 0x7,
PATTACH_WORLDORIGIN = 0x8,
@@ -151,14 +151,14 @@ struct EmitSound_t
{
}
int m_nChannel;
- const char *m_pSoundName;
+ const char* m_pSoundName;
float m_flVolume;
soundlevel_t m_SoundLevel;
int m_nFlags;
int m_nPitch;
- const Vector *m_pOrigin;
+ const Vector* m_pOrigin;
float m_flSoundTime;
- float *m_pflSoundDuration;
+ float* m_pflSoundDuration;
bool m_bEmitCloseCaption;
bool m_bWarnOnMissingCloseCaption;
bool m_bWarnOnDirectWaveReference;
diff --git a/src/cs2_sdk/entity/lights.h b/src/cs2_sdk/entity/lights.h
index 52bd5a6e..a2dec1fd 100644
--- a/src/cs2_sdk/entity/lights.h
+++ b/src/cs2_sdk/entity/lights.h
@@ -47,13 +47,13 @@ class CBarnLight : public CBaseModelEntity
SCHEMA_FIELD(float, m_flColorTemperature) // default 6500
SCHEMA_FIELD(float, m_flBrightness)
SCHEMA_FIELD(float, m_flBrightnessScale)
- SCHEMA_FIELD(int, m_nDirectLight) // Always set to 2 for dynamic
- SCHEMA_FIELD(int, m_nCastShadows) // 0 = no, 1 = dynamic (and baked but pointless here)
+ SCHEMA_FIELD(int, m_nDirectLight) // Always set to 2 for dynamic
+ SCHEMA_FIELD(int, m_nCastShadows) // 0 = no, 1 = dynamic (and baked but pointless here)
SCHEMA_FIELD(int, m_nShadowMapSize) // Shadowmap size in pixels (512 is a good starting value)
SCHEMA_FIELD(int, m_nShadowPriority)
SCHEMA_FIELD(bool, m_bContactShadow)
SCHEMA_FIELD(float, m_flRange)
- SCHEMA_FIELD(float, m_flSkirt) // Falloff over the range
+ SCHEMA_FIELD(float, m_flSkirt) // Falloff over the range
SCHEMA_FIELD(float, m_flSkirtNear) // Falloff from the source
SCHEMA_FIELD(float, m_flSoftX)
SCHEMA_FIELD(float, m_flSoftY)
diff --git a/src/cs2_sdk/entity/services.h b/src/cs2_sdk/entity/services.h
index e198332e..a9cb36e5 100644
--- a/src/cs2_sdk/entity/services.h
+++ b/src/cs2_sdk/entity/services.h
@@ -18,16 +18,16 @@
*/
#pragma once
-#include
#include "globaltypes.h"
-#include
#include
+#include
+#include
-#define AMMO_OFFSET_HEGRENADE 13
-#define AMMO_OFFSET_FLASHBANG 14
-#define AMMO_OFFSET_SMOKEGRENADE 15
-#define AMMO_OFFSET_MOLOTOV 16
-#define AMMO_OFFSET_DECOY 17
+#define AMMO_OFFSET_HEGRENADE 13
+#define AMMO_OFFSET_FLASHBANG 14
+#define AMMO_OFFSET_SMOKEGRENADE 15
+#define AMMO_OFFSET_MOLOTOV 16
+#define AMMO_OFFSET_DECOY 17
class CBaseEntity;
@@ -65,7 +65,7 @@ class CPlayerPawnComponent
SCHEMA_FIELD(CCSPlayerPawn*, __m_pChainEntity)
- CCSPlayerPawn *GetPawn() { return __m_pChainEntity; }
+ CCSPlayerPawn* GetPawn() { return __m_pChainEntity; }
};
class CPlayer_MovementServices : public CPlayerPawnComponent
@@ -155,15 +155,16 @@ class CCSPlayerController_InGameMoneyServices
public:
DECLARE_SCHEMA_CLASS(CCSPlayerController_InGameMoneyServices);
- SCHEMA_FIELD(int, m_iAccount)
+ SCHEMA_FIELD(int, m_iAccount)
};
class CCSPlayer_ItemServices
{
public:
DECLARE_SCHEMA_CLASS(CCSPlayer_ItemServices);
-
+
virtual ~CCSPlayer_ItemServices() = 0;
+
private:
virtual void unk_01() = 0;
virtual void unk_02() = 0;
@@ -182,12 +183,13 @@ class CCSPlayer_ItemServices
virtual void unk_15() = 0;
virtual void unk_16() = 0;
virtual CBaseEntity* _GiveNamedItem(const char* pchName) = 0;
+
public:
- virtual bool GiveNamedItemBool(const char* pchName) = 0;
- virtual CBaseEntity* GiveNamedItem(const char* pchName) = 0;
+ virtual bool GiveNamedItemBool(const char* pchName) = 0;
+ virtual CBaseEntity* GiveNamedItem(const char* pchName) = 0;
// Recommended to use CCSPlayer_WeaponServices::DropWeapon instead (parameter is ignored here)
- virtual void DropActiveWeapon(CBasePlayerWeapon* pWeapon) = 0;
- virtual void StripPlayerWeapons(bool removeSuit) = 0;
+ virtual void DropActiveWeapon(CBasePlayerWeapon* pWeapon) = 0;
+ virtual void StripPlayerWeapons(bool removeSuit) = 0;
};
// We need an exactly sized class to be able to iterate the vector, our schema system implementation can't do this
@@ -195,14 +197,14 @@ class WeaponPurchaseCount_t
{
private:
virtual void unk01() {};
- uint64_t unk1 = 0; // 0x8
- uint64_t unk2 = 0; // 0x10
- uint64_t unk3 = 0; // 0x18
- uint64_t unk4 = 0; // 0x20
+ uint64_t unk1 = 0; // 0x8
+ uint64_t unk2 = 0; // 0x10
+ uint64_t unk3 = 0; // 0x18
+ uint64_t unk4 = 0; // 0x20
uint64_t unk5 = -1; // 0x28
public:
- uint16_t m_nItemDefIndex; // 0x30
- uint16_t m_nCount; // 0x32
+ uint16_t m_nItemDefIndex; // 0x30
+ uint16_t m_nCount; // 0x32
private:
uint32_t unk6 = 0;
};
@@ -237,18 +239,18 @@ class CPlayer_ObserverServices
class CPlayer_CameraServices
{
public:
- DECLARE_SCHEMA_CLASS(CPlayer_CameraServices)
+ DECLARE_SCHEMA_CLASS(CPlayer_CameraServices)
- SCHEMA_FIELD(CHandle, m_hViewEntity)
+ SCHEMA_FIELD(CHandle, m_hViewEntity)
};
class CCSPlayerBase_CameraServices : public CPlayer_CameraServices
{
public:
- DECLARE_SCHEMA_CLASS(CCSPlayerBase_CameraServices)
+ DECLARE_SCHEMA_CLASS(CCSPlayerBase_CameraServices)
- SCHEMA_FIELD(CHandle, m_hZoomOwner)
- SCHEMA_FIELD(uint, m_iFOV)
+ SCHEMA_FIELD(CHandle, m_hZoomOwner)
+ SCHEMA_FIELD(uint, m_iFOV)
};
class CCSPlayer_CameraServices : public CCSPlayerBase_CameraServices
diff --git a/src/cs2_sdk/entityio.h b/src/cs2_sdk/entityio.h
index fbc8f6e6..e2934a47 100644
--- a/src/cs2_sdk/entityio.h
+++ b/src/cs2_sdk/entityio.h
@@ -1,21 +1,21 @@
/**
-* =============================================================================
-* CS2Fixes
-* Copyright (C) 2023-2024 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 .
-*/
+ * =============================================================================
+ * CS2Fixes
+ * Copyright (C) 2023-2024 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
@@ -24,10 +24,10 @@
#define NULL 0
#endif
-#include
#include
-#include
#include
+#include
+#include
struct EntityIOConnectionDesc_t
{
diff --git a/src/cs2_sdk/schema.cpp b/src/cs2_sdk/schema.cpp
index 4d1ce959..888a6e39 100644
--- a/src/cs2_sdk/schema.cpp
+++ b/src/cs2_sdk/schema.cpp
@@ -20,129 +20,125 @@
#include "schema.h"
#include "../common.h"
+#include "entity/cbaseentity.h"
+#include "plat.h"
#include "schemasystem/schemasystem.h"
#include "tier1/utlmap.h"
+
#include "tier0/memdbgon.h"
-#include "plat.h"
-#include "entity/cbaseentity.h"
-extern CGlobalVars *gpGlobals;
+extern CGlobalVars* gpGlobals;
using SchemaKeyValueMap_t = CUtlMap;
using SchemaTableMap_t = CUtlMap;
-
static bool IsFieldNetworked(SchemaClassFieldData_t& field)
{
- for (int i = 0; i < field.m_nStaticMetadataCount; i++)
- {
- static auto networkEnabled = hash_32_fnv1a_const("MNetworkEnable");
- if (networkEnabled == hash_32_fnv1a_const(field.m_pStaticMetadata[i].m_pszName))
- return true;
- }
-
- return false;
-}
+ for (int i = 0; i < field.m_nStaticMetadataCount; i++)
+ {
+ static auto networkEnabled = hash_32_fnv1a_const("MNetworkEnable");
+ if (networkEnabled == hash_32_fnv1a_const(field.m_pStaticMetadata[i].m_pszName))
+ return true;
+ }
+
+ return false;
+}
-static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* className, uint32_t classKey)
+static bool InitSchemaFieldsForClass(SchemaTableMap_t* tableMap, const char* className, uint32_t classKey)
{
- CSchemaSystemTypeScope* pType = g_pSchemaSystem->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
+ CSchemaSystemTypeScope* pType = g_pSchemaSystem->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
- if (!pType)
- return false;
+ if (!pType)
+ return false;
- SchemaClassInfoData_t *pClassInfo = pType->FindDeclaredClass(className).Get();
+ SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass(className).Get();
- if (!pClassInfo)
- {
- SchemaKeyValueMap_t *map = new SchemaKeyValueMap_t(0, 0, DefLessFunc(uint32_t));
- tableMap->Insert(classKey, map);
+ if (!pClassInfo)
+ {
+ SchemaKeyValueMap_t* map = new SchemaKeyValueMap_t(0, 0, DefLessFunc(uint32_t));
+ tableMap->Insert(classKey, map);
- Warning("InitSchemaFieldsForClass(): '%s' was not found!\n", className);
- return false;
- }
+ Warning("InitSchemaFieldsForClass(): '%s' was not found!\n", className);
+ return false;
+ }
- short fieldsSize = pClassInfo->m_nFieldCount;
- SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
+ short fieldsSize = pClassInfo->m_nFieldCount;
+ SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
- SchemaKeyValueMap_t *keyValueMap = new SchemaKeyValueMap_t(0, 0, DefLessFunc(uint32_t));
- keyValueMap->EnsureCapacity(fieldsSize);
- tableMap->Insert(classKey, keyValueMap);
+ SchemaKeyValueMap_t* keyValueMap = new SchemaKeyValueMap_t(0, 0, DefLessFunc(uint32_t));
+ keyValueMap->EnsureCapacity(fieldsSize);
+ tableMap->Insert(classKey, keyValueMap);
- for (int i = 0; i < fieldsSize; ++i)
- {
- SchemaClassFieldData_t& field = pFields[i];
+ for (int i = 0; i < fieldsSize; ++i)
+ {
+ SchemaClassFieldData_t& field = pFields[i];
#ifdef _DEBUG
Message("%s::%s found at -> 0x%X - %llx\n", className, field.m_pszName, field.m_nSingleInheritanceOffset, &field);
#endif
- keyValueMap->Insert(hash_32_fnv1a_const(field.m_pszName), {field.m_nSingleInheritanceOffset, IsFieldNetworked(field)});
- }
+ keyValueMap->Insert(hash_32_fnv1a_const(field.m_pszName), {field.m_nSingleInheritanceOffset, IsFieldNetworked(field)});
+ }
- return true;
+ return true;
}
int16_t schema::FindChainOffset(const char* className)
{
- CSchemaSystemTypeScope* pType = g_pSchemaSystem->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
+ CSchemaSystemTypeScope* pType = g_pSchemaSystem->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
- if (!pType)
- return false;
+ if (!pType)
+ return false;
- SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass(className).Get();
+ SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass(className).Get();
- do
- {
- SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
- short fieldsSize = pClassInfo->m_nFieldCount;
- for (int i = 0; i < fieldsSize; ++i)
- {
- SchemaClassFieldData_t& field = pFields[i];
+ do
+ {
+ SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
+ short fieldsSize = pClassInfo->m_nFieldCount;
+ for (int i = 0; i < fieldsSize; ++i)
+ {
+ SchemaClassFieldData_t& field = pFields[i];
- if (V_strcmp(field.m_pszName, "__m_pChainEntity") == 0)
- {
- return field.m_nSingleInheritanceOffset;
- }
- }
- } while ((pClassInfo = pClassInfo->m_pBaseClasses ? pClassInfo->m_pBaseClasses->m_pClass : nullptr) != nullptr);
+ if (V_strcmp(field.m_pszName, "__m_pChainEntity") == 0)
+ return field.m_nSingleInheritanceOffset;
+ }
+ } while ((pClassInfo = pClassInfo->m_pBaseClasses ? pClassInfo->m_pBaseClasses->m_pClass : nullptr) != nullptr);
- return 0;
+ return 0;
}
SchemaKey schema::GetOffset(const char* className, uint32_t classKey, const char* memberName, uint32_t memberKey)
{
static SchemaTableMap_t schemaTableMap(0, 0, DefLessFunc(uint32_t));
int16_t tableMapIndex = schemaTableMap.Find(classKey);
- if (!schemaTableMap.IsValidIndex(tableMapIndex))
- {
- if (InitSchemaFieldsForClass(&schemaTableMap, className, classKey))
- return GetOffset(className, classKey, memberName, memberKey);
+ if (!schemaTableMap.IsValidIndex(tableMapIndex))
+ {
+ if (InitSchemaFieldsForClass(&schemaTableMap, className, classKey))
+ return GetOffset(className, classKey, memberName, memberKey);
- return { 0, 0 };
- }
+ return {0, 0};
+ }
- SchemaKeyValueMap_t *tableMap = schemaTableMap[tableMapIndex];
+ SchemaKeyValueMap_t* tableMap = schemaTableMap[tableMapIndex];
int16_t memberIndex = tableMap->Find(memberKey);
- if (!tableMap->IsValidIndex(memberIndex))
- {
- Warning("schema::GetOffset(): '%s' was not found in '%s'!\n", memberName, className);
- return { 0, 0 };
- }
+ if (!tableMap->IsValidIndex(memberIndex))
+ {
+ Warning("schema::GetOffset(): '%s' was not found in '%s'!\n", memberName, className);
+ return {0, 0};
+ }
- return tableMap->Element(memberIndex);
+ return tableMap->Element(memberIndex);
}
void EntityNetworkStateChanged(uintptr_t entityInstance, uint nOffset)
{
- reinterpret_cast(entityInstance)->NetworkStateChanged(nOffset);
+ reinterpret_cast(entityInstance)->NetworkStateChanged(nOffset);
}
void ChainNetworkStateChanged(uintptr_t networkVarChainer, uint nLocalOffset)
{
- CEntityInstance* pEntity = *reinterpret_cast(networkVarChainer);
- if (pEntity && (pEntity->m_pEntity->m_flags & EF_IS_CONSTRUCTION_IN_PROGRESS) == 0)
- {
- pEntity->NetworkStateChanged(nLocalOffset, -1, *reinterpret_cast(networkVarChainer + 32));
- }
+ CEntityInstance* pEntity = *reinterpret_cast(networkVarChainer);
+ if (pEntity && (pEntity->m_pEntity->m_flags & EF_IS_CONSTRUCTION_IN_PROGRESS) == 0)
+ pEntity->NetworkStateChanged(nLocalOffset, -1, *reinterpret_cast(networkVarChainer + 32));
}
diff --git a/src/cs2_sdk/schema.h b/src/cs2_sdk/schema.h
index ad6cf639..0576db0a 100644
--- a/src/cs2_sdk/schema.h
+++ b/src/cs2_sdk/schema.h
@@ -20,21 +20,21 @@
#pragma once
#ifdef _WIN32
-#pragma warning(push)
-#pragma warning(disable : 4005)
+ #pragma warning(push)
+ #pragma warning(disable : 4005)
#endif
#include
#ifdef _WIN32
-#pragma warning(pop)
+ #pragma warning(pop)
#endif
#include "../addresses.h"
-#include "tier0/dbg.h"
#include "const.h"
-#include "virtual.h"
#include "stdint.h"
+#include "tier0/dbg.h"
+#include "virtual.h"
#undef schema
struct SchemaKey
@@ -51,92 +51,116 @@ constexpr uint32_t prime_32_const = 0x1000193;
constexpr uint64_t val_64_const = 0xcbf29ce484222325;
constexpr uint64_t prime_64_const = 0x100000001b3;
-inline constexpr uint32_t hash_32_fnv1a_const(const char *const str, const uint32_t value = val_32_const) noexcept
+inline constexpr uint32_t hash_32_fnv1a_const(const char* const str, const uint32_t value = val_32_const) noexcept
{
return (str[0] == '\0') ? value : hash_32_fnv1a_const(&str[1], (value ^ uint32_t(str[0])) * prime_32_const);
}
-inline constexpr uint64_t hash_64_fnv1a_const(const char *const str, const uint64_t value = val_64_const) noexcept
+inline constexpr uint64_t hash_64_fnv1a_const(const char* const str, const uint64_t value = val_64_const) noexcept
{
return (str[0] == '\0') ? value : hash_64_fnv1a_const(&str[1], (value ^ uint64_t(str[0])) * prime_64_const);
}
-#define SCHEMA_FIELD_OFFSET(type, varName, extra_offset) \
- class varName##_prop \
- { \
- public: \
- std::add_lvalue_reference_t Get() \
- { \
- static constexpr auto datatable_hash = hash_32_fnv1a_const(ThisClassName); \
- static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
- \
- static const auto m_key = \
- schema::GetOffset(ThisClassName, datatable_hash, #varName, prop_hash); \
- \
- static const size_t offset = offsetof(ThisClass, varName); \
- ThisClass *pThisClass = (ThisClass *)((byte *)this - offset); \
- \
- return *reinterpret_cast>( \
- (uintptr_t)(pThisClass) + m_key.offset + extra_offset); \
- } \
- void Set(type val) \
- { \
- static constexpr auto datatable_hash = hash_32_fnv1a_const(ThisClassName); \
- static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
- \
- static const auto m_key = \
- schema::GetOffset(ThisClassName, datatable_hash, #varName, prop_hash); \
- \
- static const auto m_chain = \
- schema::FindChainOffset(ThisClassName); \
- \
- static const size_t offset = offsetof(ThisClass, varName); \
- ThisClass *pThisClass = (ThisClass *)((byte *)this - offset); \
- \
- if (m_chain != 0 && m_key.networked) \
- { \
- DevMsg("Found chain offset %d for %s::%s\n", m_chain, ThisClassName, #varName); \
- 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 .*/ \
- if (!IsStruct) \
- EntityNetworkStateChanged((uintptr_t)pThisClass, m_key.offset + extra_offset); \
- else \
- CALL_VIRTUAL(void, 1, pThisClass, m_key.offset + extra_offset, 0xFFFFFFFF, 0xFFFFFFFF); \
- } \
- *reinterpret_cast>((uintptr_t)(pThisClass) + m_key.offset + extra_offset) = val; \
- } \
- operator std::add_lvalue_reference_t() { return Get(); } \
- std::add_lvalue_reference_t operator ()() { return Get(); } \
- std::add_lvalue_reference_t operator->() { return Get(); } \
- void operator()(type val) { Set(val); } \
- void operator=(type val) { Set(val); } \
+#define SCHEMA_FIELD_OFFSET(type, varName, extra_offset) \
+ class varName##_prop \
+ { \
+ public: \
+ std::add_lvalue_reference_t Get() \
+ { \
+ static constexpr auto datatable_hash = hash_32_fnv1a_const(ThisClassName); \
+ static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
+ \
+ static const auto m_key = \
+ schema::GetOffset(ThisClassName, datatable_hash, #varName, prop_hash); \
+ \
+ static const size_t offset = offsetof(ThisClass, varName); \
+ ThisClass* pThisClass = (ThisClass*)((byte*)this - offset); \
+ \
+ return *reinterpret_cast>( \
+ (uintptr_t)(pThisClass) + m_key.offset + extra_offset); \
+ } \
+ void Set(type val) \
+ { \
+ static constexpr auto datatable_hash = hash_32_fnv1a_const(ThisClassName); \
+ static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
+ \
+ static const auto m_key = \
+ schema::GetOffset(ThisClassName, datatable_hash, #varName, prop_hash); \
+ \
+ static const auto m_chain = \
+ schema::FindChainOffset(ThisClassName); \
+ \
+ static const size_t offset = offsetof(ThisClass, varName); \
+ ThisClass* pThisClass = (ThisClass*)((byte*)this - offset); \
+ \
+ if (m_chain != 0 && m_key.networked) \
+ { \
+ DevMsg("Found chain offset %d for %s::%s\n", m_chain, ThisClassName, #varName); \
+ 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 .*/ \
+ if (!IsStruct) \
+ EntityNetworkStateChanged((uintptr_t)pThisClass, m_key.offset + extra_offset); \
+ else \
+ CALL_VIRTUAL(void, 1, pThisClass, m_key.offset + extra_offset, 0xFFFFFFFF, 0xFFFFFFFF); \
+ } \
+ *reinterpret_cast>((uintptr_t)(pThisClass) + m_key.offset + extra_offset) = val; \
+ } \
+ operator std::add_lvalue_reference_t() \
+ { \
+ return Get(); \
+ } \
+ std::add_lvalue_reference_t operator()() \
+ { \
+ return Get(); \
+ } \
+ std::add_lvalue_reference_t operator->() \
+ { \
+ return Get(); \
+ } \
+ void operator()(type val) \
+ { \
+ Set(val); \
+ } \
+ void operator=(type val) \
+ { \
+ Set(val); \
+ } \
} varName;
-#define SCHEMA_FIELD_POINTER_OFFSET(type, varName, extra_offset) \
- class varName##_prop \
- { \
- public: \
- type *Get() \
- { \
- static constexpr auto datatable_hash = hash_32_fnv1a_const(ThisClassName); \
- static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
- \
- static const auto m_key = \
- schema::GetOffset(ThisClassName, datatable_hash, #varName, prop_hash); \
- \
- static const size_t offset = offsetof(ThisClass, varName); \
- ThisClass *pThisClass = (ThisClass *)((byte *)this - offset); \
- \
- return reinterpret_cast>( \
- (uintptr_t)(pThisClass) + m_key.offset + extra_offset); \
- } \
- operator type*() { return Get(); } \
- type* operator ()() { return Get(); } \
- type* operator->() { return Get(); } \
+#define SCHEMA_FIELD_POINTER_OFFSET(type, varName, extra_offset) \
+ class varName##_prop \
+ { \
+ public: \
+ type* Get() \
+ { \
+ static constexpr auto datatable_hash = hash_32_fnv1a_const(ThisClassName); \
+ static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
+ \
+ static const auto m_key = \
+ schema::GetOffset(ThisClassName, datatable_hash, #varName, prop_hash); \
+ \
+ static const size_t offset = offsetof(ThisClass, varName); \
+ ThisClass* pThisClass = (ThisClass*)((byte*)this - offset); \
+ \
+ return reinterpret_cast>( \
+ (uintptr_t)(pThisClass) + m_key.offset + extra_offset); \
+ } \
+ operator type*() \
+ { \
+ return Get(); \
+ } \
+ type* operator()() \
+ { \
+ return Get(); \
+ } \
+ type* operator->() \
+ { \
+ return Get(); \
+ } \
} varName;
// Use this when you want the member's value itself
@@ -149,14 +173,14 @@ inline constexpr uint64_t hash_64_fnv1a_const(const char *const str, const uint6
namespace schema
{
- int16_t FindChainOffset(const char *className);
- SchemaKey GetOffset(const char *className, uint32_t classKey, const char *memberName, uint32_t memberKey);
-}
-
-#define DECLARE_SCHEMA_CLASS_BASE(className, isStruct) \
- typedef className ThisClass; \
- static constexpr const char *ThisClassName = #className; \
- static constexpr bool IsStruct = isStruct;
+ int16_t FindChainOffset(const char* className);
+ SchemaKey GetOffset(const char* className, uint32_t classKey, const char* memberName, uint32_t memberKey);
+} // namespace schema
+
+#define DECLARE_SCHEMA_CLASS_BASE(className, isStruct) \
+ typedef className ThisClass; \
+ static constexpr const char* ThisClassName = #className; \
+ static constexpr bool IsStruct = isStruct;
#define DECLARE_SCHEMA_CLASS(className) DECLARE_SCHEMA_CLASS_BASE(className, false)
diff --git a/src/cs2fixes.cpp b/src/cs2fixes.cpp
index 8e51133d..1c5270d4 100644
--- a/src/cs2fixes.cpp
+++ b/src/cs2fixes.cpp
@@ -20,46 +20,45 @@
#include "cs2fixes.h"
#include "iserver.h"
+#include "adminsystem.h"
#include "appframework/IAppSystem.h"
-#include "common.h"
#include "commands.h"
+#include "common.h"
+#include "cs_gameevents.pb.h"
+#include "ctimer.h"
#include "detours.h"
-#include "patches.h"
-#include "icvar.h"
-#include "interface.h"
-#include "tier0/dbg.h"
-#include "tier0/vprof.h"
-#include "schemasystem/schemasystem.h"
-#include "plat.h"
-#include "entitysystem.h"
+#include "discord.h"
#include "engine/igameeventsystem.h"
-#include "networkstringtabledefs.h"
-#include "gamesystem.h"
-#include "ctimer.h"
#include "entities.h"
-#include "playermanager.h"
-#include
-#include "adminsystem.h"
-#include "commands.h"
+#include "entity/ccsplayercontroller.h"
+#include "entity/cgamerules.h"
+#include "entitylistener.h"
+#include "entitysystem.h"
#include "eventlistener.h"
#include "gameconfig.h"
-#include "votemanager.h"
-#include "zombiereborn.h"
+#include "gameevents.pb.h"
+#include "gamesystem.h"
#include "httpmanager.h"
+#include "icvar.h"
#include "idlemanager.h"
-#include "discord.h"
-#include "panoramavote.h"
+#include "interface.h"
+#include "leader.h"
#include "map_votes.h"
-#include "user_preferences.h"
-#include "entity/cgamerules.h"
-#include "entity/ccsplayercontroller.h"
-#include "entitylistener.h"
+#include "networkstringtabledefs.h"
+#include "panoramavote.h"
+#include "patches.h"
+#include "plat.h"
+#include "playermanager.h"
+#include "schemasystem/schemasystem.h"
#include "serversideclient.h"
#include "te.pb.h"
-#include "cs_gameevents.pb.h"
-#include "gameevents.pb.h"
-#include "leader.h"
+#include "tier0/dbg.h"
+#include "tier0/vprof.h"
+#include "user_preferences.h"
#include "usermessages.pb.h"
+#include "votemanager.h"
+#include "zombiereborn.h"
+#include
#include "tier0/memdbgon.h"
@@ -68,7 +67,7 @@ float g_flLastTickedTime;
bool g_bHasTicked;
int g_iRoundNum = 0;
-void Message(const char *msg, ...)
+void Message(const char* msg, ...)
{
va_list args;
va_start(args, msg);
@@ -81,7 +80,7 @@ void Message(const char *msg, ...)
va_end(args);
}
-void Panic(const char *msg, ...)
+void Panic(const char* msg, ...)
{
va_list args;
va_start(args, msg);
@@ -94,46 +93,47 @@ void Panic(const char *msg, ...)
va_end(args);
}
-class GameSessionConfiguration_t { };
+class GameSessionConfiguration_t
+{};
SH_DECL_HOOK3_void(IServerGameDLL, GameFrame, SH_NOATTRIB, 0, bool, bool, bool);
SH_DECL_HOOK0_void(IServerGameDLL, GameServerSteamAPIActivated, SH_NOATTRIB, 0);
SH_DECL_HOOK0_void(IServerGameDLL, GameServerSteamAPIDeactivated, SH_NOATTRIB, 0);
SH_DECL_HOOK1_void(IServerGameDLL, ApplyGameSettings, SH_NOATTRIB, 0, KeyValues*);
-SH_DECL_HOOK4_void(IServerGameClients, ClientActive, SH_NOATTRIB, 0, CPlayerSlot, bool, const char *, uint64);
-SH_DECL_HOOK5_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, CPlayerSlot, ENetworkDisconnectionReason, const char *, uint64, const char *);
-SH_DECL_HOOK4_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, CPlayerSlot, char const *, int, uint64);
-SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, CPlayerSlot );
-SH_DECL_HOOK6_void(IServerGameClients, OnClientConnected, SH_NOATTRIB, 0, CPlayerSlot, const char*, uint64, const char *, const char *, bool);
-SH_DECL_HOOK6(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, CPlayerSlot, const char*, uint64, const char *, bool, CBufferString *);
+SH_DECL_HOOK4_void(IServerGameClients, ClientActive, SH_NOATTRIB, 0, CPlayerSlot, bool, const char*, uint64);
+SH_DECL_HOOK5_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, CPlayerSlot, ENetworkDisconnectionReason, const char*, uint64, const char*);
+SH_DECL_HOOK4_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, CPlayerSlot, char const*, int, uint64);
+SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, CPlayerSlot);
+SH_DECL_HOOK6_void(IServerGameClients, OnClientConnected, SH_NOATTRIB, 0, CPlayerSlot, const char*, uint64, const char*, const char*, bool);
+SH_DECL_HOOK6(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, CPlayerSlot, const char*, uint64, const char*, bool, CBufferString*);
SH_DECL_HOOK8_void(IGameEventSystem, PostEventAbstract, SH_NOATTRIB, 0, CSplitScreenSlot, bool, int, const uint64*,
- INetworkMessageInternal*, const CNetMessage*, unsigned long, NetChannelBufType_t)
-SH_DECL_HOOK3_void(INetworkServerService, StartupServer, SH_NOATTRIB, 0, const GameSessionConfiguration_t&, ISource2WorldSession*, const char*);
-SH_DECL_HOOK7_void(ISource2GameEntities, CheckTransmit, SH_NOATTRIB, 0, CCheckTransmitInfo **, int, CBitVec<16384> &, const Entity2Networkable_t **, const uint16 *, int, bool);
-SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, CPlayerSlot, const CCommand &);
+ INetworkMessageInternal*, const CNetMessage*, unsigned long, NetChannelBufType_t)
+ SH_DECL_HOOK3_void(INetworkServerService, StartupServer, SH_NOATTRIB, 0, const GameSessionConfiguration_t&, ISource2WorldSession*, const char*);
+SH_DECL_HOOK7_void(ISource2GameEntities, CheckTransmit, SH_NOATTRIB, 0, CCheckTransmitInfo**, int, CBitVec<16384>&, const Entity2Networkable_t**, const uint16*, int, bool);
+SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, CPlayerSlot, const CCommand&);
SH_DECL_HOOK3_void(ICvar, DispatchConCommand, SH_NOATTRIB, 0, ConCommandHandle, const CCommandContext&, const CCommand&);
SH_DECL_MANUALHOOK1_void(CGamePlayerEquipUse, 0, 0, 0, InputData_t*);
SH_DECL_MANUALHOOK2_void(CreateWorkshopMapGroup, 0, 0, 0, const char*, const CUtlStringList&);
-SH_DECL_MANUALHOOK1(OnTakeDamage_Alive, 0, 0, 0, bool, CTakeDamageInfoContainer *);
+SH_DECL_MANUALHOOK1(OnTakeDamage_Alive, 0, 0, 0, bool, CTakeDamageInfoContainer*);
SH_DECL_MANUALHOOK1_void(CheckMovingGround, 0, 0, 0, double);
-SH_DECL_HOOK2(IGameEventManager2, LoadEventsFromFile, SH_NOATTRIB, 0, int, const char *, bool);
+SH_DECL_HOOK2(IGameEventManager2, LoadEventsFromFile, SH_NOATTRIB, 0, int, const char*, bool);
SH_DECL_MANUALHOOK1_void(GoToIntermission, 0, 0, 0, bool);
SH_DECL_MANUALHOOK2_void(PhysicsTouchShuffle, 0, 0, 0, CUtlVector*, bool);
CS2Fixes g_CS2Fixes;
-IGameEventSystem *g_gameEventSystem = nullptr;
-IGameEventManager2 *g_gameEventManager = nullptr;
-INetworkGameServer *g_pNetworkGameServer = nullptr;
-CGameEntitySystem *g_pEntitySystem = nullptr;
-CEntityListener *g_pEntityListener = nullptr;
-CGlobalVars *gpGlobals = nullptr;
-CPlayerManager *g_playerManager = nullptr;
-IVEngineServer2 *g_pEngineServer2 = nullptr;
-CGameConfig *g_GameConfig = nullptr;
-ISteamHTTP *g_http = nullptr;
+IGameEventSystem* g_gameEventSystem = nullptr;
+IGameEventManager2* g_gameEventManager = nullptr;
+INetworkGameServer* g_pNetworkGameServer = nullptr;
+CGameEntitySystem* g_pEntitySystem = nullptr;
+CEntityListener* g_pEntityListener = nullptr;
+CGlobalVars* gpGlobals = nullptr;
+CPlayerManager* g_playerManager = nullptr;
+IVEngineServer2* g_pEngineServer2 = nullptr;
+CGameConfig* g_GameConfig = nullptr;
+ISteamHTTP* g_http = nullptr;
CSteamGameServerAPIContext g_steamAPI;
-CCSGameRules *g_pGameRules = nullptr;
+CCSGameRules* g_pGameRules = nullptr;
int g_iCGamePlayerEquipUseId = -1;
int g_iCreateWorkshopMapGroupId = -1;
int g_iOnTakeDamageAliveId = -1;
@@ -142,14 +142,14 @@ int g_iLoadEventsFromFileId = -1;
int g_iGoToIntermissionId = -1;
int g_iPhysicsTouchShuffle = -1;
-CGameEntitySystem *GameEntitySystem()
+CGameEntitySystem* GameEntitySystem()
{
static int offset = g_GameConfig->GetOffset("GameEntitySystem");
- return *reinterpret_cast((uintptr_t)(g_pGameResourceServiceServer) + offset);
+ return *reinterpret_cast((uintptr_t)(g_pGameResourceServiceServer) + offset);
}
PLUGIN_EXPOSE(CS2Fixes, g_CS2Fixes);
-bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
+bool CS2Fixes::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool late)
{
PLUGIN_SAVEVARS();
@@ -171,7 +171,7 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
// Required to get the IMetamodListener events
g_SMAPI->AddListener(this, this);
- Message( "Starting plugin.\n" );
+ Message("Starting plugin.\n");
CBufferStringGrowable<256> gamedirpath;
g_pEngineServer2->GetGameDir(gamedirpath);
@@ -202,7 +202,7 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
SH_ADD_HOOK(IServerGameClients, ClientPutInServer, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientPutInServer), true);
SH_ADD_HOOK(IServerGameClients, ClientSettingsChanged, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientSettingsChanged), false);
SH_ADD_HOOK(IServerGameClients, OnClientConnected, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_OnClientConnected), false);
- SH_ADD_HOOK(IServerGameClients, ClientConnect, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientConnect), false );
+ SH_ADD_HOOK(IServerGameClients, ClientConnect, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientConnect), false);
SH_ADD_HOOK(IServerGameClients, ClientCommand, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientCommand), false);
SH_ADD_HOOK(IGameEventSystem, PostEventAbstract, g_gameEventSystem, SH_MEMBER(this, &CS2Fixes::Hook_PostEvent), false);
SH_ADD_HOOK(INetworkServerService, StartupServer, g_pNetworkServerService, SH_MEMBER(this, &CS2Fixes::Hook_StartupServer), true);
@@ -210,7 +210,7 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
SH_ADD_HOOK(ICvar, DispatchConCommand, g_pCVar, SH_MEMBER(this, &CS2Fixes::Hook_DispatchConCommand), false);
g_iCreateWorkshopMapGroupId = SH_ADD_MANUALVPHOOK(CreateWorkshopMapGroup, g_pGameTypes, SH_MEMBER(this, &CS2Fixes::Hook_CreateWorkshopMapGroup), false);
- META_CONPRINTF( "All hooks started!\n" );
+ META_CONPRINTF("All hooks started!\n");
bool bRequiredInitLoaded = true;
@@ -300,7 +300,7 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
SH_MANUALHOOK_RECONFIGURE(GoToIntermission, offset, 0, 0);
g_iGoToIntermissionId = SH_ADD_MANUALDVPHOOK(GoToIntermission, pCCSGameRulesVTable, SH_MEMBER(this, &CS2Fixes::Hook_GoToIntermission), false);
- Message( "All hooks started!\n" );
+ Message("All hooks started!\n");
UnlockConVars();
UnlockConCommands();
@@ -331,22 +331,19 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
RegisterWeaponCommands();
// Check hide distance
- new CTimer(0.5f, true, true, []()
- {
+ new CTimer(0.5f, true, true, []() {
g_playerManager->CheckHideDistances();
return 0.5f;
});
// Check for the expiration of infractions like mutes or gags
- new CTimer(30.0f, true, true, []()
- {
+ new CTimer(30.0f, true, true, []() {
g_playerManager->CheckInfractions();
return 30.0f;
});
// Check for idle players and kick them if permitted by cs2f_idle_kick_* 'convars'
- new CTimer(5.0f, true, true, []()
- {
+ new CTimer(5.0f, true, true, []() {
g_pIdleSystem->CheckForIdleClients();
return 5.0f;
});
@@ -361,9 +358,9 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
return true;
}
-bool CS2Fixes::Unload(char *error, size_t maxlen)
+bool CS2Fixes::Unload(char* error, size_t maxlen)
{
- SH_REMOVE_HOOK(IServerGameDLL, GameFrame, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameFramePost), true);
+ SH_REMOVE_HOOK(IServerGameDLL, GameFrame, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameFramePost), true);
SH_REMOVE_HOOK(IServerGameDLL, GameServerSteamAPIActivated, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameServerSteamAPIActivated), false);
SH_REMOVE_HOOK(IServerGameDLL, GameServerSteamAPIDeactivated, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_GameServerSteamAPIDeactivated), false);
SH_REMOVE_HOOK(IServerGameDLL, ApplyGameSettings, g_pSource2Server, SH_MEMBER(this, &CS2Fixes::Hook_ApplyGameSettings), false);
@@ -372,7 +369,7 @@ bool CS2Fixes::Unload(char *error, size_t maxlen)
SH_REMOVE_HOOK(IServerGameClients, ClientPutInServer, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientPutInServer), true);
SH_REMOVE_HOOK(IServerGameClients, ClientSettingsChanged, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientSettingsChanged), false);
SH_REMOVE_HOOK(IServerGameClients, OnClientConnected, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_OnClientConnected), false);
- SH_REMOVE_HOOK(IServerGameClients, ClientConnect, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientConnect), false );
+ SH_REMOVE_HOOK(IServerGameClients, ClientConnect, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientConnect), false);
SH_REMOVE_HOOK(IServerGameClients, ClientCommand, g_pSource2GameClients, SH_MEMBER(this, &CS2Fixes::Hook_ClientCommand), false);
SH_REMOVE_HOOK(IGameEventSystem, PostEventAbstract, g_gameEventSystem, SH_MEMBER(this, &CS2Fixes::Hook_PostEvent), false);
SH_REMOVE_HOOK(INetworkServerService, StartupServer, g_pNetworkServerService, SH_MEMBER(this, &CS2Fixes::Hook_StartupServer), true);
@@ -413,7 +410,7 @@ bool CS2Fixes::Unload(char *error, size_t maxlen)
if (g_pZRWeaponConfig)
delete g_pZRWeaponConfig;
-
+
if (g_pZRHitgroupConfig)
delete g_pZRHitgroupConfig;
@@ -465,7 +462,7 @@ void CS2Fixes::Hook_DispatchConCommand(ConCommandHandle cmdHandle, const CComman
// Chat messages should generate events regardless
if (pController)
{
- IGameEvent *pEvent = g_gameEventManager->CreateEvent("player_chat");
+ IGameEvent* pEvent = g_gameEventManager->CreateEvent("player_chat");
if (pEvent)
{
@@ -479,7 +476,8 @@ void CS2Fixes::Hook_DispatchConCommand(ConCommandHandle cmdHandle, const CComman
if (!bGagged && !bSilent && !bFlooding)
{
- SH_CALL(g_pCVar, &ICvar::DispatchConCommand)(cmdHandle, ctx, args);
+ SH_CALL(g_pCVar, &ICvar::DispatchConCommand)
+ (cmdHandle, ctx, args);
}
else if (bFlooding)
{
@@ -490,12 +488,12 @@ void CS2Fixes::Hook_DispatchConCommand(ConCommandHandle cmdHandle, const CComman
{
// HACK: At this point, we can safely modify the arg buffer as it won't be passed anywhere else
// The string here is originally ("@foo bar"), trim it to be (foo bar)
- char *pszMessage = (char*)(args.ArgS() + 2);
+ char* pszMessage = (char*)(args.ArgS() + 2);
pszMessage[V_strlen(pszMessage) - 1] = 0;
for (int i = 0; i < gpGlobals->maxClients; i++)
{
- ZEPlayer *pPlayer = g_playerManager->GetPlayer(i);
+ ZEPlayer* pPlayer = g_playerManager->GetPlayer(i);
if (!pPlayer)
continue;
@@ -510,16 +508,14 @@ void CS2Fixes::Hook_DispatchConCommand(ConCommandHandle cmdHandle, const CComman
// Finally, run the chat command if it is one, so anything will print after the player's message
if (bCommand)
{
- char *pszMessage = (char *)(args.ArgS() + 1);
+ char* pszMessage = (char*)(args.ArgS() + 1);
- if (pszMessage[0] == '"' || pszMessage[0] == '!' || pszMessage[0] == '/'){
+ if (pszMessage[0] == '"' || pszMessage[0] == '!' || pszMessage[0] == '/')
pszMessage += 1;
- }
// Host_Say at some point removes the trailing " for whatever reason, so we only remove if it was never called
- if (bSilent && pszMessage[V_strlen(pszMessage) - 1] == '"'){
+ if (bSilent && pszMessage[V_strlen(pszMessage) - 1] == '"')
pszMessage[V_strlen(pszMessage) - 1] = '\0';
- }
ParseChatCommand(pszMessage, pController);
}
@@ -530,7 +526,7 @@ void CS2Fixes::Hook_DispatchConCommand(ConCommandHandle cmdHandle, const CComman
RETURN_META(MRES_IGNORED);
}
-void CS2Fixes::Hook_StartupServer(const GameSessionConfiguration_t& config, ISource2WorldSession *pSession, const char *pszMapName)
+void CS2Fixes::Hook_StartupServer(const GameSessionConfiguration_t& config, ISource2WorldSession* pSession, const char* pszMapName)
{
g_pNetworkGameServer = g_pNetworkServerService->GetIGameServer();
g_pEntitySystem = GameEntitySystem();
@@ -539,7 +535,7 @@ void CS2Fixes::Hook_StartupServer(const GameSessionConfiguration_t& config, ISou
Message("Hook_StartupServer: %s\n", pszMapName);
- if(g_bHasTicked)
+ if (g_bHasTicked)
RemoveMapTimers();
g_bHasTicked = false;
@@ -580,14 +576,14 @@ void CS2Fixes::Hook_GameServerSteamAPIDeactivated()
}
void CS2Fixes::Hook_PostEvent(CSplitScreenSlot nSlot, bool bLocalOnly, int nClientCount, const uint64* clients,
- INetworkMessageInternal* pEvent, const CNetMessage* pData, unsigned long nSize, NetChannelBufType_t bufType)
+ INetworkMessageInternal* pEvent, const CNetMessage* pData, unsigned long nSize, NetChannelBufType_t bufType)
{
// Message( "Hook_PostEvent(%d, %d, %d, %lli)\n", nSlot, bLocalOnly, nClientCount, clients );
// Need to explicitly get a pointer to the right function as it's overloaded and SH_CALL can't resolve that
- static void (IGameEventSystem::*PostEventAbstract)(CSplitScreenSlot, bool, int, const uint64 *,
- INetworkMessageInternal *, const CNetMessage *, unsigned long, NetChannelBufType_t) = &IGameEventSystem::PostEventAbstract;
+ static void (IGameEventSystem::*PostEventAbstract)(CSplitScreenSlot, bool, int, const uint64*,
+ INetworkMessageInternal*, const CNetMessage*, unsigned long, NetChannelBufType_t) = &IGameEventSystem::PostEventAbstract;
- NetMessageInfo_t *info = pEvent->GetNetMessageInfo();
+ NetMessageInfo_t* info = pEvent->GetNetMessageInfo();
if (g_bEnableStopSound && info->m_MessageId == GE_FireBulletsId)
{
@@ -607,7 +603,7 @@ void CS2Fixes::Hook_PostEvent(CSplitScreenSlot nSlot, bool bLocalOnly, int nClie
msg->set_sound_type(9);
msg->set_item_def_index(61); // weapon_usp_silencer
- uint64 clientMask = *(uint64 *)clients & g_playerManager->GetSilenceSoundMask();
+ uint64 clientMask = *(uint64*)clients & g_playerManager->GetSilenceSoundMask();
SH_CALL(g_gameEventSystem, PostEventAbstract)
(nSlot, bLocalOnly, nClientCount, &clientMask, pEvent, msg, nSize, bufType);
@@ -618,12 +614,12 @@ void CS2Fixes::Hook_PostEvent(CSplitScreenSlot nSlot, bool bLocalOnly, int nClie
}
// Filter out people using stop/silence sound from the original event
- *(uint64 *)clients &= ~g_playerManager->GetStopSoundMask();
- *(uint64 *)clients &= ~g_playerManager->GetSilenceSoundMask();
+ *(uint64*)clients &= ~g_playerManager->GetStopSoundMask();
+ *(uint64*)clients &= ~g_playerManager->GetSilenceSoundMask();
}
else if (info->m_MessageId == TE_WorldDecalId)
{
- *(uint64 *)clients &= ~g_playerManager->GetStopDecalsMask();
+ *(uint64*)clients &= ~g_playerManager->GetStopDecalsMask();
}
else if (info->m_MessageId == GE_Source1LegacyGameEvent)
{
@@ -638,32 +634,31 @@ void CS2Fixes::Hook_PostEvent(CSplitScreenSlot nSlot, bool bLocalOnly, int nClie
// remove client with noshake from the event
if (g_bEnableNoShake)
- *(uint64 *)clients &= ~g_playerManager->GetNoShakeMask();
+ *(uint64*)clients &= ~g_playerManager->GetNoShakeMask();
}
-
}
void CS2Fixes::AllPluginsLoaded()
{
- /* This is where we'd do stuff that relies on the mod or other plugins
+ /* This is where we'd do stuff that relies on the mod or other plugins
* being initialized (for example, cvars added and events registered).
*/
- Message( "AllPluginsLoaded\n" );
+ Message("AllPluginsLoaded\n");
}
-CUtlVector *GetClientList()
+CUtlVector* GetClientList()
{
if (!g_pNetworkGameServer)
return nullptr;
static int offset = g_GameConfig->GetOffset("CNetworkGameServer_ClientList");
- return (CUtlVector *)(&g_pNetworkGameServer[offset]);
+ return (CUtlVector*)(&g_pNetworkGameServer[offset]);
}
-CServerSideClient *GetClientBySlot(CPlayerSlot slot)
+CServerSideClient* GetClientBySlot(CPlayerSlot slot)
{
- CUtlVector *pClients = GetClientList();
+ CUtlVector* pClients = GetClientList();
if (!pClients)
return nullptr;
@@ -676,7 +671,7 @@ void FullUpdateAllClients()
auto pClients = GetClientList();
FOR_EACH_VEC(*pClients, i)
- (*pClients)[i]->ForceFullUpdate();
+ (*pClients)[i]->ForceFullUpdate();
}
// Because sv_fullupdate doesn't work
@@ -685,15 +680,15 @@ CON_COMMAND_F(cs2f_fullupdate, "Force a full update for all clients.", FCVAR_LIN
FullUpdateAllClients();
}
-void CS2Fixes::Hook_ClientActive( CPlayerSlot slot, bool bLoadGame, const char *pszName, uint64 xuid )
+void CS2Fixes::Hook_ClientActive(CPlayerSlot slot, bool bLoadGame, const char* pszName, uint64 xuid)
{
- Message( "Hook_ClientActive(%d, %d, \"%s\", %lli)\n", slot, bLoadGame, pszName, xuid );
+ Message("Hook_ClientActive(%d, %d, \"%s\", %lli)\n", slot, bLoadGame, pszName, xuid);
}
-void CS2Fixes::Hook_ClientCommand( CPlayerSlot slot, const CCommand &args )
+void CS2Fixes::Hook_ClientCommand(CPlayerSlot slot, const CCommand& args)
{
#ifdef _DEBUG
- Message( "Hook_ClientCommand(%d, \"%s\")\n", slot, args.GetCommandString() );
+ Message("Hook_ClientCommand(%d, \"%s\")\n", slot, args.GetCommandString());
#endif
if (g_fIdleKickTime > 0.0f)
@@ -719,10 +714,10 @@ void CS2Fixes::Hook_ClientCommand( CPlayerSlot slot, const CCommand &args )
}
}
-void CS2Fixes::Hook_ClientSettingsChanged( CPlayerSlot slot )
+void CS2Fixes::Hook_ClientSettingsChanged(CPlayerSlot slot)
{
#ifdef _DEBUG
- Message( "Hook_ClientSettingsChanged(%d)\n", slot );
+ Message("Hook_ClientSettingsChanged(%d)\n", slot);
#endif
}
@@ -740,9 +735,9 @@ void CS2Fixes::Hook_OnClientConnected(CPlayerSlot slot, const char* pszName, uin
g_playerManager->OnBotConnected(slot);
}
-bool CS2Fixes::Hook_ClientConnect( CPlayerSlot slot, const char *pszName, uint64 xuid, const char *pszNetworkID, bool unk1, CBufferString *pRejectReason )
+bool CS2Fixes::Hook_ClientConnect(CPlayerSlot slot, const char* pszName, uint64 xuid, const char* pszNetworkID, bool unk1, CBufferString* pRejectReason)
{
- Message( "Hook_ClientConnect(%d, \"%s\", %lli, \"%s\", %d, \"%s\")\n", slot, pszName, xuid, pszNetworkID, unk1, pRejectReason->ToGrowable()->Get() );
+ Message("Hook_ClientConnect(%d, \"%s\", %lli, \"%s\", %d, \"%s\")\n", slot, pszName, xuid, pszNetworkID, unk1, pRejectReason->ToGrowable()->Get());
// Player is banned
if (!g_playerManager->OnClientConnected(slot, xuid, pszNetworkID))
@@ -751,9 +746,9 @@ bool CS2Fixes::Hook_ClientConnect( CPlayerSlot slot, const char *pszName, uint64
RETURN_META_VALUE(MRES_IGNORED, true);
}
-void CS2Fixes::Hook_ClientPutInServer( CPlayerSlot slot, char const *pszName, int type, uint64 xuid )
+void CS2Fixes::Hook_ClientPutInServer(CPlayerSlot slot, char const* pszName, int type, uint64 xuid)
{
- Message( "Hook_ClientPutInServer(%d, \"%s\", %d, %d, %lli)\n", slot, pszName, type, xuid );
+ Message("Hook_ClientPutInServer(%d, \"%s\", %d, %d, %lli)\n", slot, pszName, type, xuid);
if (!g_playerManager->GetPlayer(slot))
return;
@@ -764,9 +759,9 @@ void CS2Fixes::Hook_ClientPutInServer( CPlayerSlot slot, char const *pszName, in
ZR_Hook_ClientPutInServer(slot, pszName, type, xuid);
}
-void CS2Fixes::Hook_ClientDisconnect( CPlayerSlot slot, ENetworkDisconnectionReason reason, const char *pszName, uint64 xuid, const char *pszNetworkID )
+void CS2Fixes::Hook_ClientDisconnect(CPlayerSlot slot, ENetworkDisconnectionReason reason, const char* pszName, uint64 xuid, const char* pszNetworkID)
{
- Message( "Hook_ClientDisconnect(%d, %d, \"%s\", %lli)\n", slot, reason, pszName, xuid );
+ Message("Hook_ClientDisconnect(%d, %d, \"%s\", %lli)\n", slot, reason, pszName, xuid);
ZEPlayer* pPlayer = g_playerManager->GetPlayer(slot);
if (!pPlayer)
@@ -791,9 +786,7 @@ void CS2Fixes::Hook_GameFramePost(bool simulating, bool bFirstTick, bool bLastTi
VPROF_BUDGET("CS2Fixes::Hook_GameFramePost", "CS2FixesPerFrame");
if (simulating && g_bHasTicked)
- {
g_flUniversalTime += gpGlobals->curtime - g_flLastTickedTime;
- }
g_flLastTickedTime = gpGlobals->curtime;
g_bHasTicked = true;
@@ -808,7 +801,7 @@ void CS2Fixes::Hook_GameFramePost(bool simulating, bool bFirstTick, bool bLastTi
if (timer->m_flLastExecute == -1)
timer->m_flLastExecute = g_flUniversalTime;
- // Timer execute
+ // Timer execute
if (timer->m_flLastExecute + timer->m_flInterval <= g_flUniversalTime)
{
if ((!timer->m_bPreserveRoundChange && timer->m_iRoundNum != g_iRoundNum) || !timer->Execute())
@@ -826,13 +819,13 @@ void CS2Fixes::Hook_GameFramePost(bool simulating, bool bFirstTick, bool bLastTi
if (g_bEnableZR)
CZRRegenTimer::Tick();
- EntityHandler_OnGameFramePost(simulating, gpGlobals->tickcount);
+ EntityHandler_OnGameFramePost(simulating, gpGlobals->tickcount);
}
extern bool g_bFlashLightTransmitOthers;
-void CS2Fixes::Hook_CheckTransmit(CCheckTransmitInfo **ppInfoList, int infoCount, CBitVec<16384> &unionTransmitEdicts,
- const Entity2Networkable_t **pNetworkables, const uint16 *pEntityIndicies, int nEntities, bool bEnablePVSBits)
+void CS2Fixes::Hook_CheckTransmit(CCheckTransmitInfo** ppInfoList, int infoCount, CBitVec<16384>& unionTransmitEdicts,
+ const Entity2Networkable_t** pNetworkables, const uint16* pEntityIndicies, int nEntities, bool bEnablePVSBits)
{
if (!g_pEntitySystem)
return;
@@ -841,12 +834,12 @@ void CS2Fixes::Hook_CheckTransmit(CCheckTransmitInfo **ppInfoList, int infoCount
for (int i = 0; i < infoCount; i++)
{
- auto &pInfo = ppInfoList[i];
+ auto& pInfo = ppInfoList[i];
// the offset happens to have a player index here,
// though this is probably part of the client class that contains the CCheckTransmitInfo
static int offset = g_GameConfig->GetOffset("CheckTransmitPlayerSlot");
- int iPlayerSlot = (int)*((uint8 *)pInfo + offset);
+ int iPlayerSlot = (int)*((uint8*)pInfo + offset);
CCSPlayerController* pSelfController = CCSPlayerController::FromSlot(iPlayerSlot);
@@ -866,18 +859,16 @@ void CS2Fixes::Hook_CheckTransmit(CCheckTransmitInfo **ppInfoList, int infoCount
continue;
// Don't transmit other players' flashlights
- CBarnLight *pFlashLight = pController->IsConnected() ? g_playerManager->GetPlayer(j)->GetFlashLight() : nullptr;
+ CBarnLight* pFlashLight = pController->IsConnected() ? g_playerManager->GetPlayer(j)->GetFlashLight() : nullptr;
if (!g_bFlashLightTransmitOthers && pFlashLight)
- {
pInfo->m_pTransmitEntity->Clear(pFlashLight->entindex());
- }
// Always transmit other players if spectating
if (!g_bEnableHide || pSelfController->GetPawnState() == STATE_OBSERVER_MODE)
continue;
// Get the actual pawn as the player could be currently spectating
- CCSPlayerPawn *pPawn = pController->GetPlayerPawn();
+ CCSPlayerPawn* pPawn = pController->GetPlayerPawn();
if (!pPawn)
continue;
@@ -885,13 +876,13 @@ void CS2Fixes::Hook_CheckTransmit(CCheckTransmitInfo **ppInfoList, int infoCount
// Hide players marked as hidden or ANY dead player, it seems that a ragdoll of a previously hidden player can crash?
// TODO: Revert this if/when valve fixes the issue?
// Also do not hide leaders to other players
- ZEPlayer *pOtherZEPlayer = g_playerManager->GetPlayer(j);
+ ZEPlayer* pOtherZEPlayer = g_playerManager->GetPlayer(j);
if ((pSelfZEPlayer->ShouldBlockTransmit(j) && (pOtherZEPlayer && !pOtherZEPlayer->IsLeader())) || !pPawn->IsAlive())
pInfo->m_pTransmitEntity->Clear(pPawn->entindex());
}
// Don't transmit glow model to it's owner
- CBaseModelEntity *pGlowModel = pSelfZEPlayer->GetGlowModel();
+ CBaseModelEntity* pGlowModel = pSelfZEPlayer->GetGlowModel();
if (pGlowModel)
pInfo->m_pTransmitEntity->Clear(pGlowModel->entindex());
@@ -929,9 +920,9 @@ bool g_bDropMapWeapons = false;
FAKE_BOOL_CVAR(cs2f_drop_map_weapons, "Whether to force drop map-spawned weapons on death", g_bDropMapWeapons, false, false)
-bool CS2Fixes::Hook_OnTakeDamage_Alive(CTakeDamageInfoContainer *pInfoContainer)
+bool CS2Fixes::Hook_OnTakeDamage_Alive(CTakeDamageInfoContainer* pInfoContainer)
{
- CCSPlayerPawn *pPawn = META_IFACEPTR(CCSPlayerPawn);
+ CCSPlayerPawn* pPawn = META_IFACEPTR(CCSPlayerPawn);
if (g_bEnableZR && ZR_Hook_OnTakeDamage_Alive(pInfoContainer->pInfo, pPawn))
RETURN_META_VALUE(MRES_SUPERCEDE, false);
@@ -1008,21 +999,21 @@ void CS2Fixes::Hook_PhysicsTouchShuffle(CUtlVector* pList, bool u
pList->Purge();
- for (const auto &link : touchingLinks)
+ for (const auto& link : touchingLinks)
pList->AddToTail(link);
- for (const auto &link : unTouchLinks)
+ for (const auto& link : unTouchLinks)
pList->AddToTail(link);
}
void CS2Fixes::Hook_CheckMovingGround(double frametime)
{
- CCSPlayer_MovementServices *pMove = META_IFACEPTR(CCSPlayer_MovementServices);
- CCSPlayerPawn *pPawn = pMove->GetPawn();
+ CCSPlayer_MovementServices* pMove = META_IFACEPTR(CCSPlayer_MovementServices);
+ CCSPlayerPawn* pPawn = pMove->GetPawn();
if (!pPawn)
RETURN_META(MRES_IGNORED);
- CCSPlayerController *pController = pPawn->GetOriginalController();
+ CCSPlayerController* pController = pPawn->GetOriginalController();
if (!pController)
RETURN_META(MRES_IGNORED);
@@ -1041,19 +1032,19 @@ void CS2Fixes::Hook_CheckMovingGround(double frametime)
RETURN_META(MRES_IGNORED);
}
-int CS2Fixes::Hook_LoadEventsFromFile(const char *filename, bool bSearchAll)
+int CS2Fixes::Hook_LoadEventsFromFile(const char* filename, bool bSearchAll)
{
ExecuteOnce(g_gameEventManager = META_IFACEPTR(IGameEventManager2));
RETURN_META_VALUE(MRES_IGNORED, 0);
}
-void CS2Fixes::OnLevelInit( char const *pMapName,
- char const *pMapEntities,
- char const *pOldLevel,
- char const *pLandmarkName,
- bool loadGame,
- bool background )
+void CS2Fixes::OnLevelInit(char const* pMapName,
+ char const* pMapEntities,
+ char const* pOldLevel,
+ char const* pLandmarkName,
+ bool loadGame,
+ bool background)
{
Message("OnLevelInit(%s)\n", pMapName);
g_iRoundNum = 0;
@@ -1079,56 +1070,56 @@ void CS2Fixes::OnLevelShutdown()
Message("OnLevelShutdown()\n");
}
-bool CS2Fixes::Pause(char *error, size_t maxlen)
+bool CS2Fixes::Pause(char* error, size_t maxlen)
{
return true;
}
-bool CS2Fixes::Unpause(char *error, size_t maxlen)
+bool CS2Fixes::Unpause(char* error, size_t maxlen)
{
return true;
}
-const char *CS2Fixes::GetLicense()
+const char* CS2Fixes::GetLicense()
{
return "GPL v3 License";
}
-const char *CS2Fixes::GetVersion()
+const char* CS2Fixes::GetVersion()
{
#ifndef CS2FIXES_VERSION
-#define CS2FIXES_VERSION "1.7-dev"
+ #define CS2FIXES_VERSION "1.7-dev"
#endif
return CS2FIXES_VERSION; // defined by the build script
}
-const char *CS2Fixes::GetDate()
+const char* CS2Fixes::GetDate()
{
return __DATE__;
}
-const char *CS2Fixes::GetLogTag()
+const char* CS2Fixes::GetLogTag()
{
return "CS2Fixes";
}
-const char *CS2Fixes::GetAuthor()
+const char* CS2Fixes::GetAuthor()
{
return "xen, Poggu, and the Source2ZE community";
}
-const char *CS2Fixes::GetDescription()
+const char* CS2Fixes::GetDescription()
{
return "A bunch of experiments thrown together into one big mess of a plugin.";
}
-const char *CS2Fixes::GetName()
+const char* CS2Fixes::GetName()
{
return "CS2Fixes";
}
-const char *CS2Fixes::GetURL()
+const char* CS2Fixes::GetURL()
{
return "https://github.com/Source2ZE/CS2Fixes";
}
\ No newline at end of file
diff --git a/src/cs2fixes.h b/src/cs2fixes.h
index c51ac92a..77acd441 100644
--- a/src/cs2fixes.h
+++ b/src/cs2fixes.h
@@ -19,12 +19,12 @@
#pragma once
-#include
#include "igameevents.h"
-#include
-#include
#include "networksystem/inetworkserializer.h"
+#include
+#include
#include
+#include
struct CTakeDamageInfoContainer;
class CCSPlayer_MovementServices;
@@ -34,40 +34,41 @@ struct TouchLinked_t;
class CS2Fixes : public ISmmPlugin, public IMetamodListener
{
public:
- bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
+ bool Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool late);
void Hook_PostEvent(CSplitScreenSlot nSlot, bool bLocalOnly, int nClientCount, const uint64* clients,
- INetworkMessageInternal* pEvent, const CNetMessage* pData, unsigned long nSize, NetChannelBufType_t bufType);
- bool Unload(char *error, size_t maxlen);
- bool Pause(char *error, size_t maxlen);
- bool Unpause(char *error, size_t maxlen);
+ INetworkMessageInternal* pEvent, const CNetMessage* pData, unsigned long nSize, NetChannelBufType_t bufType);
+ bool Unload(char* error, size_t maxlen);
+ bool Pause(char* error, size_t maxlen);
+ bool Unpause(char* error, size_t maxlen);
void AllPluginsLoaded();
-public: //hooks
+
+public: // hooks
void Hook_GameServerSteamAPIActivated();
void Hook_GameServerSteamAPIDeactivated();
- void OnLevelInit( char const *pMapName,
- char const *pMapEntities,
- char const *pOldLevel,
- char const *pLandmarkName,
- bool loadGame,
- bool background );
+ void OnLevelInit(char const* pMapName,
+ char const* pMapEntities,
+ char const* pOldLevel,
+ char const* pLandmarkName,
+ bool loadGame,
+ bool background);
void OnLevelShutdown();
void Hook_GameFramePost(bool simulating, bool bFirstTick, bool bLastTick);
- void Hook_ClientActive( CPlayerSlot slot, bool bLoadGame, const char *pszName, uint64 xuid );
- void Hook_ClientDisconnect( CPlayerSlot slot, ENetworkDisconnectionReason reason, const char *pszName, uint64 xuid, const char *pszNetworkID );
- void Hook_ClientPutInServer( CPlayerSlot slot, char const *pszName, int type, uint64 xuid );
- void Hook_ClientSettingsChanged( CPlayerSlot slot );
- void Hook_OnClientConnected( CPlayerSlot slot, const char *pszName, uint64 xuid, const char *pszNetworkID, const char *pszAddress, bool bFakePlayer );
- bool Hook_ClientConnect( CPlayerSlot slot, const char *pszName, uint64 xuid, const char *pszNetworkID, bool unk1, CBufferString *pRejectReason );
- void Hook_ClientCommand( CPlayerSlot nSlot, const CCommand &_cmd );
- void Hook_CheckTransmit(CCheckTransmitInfo **ppInfoList, int infoCount, CBitVec<16384> &unionTransmitEdicts,
- const Entity2Networkable_t **pNetworkables, const uint16 *pEntityIndicies, int nEntities, bool bEnablePVSBits);
+ void Hook_ClientActive(CPlayerSlot slot, bool bLoadGame, const char* pszName, uint64 xuid);
+ void Hook_ClientDisconnect(CPlayerSlot slot, ENetworkDisconnectionReason reason, const char* pszName, uint64 xuid, const char* pszNetworkID);
+ void Hook_ClientPutInServer(CPlayerSlot slot, char const* pszName, int type, uint64 xuid);
+ void Hook_ClientSettingsChanged(CPlayerSlot slot);
+ void Hook_OnClientConnected(CPlayerSlot slot, const char* pszName, uint64 xuid, const char* pszNetworkID, const char* pszAddress, bool bFakePlayer);
+ bool Hook_ClientConnect(CPlayerSlot slot, const char* pszName, uint64 xuid, const char* pszNetworkID, bool unk1, CBufferString* pRejectReason);
+ void Hook_ClientCommand(CPlayerSlot nSlot, const CCommand& _cmd);
+ void Hook_CheckTransmit(CCheckTransmitInfo** ppInfoList, int infoCount, CBitVec<16384>& unionTransmitEdicts,
+ const Entity2Networkable_t** pNetworkables, const uint16* pEntityIndicies, int nEntities, bool bEnablePVSBits);
void Hook_DispatchConCommand(ConCommandHandle cmd, const CCommandContext& ctx, const CCommand& args);
void Hook_CGamePlayerEquipUse(class InputData_t*);
void Hook_StartupServer(const GameSessionConfiguration_t& config, ISource2WorldSession*, const char*);
void Hook_ApplyGameSettings(KeyValues* pKV);
void Hook_CreateWorkshopMapGroup(const char* name, const CUtlStringList& mapList);
void Hook_GoToIntermission(bool bAbortedMatch);
- bool Hook_OnTakeDamage_Alive(CTakeDamageInfoContainer *pInfoContainer);
+ bool Hook_OnTakeDamage_Alive(CTakeDamageInfoContainer* pInfoContainer);
void Hook_PhysicsTouchShuffle(CUtlVector* pList, bool unknown);
#ifdef PLATFORM_WINDOWS
Vector* Hook_GetEyePosition(Vector*);
@@ -77,17 +78,17 @@ class CS2Fixes : public ISmmPlugin, public IMetamodListener
QAngle Hook_GetEyeAngles();
#endif
void Hook_CheckMovingGround(double frametime);
- int Hook_LoadEventsFromFile(const char *filename, bool bSearchAll);
+ int Hook_LoadEventsFromFile(const char* filename, bool bSearchAll);
public:
- const char *GetAuthor();
- const char *GetName();
- const char *GetDescription();
- const char *GetURL();
- const char *GetLicense();
- const char *GetVersion();
- const char *GetDate();
- const char *GetLogTag();
+ const char* GetAuthor();
+ const char* GetName();
+ const char* GetDescription();
+ const char* GetURL();
+ const char* GetLicense();
+ const char* GetVersion();
+ const char* GetDate();
+ const char* GetLogTag();
};
extern CS2Fixes g_CS2Fixes;
diff --git a/src/ctimer.cpp b/src/ctimer.cpp
index 2fc938e8..47b7bd9d 100644
--- a/src/ctimer.cpp
+++ b/src/ctimer.cpp
@@ -28,15 +28,15 @@ void RemoveTimers()
void RemoveMapTimers()
{
- for (int i = g_timers.Tail(); i != g_timers.InvalidIndex();)
- {
- int prevIndex = i;
- i = g_timers.Previous(i);
+ for (int i = g_timers.Tail(); i != g_timers.InvalidIndex();)
+ {
+ int prevIndex = i;
+ i = g_timers.Previous(i);
- if(g_timers[prevIndex]->m_bPreserveMapChange)
- continue;
+ if (g_timers[prevIndex]->m_bPreserveMapChange)
+ continue;
- delete g_timers[prevIndex];
- g_timers.Remove(prevIndex);
- }
+ delete g_timers[prevIndex];
+ g_timers.Remove(prevIndex);
+ }
}
\ No newline at end of file
diff --git a/src/ctimer.h b/src/ctimer.h
index 2abc13ab..f0140bc3 100644
--- a/src/ctimer.h
+++ b/src/ctimer.h
@@ -18,26 +18,27 @@
*/
#pragma once
-#include
#include "utllinkedlist.h"
+#include
extern int g_iRoundNum;
-class CTimerBase {
+class CTimerBase
+{
public:
- CTimerBase(float flInitialInterval, bool bPreserveMapChange, bool bPreserveRoundChange) :
- m_flInterval(flInitialInterval), m_bPreserveMapChange(bPreserveMapChange), m_bPreserveRoundChange(bPreserveRoundChange)
- {
- m_iRoundNum = g_iRoundNum;
- }
+ CTimerBase(float flInitialInterval, bool bPreserveMapChange, bool bPreserveRoundChange) :
+ m_flInterval(flInitialInterval), m_bPreserveMapChange(bPreserveMapChange), m_bPreserveRoundChange(bPreserveRoundChange)
+ {
+ m_iRoundNum = g_iRoundNum;
+ }
- virtual bool Execute() = 0;
+ virtual bool Execute() = 0;
- float m_flInterval;
- float m_flLastExecute = -1;
- bool m_bPreserveMapChange;
- bool m_bPreserveRoundChange;
- int m_iRoundNum;
+ float m_flInterval;
+ float m_flLastExecute = -1;
+ bool m_bPreserveMapChange;
+ bool m_bPreserveRoundChange;
+ int m_iRoundNum;
};
extern CUtlLinkedList g_timers;
@@ -47,22 +48,21 @@ extern CUtlLinkedList g_timers;
class CTimer : public CTimerBase
{
public:
- CTimer(float flInitialInterval, bool bPreserveMapChange, bool bPreserveRoundChange, std::function func) :
+ CTimer(float flInitialInterval, bool bPreserveMapChange, bool bPreserveRoundChange, std::function func) :
CTimerBase(flInitialInterval, bPreserveMapChange, bPreserveRoundChange), m_func(func)
- {
- g_timers.AddToTail(this);
- };
+ {
+ g_timers.AddToTail(this);
+ };
- inline bool Execute() override
- {
- m_flInterval = m_func();
+ inline bool Execute() override
+ {
+ m_flInterval = m_func();
- return m_flInterval >= 0;
+ return m_flInterval >= 0;
}
- std::function m_func;
+ std::function m_func;
};
-
void RemoveTimers();
void RemoveMapTimers();
\ No newline at end of file
diff --git a/src/customio.cpp b/src/customio.cpp
index 7b0a6d2d..2d06d8df 100644
--- a/src/customio.cpp
+++ b/src/customio.cpp
@@ -35,369 +35,369 @@ extern CGlobalVars* gpGlobals;
struct AddOutputKey_t
{
- AddOutputKey_t(const char* pName, int32_t parts) :
- m_pName(pName)
- {
- m_nLength = strlen(pName);
- m_nParts = parts;
- }
-
- AddOutputKey_t(const AddOutputKey_t& other) :
- m_pName(other.m_pName),
- m_nLength(other.m_nLength),
- m_nParts(other.m_nParts) {}
-
- const char* m_pName;
- size_t m_nLength;
- int32_t m_nParts;
+ AddOutputKey_t(const char* pName, int32_t parts) :
+ m_pName(pName)
+ {
+ m_nLength = strlen(pName);
+ m_nParts = parts;
+ }
+
+ AddOutputKey_t(const AddOutputKey_t& other) :
+ m_pName(other.m_pName),
+ m_nLength(other.m_nLength),
+ m_nParts(other.m_nParts) {}
+
+ const char* m_pName;
+ size_t m_nLength;
+ int32_t m_nParts;
};
-using AddOutputHandler_t = void (*)(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs);
+using AddOutputHandler_t = void (*)(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs);
struct AddOutputInfo_t
{
- AddOutputInfo_t(const AddOutputKey_t& key, const AddOutputHandler_t& handler) :
- m_Key(key), m_Handler(handler) {}
+ AddOutputInfo_t(const AddOutputKey_t& key, const AddOutputHandler_t& handler) :
+ m_Key(key), m_Handler(handler) {}
- AddOutputKey_t m_Key;
- AddOutputHandler_t m_Handler;
+ AddOutputKey_t m_Key;
+ AddOutputHandler_t m_Handler;
};
static void AddOutputCustom_Targetname(CBaseEntity* pInstance, CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- pInstance->SetName(vecArgs[1].c_str());
+ pInstance->SetName(vecArgs[1].c_str());
#ifdef _DEBUG
- Message("SetName %s to %d", vecArgs[1].c_str(), pInstance->GetHandle().GetEntryIndex());
+ Message("SetName %s to %d", vecArgs[1].c_str(), pInstance->GetHandle().GetEntryIndex());
#endif
}
-static void AddOutputCustom_Origin(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_Origin(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- Vector origin(clamp(Q_atof(vecArgs[1].c_str()), -16384.f, 16384.f),
- clamp(Q_atof(vecArgs[2].c_str()), -16384.f, 16384.f),
- clamp(Q_atof(vecArgs[3].c_str()), -16384.f, 16384.f));
- pInstance->Teleport(&origin, nullptr, nullptr);
+ Vector origin(clamp(Q_atof(vecArgs[1].c_str()), -16384.f, 16384.f),
+ clamp(Q_atof(vecArgs[2].c_str()), -16384.f, 16384.f),
+ clamp(Q_atof(vecArgs[3].c_str()), -16384.f, 16384.f));
+ pInstance->Teleport(&origin, nullptr, nullptr);
#ifdef _DEBUG
- Message("SetOrigin %f %f %f for %s", origin.x, origin.y, origin.z, pInstance->GetName());
+ Message("SetOrigin %f %f %f for %s", origin.x, origin.y, origin.z, pInstance->GetName());
#endif
}
-static void AddOutputCustom_Angles(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_Angles(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- QAngle angles(clamp(Q_atof(vecArgs[1].c_str()), -360.f, 360.f),
- clamp(Q_atof(vecArgs[2].c_str()), -360.f, 360.f),
- clamp(Q_atof(vecArgs[3].c_str()), -360.f, 360.f));
- pInstance->Teleport(nullptr, &angles, nullptr);
+ QAngle angles(clamp(Q_atof(vecArgs[1].c_str()), -360.f, 360.f),
+ clamp(Q_atof(vecArgs[2].c_str()), -360.f, 360.f),
+ clamp(Q_atof(vecArgs[3].c_str()), -360.f, 360.f));
+ pInstance->Teleport(nullptr, &angles, nullptr);
#ifdef _DEBUG
- Message("SetAngles %f %f %f for %s", angles.x, angles.y, angles.z, pInstance->GetName());
+ Message("SetAngles %f %f %f for %s", angles.x, angles.y, angles.z, pInstance->GetName());
#endif
}
-static void AddOutputCustom_MaxHealth(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_MaxHealth(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- pInstance->m_iMaxHealth(clamp(Q_atoi(vecArgs[1].c_str()), 0, INT_MAX));
+ pInstance->m_iMaxHealth(clamp(Q_atoi(vecArgs[1].c_str()), 0, INT_MAX));
#ifdef _DEBUG
- const int m_iMaxHealth = pInstance->m_iMaxHealth;
- Message("SetMaxHealth %d for %s", m_iMaxHealth, pInstance->GetName());
+ const int m_iMaxHealth = pInstance->m_iMaxHealth;
+ Message("SetMaxHealth %d for %s", m_iMaxHealth, pInstance->GetName());
#endif
}
-static void AddOutputCustom_Health(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_Health(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- pInstance->m_iHealth(clamp(Q_atoi(vecArgs[1].c_str()), 0, INT_MAX));
+ pInstance->m_iHealth(clamp(Q_atoi(vecArgs[1].c_str()), 0, INT_MAX));
#ifdef _DEBUG
- const int m_iHealth = pInstance->m_iHealth;
- Message("SetHealth %d for %s", m_iHealth, pInstance->GetName());
+ const int m_iHealth = pInstance->m_iHealth;
+ Message("SetHealth %d for %s", m_iHealth, pInstance->GetName());
#endif
}
-static void AddOutputCustom_MoveType(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_MoveType(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- static Vector stopVelocity(0, 0, 0);
- const auto value = clamp(Q_atoi(vecArgs[1].c_str()), MOVETYPE_NONE, MOVETYPE_LAST);
- const auto type = static_cast(value);
+ static Vector stopVelocity(0, 0, 0);
+ const auto value = clamp(Q_atoi(vecArgs[1].c_str()), MOVETYPE_NONE, MOVETYPE_LAST);
+ const auto type = static_cast(value);
- pInstance->SetMoveType(type);
+ pInstance->SetMoveType(type);
#ifdef _DEBUG
- Message("SetMoveType %d for %s", type, pInstance->GetName());
+ Message("SetMoveType %d for %s", type, pInstance->GetName());
#endif
}
-static void AddOutputCustom_EntityTemplate(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_EntityTemplate(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- if (strcmp(pInstance->GetClassname(), "env_entity_maker") == 0)
- {
- const auto pEntity = reinterpret_cast(pInstance);
- const auto pValue = g_pEntitySystem->AllocPooledString(vecArgs[1].c_str());
- pEntity->m_iszTemplate(pValue);
+ if (strcmp(pInstance->GetClassname(), "env_entity_maker") == 0)
+ {
+ const auto pEntity = reinterpret_cast(pInstance);
+ const auto pValue = g_pEntitySystem->AllocPooledString(vecArgs[1].c_str());
+ pEntity->m_iszTemplate(pValue);
#ifdef _DEBUG
- Message("Set EntityTemplate to %s for %s\n", pValue.String(), pInstance->GetName());
+ Message("Set EntityTemplate to %s for %s\n", pValue.String(), pInstance->GetName());
#endif
- }
- else
- Message("Only env_entity_maker is supported\n");
+ }
+ else
+ Message("Only env_entity_maker is supported\n");
}
-static void AddOutputCustom_BaseVelocity(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_BaseVelocity(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- const Vector velocity(clamp(Q_atof(vecArgs[1].c_str()), -4096.f, 4096.f),
- clamp(Q_atof(vecArgs[2].c_str()), -4096.f, 4096.f),
- clamp(Q_atof(vecArgs[3].c_str()), -4096.f, 4096.f));
+ const Vector velocity(clamp(Q_atof(vecArgs[1].c_str()), -4096.f, 4096.f),
+ clamp(Q_atof(vecArgs[2].c_str()), -4096.f, 4096.f),
+ clamp(Q_atof(vecArgs[3].c_str()), -4096.f, 4096.f));
- pInstance->SetBaseVelocity(velocity);
+ pInstance->SetBaseVelocity(velocity);
#ifdef _DEBUG
- Message("SetOrigin %f %f %f for %s", velocity.x, velocity.y, velocity.z, pInstance->GetName());
+ Message("SetOrigin %f %f %f for %s", velocity.x, velocity.y, velocity.z, pInstance->GetName());
#endif
}
-static void AddOutputCustom_AbsVelocity(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_AbsVelocity(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- Vector velocity(clamp(Q_atof(vecArgs[1].c_str()), -4096.f, 4096.f),
- clamp(Q_atof(vecArgs[2].c_str()), -4096.f, 4096.f),
- clamp(Q_atof(vecArgs[3].c_str()), -4096.f, 4096.f));
+ Vector velocity(clamp(Q_atof(vecArgs[1].c_str()), -4096.f, 4096.f),
+ clamp(Q_atof(vecArgs[2].c_str()), -4096.f, 4096.f),
+ clamp(Q_atof(vecArgs[3].c_str()), -4096.f, 4096.f));
- pInstance->Teleport(nullptr, nullptr, &velocity);
+ pInstance->Teleport(nullptr, nullptr, &velocity);
#ifdef _DEBUG
- Message("SetOrigin %f %f %f for %s", velocity.x, velocity.y, velocity.z, pInstance->GetName());
+ Message("SetOrigin %f %f %f for %s", velocity.x, velocity.y, velocity.z, pInstance->GetName());
#endif
}
-static void AddOutputCustom_Target(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_Target(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- if (const auto pTarget = UTIL_FindEntityByName(nullptr, vecArgs[1].c_str()))
- {
- const auto pEntity = pInstance;
- pEntity->m_target(pTarget->m_pEntity->m_name);
+ if (const auto pTarget = UTIL_FindEntityByName(nullptr, vecArgs[1].c_str()))
+ {
+ const auto pEntity = pInstance;
+ pEntity->m_target(pTarget->m_pEntity->m_name);
#ifdef _DEBUG
- Message("Set Target to %s for %s\n", pTarget->m_pEntity->m_name.String(), pEntity->m_pEntity->m_name.String());
+ Message("Set Target to %s for %s\n", pTarget->m_pEntity->m_name.String(), pEntity->m_pEntity->m_name.String());
#endif
- }
+ }
}
-static void AddOutputCustom_FilterName(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_FilterName(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- if (V_strncasecmp(pInstance->GetClassname(), "trigger_", 8) == 0)
- {
- if (const auto pTarget = UTIL_FindEntityByName(nullptr, vecArgs[1].c_str()))
- {
- if (V_strncasecmp(pTarget->GetClassname(), "filter_", 7) == 0)
- {
- const auto pTrigger = reinterpret_cast(pInstance);
- pTrigger->m_iFilterName(pTarget->GetName());
- pTrigger->m_hFilter(pTarget->GetRefEHandle());
+ if (V_strncasecmp(pInstance->GetClassname(), "trigger_", 8) == 0)
+ {
+ if (const auto pTarget = UTIL_FindEntityByName(nullptr, vecArgs[1].c_str()))
+ {
+ if (V_strncasecmp(pTarget->GetClassname(), "filter_", 7) == 0)
+ {
+ const auto pTrigger = reinterpret_cast(pInstance);
+ pTrigger->m_iFilterName(pTarget->GetName());
+ pTrigger->m_hFilter(pTarget->GetRefEHandle());
#ifdef _DEBUG
- Message("Set FilterName to %s for %s\n", pTarget->GetName(),
- pTrigger->GetName());
+ Message("Set FilterName to %s for %s\n", pTarget->GetName(),
+ pTrigger->GetName());
#endif
- }
- }
- }
+ }
+ }
+ }
}
-static void AddOutputCustom_Force(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_Force(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- const auto value = Q_atof(vecArgs[1].c_str());
- const auto pEntity = reinterpret_cast(pInstance);
- if (V_strcasecmp(pEntity->GetClassname(), "phys_thruster") == 0)
- {
- pEntity->m_force(value);
+ const auto value = Q_atof(vecArgs[1].c_str());
+ const auto pEntity = reinterpret_cast(pInstance);
+ if (V_strcasecmp(pEntity->GetClassname(), "phys_thruster") == 0)
+ {
+ pEntity->m_force(value);
#ifdef _DEBUG
- Message("Set force to %f for %s\n", value, pEntity->GetName());
+ Message("Set force to %f for %s\n", value, pEntity->GetName());
#endif
- }
+ }
}
-static void AddOutputCustom_Gravity(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_Gravity(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- const auto value = Q_atof(vecArgs[1].c_str());
+ const auto value = Q_atof(vecArgs[1].c_str());
- pInstance->m_flGravityScale = value;
+ pInstance->m_flGravityScale = value;
#ifdef _DEBUG
- Message("Set gravity to %f for %s\n", value, pInstance->GetName());
+ Message("Set gravity to %f for %s\n", value, pInstance->GetName());
#endif
}
-static void AddOutputCustom_Timescale(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_Timescale(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- const auto value = Q_atof(vecArgs[1].c_str());
+ const auto value = Q_atof(vecArgs[1].c_str());
- pInstance->m_flTimeScale = value;
+ pInstance->m_flTimeScale = value;
#ifdef _DEBUG
- Message("Set timescale to %f for %s\n", value, pInstance->GetName());
+ Message("Set timescale to %f for %s\n", value, pInstance->GetName());
#endif
}
-static void AddOutputCustom_Friction(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_Friction(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- const auto value = Q_atof(vecArgs[1].c_str());
+ const auto value = Q_atof(vecArgs[1].c_str());
- pInstance->m_flFriction = value;
+ pInstance->m_flFriction = value;
#ifdef _DEBUG
- Message("Set friction to %f for %s\n", value, pInstance->GetName());
+ Message("Set friction to %f for %s\n", value, pInstance->GetName());
#endif
}
-static void AddOutputCustom_Speed(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_Speed(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- if (!pInstance->IsPawn())
- return;
+ if (!pInstance->IsPawn())
+ return;
- const auto pPawn = reinterpret_cast(pInstance);
- const auto pController = pPawn->GetOriginalController();
+ const auto pPawn = reinterpret_cast(pInstance);
+ const auto pController = pPawn->GetOriginalController();
- if (!pController || !pController->IsConnected())
- return;
+ if (!pController || !pController->IsConnected())
+ return;
- const auto value = Q_atof(vecArgs[1].c_str());
+ const auto value = Q_atof(vecArgs[1].c_str());
- pController->GetZEPlayer()->SetSpeedMod(value);
+ pController->GetZEPlayer()->SetSpeedMod(value);
#ifdef _DEBUG
- Message("Set speed to %f for %s\n", value, pInstance->GetName());
+ Message("Set speed to %f for %s\n", value, pInstance->GetName());
#endif
}
-static void AddOutputCustom_RunSpeed(CBaseEntity* pInstance,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller,
- const std::vector& vecArgs)
+static void AddOutputCustom_RunSpeed(CBaseEntity* pInstance,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller,
+ const std::vector& vecArgs)
{
- if (!pInstance->IsPawn())
- return;
+ if (!pInstance->IsPawn())
+ return;
- const auto pPawn = reinterpret_cast(pInstance);
+ const auto pPawn = reinterpret_cast(pInstance);
- const auto value = Q_atof(vecArgs[1].c_str());
+ const auto value = Q_atof(vecArgs[1].c_str());
- pPawn->m_flVelocityModifier = value;
+ pPawn->m_flVelocityModifier = value;
#ifdef _DEBUG
- Message("Set runspeed to %f for %s\n", value, pInstance->GetName());
+ Message("Set runspeed to %f for %s\n", value, pInstance->GetName());
#endif
}
const std::vector s_AddOutputHandlers = {
- {{"targetname", 2}, AddOutputCustom_Targetname },
- {{"origin", 4}, AddOutputCustom_Origin },
- {{"angles", 4}, AddOutputCustom_Angles },
- {{"max_health", 2}, AddOutputCustom_MaxHealth },
- {{"health", 2}, AddOutputCustom_Health },
- {{"movetype", 2}, AddOutputCustom_MoveType },
- {{"EntityTemplate", 2}, AddOutputCustom_EntityTemplate},
- {{"basevelocity", 4}, AddOutputCustom_BaseVelocity },
- {{"absvelocity", 4}, AddOutputCustom_AbsVelocity },
- {{"target", 2}, AddOutputCustom_Target },
- {{"filtername", 2}, AddOutputCustom_FilterName },
- {{"force", 2}, AddOutputCustom_Force },
- {{"gravity", 2}, AddOutputCustom_Gravity },
- {{"timescale", 2}, AddOutputCustom_Timescale },
- {{"friction", 2}, AddOutputCustom_Friction },
- {{"speed", 2}, AddOutputCustom_Speed },
- {{"runspeed", 2}, AddOutputCustom_RunSpeed },
+ {{"targetname", 2}, AddOutputCustom_Targetname },
+ {{"origin", 4}, AddOutputCustom_Origin },
+ {{"angles", 4}, AddOutputCustom_Angles },
+ {{"max_health", 2}, AddOutputCustom_MaxHealth },
+ {{"health", 2}, AddOutputCustom_Health },
+ {{"movetype", 2}, AddOutputCustom_MoveType },
+ {{"EntityTemplate", 2}, AddOutputCustom_EntityTemplate},
+ {{"basevelocity", 4}, AddOutputCustom_BaseVelocity },
+ {{"absvelocity", 4}, AddOutputCustom_AbsVelocity },
+ {{"target", 2}, AddOutputCustom_Target },
+ {{"filtername", 2}, AddOutputCustom_FilterName },
+ {{"force", 2}, AddOutputCustom_Force },
+ {{"gravity", 2}, AddOutputCustom_Gravity },
+ {{"timescale", 2}, AddOutputCustom_Timescale },
+ {{"friction", 2}, AddOutputCustom_Friction },
+ {{"speed", 2}, AddOutputCustom_Speed },
+ {{"runspeed", 2}, AddOutputCustom_RunSpeed },
};
inline std::vector StringSplit(const char* str, const char* delimiter)
{
- std::vector result;
- std::string_view strV(str);
- size_t pos;
-
- while ((pos = strV.find(delimiter)) != std::string_view::npos)
- {
- result.emplace_back(strV.substr(0, pos));
- strV.remove_prefix(pos + std::string_view(delimiter).size());
- }
-
- result.emplace_back(strV);
- return result;
+ std::vector result;
+ std::string_view strV(str);
+ size_t pos;
+
+ while ((pos = strV.find(delimiter)) != std::string_view::npos)
+ {
+ result.emplace_back(strV.substr(0, pos));
+ strV.remove_prefix(pos + std::string_view(delimiter).size());
+ }
+
+ result.emplace_back(strV);
+ return result;
}
bool CustomIO_HandleInput(CEntityInstance* pInstance,
- const char* param,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller)
+ const char* param,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller)
{
- for (auto& [input, handler] : s_AddOutputHandlers)
- {
- if (V_strncasecmp(param, input.m_pName, input.m_nLength) == 0)
- {
- if (const auto split = StringSplit(param, " ");
- split.size() == input.m_nParts)
- {
- handler(reinterpret_cast(pInstance), pActivator, pCaller, split);
- return true;
- }
-
- break;
- }
- }
-
- return false;
+ for (auto& [input, handler] : s_AddOutputHandlers)
+ {
+ if (V_strncasecmp(param, input.m_pName, input.m_nLength) == 0)
+ {
+ if (const auto split = StringSplit(param, " ");
+ split.size() == input.m_nParts)
+ {
+ handler(reinterpret_cast(pInstance), pActivator, pCaller, split);
+ return true;
+ }
+
+ break;
+ }
+ }
+
+ return false;
}
std::string g_sBurnParticle = "particles/burning_fx/burning_character_b.vpcf";
@@ -414,75 +414,75 @@ FAKE_FLOAT_CVAR(cs2f_burn_interval, "The interval between burn damage ticks", g_
bool IgnitePawn(CCSPlayerPawn* pPawn, float flDuration, CBaseEntity* pInflictor, CBaseEntity* pAttacker, CBaseEntity* pAbility, DamageTypes_t nDamageType)
{
- auto pParticleEnt = reinterpret_cast(pPawn->m_hEffectEntity().Get());
+ auto pParticleEnt = reinterpret_cast(pPawn->m_hEffectEntity().Get());
- // This guy is already burning, don't ignite again
- if (pParticleEnt)
- {
- // Override the end time instead of just adding to it so players who get a ton of ignite inputs don't burn forever
- pParticleEnt->m_flDissolveStartTime = gpGlobals->curtime + flDuration;
- return true;
- }
+ // This guy is already burning, don't ignite again
+ if (pParticleEnt)
+ {
+ // Override the end time instead of just adding to it so players who get a ton of ignite inputs don't burn forever
+ pParticleEnt->m_flDissolveStartTime = gpGlobals->curtime + flDuration;
+ return true;
+ }
- const auto vecOrigin = pPawn->GetAbsOrigin();
+ const auto vecOrigin = pPawn->GetAbsOrigin();
- pParticleEnt = CreateEntityByName("info_particle_system");
+ pParticleEnt = CreateEntityByName("info_particle_system");
- pParticleEnt->m_bStartActive(true);
- pParticleEnt->m_iszEffectName(g_sBurnParticle.c_str());
- pParticleEnt->m_hControlPointEnts[0] = pPawn;
- pParticleEnt->m_flDissolveStartTime = gpGlobals->curtime + flDuration; // Store the end time in the particle itself so we can increment if needed
- pParticleEnt->Teleport(&vecOrigin, nullptr, nullptr);
+ pParticleEnt->m_bStartActive(true);
+ pParticleEnt->m_iszEffectName(g_sBurnParticle.c_str());
+ pParticleEnt->m_hControlPointEnts[0] = pPawn;
+ pParticleEnt->m_flDissolveStartTime = gpGlobals->curtime + flDuration; // Store the end time in the particle itself so we can increment if needed
+ pParticleEnt->Teleport(&vecOrigin, nullptr, nullptr);
- pParticleEnt->DispatchSpawn();
+ pParticleEnt->DispatchSpawn();
- pParticleEnt->SetParent(pPawn);
+ pParticleEnt->SetParent(pPawn);
- pPawn->m_hEffectEntity = pParticleEnt;
+ pPawn->m_hEffectEntity = pParticleEnt;
- CHandle hPawn(pPawn);
- CHandle hInflictor(pInflictor);
- CHandle hAttacker(pAttacker);
- CHandle hAbility(pAbility);
+ CHandle hPawn(pPawn);
+ CHandle hInflictor(pInflictor);
+ CHandle hAttacker(pAttacker);
+ CHandle hAbility(pAbility);
- new CTimer(0.f, false, false, [hPawn, hInflictor, hAttacker, hAbility, nDamageType]() {
- CCSPlayerPawn* pPawn = hPawn.Get();
+ new CTimer(0.f, false, false, [hPawn, hInflictor, hAttacker, hAbility, nDamageType]() {
+ CCSPlayerPawn* pPawn = hPawn.Get();
- if (!pPawn)
- return -1.f;
+ if (!pPawn)
+ return -1.f;
- const auto pParticleEnt = reinterpret_cast(pPawn->m_hEffectEntity().Get());
+ const auto pParticleEnt = reinterpret_cast(pPawn->m_hEffectEntity().Get());
- if (!pParticleEnt)
- return -1.f;
+ if (!pParticleEnt)
+ return -1.f;
- if (V_strncmp(pParticleEnt->GetClassname(), "info_part", 9) != 0)
- {
- // This should never happen but just in case
- Panic("Found unexpected entity %s while burning a pawn!\n", pParticleEnt->GetClassname());
- return -1.f;
- }
+ if (V_strncmp(pParticleEnt->GetClassname(), "info_part", 9) != 0)
+ {
+ // This should never happen but just in case
+ Panic("Found unexpected entity %s while burning a pawn!\n", pParticleEnt->GetClassname());
+ return -1.f;
+ }
- if (pParticleEnt->m_flDissolveStartTime() <= gpGlobals->curtime || !pPawn->IsAlive())
- {
- pParticleEnt->AcceptInput("Stop");
- UTIL_AddEntityIOEvent(pParticleEnt, "Kill"); // Kill on the next frame
+ if (pParticleEnt->m_flDissolveStartTime() <= gpGlobals->curtime || !pPawn->IsAlive())
+ {
+ pParticleEnt->AcceptInput("Stop");
+ UTIL_AddEntityIOEvent(pParticleEnt, "Kill"); // Kill on the next frame
- return -1.f;
- }
+ return -1.f;
+ }
- CTakeDamageInfo info(hInflictor, hAttacker, hAbility, g_flBurnDamage, nDamageType);
+ CTakeDamageInfo info(hInflictor, hAttacker, hAbility, g_flBurnDamage, nDamageType);
- // Damage doesn't apply if the inflictor is null
- if (!hInflictor.Get())
- info.m_hInflictor.Set(hAttacker);
+ // Damage doesn't apply if the inflictor is null
+ if (!hInflictor.Get())
+ info.m_hInflictor.Set(hAttacker);
- pPawn->TakeDamage(info);
+ pPawn->TakeDamage(info);
- pPawn->m_flVelocityModifier = g_flBurnSlowdown;
+ pPawn->m_flVelocityModifier = g_flBurnSlowdown;
- return g_flBurnInterval;
- });
+ return g_flBurnInterval;
+ });
- return true;
+ return true;
}
diff --git a/src/customio.h b/src/customio.h
index 7ea53568..16cdba63 100644
--- a/src/customio.h
+++ b/src/customio.h
@@ -26,13 +26,13 @@ class CCSPlayerPawn;
enum DamageTypes_t : unsigned int;
bool CustomIO_HandleInput(CEntityInstance* pEntityInstance,
- const char* pParams,
- CEntityInstance* pActivator,
- CEntityInstance* pCaller);
+ const char* pParams,
+ CEntityInstance* pActivator,
+ CEntityInstance* pCaller);
-bool IgnitePawn(CCSPlayerPawn *pEntity,
- float flDuration,
- CBaseEntity *pInflictor = nullptr,
- CBaseEntity *pAttacker = nullptr,
- CBaseEntity *pAbility = nullptr,
- DamageTypes_t nDamageType = DamageTypes_t(8)); // DMG_BURN
+bool IgnitePawn(CCSPlayerPawn* pEntity,
+ float flDuration,
+ CBaseEntity* pInflictor = nullptr,
+ CBaseEntity* pAttacker = nullptr,
+ CBaseEntity* pAbility = nullptr,
+ DamageTypes_t nDamageType = DamageTypes_t(8)); // DMG_BURN
diff --git a/src/cvars.cpp b/src/cvars.cpp
index f6de75f3..b47abb75 100644
--- a/src/cvars.cpp
+++ b/src/cvars.cpp
@@ -24,8 +24,8 @@
static uint64 g_iFlagsToRemove = (FCVAR_HIDDEN | FCVAR_DEVELOPMENTONLY | FCVAR_MISSING0 | FCVAR_MISSING1 | FCVAR_MISSING2 | FCVAR_MISSING3);
-static constexpr const char *pUnCheatCvars[] = { "bot_stop", "bot_freeze", "bot_zombie" };
-static constexpr const char* pUnCheatCmds[] = { "report_entities", "endround" };
+static constexpr const char* pUnCheatCvars[] = {"bot_stop", "bot_freeze", "bot_zombie"};
+static constexpr const char* pUnCheatCmds[] = {"report_entities", "endround"};
void UnlockConVars()
{
@@ -34,7 +34,7 @@ void UnlockConVars()
int iUnhiddenConVars = 0;
- ConVar *pCvar = nullptr;
+ ConVar* pCvar = nullptr;
ConVarHandle hCvarHandle;
hCvarHandle.Set(0);
@@ -47,12 +47,10 @@ void UnlockConVars()
if (!pCvar)
continue;
-
+
for (int i = 0; i < sizeof(pUnCheatCvars) / sizeof(*pUnCheatCvars); i++)
- {
if (!V_strcmp(pCvar->m_pszName, pUnCheatCvars[i]))
pCvar->flags &= ~FCVAR_CHEAT;
- }
if (!(pCvar->flags & g_iFlagsToRemove))
continue;
@@ -71,8 +69,8 @@ void UnlockConCommands()
int iUnhiddenConCommands = 0;
- ConCommand *pConCommand = nullptr;
- ConCommand *pInvalidCommand = g_pCVar->GetCommand(ConCommandHandle());
+ ConCommand* pConCommand = nullptr;
+ ConCommand* pInvalidCommand = g_pCVar->GetCommand(ConCommandHandle());
ConCommandHandle hConCommandHandle;
hConCommandHandle.Set(0);
@@ -86,10 +84,8 @@ void UnlockConCommands()
continue;
for (int i = 0; i < sizeof(pUnCheatCmds) / sizeof(*pUnCheatCmds); i++)
- {
if (!V_strcmp(pConCommand->GetName(), pUnCheatCmds[i]))
pConCommand->RemoveFlags(FCVAR_CHEAT);
- }
if (pConCommand->GetFlags() & g_iFlagsToRemove)
{
@@ -103,7 +99,7 @@ void UnlockConCommands()
CON_COMMAND_F(c_dump_cvars, "dump all cvars", FCVAR_SPONLY | FCVAR_LINKED_CONCOMMAND)
{
- ConVar *pCvar = nullptr;
+ ConVar* pCvar = nullptr;
ConVarHandle hCvarHandle;
hCvarHandle.Set(0);
@@ -114,75 +110,73 @@ CON_COMMAND_F(c_dump_cvars, "dump all cvars", FCVAR_SPONLY | FCVAR_LINKED_CONCOM
hCvarHandle.Set(hCvarHandle.Get() + 1);
if (pCvar)
- {
switch (pCvar->m_eVarType)
{
- case EConVarType_Bool:
- Message("%s : bool : %s\n", pCvar->m_pszName, (bool)pCvar->values ? "true" : "false");
- break;
- case EConVarType_Int16:
- Message("%s : int16 : %i\n", pCvar->m_pszName, *(int16*)&pCvar->values);
- break;
- case EConVarType_Int32:
- Message("%s : int32 : %i\n", pCvar->m_pszName, *(int32*)&pCvar->values);
- break;
- case EConVarType_Int64:
- Message("%s : int64 : %lli\n", pCvar->m_pszName, (int64)pCvar->values);
- break;
- case EConVarType_UInt16:
- Message("%s : uint16 : %i\n", pCvar->m_pszName, *(uint16*)&pCvar->values);
- break;
- case EConVarType_UInt32:
- Message("%s : uint32 : %i\n", pCvar->m_pszName, *(uint32*)&pCvar->values);
- break;
- case EConVarType_UInt64:
- Message("%s : uint64 : %lli\n", pCvar->m_pszName, (uint64)pCvar->values);
- break;
- case EConVarType_Float32:
- Message("%s : float32 : %.2f\n", pCvar->m_pszName, *(float32 *)&pCvar->values);
- break;
- case EConVarType_Float64:
- Message("%s : float64 : %.2f\n", pCvar->m_pszName, *(float64 *)&pCvar->values);
- break;
- case EConVarType_String:
- Message("%s : string : %s\n", pCvar->m_pszName, (char *)pCvar->values);
- break;
-
- case EConVarType_Color:
- int color[4];
- V_memcpy(&color, &pCvar->values, sizeof(color));
- Message("%s : color : %.2f %.2f %.2f %.2f\n", pCvar->m_pszName, color[0], color[1], color[2], color[3]);
- break;
-
- case EConVarType_Vector2:
- float vec2[2];
- V_memcpy(&vec2, &pCvar->values, sizeof(vec2));
- Message("%s : vector2 : %.2f %.2f\n", pCvar->m_pszName, vec2[0], vec2[1]);
- break;
-
- case EConVarType_Vector3:
- float vec3[3];
- V_memcpy(&vec3, &pCvar->values, sizeof(vec3));
- Message("%s : vector3 : %.2f %.2f %.2f\n", pCvar->m_pszName, vec3[0], vec3[1], vec3[2]);
- break;
-
- case EConVarType_Vector4:
- float vec4[4];
- V_memcpy(&vec4, &pCvar->values, sizeof(vec4));
- Message("%s : vector4 : %.2f %.2f %.2f %.2f\n", pCvar->m_pszName, vec4[0], vec4[1], vec4[2], vec4[3]);
- break;
-
- case EConVarType_Qangle:
- float angle[3];
- V_memcpy(&vec3, &pCvar->values, sizeof(angle));
- Message("%s : qangle : %.2f %.2f %.2f\n", pCvar->m_pszName, angle[0], angle[1], angle[2]);
- break;
-
- default:
- Message("%s : unknown type : %p\n", pCvar->m_pszName, (void*)pCvar->values);
- break;
+ case EConVarType_Bool:
+ Message("%s : bool : %s\n", pCvar->m_pszName, (bool)pCvar->values ? "true" : "false");
+ break;
+ case EConVarType_Int16:
+ Message("%s : int16 : %i\n", pCvar->m_pszName, *(int16*)&pCvar->values);
+ break;
+ case EConVarType_Int32:
+ Message("%s : int32 : %i\n", pCvar->m_pszName, *(int32*)&pCvar->values);
+ break;
+ case EConVarType_Int64:
+ Message("%s : int64 : %lli\n", pCvar->m_pszName, (int64)pCvar->values);
+ break;
+ case EConVarType_UInt16:
+ Message("%s : uint16 : %i\n", pCvar->m_pszName, *(uint16*)&pCvar->values);
+ break;
+ case EConVarType_UInt32:
+ Message("%s : uint32 : %i\n", pCvar->m_pszName, *(uint32*)&pCvar->values);
+ break;
+ case EConVarType_UInt64:
+ Message("%s : uint64 : %lli\n", pCvar->m_pszName, (uint64)pCvar->values);
+ break;
+ case EConVarType_Float32:
+ Message("%s : float32 : %.2f\n", pCvar->m_pszName, *(float32*)&pCvar->values);
+ break;
+ case EConVarType_Float64:
+ Message("%s : float64 : %.2f\n", pCvar->m_pszName, *(float64*)&pCvar->values);
+ break;
+ case EConVarType_String:
+ Message("%s : string : %s\n", pCvar->m_pszName, (char*)pCvar->values);
+ break;
+
+ case EConVarType_Color:
+ int color[4];
+ V_memcpy(&color, &pCvar->values, sizeof(color));
+ Message("%s : color : %.2f %.2f %.2f %.2f\n", pCvar->m_pszName, color[0], color[1], color[2], color[3]);
+ break;
+
+ case EConVarType_Vector2:
+ float vec2[2];
+ V_memcpy(&vec2, &pCvar->values, sizeof(vec2));
+ Message("%s : vector2 : %.2f %.2f\n", pCvar->m_pszName, vec2[0], vec2[1]);
+ break;
+
+ case EConVarType_Vector3:
+ float vec3[3];
+ V_memcpy(&vec3, &pCvar->values, sizeof(vec3));
+ Message("%s : vector3 : %.2f %.2f %.2f\n", pCvar->m_pszName, vec3[0], vec3[1], vec3[2]);
+ break;
+
+ case EConVarType_Vector4:
+ float vec4[4];
+ V_memcpy(&vec4, &pCvar->values, sizeof(vec4));
+ Message("%s : vector4 : %.2f %.2f %.2f %.2f\n", pCvar->m_pszName, vec4[0], vec4[1], vec4[2], vec4[3]);
+ break;
+
+ case EConVarType_Qangle:
+ float angle[3];
+ V_memcpy(&vec3, &pCvar->values, sizeof(angle));
+ Message("%s : qangle : %.2f %.2f %.2f\n", pCvar->m_pszName, angle[0], angle[1], angle[2]);
+ break;
+
+ default:
+ Message("%s : unknown type : %p\n", pCvar->m_pszName, (void*)pCvar->values);
+ break;
};
- }
} while (pCvar);
}
diff --git a/src/detours.cpp b/src/detours.cpp
index be839315..cd76871d 100644
--- a/src/detours.cpp
+++ b/src/detours.cpp
@@ -22,6 +22,7 @@
#include "usercmd.pb.h"
#include "addresses.h"
+#include "buttonwatch.h"
#include "cdetour.h"
#include "commands.h"
#include "common.h"
@@ -49,18 +50,17 @@
#include "serversideclient.h"
#include "tier0/vprof.h"
#include "zombiereborn.h"
-#include "buttonwatch.h"
#include "tier0/memdbgon.h"
-extern CGlobalVars *gpGlobals;
-extern CGameEntitySystem *g_pEntitySystem;
-extern IGameEventManager2 *g_gameEventManager;
-extern CCSGameRules *g_pGameRules;
-extern CMapVoteSystem *g_pMapVoteSystem;
+extern CGlobalVars* gpGlobals;
+extern CGameEntitySystem* g_pEntitySystem;
+extern IGameEventManager2* g_gameEventManager;
+extern CCSGameRules* g_pGameRules;
+extern CMapVoteSystem* g_pMapVoteSystem;
extern CUtlVector* GetClientList();
-CUtlVector g_vecDetours;
+CUtlVector g_vecDetours;
DECLARE_DETOUR(UTIL_SayTextFilter, Detour_UTIL_SayTextFilter);
DECLARE_DETOUR(UTIL_SayText2Filter, Detour_UTIL_SayText2Filter);
@@ -90,7 +90,7 @@ FAKE_BOOL_CVAR(cs2f_block_molotov_self_dmg, "Whether to block self-damage from m
FAKE_BOOL_CVAR(cs2f_block_all_dmg, "Whether to block all damage to players", g_bBlockAllDamage, false, false)
FAKE_BOOL_CVAR(cs2f_fix_block_dmg, "Whether to fix block-damage on players", g_bFixBlockDamage, false, false)
-void FASTCALL Detour_CBaseEntity_TakeDamageOld(CBaseEntity *pThis, CTakeDamageInfo *inputInfo)
+void FASTCALL Detour_CBaseEntity_TakeDamageOld(CBaseEntity* pThis, CTakeDamageInfo* inputInfo)
{
#ifdef _DEBUG
Message("\n--------------------------------\n"
@@ -108,13 +108,13 @@ void FASTCALL Detour_CBaseEntity_TakeDamageOld(CBaseEntity *pThis, CTakeDamageIn
inputInfo->m_flDamage,
inputInfo->m_bitsDamageType);
#endif
-
+
// Block all player damage if desired
if (g_bBlockAllDamage && pThis->IsPawn())
return;
- CBaseEntity *pInflictor = inputInfo->m_hInflictor.Get();
- const char *pszInflictorClass = pInflictor ? pInflictor->GetClassname() : "";
+ CBaseEntity* pInflictor = inputInfo->m_hInflictor.Get();
+ const char* pszInflictorClass = pInflictor ? pInflictor->GetClassname() : "";
// After Armory update, activator became attacker on block damage, which broke it..
if (g_bFixBlockDamage && inputInfo->m_AttackerInfo.m_bIsPawn && inputInfo->m_bitsDamageType ^ DMG_BULLET && inputInfo->m_hAttacker != pThis->GetHandle())
@@ -190,9 +190,7 @@ void FASTCALL Detour_TriggerPush_Touch(CTriggerPush* pPush, CBaseEntity* pOther)
uint32 flags = pOther->m_fFlags();
if (flags & FL_BASEVELOCITY)
- {
vecPush = vecPush + pOther->m_vecBaseVelocity();
- }
if (vecPush.z > 0 && (flags & FL_ONGROUND))
{
@@ -233,7 +231,7 @@ bool FASTCALL Detour_IsHearingClient(void* serverClient, int index)
return IsHearingClient(serverClient, index);
}
-void SayChatMessageWithTimer(IRecipientFilter &filter, const char *pText, CCSPlayerController *pPlayer, uint64 eMessageType)
+void SayChatMessageWithTimer(IRecipientFilter& filter, const char* pText, CCSPlayerController* pPlayer, uint64 eMessageType)
{
VPROF("SayChatMessageWithTimer");
@@ -256,7 +254,7 @@ void SayChatMessageWithTimer(IRecipientFilter &filter, const char *pText, CCSPla
// Split console message into words seperated by the space character
CSplitString words(filteredText, " ");
- //Word count includes the first word "Console:" at index 0, first relevant word is at index 1
+ // Word count includes the first word "Console:" at index 0, first relevant word is at index 1
int iWordCount = words.Count();
uint32 uiTriggerTimerLength = 0;
@@ -294,7 +292,7 @@ void SayChatMessageWithTimer(IRecipientFilter &filter, const char *pText, CCSPla
{
if (pCurrentWord[j] >= '0' && pCurrentWord[j] <= '9')
continue;
-
+
if (pCurrentWord[j] == 's')
{
pCurrentWord[j] = '\0';
@@ -331,7 +329,7 @@ bool g_bEnableTriggerTimer = false;
FAKE_BOOL_CVAR(cs2f_trigger_timer_enable, "Whether to process countdown messages said by Console (e.g. Hold for 10 seconds) and append the round time where the countdown resolves", g_bEnableTriggerTimer, false, false)
-void FASTCALL Detour_UTIL_SayTextFilter(IRecipientFilter &filter, const char *pText, CCSPlayerController *pPlayer, uint64 eMessageType)
+void FASTCALL Detour_UTIL_SayTextFilter(IRecipientFilter& filter, const char* pText, CCSPlayerController* pPlayer, uint64 eMessageType)
{
if (pPlayer)
return UTIL_SayTextFilter(filter, pText, pPlayer, eMessageType);
@@ -346,17 +344,17 @@ void FASTCALL Detour_UTIL_SayTextFilter(IRecipientFilter &filter, const char *pT
}
void FASTCALL Detour_UTIL_SayText2Filter(
- IRecipientFilter &filter,
- CCSPlayerController *pEntity,
+ IRecipientFilter& filter,
+ CCSPlayerController* pEntity,
uint64 eMessageType,
- const char *msg_name,
- const char *param1,
- const char *param2,
- const char *param3,
- const char *param4)
+ const char* msg_name,
+ const char* param1,
+ const char* param2,
+ const char* param3,
+ const char* param4)
{
#ifdef _DEBUG
- CPlayerSlot slot = filter.GetRecipientIndex(0);
+ CPlayerSlot slot = filter.GetRecipientIndex(0);
CCSPlayerController* target = CCSPlayerController::FromSlot(slot);
if (target)
@@ -366,12 +364,10 @@ void FASTCALL Detour_UTIL_SayText2Filter(
UTIL_SayText2Filter(filter, pEntity, eMessageType, msg_name, param1, param2, param3, param4);
}
-bool FASTCALL Detour_CCSPlayer_WeaponServices_CanUse(CCSPlayer_WeaponServices *pWeaponServices, CBasePlayerWeapon* pPlayerWeapon)
+bool FASTCALL Detour_CCSPlayer_WeaponServices_CanUse(CCSPlayer_WeaponServices* pWeaponServices, CBasePlayerWeapon* pPlayerWeapon)
{
if (g_bEnableZR && !ZR_Detour_CCSPlayer_WeaponServices_CanUse(pWeaponServices, pPlayerWeapon))
- {
return false;
- }
return CCSPlayer_WeaponServices_CanUse(pWeaponServices, pPlayerWeapon);
}
@@ -404,7 +400,7 @@ bool FASTCALL Detour_CEntityIdentity_AcceptInput(CEntityIdentity* pThis, CUtlSym
else
flDuration = value->m_float;
- CCSPlayerPawn *pPawn = reinterpret_cast(pThis->m_pInstance);
+ CCSPlayerPawn* pPawn = reinterpret_cast(pThis->m_pInstance);
if (pPawn->IsPawn() && IgnitePawn(pPawn, flDuration, pPawn, pPawn))
return true;
@@ -418,7 +414,7 @@ bool FASTCALL Detour_CEntityIdentity_AcceptInput(CEntityIdentity* pThis, CUtlSym
else
iScore = value->m_int;
- CCSPlayerPawn *pPawn = reinterpret_cast(pThis->m_pInstance);
+ CCSPlayerPawn* pPawn = reinterpret_cast(pThis->m_pInstance);
if (pPawn->IsPawn() && pPawn->GetOriginalController())
{
@@ -426,14 +422,12 @@ bool FASTCALL Detour_CEntityIdentity_AcceptInput(CEntityIdentity* pThis, CUtlSym
return true;
}
}
- else if (!V_strcasecmp(pInputName->String(), "SetMessage"))
+ else if (!V_strcasecmp(pInputName->String(), "SetMessage"))
{
if (const auto pHudHint = reinterpret_cast(pThis->m_pInstance)->AsHudHint())
{
if ((value->m_type == FIELD_CSTRING || value->m_type == FIELD_STRING) && value->m_pszString)
- {
pHudHint->m_iszMessage(GameEntitySystem()->AllocPooledString(value->m_pszString));
- }
return true;
}
}
@@ -442,9 +436,7 @@ bool FASTCALL Detour_CEntityIdentity_AcceptInput(CEntityIdentity* pThis, CUtlSym
if (const auto pModelEntity = reinterpret_cast(pThis->m_pInstance)->AsBaseModelEntity())
{
if ((value->m_type == FIELD_CSTRING || value->m_type == FIELD_STRING) && value->m_pszString)
- {
pModelEntity->SetModel(value->m_pszString);
- }
return true;
}
}
@@ -469,7 +461,7 @@ bool FASTCALL Detour_CEntityIdentity_AcceptInput(CEntityIdentity* pThis, CUtlSym
VPROF_SCOPE_END();
- return CEntityIdentity_AcceptInput(pThis, pInputName, pActivator, pCaller, value, nOutputID);
+ return CEntityIdentity_AcceptInput(pThis, pInputName, pActivator, pCaller, value, nOutputID);
}
bool g_bBlockNavLookup = false;
@@ -484,14 +476,14 @@ void* FASTCALL Detour_CNavMesh_GetNearestNavArea(int64_t unk1, float* unk2, unsi
return CNavMesh_GetNearestNavArea(unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8);
}
-void FASTCALL Detour_ProcessMovement(CCSPlayer_MovementServices *pThis, void *pMove)
+void FASTCALL Detour_ProcessMovement(CCSPlayer_MovementServices* pThis, void* pMove)
{
- CCSPlayerPawn *pPawn = pThis->GetPawn();
+ CCSPlayerPawn* pPawn = pThis->GetPawn();
if (!pPawn->IsAlive())
return ProcessMovement(pThis, pMove);
- CCSPlayerController *pController = pPawn->GetOriginalController();
+ CCSPlayerController* pController = pPawn->GetOriginalController();
if (!pController || !pController->IsConnected())
return ProcessMovement(pThis, pMove);
@@ -501,7 +493,6 @@ void FASTCALL Detour_ProcessMovement(CCSPlayer_MovementServices *pThis, void *pM
if (flSpeedMod == 1.f)
return ProcessMovement(pThis, pMove);
-
// Yes, this is what source1 does to scale player speed
// Scale frametime during the entire movement processing step and revert right after
float flStoreFrametime = gpGlobals->frametime;
@@ -530,7 +521,7 @@ class CUserCmd
#endif
};
-void* FASTCALL Detour_ProcessUsercmds(CCSPlayerController *pController, CUserCmd *cmds, int numcmds, bool paused, float margin)
+void* FASTCALL Detour_ProcessUsercmds(CCSPlayerController* pController, CUserCmd* cmds, int numcmds, bool paused, float margin)
{
// Push fix only works properly if subtick movement is also disabled
if (!g_bDisableSubtick && !g_bUseOldPush)
@@ -558,8 +549,8 @@ void* FASTCALL Detour_ProcessUsercmds(CCSPlayerController *pController, CUserCmd
void FASTCALL Detour_CGamePlayerEquip_InputTriggerForAllPlayers(CGamePlayerEquip* pEntity, InputData_t* pInput)
{
- CGamePlayerEquipHandler::TriggerForAllPlayers(pEntity, pInput);
- CGamePlayerEquip_InputTriggerForAllPlayers(pEntity, pInput);
+ CGamePlayerEquipHandler::TriggerForAllPlayers(pEntity, pInput);
+ CGamePlayerEquip_InputTriggerForAllPlayers(pEntity, pInput);
}
void FASTCALL Detour_CGamePlayerEquip_InputTriggerForActivatedPlayer(CGamePlayerEquip* pEntity, InputData_t* pInput)
{
@@ -592,9 +583,7 @@ float FASTCALL Detour_CCSPlayerPawn_GetMaxSpeed(CCSPlayerPawn* pPawn)
const auto pController = reinterpret_cast(pPawn->GetController());
if (const auto pPlayer = pController != nullptr ? pController->GetZEPlayer() : nullptr)
- {
flMaxSpeed *= pPlayer->GetMaxSpeed();
- }
return flMaxSpeed;
}
@@ -615,7 +604,7 @@ bool FASTCALL Detour_TraceFunc(int64* a1, int* a2, float* a3, uint64 traceMask)
{
if (g_bPreventUsingPlayers && g_bFindingUseEntity)
{
- uint64 newMask = traceMask & ( ~(CONTENTS_PLAYER & CONTENTS_NPC) );
+ uint64 newMask = traceMask & (~(CONTENTS_PLAYER & CONTENTS_NPC));
return TraceFunc(a1, a2, a3, newMask);
}
@@ -633,7 +622,6 @@ bool FASTCALL Detour_TraceShape(int64* a1, int64 a2, int64 a3, int64 a4, CTraceF
return TraceShape(a1, a2, a3, a4, filter, a6);
}
-
CDetour* CEntityIOOutput_FireOutputInternal = nullptr;
std::map> mapIOFunctions{};
void FASTCALL Detour_CEntityIOOutput_FireOutputInternal(const CEntityIOOutput* pThis, CEntityInstance* pActivator, CEntityInstance* pCaller, const CVariant* value, float flDelay)
@@ -667,50 +655,50 @@ bool SetupFireOutputInternalDetour()
#ifdef PLATFORM_WINDOWS
Vector* FASTCALL Detour_CBasePlayerPawn_GetEyePosition(CBasePlayerPawn* pPawn, Vector* pRet)
{
- if (pPawn->IsAlive() && CPointViewControlHandler::IsViewControl(reinterpret_cast(pPawn)))
- {
- const auto& origin = pPawn->GetEyePosition();
- pRet->Init(origin.x, origin.y, origin.z);
- return pRet;
- }
-
- return CBasePlayerPawn_GetEyePosition(pPawn, pRet);
+ if (pPawn->IsAlive() && CPointViewControlHandler::IsViewControl(reinterpret_cast(pPawn)))
+ {
+ const auto& origin = pPawn->GetEyePosition();
+ pRet->Init(origin.x, origin.y, origin.z);
+ return pRet;
+ }
+
+ return CBasePlayerPawn_GetEyePosition(pPawn, pRet);
}
QAngle* FASTCALL Detour_CBasePlayerPawn_GetEyeAngles(CBasePlayerPawn* pPawn, QAngle* pRet)
{
- if (pPawn->IsAlive() && CPointViewControlHandler::IsViewControl(reinterpret_cast(pPawn)))
- {
- const auto& angles = pPawn->v_angle();
- pRet->Init(angles.x, angles.y, angles.z);
- return pRet;
- }
-
- return CBasePlayerPawn_GetEyeAngles(pPawn, pRet);
+ if (pPawn->IsAlive() && CPointViewControlHandler::IsViewControl(reinterpret_cast(pPawn)))
+ {
+ const auto& angles = pPawn->v_angle();
+ pRet->Init(angles.x, angles.y, angles.z);
+ return pRet;
+ }
+
+ return CBasePlayerPawn_GetEyeAngles(pPawn, pRet);
}
#else
Vector FASTCALL Detour_CBasePlayerPawn_GetEyePosition(CBasePlayerPawn* pPawn)
{
- if (pPawn->IsAlive() && CPointViewControlHandler::IsViewControl(reinterpret_cast(pPawn)))
- {
- const auto& origin = pPawn->GetEyePosition();
- return origin;
- }
+ if (pPawn->IsAlive() && CPointViewControlHandler::IsViewControl(reinterpret_cast(pPawn)))
+ {
+ const auto& origin = pPawn->GetEyePosition();
+ return origin;
+ }
- return CBasePlayerPawn_GetEyePosition(pPawn);
+ return CBasePlayerPawn_GetEyePosition(pPawn);
}
QAngle FASTCALL Detour_CBasePlayerPawn_GetEyeAngles(CBasePlayerPawn* pPawn)
{
- if (pPawn->IsAlive() && CPointViewControlHandler::IsViewControl(reinterpret_cast(pPawn)))
- {
- const auto& angles = pPawn->v_angle();
- return angles;
- }
+ if (pPawn->IsAlive() && CPointViewControlHandler::IsViewControl(reinterpret_cast(pPawn)))
+ {
+ const auto& angles = pPawn->v_angle();
+ return angles;
+ }
- return CBasePlayerPawn_GetEyeAngles(pPawn);
+ return CBasePlayerPawn_GetEyeAngles(pPawn);
}
#endif
-bool InitDetours(CGameConfig *gameConfig)
+bool InitDetours(CGameConfig* gameConfig)
{
bool success = true;
@@ -718,7 +706,7 @@ bool InitDetours(CGameConfig *gameConfig)
{
if (!g_vecDetours[i]->CreateDetour(gameConfig))
success = false;
-
+
g_vecDetours[i]->EnableDetour();
}
diff --git a/src/detours.h b/src/detours.h
index a2df94b7..e3b2ea4e 100644
--- a/src/detours.h
+++ b/src/detours.h
@@ -19,8 +19,8 @@
#pragma once
#include "cdetour.h"
-#include
#include "cs2_sdk/entityio.h"
+#include
class CCheckTransmitInfo;
class IRecipientFilter;
@@ -51,7 +51,7 @@ class CTraceFilter;
class Vector;
class QAngle;
-bool InitDetours(CGameConfig *gameConfig);
+bool InitDetours(CGameConfig* gameConfig);
void FlushAllDetours();
bool SetupFireOutputInternalDetour();
@@ -59,18 +59,18 @@ bool SetupFireOutputInternalDetour();
// to make it more modular/cleaner than shoving everything into the detour (buttonwatch, entwatch, etc.)
extern std::map> mapIOFunctions;
-void FASTCALL Detour_UTIL_SayTextFilter(IRecipientFilter &, const char *, CCSPlayerController *, uint64);
-void FASTCALL Detour_UTIL_SayText2Filter(IRecipientFilter &, CCSPlayerController *, uint64, const char *, const char *, const char *, const char *, const char *);
+void FASTCALL Detour_UTIL_SayTextFilter(IRecipientFilter&, const char*, CCSPlayerController*, uint64);
+void FASTCALL Detour_UTIL_SayText2Filter(IRecipientFilter&, CCSPlayerController*, uint64, const char*, const char*, const char*, const char*, const char*);
bool FASTCALL Detour_IsHearingClient(void*, int);
void FASTCALL Detour_TriggerPush_Touch(CTriggerPush* pPush, CBaseEntity* pOther);
-void FASTCALL Detour_CBaseEntity_TakeDamageOld(CBaseEntity *pThis, CTakeDamageInfo *inputInfo);
-bool FASTCALL Detour_CCSPlayer_WeaponServices_CanUse(CCSPlayer_WeaponServices *, CBasePlayerWeapon *);
+void FASTCALL Detour_CBaseEntity_TakeDamageOld(CBaseEntity* pThis, CTakeDamageInfo* inputInfo);
+bool FASTCALL Detour_CCSPlayer_WeaponServices_CanUse(CCSPlayer_WeaponServices*, CBasePlayerWeapon*);
bool FASTCALL Detour_CEntityIdentity_AcceptInput(CEntityIdentity* pThis, CUtlSymbolLarge* pInputName, CEntityInstance* pActivator, CEntityInstance* pCaller, variant_t* value, int nOutputID);
void* FASTCALL Detour_CNavMesh_GetNearestNavArea(int64_t unk1, float* unk2, unsigned int* unk3, unsigned int unk4, int64_t unk5, int64_t unk6, float unk7, int64_t unk8);
-void FASTCALL Detour_ProcessMovement(CCSPlayer_MovementServices *pThis, void *pMove);
-void *FASTCALL Detour_ProcessUsercmds(CCSPlayerController *pController, CUserCmd *cmds, int numcmds, bool paused, float margin);
-void FASTCALL Detour_CGamePlayerEquip_InputTriggerForAllPlayers(CGamePlayerEquip*, InputData_t*);
-void FASTCALL Detour_CGamePlayerEquip_InputTriggerForActivatedPlayer(CGamePlayerEquip*, InputData_t*);
+void FASTCALL Detour_ProcessMovement(CCSPlayer_MovementServices* pThis, void* pMove);
+void* FASTCALL Detour_ProcessUsercmds(CCSPlayerController* pController, CUserCmd* cmds, int numcmds, bool paused, float margin);
+void FASTCALL Detour_CGamePlayerEquip_InputTriggerForAllPlayers(CGamePlayerEquip*, InputData_t*);
+void FASTCALL Detour_CGamePlayerEquip_InputTriggerForActivatedPlayer(CGamePlayerEquip*, InputData_t*);
CServerSideClient* FASTCALL Detour_GetFreeClient(int64_t unk1, const __m128i* unk2, unsigned int unk3, int64_t unk4, char unk5, void* unk6);
float FASTCALL Detour_CCSPlayerPawn_GetMaxSpeed(CCSPlayerPawn*);
int64 FASTCALL Detour_FindUseEntity(CCSPlayer_UseServices* pThis, float);
diff --git a/src/discord.cpp b/src/discord.cpp
index 19fcb97d..226c8069 100644
--- a/src/discord.cpp
+++ b/src/discord.cpp
@@ -17,18 +17,17 @@
* this program. If not, see .
*/
-#include "common.h"
#include "discord.h"
#include "KeyValues.h"
-#include "interfaces/interfaces.h"
+#include "common.h"
#include "httpmanager.h"
+#include "interfaces/interfaces.h"
#include "utlstring.h"
#include "vendor/nlohmann/json.hpp"
using json = nlohmann::json;
-
CDiscordBotManager* g_pDiscordBotManager = nullptr;
// TODO: CVAR
@@ -44,27 +43,26 @@ CON_COMMAND_F(cs2f_debug_discord_messages, "Whether to include debug information
void DiscordHttpCallback(HTTPRequestHandle request, json response)
{
- if (g_bDebugDiscordRequests) {
+ if (g_bDebugDiscordRequests)
Message("Discord post received response: %s\n", response.dump().c_str());
- }
}
-void CDiscordBotManager::PostDiscordMessage(const char* sDiscordBotName, const char* sMessage) {
+void CDiscordBotManager::PostDiscordMessage(const char* sDiscordBotName, const char* sMessage)
+{
FOR_EACH_VEC(m_vecDiscordBots, i)
{
CDiscordBot bot = m_vecDiscordBots[i];
- if (g_bDebugDiscordRequests) {
+ if (g_bDebugDiscordRequests)
Message("The bot at %i is %s with %s webhook and %s avatar.\n", i, bot.GetName(), bot.GetWebhookUrl(), bot.GetAvatarUrl());
- }
- if (!V_stricmp(sDiscordBotName, bot.GetName())) {
+ if (!V_stricmp(sDiscordBotName, bot.GetName()))
bot.PostMessage(sMessage);
- }
}
}
-void CDiscordBot::PostMessage(const char* sMessage) {
+void CDiscordBot::PostMessage(const char* sMessage)
+{
json jRequestBody;
// Fill up the Json fields
@@ -78,9 +76,8 @@ void CDiscordBot::PostMessage(const char* sMessage) {
// Send the request
std::string sRequestBody = jRequestBody.dump();
- if (g_bDebugDiscordRequests) {
+ if (g_bDebugDiscordRequests)
Message("Sending '%s' to %s.\n", sRequestBody.c_str(), GetWebhookUrl());
- }
g_HTTPManager.POST(m_pszWebhookUrl, sRequestBody.c_str(), &DiscordHttpCallback);
}
diff --git a/src/discord.h b/src/discord.h
index 4e998cea..2be0dae5 100644
--- a/src/discord.h
+++ b/src/discord.h
@@ -43,7 +43,6 @@ class CDiscordBot
bool m_bOverrideName;
};
-
class CDiscordBotManager
{
public:
diff --git a/src/entities.cpp b/src/entities.cpp
index df78e41a..147ddf00 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -36,689 +36,656 @@ extern CCSGameRules* g_pGameRules;
class InputData_t
{
public:
- CBaseEntity* pActivator;
- CBaseEntity* pCaller;
- variant_t value;
- int nOutputID;
+ CBaseEntity* pActivator;
+ CBaseEntity* pCaller;
+ variant_t value;
+ int nOutputID;
};
inline bool StripPlayer(CCSPlayerPawn* pPawn)
{
- const auto pItemServices = pPawn->m_pItemServices();
+ const auto pItemServices = pPawn->m_pItemServices();
- if (!pItemServices)
- return false;
+ if (!pItemServices)
+ return false;
- pItemServices->StripPlayerWeapons(true);
+ pItemServices->StripPlayerWeapons(true);
- return true;
+ return true;
}
// Must be called in GameFramePre
inline void DelayInput(CBaseEntity* pCaller, const char* input, const char* param = "")
{
- const auto eh = pCaller->GetHandle();
+ const auto eh = pCaller->GetHandle();
- new CTimer(0.f, false, false, [eh, input, param]() {
- if (const auto entity = reinterpret_cast(eh.Get()))
- entity->AcceptInput(input, param, nullptr, entity);
+ new CTimer(0.f, false, false, [eh, input, param]() {
+ if (const auto entity = reinterpret_cast(eh.Get()))
+ entity->AcceptInput(input, param, nullptr, entity);
- return -1.f;
- });
+ return -1.f;
+ });
}
// Must be called in GameFramePre
inline void DelayInput(CBaseEntity* pCaller, CBaseEntity* pActivator, const char* input, const char* param = "")
{
- const auto eh = pCaller->GetHandle();
- const auto ph = pActivator->GetHandle();
+ const auto eh = pCaller->GetHandle();
+ const auto ph = pActivator->GetHandle();
- new CTimer(0.f, false, false, [eh, ph, input, param]() {
- const auto player = reinterpret_cast(ph.Get());
- if (const auto entity = reinterpret_cast(eh.Get()))
- entity->AcceptInput(input, param, player, entity);
+ new CTimer(0.f, false, false, [eh, ph, input, param]() {
+ const auto player = reinterpret_cast(ph.Get());
+ if (const auto entity = reinterpret_cast(eh.Get()))
+ entity->AcceptInput(input, param, player, entity);
- return -1.f;
- });
+ return -1.f;
+ });
}
namespace CGamePlayerEquipHandler
{
-
-void Use(CGamePlayerEquip* pEntity, InputData_t* pInput)
-{
- const auto pCaller = pInput->pActivator;
-
- if (!pCaller || !pCaller->IsPawn())
- return;
-
- const auto pPawn = reinterpret_cast(pCaller);
-
- const auto flags = pEntity->m_spawnflags();
-
- if (flags & CGamePlayerEquip::SF_PLAYEREQUIP_STRIPFIRST)
- {
- if (!StripPlayer(pPawn))
- return;
- }
- else if (flags & ::CGamePlayerEquip::SF_PLAYEREQUIP_ONLYSTRIPSAME)
- {
- // TODO support strip same flags
- }
-}
-
-void TriggerForAllPlayers(CGamePlayerEquip* pEntity, InputData_t* pInput)
-{
- const auto flags = pEntity->m_spawnflags();
-
- if (flags & CGamePlayerEquip::SF_PLAYEREQUIP_STRIPFIRST)
- {
- CCSPlayerPawn* pPawn = nullptr;
- while ((pPawn = reinterpret_cast