Cstrike: Do some more cleanup
This commit is contained in:
		@@ -16,6 +16,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "amxxmodule.h"
 | 
					#include "amxxmodule.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Weapon Ids for use with CS_OnBuyAttempt(), CS_OnBuy().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
#define CSI_P228						CSW_P228
 | 
					#define CSI_P228						CSW_P228
 | 
				
			||||||
#define CSI_SCOUT						CSW_SCOUT
 | 
					#define CSI_SCOUT						CSW_SCOUT
 | 
				
			||||||
#define CSI_HEGRENADE					CSW_HEGRENADE
 | 
					#define CSI_HEGRENADE					CSW_HEGRENADE
 | 
				
			||||||
@@ -55,7 +58,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define BITS_PISTOLS					(1<<CSI_GLOCK18 | 1<<CSI_USP | 1<<CSI_P228 | 1<<CSI_DEAGLE | 1<<CSI_ELITE | 1<<CSI_FIVESEVEN)
 | 
					#define BITS_PISTOLS					(1<<CSI_GLOCK18 | 1<<CSI_USP | 1<<CSI_P228 | 1<<CSI_DEAGLE | 1<<CSI_ELITE | 1<<CSI_FIVESEVEN)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Ids of weapons in CS
 | 
					/**
 | 
				
			||||||
 | 
					 * Weapons Ids.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
#define CSW_P228						1
 | 
					#define CSW_P228						1
 | 
				
			||||||
#define CSW_SCOUT						3
 | 
					#define CSW_SCOUT						3
 | 
				
			||||||
#define CSW_HEGRENADE					4
 | 
					#define CSW_HEGRENADE					4
 | 
				
			||||||
@@ -89,7 +94,9 @@
 | 
				
			|||||||
#define CSW_VESTHELM					32 // Brand new invention!
 | 
					#define CSW_VESTHELM					32 // Brand new invention!
 | 
				
			||||||
#define CSW_SHIELDGUN					99
 | 
					#define CSW_SHIELDGUN					99
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// These are used with armoury_entity:s.
 | 
					/**
 | 
				
			||||||
 | 
					 * Armoury entity ids for use with cs_get/set_armoury_type().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
#define CSA_MP5NAVY						0
 | 
					#define CSA_MP5NAVY						0
 | 
				
			||||||
#define CSA_TMP							1
 | 
					#define CSA_TMP							1
 | 
				
			||||||
#define CSA_P90							2
 | 
					#define CSA_P90							2
 | 
				
			||||||
@@ -110,6 +117,9 @@
 | 
				
			|||||||
#define CSA_VESTHELM					17
 | 
					#define CSA_VESTHELM					17
 | 
				
			||||||
#define CSA_SMOKEGRENADE				18
 | 
					#define CSA_SMOKEGRENADE				18
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Weapon states of the following weapons: usp, elite, glock18, famas and m4a1.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
enum WeaponState
 | 
					enum WeaponState
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	WPNSTATE_USP_SILENCED       = (1 << 0),
 | 
						WPNSTATE_USP_SILENCED       = (1 << 0),
 | 
				
			||||||
@@ -120,6 +130,9 @@ enum WeaponState
 | 
				
			|||||||
	WPNSTATE_SHIELD_DRAWN       = (1 << 5),
 | 
						WPNSTATE_SHIELD_DRAWN       = (1 << 5),
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * M4A1 animations
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
enum m4a1_e
 | 
					enum m4a1_e
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	M4A1_IDLE,
 | 
						M4A1_IDLE,
 | 
				
			||||||
@@ -138,6 +151,9 @@ enum m4a1_e
 | 
				
			|||||||
	M4A1_DETACH_SILENCER
 | 
						M4A1_DETACH_SILENCER
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * USP animations
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
enum usp_e
 | 
					enum usp_e
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	USP_IDLE,
 | 
						USP_IDLE,
 | 
				
			||||||
@@ -158,6 +174,9 @@ enum usp_e
 | 
				
			|||||||
	USP_DETACH_SILENCER
 | 
						USP_DETACH_SILENCER
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * States of gameplay zones.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
enum SignalState
 | 
					enum SignalState
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	SIGNAL_BUY       = (1 << 0),
 | 
						SIGNAL_BUY       = (1 << 0),
 | 
				
			||||||
@@ -167,48 +186,48 @@ enum SignalState
 | 
				
			|||||||
	SIGNAL_VIPSAFETY = (1 << 4),
 | 
						SIGNAL_VIPSAFETY = (1 << 4),
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Default team indexes.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
#define TEAM_UNASSIGNED					0
 | 
					#define TEAM_UNASSIGNED					0
 | 
				
			||||||
#define TEAM_T							1
 | 
					#define TEAM_T							1
 | 
				
			||||||
#define TEAM_CT							2
 | 
					#define TEAM_CT							2
 | 
				
			||||||
#define TEAM_SPECTATOR					3
 | 
					#define TEAM_SPECTATOR					3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Default color of defuser HUD icon.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
#define DEFUSER_COLOUR_R				0
 | 
					#define DEFUSER_COLOUR_R				0
 | 
				
			||||||
#define DEFUSER_COLOUR_G				160
 | 
					#define DEFUSER_COLOUR_G				160
 | 
				
			||||||
#define DEFUSER_COLOUR_B				0
 | 
					#define DEFUSER_COLOUR_B				0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Values for use with ScoreAttrib message.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
#define SCOREATTRIB_NOTHING				0
 | 
					#define SCOREATTRIB_NOTHING				0
 | 
				
			||||||
#define SCOREATTRIB_DEAD				1
 | 
					#define SCOREATTRIB_DEAD				1
 | 
				
			||||||
#define SCOREATTRIB_BOMB				2 // t only
 | 
					#define SCOREATTRIB_BOMB				2 // t only
 | 
				
			||||||
#define SCOREATTRIB_VIP					4 // ct only
 | 
					#define SCOREATTRIB_VIP					4 // ct only
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define AMD64_STATIONARY_NO				2
 | 
					/**
 | 
				
			||||||
#define AMD64_STATIONARY_YES			3
 | 
					 * Armor types for use with cs_get/Set_user_armor().
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
#define CS_ARMOR_NONE					0
 | 
					#define CS_ARMOR_NONE					0
 | 
				
			||||||
#define CS_ARMOR_KEVLAR					1
 | 
					#define CS_ARMOR_KEVLAR					1
 | 
				
			||||||
#define CS_ARMOR_ASSAULTSUIT			2
 | 
					#define CS_ARMOR_ASSAULTSUIT			2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Default FOV values.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
#define CS_FIRST_ZOOM					40
 | 
					#define CS_FIRST_ZOOM					40
 | 
				
			||||||
#define CS_SECOND_AWP_ZOOM				10
 | 
					#define CS_SECOND_AWP_ZOOM				10
 | 
				
			||||||
#define CS_SECOND_NONAWP_ZOOM			15
 | 
					#define CS_SECOND_NONAWP_ZOOM			15
 | 
				
			||||||
#define CS_AUGSG552_ZOOM				55
 | 
					#define CS_AUGSG552_ZOOM				55
 | 
				
			||||||
#define CS_NO_ZOOM						90
 | 
					#define CS_NO_ZOOM						90
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum CS_Internal_Models {
 | 
					/**
 | 
				
			||||||
	CS_DONTCHANGE = 0,
 | 
					 * Zoom value for use with cs_get/set_user_zoom().
 | 
				
			||||||
	CS_CT_URBAN = 1,
 | 
					 */
 | 
				
			||||||
	CS_T_TERROR = 2,
 | 
					 | 
				
			||||||
	CS_T_LEET = 3,
 | 
					 | 
				
			||||||
	CS_T_ARCTIC = 4,
 | 
					 | 
				
			||||||
	CS_CT_GSG9 = 5,
 | 
					 | 
				
			||||||
	CS_CT_GIGN = 6,
 | 
					 | 
				
			||||||
	CS_CT_SAS = 7,
 | 
					 | 
				
			||||||
	CS_T_GUERILLA = 8,
 | 
					 | 
				
			||||||
	CS_CT_VIP = 9,
 | 
					 | 
				
			||||||
	CZ_T_MILITIA = 10,
 | 
					 | 
				
			||||||
	CZ_CT_SPETSNAZ = 11
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
enum
 | 
					enum
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	CS_RESET_ZOOM = 0,
 | 
						CS_RESET_ZOOM = 0,
 | 
				
			||||||
