Merge branch 'master' into csgo-hashmap

This commit is contained in:
Ruben Gonzalez
2017-10-27 18:57:28 -04:00
committed by GitHub
53 changed files with 1721 additions and 1251 deletions
+2 -2
View File
@@ -8,9 +8,9 @@ binary.compiler.cxxincludes += [
os.path.join(builder.sourcePath, 'public', 'jit'),
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.sources += [
+2 -2
View File
@@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'clientprefs.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.sources += [
+346 -346
View File
@@ -31,35 +31,35 @@
#include "extension.h"
#include "util_cstrike.h"
#include "RegNatives.h"
#include <iplayerinfo.h>
#if SOURCE_ENGINE == SE_CSGO
#include "itemdef-hash.h"
#include "RegNatives.h"
#include <iplayerinfo.h>
#if SOURCE_ENGINE == SE_CSGO
#include "itemdef-hash.h"
ClassnameMap g_mapClassToDefIdx;
ItemIndexMap g_mapDefIdxToClass;
WeaponIDMap g_mapWeaponIDToDefIdx;
#endif
#define REGISTER_ADDR(name, defaultret, code) \
void *addr; \
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
{ \
g_pSM->LogError(myself, "Failed to lookup %s signature.", name); \
return defaultret; \
} \
code; \
g_RegNatives.Register(pWrapper);
ItemIndexMap g_mapDefIdxToClass;
WeaponIDMap g_mapWeaponIDToDefIdx;
#endif
#define REGISTER_ADDR(name, defaultret, code) \
void *addr; \
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
{ \
g_pSM->LogError(myself, "Failed to lookup %s signature.", name); \
return defaultret; \
} \
code; \
g_RegNatives.Register(pWrapper);
#define GET_MEMSIG(name, defaultret) \
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
{ \
g_pSM->LogError(myself, "Failed to lookup %s signature.", name); \
return defaultret;\
}
#if SOURCE_ENGINE == SE_CSGO
}
#if SOURCE_ENGINE == SE_CSGO
// Get a CEconItemView for the m4
// Found in CCSPlayer::HandleCommand_Buy_Internal
// Linux a1 - CCSPlayer *pEntity, v5 - Player Team, a3 - ItemLoadoutSlot -1 use default loadoutslot:
@@ -70,16 +70,16 @@ WeaponIDMap g_mapWeaponIDToDefIdx;
// The function is CCSPlayerInventory::GetItemInLoadout(int, int)
// We can pass NULL view to the GetAttribute to use default loadoutslot.
// We only really care about m4a1/m4a4 as price differs between them
// thisPtrOffset = 9472/9492
CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot)
{
if (!pEntity)
return NULL;
static ICallWrapper *pWrapper = NULL;
static int thisPtrOffset = -1;
// thisPtrOffset = 9472/9492
CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot)
{
if (!pEntity)
return NULL;
static ICallWrapper *pWrapper = NULL;
static int thisPtrOffset = -1;
if (!pWrapper)
{
int offset = -1;
@@ -119,22 +119,22 @@ CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot)
pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, &ret, pass, 2);
g_RegNatives.Register(pWrapper);
}
}
int client = gamehelpers->EntityToBCompatRef(pEntity);
IPlayerInfo *playerinfo = playerhelpers->GetGamePlayer(client)->GetPlayerInfo();
if (!playerinfo)
return NULL;
int team = playerinfo->GetTeamIndex();
if (team != 2 && team != 3)
return NULL;
CEconItemView *ret;
}
}
int client = gamehelpers->EntityToBCompatRef(pEntity);
IPlayerInfo *playerinfo = playerhelpers->GetGamePlayer(client)->GetPlayerInfo();
if (!playerinfo)
return NULL;
int team = playerinfo->GetTeamIndex();
if (team != 2 && team != 3)
return NULL;
CEconItemView *ret;
unsigned char vstk[sizeof(void *) + sizeof(int) * 2];
unsigned char *vptr = vstk;
@@ -144,51 +144,51 @@ CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot)
vptr += sizeof(int);
*(int *)vptr = iSlot;
pWrapper->Execute(vstk, &ret);
return ret;
}
CCSWeaponData *GetCCSWeaponData(CEconItemView *view)
{
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetCCSWeaponData", NULL,
PassInfo retpass; \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(CCSWeaponData *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, &retpass, NULL, 0))
}
unsigned char vstk[sizeof(CEconItemView *)];
unsigned char *vptr = vstk;
*(CEconItemView **)vptr = view;
CCSWeaponData *pWpnData = NULL;
pWrapper->Execute(vstk, &pWpnData);
return pWpnData;
}
CEconItemSchema *GetItemSchema()
{
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetItemSchema", NULL,
PassInfo retpass; \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(void *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, NULL, 0))
}
pWrapper->Execute(vstk, &ret);
return ret;
}
CCSWeaponData *GetCCSWeaponData(CEconItemView *view)
{
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetCCSWeaponData", NULL,
PassInfo retpass; \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(CCSWeaponData *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, &retpass, NULL, 0))
}
unsigned char vstk[sizeof(CEconItemView *)];
unsigned char *vptr = vstk;
*(CEconItemView **)vptr = view;
CCSWeaponData *pWpnData = NULL;
pWrapper->Execute(vstk, &pWpnData);
return pWpnData;
}
CEconItemSchema *GetItemSchema()
{
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetItemSchema", NULL,
PassInfo retpass; \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(void *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, NULL, 0))
}
void *pSchema = NULL;
pWrapper->Execute(NULL, &pSchema);
@@ -197,28 +197,28 @@ CEconItemSchema *GetItemSchema()
return (CEconItemSchema *)((intptr_t)pSchema + 4);
#else
return (CEconItemSchema *)pSchema;
#endif
}
CEconItemDefinition *GetItemDefintionByName(const char *classname)
{
CEconItemSchema *pSchema = GetItemSchema();
if (!pSchema)
return NULL;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
#endif
}
CEconItemDefinition *GetItemDefintionByName(const char *classname)
{
CEconItemSchema *pSchema = GetItemSchema();
if (!pSchema)
return NULL;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
int offset = -1;
if (!g_pGameConf->GetOffset("GetItemDefintionByName", &offset) || offset == -1)
{
smutils->LogError(myself, "Failed to get GetItemDefintionByName offset.");
return NULL;
}
}
PassInfo pass[1];
PassInfo ret;
pass[0].flags = PASSFLAG_BYVAL;
@@ -229,11 +229,11 @@ CEconItemDefinition *GetItemDefintionByName(const char *classname)
ret.type = PassType_Basic;
ret.size = sizeof(CEconItemDefinition *);
pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, &ret, pass, 1);
g_RegNatives.Register(pWrapper);
}
pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, &ret, pass, 1);
g_RegNatives.Register(pWrapper);
}
unsigned char vstk[sizeof(void *) + sizeof(const char *)];
unsigned char *vptr = vstk;
@@ -244,16 +244,16 @@ CEconItemDefinition *GetItemDefintionByName(const char *classname)
CEconItemDefinition *pItemDef = NULL;
pWrapper->Execute(vstk, &pItemDef);
return pItemDef;
}
void CreateHashMaps()
{
CEconItemSchema *pSchema = GetItemSchema();
if (!pSchema)
return;
return pItemDef;
}
void CreateHashMaps()
{
CEconItemSchema *pSchema = GetItemSchema();
if (!pSchema)
return;
static const char *pPriceKey = NULL;
if (!pPriceKey)
@@ -263,18 +263,18 @@ void CreateHashMaps()
{
return;
}
}
static int iHashMapOffset = -1;
if (iHashMapOffset == -1)
{
}
static int iHashMapOffset = -1;
if (iHashMapOffset == -1)
{
if (!g_pGameConf->GetOffset("ItemDefHashOffset", &iHashMapOffset) || iHashMapOffset == -1)
{
return;
}
}
}
}
g_mapClassToDefIdx.init();
g_mapDefIdxToClass.init();
g_mapWeaponIDToDefIdx.init();
@@ -314,112 +314,112 @@ void CreateHashMaps()
g_mapWeaponIDToDefIdx.add(t, iWeaponID, ItemDefHashValue(iLoadoutslot, price, iWeaponID, iItemDefIdx, classname));
}
}
}
}
void ClearHashMaps()
{
g_mapClassToDefIdx.clear();
g_mapDefIdxToClass.clear();
g_mapWeaponIDToDefIdx.clear();
}
SMCSWeapon GetWeaponIdFromDefIdx(uint16_t iDefIdx)
{
//DEAR GOD THIS IS HIDEOUS
//None in the middle are weapons that dont exist.
//If they are added and use the same idx they should be changed to their respective ones
static SMCSWeapon weaponIDMap[SMCSWeapon_MAXWEAPONIDS] =
{
SMCSWeapon_NONE, SMCSWeapon_DEAGLE, SMCSWeapon_ELITE, SMCSWeapon_FIVESEVEN,
SMCSWeapon_GLOCK, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_AK47,
SMCSWeapon_AUG, SMCSWeapon_AWP, SMCSWeapon_FAMAS, SMCSWeapon_G3SG1,
SMCSWeapon_NONE, SMCSWeapon_GALILAR, SMCSWeapon_M249, SMCSWeapon_NONE,
SMCSWeapon_M4A1, SMCSWeapon_MAC10, SMCSWeapon_NONE, SMCSWeapon_P90,
SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE,
SMCSWeapon_UMP45, SMCSWeapon_XM1014, SMCSWeapon_BIZON, SMCSWeapon_MAG7,
SMCSWeapon_NEGEV, SMCSWeapon_SAWEDOFF, SMCSWeapon_TEC9, SMCSWeapon_TASER,
SMCSWeapon_HKP2000, SMCSWeapon_MP7, SMCSWeapon_MP9, SMCSWeapon_NOVA,
SMCSWeapon_P250, SMCSWeapon_NONE, SMCSWeapon_SCAR20, SMCSWeapon_SG556,
SMCSWeapon_SSG08, SMCSWeapon_KNIFE_GG, SMCSWeapon_KNIFE, SMCSWeapon_FLASHBANG,
SMCSWeapon_HEGRENADE, SMCSWeapon_SMOKEGRENADE, SMCSWeapon_MOLOTOV, SMCSWeapon_DECOY,
SMCSWeapon_INCGRENADE, SMCSWeapon_C4, SMCSWeapon_KEVLAR, SMCSWeapon_ASSAULTSUIT,
SMCSWeapon_HEAVYASSAULTSUIT, SMCSWeapon_NONE, SMCSWeapon_NIGHTVISION, SMCSWeapon_DEFUSER
};
if (iDefIdx >= SMCSWeapon_MAXWEAPONIDS)
return (SMCSWeapon)iDefIdx;
else
return weaponIDMap[iDefIdx];
}
ItemDefHashValue *GetHashValueFromWeapon(const char *szWeapon)
{
char tempWeapon[MAX_WEAPON_NAME_LENGTH];
Q_strncpy(tempWeapon, szWeapon, sizeof(tempWeapon));
Q_strlower(tempWeapon);
if (strstr(tempWeapon, "weapon_") == NULL && strstr(tempWeapon, "item_") == NULL)
{
}
}
void ClearHashMaps()
{
g_mapClassToDefIdx.clear();
g_mapDefIdxToClass.clear();
g_mapWeaponIDToDefIdx.clear();
}
SMCSWeapon GetWeaponIdFromDefIdx(uint16_t iDefIdx)
{
//DEAR GOD THIS IS HIDEOUS
//None in the middle are weapons that dont exist.
//If they are added and use the same idx they should be changed to their respective ones
static SMCSWeapon weaponIDMap[SMCSWeapon_MAXWEAPONIDS] =
{
SMCSWeapon_NONE, SMCSWeapon_DEAGLE, SMCSWeapon_ELITE, SMCSWeapon_FIVESEVEN,
SMCSWeapon_GLOCK, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_AK47,
SMCSWeapon_AUG, SMCSWeapon_AWP, SMCSWeapon_FAMAS, SMCSWeapon_G3SG1,
SMCSWeapon_NONE, SMCSWeapon_GALILAR, SMCSWeapon_M249, SMCSWeapon_NONE,
SMCSWeapon_M4A1, SMCSWeapon_MAC10, SMCSWeapon_NONE, SMCSWeapon_P90,
SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE,
SMCSWeapon_UMP45, SMCSWeapon_XM1014, SMCSWeapon_BIZON, SMCSWeapon_MAG7,
SMCSWeapon_NEGEV, SMCSWeapon_SAWEDOFF, SMCSWeapon_TEC9, SMCSWeapon_TASER,
SMCSWeapon_HKP2000, SMCSWeapon_MP7, SMCSWeapon_MP9, SMCSWeapon_NOVA,
SMCSWeapon_P250, SMCSWeapon_NONE, SMCSWeapon_SCAR20, SMCSWeapon_SG556,
SMCSWeapon_SSG08, SMCSWeapon_KNIFE_GG, SMCSWeapon_KNIFE, SMCSWeapon_FLASHBANG,
SMCSWeapon_HEGRENADE, SMCSWeapon_SMOKEGRENADE, SMCSWeapon_MOLOTOV, SMCSWeapon_DECOY,
SMCSWeapon_INCGRENADE, SMCSWeapon_C4, SMCSWeapon_KEVLAR, SMCSWeapon_ASSAULTSUIT,
SMCSWeapon_HEAVYASSAULTSUIT, SMCSWeapon_NONE, SMCSWeapon_NIGHTVISION, SMCSWeapon_DEFUSER
};
if (iDefIdx >= SMCSWeapon_MAXWEAPONIDS)
return (SMCSWeapon)iDefIdx;
else
return weaponIDMap[iDefIdx];
}
ItemDefHashValue *GetHashValueFromWeapon(const char *szWeapon)
{
char tempWeapon[MAX_WEAPON_NAME_LENGTH];
Q_strncpy(tempWeapon, szWeapon, sizeof(tempWeapon));
Q_strlower(tempWeapon);
if (strstr(tempWeapon, "weapon_") == NULL && strstr(tempWeapon, "item_") == NULL)
{
static const char *szClassPrefixs[] = { "weapon_", "item_" };
for (unsigned int i = 0; i < SM_ARRAYSIZE(szClassPrefixs); i++)
{
char classname[MAX_WEAPON_NAME_LENGTH];
Q_snprintf(classname, sizeof(classname), "%s%s", szClassPrefixs[i], tempWeapon);
ClassnameMap::Result res = g_mapClassToDefIdx.find(classname);
if (res.found())
ClassnameMap::Result res = g_mapClassToDefIdx.find(classname);
if (res.found())
return &res->value;
}
return NULL;
}
ClassnameMap::Result res = g_mapClassToDefIdx.find(tempWeapon);
if (res.found())
return &res->value;
return NULL;
}
#endif
#if SOURCE_ENGINE != SE_CSGO
void *GetWeaponInfo(int weaponID)
{
void *info;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetWeaponInfo", NULL,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(int); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(void *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(int)];
unsigned char *vptr = vstk;
*(int *)vptr = weaponID;
pWrapper->Execute(vstk, &info);
return info;
}
#endif
const char *GetWeaponNameFromClassname(const char *weapon)
{
}
return NULL;
}
ClassnameMap::Result res = g_mapClassToDefIdx.find(tempWeapon);
if (res.found())
return &res->value;
return NULL;
}
#endif
#if SOURCE_ENGINE != SE_CSGO
void *GetWeaponInfo(int weaponID)
{
void *info;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetWeaponInfo", NULL,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(int); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(void *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(int)];
unsigned char *vptr = vstk;
*(int *)vptr = weaponID;
pWrapper->Execute(vstk, &info);
return info;
}
#endif
const char *GetWeaponNameFromClassname(const char *weapon)
{
char *szTemp = strstr((char *)weapon, "_");
if (!szTemp)
@@ -429,103 +429,103 @@ const char *GetWeaponNameFromClassname(const char *weapon)
else
{
return (const char *)((intptr_t)szTemp + 1);
}
}
const char *GetTranslatedWeaponAlias(const char *weapon)
{
#if SOURCE_ENGINE != SE_CSGO
const char *alias = NULL;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetTranslatedWeaponAlias", weapon,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(const char *); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(const char *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
pWrapper->Execute(vstk, &alias);
return alias;
#else //this should work for both games maybe replace both?
static const char *szAliases[] =
{
"cv47", "ak47",
"magnum", "awp",
"d3au1", "g3sg1",
"clarion", "famas",
"bullpup", "aug",
"9x19mm", "glock",
"nighthawk", "deagle",
"elites", "elite",
"fn57", "fiveseven",
"autoshotgun", "xm1014",
"c90", "p90",
"vest", "kevlar",
"vesthelm", "assaultsuit",
"nvgs", "nightvision"
};
for (size_t i = 0; i < SM_ARRAYSIZE(szAliases) / 2; i++)
{
if (Q_stristr(GetWeaponNameFromClassname(weapon), szAliases[i * 2]) != 0)
return szAliases[i * 2 + 1];
}
return GetWeaponNameFromClassname(weapon);
#endif
}
int AliasToWeaponID(const char *weapon)
{
#if SOURCE_ENGINE != SE_CSGO
int weaponID = 0;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("AliasToWeaponID", 0,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(const char *); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(int); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
pWrapper->Execute(vstk, &weaponID);
return weaponID;
#else
ItemDefHashValue *pHashValue = GetHashValueFromWeapon(weapon);
if (pHashValue)
return pHashValue->m_iWeaponID;
return 0;
#endif
}
}
const char *GetTranslatedWeaponAlias(const char *weapon)
{
#if SOURCE_ENGINE != SE_CSGO
const char *alias = NULL;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetTranslatedWeaponAlias", weapon,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(const char *); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(const char *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
pWrapper->Execute(vstk, &alias);
return alias;
#else //this should work for both games maybe replace both?
static const char *szAliases[] =
{
"cv47", "ak47",
"magnum", "awp",
"d3au1", "g3sg1",
"clarion", "famas",
"bullpup", "aug",
"9x19mm", "glock",
"nighthawk", "deagle",
"elites", "elite",
"fn57", "fiveseven",
"autoshotgun", "xm1014",
"c90", "p90",
"vest", "kevlar",
"vesthelm", "assaultsuit",
"nvgs", "nightvision"
};
for (size_t i = 0; i < SM_ARRAYSIZE(szAliases) / 2; i++)
{
if (Q_stristr(GetWeaponNameFromClassname(weapon), szAliases[i * 2]) != 0)
return szAliases[i * 2 + 1];
}
return GetWeaponNameFromClassname(weapon);
#endif
}
int AliasToWeaponID(const char *weapon)
{
#if SOURCE_ENGINE != SE_CSGO
int weaponID = 0;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("AliasToWeaponID", 0,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(const char *); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(int); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
pWrapper->Execute(vstk, &weaponID);
return weaponID;
#else
ItemDefHashValue *pHashValue = GetHashValueFromWeapon(weapon);
if (pHashValue)
return pHashValue->m_iWeaponID;
return 0;
#endif
}
const char *WeaponIDToAlias(int weaponID)
@@ -565,19 +565,19 @@ const char *WeaponIDToAlias(int weaponID)
return NULL;
#endif
}
bool IsValidWeaponID(int id)
{
if (id <= (int)SMCSWeapon_NONE)
return false;
#if SOURCE_ENGINE == SE_CSGO
WeaponIDMap::Result res = g_mapWeaponIDToDefIdx.find((SMCSWeapon)id);
if (!res.found())
return false;
#else
else if (id > SMCSWeapon_NIGHTVISION || !GetWeaponInfo(id))
return false;
#endif
return true;
}
}
bool IsValidWeaponID(int id)
{
if (id <= (int)SMCSWeapon_NONE)
return false;
#if SOURCE_ENGINE == SE_CSGO
WeaponIDMap::Result res = g_mapWeaponIDToDefIdx.find((SMCSWeapon)id);
if (!res.found())
return false;
#else
else if (id > SMCSWeapon_NIGHTVISION || !GetWeaponInfo(id))
return false;
#endif
return true;
}
+5 -5
View File
@@ -1,21 +1,21 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python :
import os
libcurl = builder.RunScript('curl-src/lib/AMBuilder')
libcurl = builder.Build('curl-src/lib/AMBuilder')
binary = SM.ExtLibrary(builder, 'webternet.ext')
binary.compiler.includes += [
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include')
]
binary.compiler.defines += ['CURL_STATICLIB']
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.compiler.postlink += [libcurl.binary]
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
binary.compiler.postlink += ['-lrt']
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
binary.compiler.postlink += ['ws2_32.lib']
binary.sources += [
+5 -5
View File
@@ -3,27 +3,27 @@ import os, platform
builder.SetBuildFolder('libcurl')
binary = builder.compiler.StaticLibrary('curl')
binary = SM.StaticLibrary(builder, 'curl')
binary.compiler.includes += [
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'lib'),
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include')
]
if builder.target_platform == 'mac':
if builder.target.platform == 'mac':
mac_version, ignore, ignore = platform.mac_ver()
mac_tuple = mac_version.split('.')
if int(mac_tuple[0]) >= 10 and int(mac_tuple[1]) >= 9:
binary.compiler.defines += ['BUILTIN_STRLCAT']
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
binary.compiler.defines += [
'BUILDING_LIBCURL',
'CURL_STATICLIB',
'CURL_DISABLE_LDAP',
]
elif builder.target_platform == 'linux':
elif builder.target.platform == 'linux':
binary.compiler.defines += ['_GNU_SOURCE']
if binary.compiler.vendor == 'clang':
if binary.compiler.family == 'clang':
# https://llvm.org/bugs/show_bug.cgi?id=16428
binary.compiler.cflags += ['-Wno-attributes']
+3 -3
View File
@@ -2,11 +2,11 @@
import os
binary = SM.ExtLibrary(builder, 'geoip.ext')
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
if builder.target_platform == 'windows':
if builder.target.platform == 'windows':
binary.compiler.postlink += ['wsock32.lib']
binary.sources += [
+6 -6
View File
@@ -7,21 +7,21 @@ if SM.mysql_root:
os.path.join(SM.mysql_root, 'include'),
os.path.join(SM.mms_root, 'core', 'sourcehook')
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
if builder.target_platform == 'linux' or builder.target_platform == 'mac':
if builder.target.platform == 'linux' or builder.target.platform == 'mac':
binary.compiler.postlink += [
os.path.join(SM.mysql_root, 'lib', 'libmysqlclient_r.a'),
'-lz',
'-lpthread',
'-lm',
]
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
binary.compiler.postlink += ['-lrt']
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
binary.compiler.postlink += [
os.path.join(SM.mysql_root, 'lib', 'opt', 'mysqlclient.lib'),
os.path.join(SM.mysql_root, 'lib', 'opt', 'zlib.lib'),
@@ -38,7 +38,7 @@ if SM.mysql_root:
'extension.cpp'
]
if binary.compiler.vendor == 'msvc' and binary.compiler.version >= 1900:
if binary.compiler.family == 'msvc' and binary.compiler.version >= 1900:
binary.sources += [ 'msvc15hack.c' ]
binary.compiler.linkflags += ['legacy_stdio_definitions.lib', 'legacy_stdio_wide_specifiers.lib']
+5 -5
View File
@@ -5,16 +5,16 @@ binary = SM.ExtLibrary(builder, 'regex.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_linux', 'libpcre.a')
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_win', 'pcre.lib')
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_darwin', 'libpcre.a')
binary.compiler.postlink += [binary.Dep(path)]
+1 -1
View File
@@ -17,7 +17,7 @@ for sdk_name in SM.sdks:
binary.compiler.cxxincludes += [
os.path.join(sdk.path, 'game', 'shared')
]
if binary.compiler.cxx.behavior == 'gcc':
if binary.compiler.behavior == 'gcc':
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
SM.extensions += builder.Add(project)
+1 -1
View File
@@ -957,7 +957,7 @@ bool SDKHooks::Hook_CanBeAutobalanced()
// Only update our new ret if different from original
// (so if multiple plugins returning different answers,
// the one(s) that changed it win)
if (res != origRet)
if ((bool)res != origRet)
newRet = !origRet;
}
+1 -1
View File
@@ -42,7 +42,7 @@ for sdk_name in SM.sdks:
if sdk.name != 'episode1':
binary.compiler.defines += ['HOOKING_ENABLED']
if binary.compiler.cxx.behavior == 'gcc':
if binary.compiler.behavior == 'gcc':
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
SM.extensions += builder.Add(project)
+10
View File
@@ -191,6 +191,11 @@ void CHookManager::PlayerRunCmdHook(int client, bool post)
void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper)
{
if (!ucmd)
{
RETURN_META(MRES_IGNORED);
}
if (m_usercmdsFwd->GetFunctionCount() == 0)
{
RETURN_META(MRES_IGNORED);
@@ -254,6 +259,11 @@ void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper)
void CHookManager::PlayerRunCmdPost(CUserCmd *ucmd, IMoveHelper *moveHelper)
{
if (!ucmd)
{
RETURN_META(MRES_IGNORED);
}
if (m_usercmdsPostFwd->GetFunctionCount() == 0)
{
RETURN_META(MRES_IGNORED);
+9
View File
@@ -929,7 +929,16 @@ static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params)
char *classname;
pContext->LocalToString(params[1], &classname);
#if SOURCE_ENGINE != SE_CSGO
CBaseEntity *pEntity = (CBaseEntity *)servertools->CreateEntityByName(classname);
#else
CBaseEntity *pEntity = (CBaseEntity *)servertools->CreateItemEntityByName(classname);
if(!pEntity)
{
pEntity = (CBaseEntity *)servertools->CreateEntityByName(classname);
}
#endif
return gamehelpers->EntityToBCompatRef(pEntity);
}
#else
+3 -3
View File
@@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'dbi.sqlite.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.compiler.defines += [
@@ -16,7 +16,7 @@ binary.compiler.defines += [
'SQLITE_USE_URI',
'SQLITE_ALLOW_URI_AUTHORITY',
]
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
binary.compiler.postlink += ['-ldl', '-lpthread']
binary.sources += [
+3 -1
View File
@@ -143,6 +143,7 @@ PlayerConditionsMgr::PlayerConditionsMgr()
m_CondOffset[m_nPlayerCondEx] = 32;
m_CondOffset[m_nPlayerCondEx2] = 64;
m_CondOffset[m_nPlayerCondEx3] = 96;
m_CondOffset[m_nPlayerCondEx4] = 128;
}
bool PlayerConditionsMgr::Init()
@@ -153,7 +154,8 @@ bool PlayerConditionsMgr::Init()
&& SetupProp<_condition_bits>("_condition_bits")
&& SetupProp<m_nPlayerCondEx>("m_nPlayerCondEx")
&& SetupProp<m_nPlayerCondEx2>("m_nPlayerCondEx2")
&& SetupProp<m_nPlayerCondEx3>("m_nPlayerCondEx3");
&& SetupProp<m_nPlayerCondEx3>("m_nPlayerCondEx3")
&& SetupProp<m_nPlayerCondEx4>("m_nPlayerCondEx4");
if (!bFoundProps)
return false;
+1
View File
@@ -52,6 +52,7 @@ public:
m_nPlayerCondEx,
m_nPlayerCondEx2,
m_nPlayerCondEx3,
m_nPlayerCondEx4,
CondVar_Count
};
+10 -5
View File
@@ -45,7 +45,7 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
if(!pWrapper)
{
REGISTER_NATIVE_ADDR("MakeBleed",
PassInfo pass[5]; \
PassInfo pass[6]; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].size = sizeof(CBaseEntity *); \
pass[0].type = PassType_Basic; \
@@ -61,7 +61,10 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
pass[4].flags = PASSFLAG_BYVAL; \
pass[4].size = sizeof(bool); \
pass[4].type = PassType_Basic; \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 5))
pass[5].flags = PASSFLAG_BYVAL; \
pass[5].size = sizeof(int); \
pass[5].type = PassType_Basic; \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 6))
}
CBaseEntity *pEntity;
@@ -78,7 +81,7 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float) + sizeof(int) + sizeof(bool)];
unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float) + sizeof(int) + sizeof(bool) + sizeof(int)];
unsigned char *vptr = vstk;
*(void **)vptr = obj;
@@ -89,9 +92,11 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
vptr += sizeof(CBaseEntity *);
*(float *)vptr = sp_ctof(params[3]);
vptr += sizeof(float);
*(int *)vptr = 4;
*(int *)vptr = 4; // Damage amount
vptr += sizeof(int);
*(bool *)vptr = false;
*(bool *)vptr = false; // Permanent
vptr += sizeof(bool);
*(int *)vptr = 34; // Custom Damage type (bleeding)
pWrapper->Execute(vstk, NULL);
+2 -2
View File
@@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'topmenus.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.sources += [
+2 -2
View File
@@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'updater.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.sources += [