@@ -216,8 +235,31 @@ enum
 | 
				
			|||||||
	CS_SET_FIRST_ZOOM,
 | 
						CS_SET_FIRST_ZOOM,
 | 
				
			||||||
	CS_SET_SECOND_ZOOM,
 | 
						CS_SET_SECOND_ZOOM,
 | 
				
			||||||
	CS_SET_AUGSG552_ZOOM,
 | 
						CS_SET_AUGSG552_ZOOM,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Player's model types.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					enum CS_Internal_Models 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						CS_DONTCHANGE  = 0,
 | 
				
			||||||
 | 
						CS_CT_URBAN    = 1,
 | 
				
			||||||
 | 
						CS_T_TERROR    = 2,
 | 
				
			||||||
 | 
						CS_T_LEET      = 3,
 | 
				
			||||||
 | 
						CS_T_ARCTIC    = 4,
 | 
				
			||||||
 | 
						CS_CT_GSG9     = 5,
 | 
				
			||||||
 | 
						CS_CT_GIGN     = 6,
 | 
				
			||||||
 | 
						CS_CT_SAS      = 7,
 | 
				
			||||||
 | 
						CS_T_GUERILLA  = 8,
 | 
				
			||||||
 | 
						CS_CT_VIP      = 9,
 | 
				
			||||||
 | 
						CZ_T_MILITIA   = 10,
 | 
				
			||||||
 | 
						CZ_CT_SPETSNAZ = 11
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Menu states.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
typedef enum
 | 
					typedef enum
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Menu_OFF,
 | 
						Menu_OFF,
 | 
				
			||||||
@@ -238,7 +280,4 @@ typedef enum
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
} Menu;
 | 
					} Menu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef edict_t* (*CreateNamedEntityFunc)(string_t iszClassname);
 | 
					 | 
				
			||||||
typedef void*    (*UTIL_FindEntityByStringFunc)(void* pStartEntity, const char *szKeyword, const char *szValue);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // CSTRIKE_DATA_H
 | 
					#endif // CSTRIKE_DATA_H
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,16 +17,16 @@ HL_TypeConversion  G_HL_TypeConversion;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void OffsetHandler::search_pev()
 | 
					void OffsetHandler::search_pev()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	edict_t* edict = INDEXENT(0);
 | 
						edict_t *pEdict = INDEXENT(0);
 | 
				
			||||||
	entvars_t* entvars = &edict->v;
 | 
						entvars_t *pev = VARS(pEdict);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	byte* private_c = (byte*)edict->pvPrivateData;
 | 
						byte *privateData = reinterpret_cast<byte*>(pEdict->pvPrivateData);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (int i = 0; i < 0xFFF; i++)
 | 
						for (int i = 0; i < 0xFFF; i++)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uintptr_t val = *((uintptr_t*)(private_c + i));
 | 
							entvars_t *val = *(reinterpret_cast<entvars_t**>(privateData + i));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (val == (uintptr_t)entvars)
 | 
							if (val == pev)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			this->pev = i;
 | 
								this->pev = i;
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
@@ -82,7 +82,8 @@ void* HL_TypeConversion::id_to_cbase(int index)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
entvars_t* HL_TypeConversion::id_to_entvar(int index)
 | 
					entvars_t* HL_TypeConversion::id_to_entvar(int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return &(INDEXENT2(index)->v);
 | 
						edict_t *pEdict = INDEXENT2(index);
 | 
				
			||||||
 | 
						return pEdict ? VARS(pEdict) : nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
entvars_t* HL_TypeConversion::cbase_to_entvar(void* cbase)
 | 
					entvars_t* HL_TypeConversion::cbase_to_entvar(void* cbase)
 | 
				
			||||||
@@ -92,7 +93,7 @@ entvars_t* HL_TypeConversion::cbase_to_entvar(void* cbase)
 | 
				
			|||||||
		return nullptr;
 | 
							return nullptr;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return *(entvars_t **)((char *)(cbase) + G_OffsetHandler->pev);
 | 
						return *reinterpret_cast<entvars_t**>(reinterpret_cast<int8*>(cbase) + G_OffsetHandler->pev);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int HL_TypeConversion::cbase_to_id(void *cbase)
 | 
					int HL_TypeConversion::cbase_to_id(void *cbase)
 | 
				
			||||||
@@ -102,7 +103,7 @@ int HL_TypeConversion::cbase_to_id(void *cbase)
 | 
				
			|||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	entvars_t* pev = this->cbase_to_entvar(cbase);
 | 
						entvars_t *pev = this->cbase_to_entvar(cbase);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!pev)
 | 
						if (!pev)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,45 +13,47 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "CstrikeDatas.h"
 | 
					#include "CstrikeDatas.h"
 | 
				
			||||||
#include "CstrikeUtils.h"
 | 
					#include "CstrikeUtils.h"
 | 
				
			||||||
#include "CDetour/detours.h"
 | 
					#include "CstrikeHacks.h"
 | 
				
			||||||
#include <sm_stringhashmap.h>
 | 
					#include <sm_stringhashmap.h>
 | 
				
			||||||
 | 
					#include "CstrikeHLTypeConversion.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CtrlDetours_ClientCommand(bool set);
 | 
					void CtrlDetours_ClientCommand(bool set);
 | 
				
			||||||
void CtrlDetours_BuyCommands(bool set);
 | 
					void CtrlDetours_BuyCommands(bool set);
 | 
				
			||||||
 | 
					void CtrlDetours_Natives(bool set);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ForwardInternalCommand = -1;
 | 
					int ForwardInternalCommand = -1;
 | 
				
			||||||
int ForwardOnBuy = -1;
 | 
					int ForwardOnBuy           = -1;
 | 
				
			||||||
int ForwardOnBuyAttempt = -1;
 | 
					int ForwardOnBuyAttempt    = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int *UseBotArgs      = NULL;
 | 
					int *UseBotArgs;
 | 
				
			||||||
const char **BotArgs = NULL;
 | 
					const char **BotArgs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CDetour *ClientCommandDetour = NULL;
 | 
					CDetour *ClientCommandDetour;
 | 
				
			||||||
CDetour *GiveShieldDetour    = NULL;
 | 
					CDetour *GiveShieldDetour;
 | 
				
			||||||
CDetour *GiveNamedItemDetour = NULL;
 | 
					CDetour *GiveNamedItemDetour;
 | 
				
			||||||
CDetour *AddAccountDetour    = NULL;
 | 
					CDetour *AddAccountDetour;
 | 
				
			||||||
 | 
					CDetour *GiveDefaultItemsDetour;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int CurrentItemId = 0;
 | 
					CreateNamedEntityFunc       CS_CreateNamedEntity;
 | 
				
			||||||
 | 
					UTIL_FindEntityByStringFunc CS_UTIL_FindEntityByString;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CurrentItemId;
 | 
				
			||||||
StringHashMap<int> ItemAliasList;
 | 
					StringHashMap<int> ItemAliasList;
 | 
				
			||||||
int TeamOffset = 0;
 | 
					int TeamOffset;
 | 
				
			||||||
int MenuOffset = 0;
 | 
					int MenuOffset;
 | 
				
			||||||
 | 
					 | 
				
			||||||
extern enginefuncs_t *g_pengfuncsTable;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void InitializeHacks()
 | 
					void InitializeHacks()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#if defined AMD64
 | 
					 | 
				
			||||||
	#error UNSUPPORTED
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	CtrlDetours_ClientCommand(true);
 | 
						CtrlDetours_ClientCommand(true);
 | 
				
			||||||
	CtrlDetours_BuyCommands(true);
 | 
						CtrlDetours_BuyCommands(true);
 | 
				
			||||||
 | 
						CtrlDetours_Natives(true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ShutdownHacks()
 | 
					void ShutdownHacks()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	CtrlDetours_ClientCommand(false);
 | 
						CtrlDetours_ClientCommand(false);
 | 
				
			||||||
	CtrlDetours_BuyCommands(false);
 | 
						CtrlDetours_BuyCommands(false);
 | 
				
			||||||
 | 
						CtrlDetours_Natives(false);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef CMD_ARGV
 | 
					#undef CMD_ARGV
 | 
				
			||||||
@@ -65,7 +67,7 @@ const char *CMD_ARGV(int i)
 | 
				
			|||||||
			return BotArgs[i];
 | 
								return BotArgs[i];
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return NULL;
 | 
							return nullptr;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return g_engfuncs.pfnCmd_Argv(i);
 | 
						return g_engfuncs.pfnCmd_Argv(i);
 | 
				
			||||||
@@ -76,7 +78,7 @@ void OnEmitSound(edict_t *entity, int channel, const char *sample, float volume,
 | 
				
			|||||||
	// If shield is blocked with CS_OnBuy, we need to block the pickup sound ("items/gunpickup2.wav") 
 | 
						// If shield is blocked with CS_OnBuy, we need to block the pickup sound ("items/gunpickup2.wav") 
 | 
				
			||||||
	// as well played right after. Why this sound is not contained in GiveShield()?
 | 
						// as well played right after. Why this sound is not contained in GiveShield()?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	g_pengfuncsTable->pfnEmitSound = NULL;
 | 
						g_pengfuncsTable->pfnEmitSound = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	RETURN_META(MRES_SUPERCEDE);
 | 
						RETURN_META(MRES_SUPERCEDE);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -177,7 +179,7 @@ DETOUR_DECL_MEMBER1(GiveNamedItem, void, const char*, pszName) // void CBasePlay
 | 
				
			|||||||
	// If the current item id is not null, this means player has triggers a buy command.
 | 
						// If the current item id is not null, this means player has triggers a buy command.
 | 
				
			||||||
	if (CurrentItemId)
 | 
						if (CurrentItemId)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		int client = PrivateToIndex(this);
 | 
							int client = G_HL_TypeConversion.cbase_to_id(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0)
 | 
							if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -198,7 +200,7 @@ DETOUR_DECL_MEMBER1(GiveShield, void, bool, bRetire) // void CBasePlayer::GiveSh
 | 
				
			|||||||
	// Special case for shield. Game doesn't use GiveNamedItem() to give a shield.
 | 
						// Special case for shield. Game doesn't use GiveNamedItem() to give a shield.
 | 
				
			||||||
	if (CurrentItemId == CSI_SHIELDGUN)
 | 
						if (CurrentItemId == CSI_SHIELDGUN)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		int client = PrivateToIndex(this);
 | 
							int client = G_HL_TypeConversion.cbase_to_id(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), CSI_SHIELDGUN) > 0)
 | 
							if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), CSI_SHIELDGUN) > 0)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -244,12 +246,12 @@ void CtrlDetours_ClientCommand(bool set)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		int offset = 0;
 | 
							int offset = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (MainConfig->GetOffset("UseBotArgs", &offset) && offset)
 | 
							if (MainConfig->GetOffset("UseBotArgs", &offset))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			UseBotArgs = get_pdata<int*>(base, offset);
 | 
								UseBotArgs = get_pdata<int*>(base, offset);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (MainConfig->GetOffset("BotArgs", &offset) && offset)
 | 
							if (MainConfig->GetOffset("BotArgs", &offset))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			BotArgs = get_pdata<const char**>(base, offset);
 | 
								BotArgs = get_pdata<const char**>(base, offset);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -258,12 +260,12 @@ void CtrlDetours_ClientCommand(bool set)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		void *address = nullptr;
 | 
							void *address = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (MainConfig->GetMemSig("UseBotArgs", &address) && address)
 | 
							if (MainConfig->GetMemSig("UseBotArgs", &address))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			UseBotArgs = reinterpret_cast<int *>(address);
 | 
								UseBotArgs = reinterpret_cast<int *>(address);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (MainConfig->GetMemSig("BotArgs", &address) && address)
 | 
							if (MainConfig->GetMemSig("BotArgs", &address))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			BotArgs = reinterpret_cast<const char **>(address);
 | 
								BotArgs = reinterpret_cast<const char **>(address);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -336,10 +338,10 @@ void ToggleDetour_ClientCommands(bool enable)
 | 
				
			|||||||
			{ "nvgs"       , CSI_NVGS       }, { "shield"     , CSI_SHIELDGUN    },
 | 
								{ "nvgs"       , CSI_NVGS       }, { "shield"     , CSI_SHIELDGUN    },
 | 
				
			||||||
			{ "buyammo1"   , CSI_PRIMAMMO   }, { "primammo"   , CSI_PRIMAMMO     },
 | 
								{ "buyammo1"   , CSI_PRIMAMMO   }, { "primammo"   , CSI_PRIMAMMO     },
 | 
				
			||||||
			{ "buyammo2"   , CSI_SECAMMO    }, { "secammo"    , CSI_SECAMMO      },
 | 
								{ "buyammo2"   , CSI_SECAMMO    }, { "secammo"    , CSI_SECAMMO      },
 | 
				
			||||||
			{ NULL         , 0 }
 | 
								{ nullptr         , 0 }
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (size_t i = 0; aliasToId[i].alias != NULL; ++i)
 | 
							for (size_t i = 0; aliasToId[i].alias != nullptr; ++i)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ItemAliasList.insert(aliasToId[i].alias, aliasToId[i].id);
 | 
								ItemAliasList.insert(aliasToId[i].alias, aliasToId[i].id);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -357,14 +359,20 @@ void CtrlDetours_BuyCommands(bool set)
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		void *address = nullptr;
 | 
							void *address = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		MainConfig->GetMemSig("GiveShield", &address);
 | 
							if (MainConfig->GetMemSig("GiveShield", &address))
 | 
				
			||||||
		GiveShieldDetour = DETOUR_CREATE_MEMBER_FIXED(GiveShield, address); address = nullptr;
 | 
							{
 | 
				
			||||||
 | 
								GiveShieldDetour = DETOUR_CREATE_MEMBER_FIXED(GiveShield, address);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		MainConfig->GetMemSig("GiveNamedItem", &address);
 | 
							if (MainConfig->GetMemSig("GiveNamedItem", &address))
 | 
				
			||||||
		GiveNamedItemDetour = DETOUR_CREATE_MEMBER_FIXED(GiveNamedItem, address);  address = nullptr;
 | 
							{
 | 
				
			||||||
 | 
								GiveNamedItemDetour = DETOUR_CREATE_MEMBER_FIXED(GiveNamedItem, address);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		MainConfig->GetMemSig("AddAccount", &address);
 | 
							if (MainConfig->GetMemSig("AddAccount", &address))
 | 
				
			||||||
		AddAccountDetour = DETOUR_CREATE_MEMBER_FIXED(AddAccount, address);  address = nullptr;
 | 
							{
 | 
				
			||||||
 | 
								AddAccountDetour = DETOUR_CREATE_MEMBER_FIXED(AddAccount, address);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (!GiveShieldDetour || !GiveNamedItemDetour || !AddAccountDetour)
 | 
							if (!GiveShieldDetour || !GiveNamedItemDetour || !AddAccountDetour)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -424,3 +432,31 @@ void ToggleDetour_BuyCommands(bool enable)
 | 
				
			|||||||
		(enable) ? AddAccountDetour->EnableDetour() : AddAccountDetour->DisableDetour();
 | 
							(enable) ? AddAccountDetour->EnableDetour() : AddAccountDetour->DisableDetour();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CtrlDetours_Natives(bool set)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (set)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							void *address = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (MainConfig->GetMemSig("CreateNamedEntity", &address)) // cs_create_entity()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								CS_CreateNamedEntity = reinterpret_cast<CreateNamedEntityFunc>(address);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (MainConfig->GetMemSig("FindEntityByString", &address)) // cs_find_ent_by_class()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								CS_UTIL_FindEntityByString = reinterpret_cast<UTIL_FindEntityByStringFunc>(address);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!CS_CreateNamedEntity)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MF_Log("CREATE_NAMED_ENITTY is not available - native cs_create_entity() has been disabled");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!CS_UTIL_FindEntityByString)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MF_Log("UTIL_FindEntByString is not available - native cs_find_ent_by_class() has been disabled");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										54
									
								
								modules/cstrike/cstrike/CstrikeHacks.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								modules/cstrike/cstrike/CstrikeHacks.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					// vim: set ts=4 sw=4 tw=99 noet:
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
 | 
				
			||||||
 | 
					// Copyright (C) The AMX Mod X Development Team.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// This software is licensed under the GNU General Public License, version 3 or higher.
 | 
				
			||||||
 | 
					// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
 | 
				
			||||||
 | 
					//     https://alliedmods.net/amxmodx-license
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Counter-Strike Module
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef CSTRIKE_HACKS_H
 | 
				
			||||||
 | 
					#define CSTRIKE_HACKS_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <amxxmodule.h>
 | 
				
			||||||
 | 
					#include <IGameConfigs.h>
 | 
				
			||||||
 | 
					#include <CDetour/detours.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void InitializeHacks();
 | 
				
			||||||
 | 
					void ShutdownHacks();
 | 
				
			||||||
 | 
					void ToggleDetour_ClientCommands(bool enable);
 | 
				
			||||||
 | 
					void ToggleDetour_BuyCommands(bool enable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern int MessageIdArmorType;
 | 
				
			||||||
 | 
					extern int MessageIdMoney;
 | 
				
			||||||
 | 
					extern int MessageIdResetHUD;
 | 
				
			||||||
 | 
					extern int MessageIdScoreAttrib;
 | 
				
			||||||
 | 
					extern int MessageIdScoreInfo;
 | 
				
			||||||
 | 
					extern int MessageIdStatusIcon;
 | 
				
			||||||
 | 
					extern int MessageIdTeamInfo;
 | 
				
			||||||
 | 
					extern int MessageIdTextMsg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern AMX_NATIVE_INFO CstrikeNatives[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern IGameConfig *MainConfig;
 | 
				
			||||||
 | 
					extern IGameConfig *OffsetConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern int ForwardInternalCommand;
 | 
				
			||||||
 | 
					extern int ForwardOnBuy;
 | 
				
			||||||
 | 
					extern int ForwardOnBuyAttempt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef edict_t* (*CreateNamedEntityFunc)(string_t iszClassname);
 | 
				
			||||||
 | 
					typedef void*    (*UTIL_FindEntityByStringFunc)(void* pStartEntity, const char *szKeyword, const char *szValue);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern CreateNamedEntityFunc       CS_CreateNamedEntity;
 | 
				
			||||||
 | 
					extern UTIL_FindEntityByStringFunc CS_UTIL_FindEntityByString;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern CDetour *GiveDefaultItemsDetour;
 | 
				
			||||||
 | 
					extern enginefuncs_t *g_pengfuncsTable;
 | 
				
			||||||
 | 
					extern bool NoKifesMode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // CSTRIKE_HACKS_H
 | 
				
			||||||
@@ -14,23 +14,25 @@
 | 
				
			|||||||
#include "CstrikeDatas.h"
 | 
					#include "CstrikeDatas.h"
 | 
				
			||||||
#include "CstrikePlayer.h"
 | 
					#include "CstrikePlayer.h"
 | 
				
			||||||
#include "CstrikeUtils.h"
 | 
					#include "CstrikeUtils.h"
 | 
				
			||||||
 | 
					#include "CstrikeHacks.h"
 | 
				
			||||||
#include "CstrikeHLTypeConversion.h"
 | 
					#include "CstrikeHLTypeConversion.h"
 | 
				
			||||||
 | 
					#include <CDetour/detours.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CCstrikePlayer g_players[33];
 | 
					CCstrikePlayer g_players[33];
 | 
				
			||||||
int g_zooming[33] = {0};
 | 
					int g_zooming[33] = {0};
 | 
				
			||||||
bool g_precachedknife = false;
 | 
					bool g_precachedknife = false;
 | 
				
			||||||
bool g_noknives = false;
 | 
					bool g_noknives = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern CreateNamedEntityFunc       CS_CreateNamedEntity;
 | 
					bool NoKifesMode = false;
 | 
				
			||||||
extern UTIL_FindEntityByStringFunc CS_UTIL_FindEntityByString;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int MessageIdMoney;
 | 
					int MessageIdArmorType;
 | 
				
			||||||
extern int MessageIdScoreInfo;
 | 
					int MessageIdMoney;
 | 
				
			||||||
extern int MessageIdArmorType;
 | 
					int MessageIdResetHUD;
 | 
				
			||||||
extern int MessageIdTeamInfo;
 | 
					int MessageIdScoreAttrib;
 | 
				
			||||||
extern int MessageIdStatusIcon;
 | 
					int MessageIdScoreInfo;
 | 
				
			||||||
extern int MessageIdScoreAttrib;
 | 
					int MessageIdStatusIcon;
 | 
				
			||||||
extern int MessageIdResetHUD;
 | 
					int MessageIdTeamInfo;
 | 
				
			||||||
 | 
					int MessageIdTextMsg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// native cs_set_user_money(index, money, flash = 1);
 | 
					// native cs_set_user_money(index, money, flash = 1);
 | 
				
			||||||
static cell AMX_NATIVE_CALL cs_set_user_money(AMX *amx, cell *params)
 | 
					static cell AMX_NATIVE_CALL cs_set_user_money(AMX *amx, cell *params)
 | 
				
			||||||
@@ -938,13 +940,13 @@ static cell AMX_NATIVE_CALL cs_get_user_hasprimary(AMX *amx, cell *params)
 | 
				
			|||||||
// native cs_get_no_knives();
 | 
					// native cs_get_no_knives();
 | 
				
			||||||
static cell AMX_NATIVE_CALL cs_get_no_knives(AMX *amx, cell *params)
 | 
					static cell AMX_NATIVE_CALL cs_get_no_knives(AMX *amx, cell *params)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return g_noknives ? 1 : 0;
 | 
						return NoKifesMode ? 1 : 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// native cs_set_no_knives(noknives = 0);
 | 
					// native cs_set_no_knives(noknives = 0);
 | 
				
			||||||
static cell AMX_NATIVE_CALL cs_set_no_knives(AMX *amx, cell *params)
 | 
					static cell AMX_NATIVE_CALL cs_set_no_knives(AMX *amx, cell *params)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	g_noknives = params[1] != 0;
 | 
						NoKifesMode = params[1] != 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,6 @@
 | 
				
			|||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "amxxmodule.h"
 | 
					#include "amxxmodule.h"
 | 
				
			||||||
#include "MemoryUtils.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int MessageIdTextMsg;
 | 
					extern int MessageIdTextMsg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -36,7 +35,7 @@ bool UTIL_CheckForPublic(const char *publicname)
 | 
				
			|||||||
	int i = 0;
 | 
						int i = 0;
 | 
				
			||||||
	char blah[64];
 | 
						char blah[64];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	strncpy(blah, publicname, sizeof(blah)-  1);
 | 
						strncpy(blah, publicname, sizeof(blah) - 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while ((amx = MF_GetScriptAmx(i++)))
 | 
						while ((amx = MF_GetScriptAmx(i++)))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -48,4 +47,3 @@ bool UTIL_CheckForPublic(const char *publicname)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,16 +14,9 @@
 | 
				
			|||||||
#ifndef CSTRIKE_UTILS_H
 | 
					#ifndef CSTRIKE_UTILS_H
 | 
				
			||||||
#define CSTRIKE_UTILS_H
 | 
					#define CSTRIKE_UTILS_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <IGameConfigs.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool UTIL_IsPlayer(edict_t *pPlayer);
 | 
					bool UTIL_IsPlayer(edict_t *pPlayer);
 | 
				
			||||||
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message);
 | 
					void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message);
 | 
				
			||||||
void *UTIL_FindAddressFromEntry(const char *entry, bool isHidden = false, const char *library = "mod");
 | 
					 | 
				
			||||||
bool UTIL_CheckForPublic(const char *publicname);
 | 
					bool UTIL_CheckForPublic(const char *publicname);
 | 
				
			||||||
char *UTIL_StringToLower(char *str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern IGameConfig *MainConfig;
 | 
					 | 
				
			||||||
extern IGameConfig *OffsetConfig;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GETINFOKEYBUFFER	(*g_engfuncs.pfnGetInfoKeyBuffer)
 | 
					#define GETINFOKEYBUFFER	(*g_engfuncs.pfnGetInfoKeyBuffer)
 | 
				
			||||||
#define	SETCLIENTKEYVALUE	(*g_engfuncs.pfnSetClientKeyValue)
 | 
					#define	SETCLIENTKEYVALUE	(*g_engfuncs.pfnSetClientKeyValue)
 | 
				
			||||||
@@ -119,39 +112,6 @@ inline void set_pdata(void *pEntity, int offset, T value, int element = 0)
 | 
				
			|||||||
	*reinterpret_cast<T*>(reinterpret_cast<int8*>(pEntity) + offset + element * sizeof(T)) = value;
 | 
						*reinterpret_cast<T*>(reinterpret_cast<int8*>(pEntity) + offset + element * sizeof(T)) = value;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
inline edict_t *PrivateToEdict(const void *pdata)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (!pdata)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	char *ptr = (char*)pdata;
 | 
					 | 
				
			||||||
	ptr += 4;
 | 
					 | 
				
			||||||
	entvars_t *pev = *(entvars_t **)ptr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!pev)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return pev->pContainingEntity;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
inline int PrivateToIndex(const void *pdata)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	edict_t *pEntity = PrivateToEdict(pdata);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!pEntity)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		return -1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ENTINDEX(pEntity);
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class EHANDLE
 | 
					class EHANDLE
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,36 +14,14 @@
 | 
				
			|||||||
#include "amxxmodule.h"
 | 
					#include "amxxmodule.h"
 | 
				
			||||||
#include "CstrikeUtils.h"
 | 
					#include "CstrikeUtils.h"
 | 
				
			||||||
#include "CstrikeDatas.h"
 | 
					#include "CstrikeDatas.h"
 | 
				
			||||||
 | 
					#include "CstrikeHacks.h"
 | 
				
			||||||
#include "CstrikeHLTypeConversion.h"
 | 
					#include "CstrikeHLTypeConversion.h"
 | 
				
			||||||
#include <IGameConfigs.h>
 | 
					#include <IGameConfigs.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern AMX_NATIVE_INFO CstrikeNatives[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int ForwardInternalCommand;
 | 
					 | 
				
			||||||
extern int ForwardOnBuy;
 | 
					 | 
				
			||||||
extern int ForwardOnBuyAttempt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void InitializeHacks();
 | 
					 | 
				
			||||||
void ShutdownHacks();
 | 
					 | 
				
			||||||
void ToggleDetour_ClientCommands(bool enable);
 | 
					 | 
				
			||||||
void ToggleDetour_BuyCommands(bool enable);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
CreateNamedEntityFunc CS_CreateNamedEntity = nullptr;
 | 
					 | 
				
			||||||
UTIL_FindEntityByStringFunc CS_UTIL_FindEntityByString = nullptr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
IGameConfig *MainConfig;
 | 
					IGameConfig *MainConfig;
 | 
				
			||||||
IGameConfig *OffsetConfig;
 | 
					IGameConfig *OffsetConfig;
 | 
				
			||||||
IGameConfigManager *ConfigManager;
 | 
					IGameConfigManager *ConfigManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MessageIdArmorType;
 | 
					 | 
				
			||||||
int MessageIdMoney;
 | 
					 | 
				
			||||||
int MessageIdResetHUD;
 | 
					 | 
				
			||||||
int MessageIdScoreAttrib;
 | 
					 | 
				
			||||||
int MessageIdScoreInfo;
 | 
					 | 
				
			||||||
int MessageIdStatusIcon;
 | 
					 | 
				
			||||||
int MessageIdTeamInfo;
 | 
					 | 
				
			||||||
int MessageIdTextMsg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct UserMsg
 | 
					struct UserMsg
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const char* name;
 | 
						const char* name;
 | 
				
			||||||
@@ -60,10 +38,9 @@ UserMsg MessagesList[] =
 | 
				
			|||||||
	{ "StatusIcon" , &MessageIdStatusIcon  },
 | 
						{ "StatusIcon" , &MessageIdStatusIcon  },
 | 
				
			||||||
	{ "TeamInfo"   , &MessageIdTeamInfo    },
 | 
						{ "TeamInfo"   , &MessageIdTeamInfo    },
 | 
				
			||||||
	{ "TextMsg"    , &MessageIdTextMsg     },
 | 
						{ "TextMsg"    , &MessageIdTextMsg     },
 | 
				
			||||||
	{ nullptr      , 0                     }
 | 
						{ nullptr      , nullptr               }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
int AmxxCheckGame(const char *game)
 | 
					int AmxxCheckGame(const char *game)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (strcasecmp(game, "cstrike") == 0 ||
 | 
						if (strcasecmp(game, "cstrike") == 0 ||
 | 
				
			||||||
@@ -97,28 +74,6 @@ void OnAmxxAttach()
 | 
				
			|||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void *address = nullptr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (MainConfig->GetMemSig("CreateNamedEntity", &address) && address) // cs_create_entity()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		CS_CreateNamedEntity = reinterpret_cast<CreateNamedEntityFunc>(address);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (MainConfig->GetMemSig("FindEntityByString", &address) && address) // cs_find_ent_by_class()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		CS_UTIL_FindEntityByString = reinterpret_cast<UTIL_FindEntityByStringFunc>(address);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!CS_CreateNamedEntity)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		MF_Log("CREATE_NAMED_ENITTY is not available - native cs_create_entity() has been disabled");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!CS_UTIL_FindEntityByString)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		MF_Log("UTIL_FindEntByString is not available - native cs_find_ent_by_class() has been disabled");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	InitializeHacks();
 | 
						InitializeHacks();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -158,6 +158,7 @@
 | 
				
			|||||||
    <ClInclude Include="..\..\..\..\public\memtools\CDetour\detours.h" />
 | 
					    <ClInclude Include="..\..\..\..\public\memtools\CDetour\detours.h" />
 | 
				
			||||||
    <ClInclude Include="..\..\..\..\public\memtools\MemoryUtils.h" />
 | 
					    <ClInclude Include="..\..\..\..\public\memtools\MemoryUtils.h" />
 | 
				
			||||||
    <ClInclude Include="..\CstrikeDatas.h" />
 | 
					    <ClInclude Include="..\CstrikeDatas.h" />
 | 
				
			||||||
 | 
					    <ClInclude Include="..\CstrikeHacks.h" />
 | 
				
			||||||
    <ClInclude Include="..\CstrikePlayer.h" />
 | 
					    <ClInclude Include="..\CstrikePlayer.h" />
 | 
				
			||||||
    <ClInclude Include="..\moduleconfig.h" />
 | 
					    <ClInclude Include="..\moduleconfig.h" />
 | 
				
			||||||
    <ClInclude Include="..\..\..\..\public\sdk\amxxmodule.h" />
 | 
					    <ClInclude Include="..\..\..\..\public\sdk\amxxmodule.h" />
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -88,6 +88,9 @@
 | 
				
			|||||||
    <ClInclude Include="..\moduleconfig.h">
 | 
					    <ClInclude Include="..\moduleconfig.h">
 | 
				
			||||||
      <Filter>Module SDK</Filter>
 | 
					      <Filter>Module SDK</Filter>
 | 
				
			||||||
    </ClInclude>
 | 
					    </ClInclude>
 | 
				
			||||||
 | 
					    <ClInclude Include="..\CstrikeHacks.h">
 | 
				
			||||||
 | 
					      <Filter>Header Files</Filter>
 | 
				
			||||||
 | 
					    </ClInclude>
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <None Include="..\..\..\..\plugins\include\cstrike.inc">
 | 
					    <None Include="..\..\..\..\plugins\include\cstrike.inc">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user