Unverified Commit d4b3e3c7 authored by s1lent's avatar s1lent

GCC support and fixed warnings

parent 0eed4cd8
......@@ -14,6 +14,7 @@ import gradlecpp.VelocityUtils
apply plugin: 'cpp'
apply plugin: 'windows-resources'
apply plugin: IccCompilerPlugin
apply plugin: GccCompilerPlugin
List<Task> getRcCompileTasks(NativeBinarySpec binary) {
def linkTask = GradleCppUtils.getLinkTask(binary)
......@@ -36,6 +37,7 @@ void postEvaluate(NativeBinarySpec b) {
}
void setupToolchain(NativeBinarySpec b) {
boolean useGcc = project.hasProperty("useGcc")
ToolchainConfig cfg = rootProject.createToolchainConfig(b)
cfg.projectInclude(project, '', '/src', '/common', '/src/mods', '/src/natives', '/include', '/include/metamod', '/include/cssdk/common', '/include/cssdk/dlls', '/include/cssdk/engine', '/include/cssdk/game_shared', '/include/cssdk/pm_shared', '/include/cssdk/public')
cfg.singleDefines('HAVE_STRONG_TYPEDEF');
......@@ -49,11 +51,13 @@ void setupToolchain(NativeBinarySpec b) {
cfg.compilerOptions.args '/Ob2', '/Oi', '/GF', '/GR-', '/GS-'
cfg.singleDefines('_CRT_SECURE_NO_WARNINGS')
} else if (cfg instanceof GccToolchainConfig) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'reapi_pch'
)
cfg.compilerOptions.languageStandard = 'c++0x'
if (!useGcc) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'reapi_pch'
)
}
cfg.compilerOptions.languageStandard = 'c++11'
cfg.defines([
'_stricmp': 'strcasecmp',
'_strnicmp': 'strncasecmp',
......@@ -61,7 +65,13 @@ void setupToolchain(NativeBinarySpec b) {
'_snprintf': 'snprintf'
])
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-msse2', '-fomit-frame-pointer', '-inline-forceinline', '-fvisibility=default', '-fvisibility-inlines-hidden', '-fno-rtti', '-g0', '-s', '-fno-exceptions', '-no-ansi-alias'
if (useGcc) {
cfg.compilerOptions.args '-fno-strict-aliasing', '-finline-functions'
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-inline-forceinline', '-no-ansi-alias'
}
cfg.compilerOptions.args '-Wall', '-Wno-unknown-pragmas', '-msse2', '-fomit-frame-pointer', '-fvisibility=default', '-fvisibility-inlines-hidden', '-fno-rtti', '-g0', '-s', '-fno-exceptions'
}
ToolchainConfigUtils.apply(project, cfg, b)
......@@ -84,9 +94,11 @@ model {
}
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
visualCpp(VisualCpp)
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}
......
......@@ -32,11 +32,9 @@
#pragma once
#endif
#include "osconfig.h"
#include "mathlib.h"
// Has no references on server side.
#define NOXREF
// Function body is not implemented.
......@@ -44,6 +42,26 @@
// Function is not tested at all.
#define UNTESTED
#define CONST_INTEGER_AS_STRING(x) #x //Wraps the integer in quotes, allowing us to form constant strings with it
#define __HACK_LINE_AS_STRING__(x) CONST_INTEGER_AS_STRING(x) //__LINE__ can only be converted to an actual number by going through this, otherwise the output is literally "__LINE__"
#define __LINE__AS_STRING __HACK_LINE_AS_STRING__(__LINE__) //Gives you the line number in constant string form
#if defined _MSC_VER || defined __INTEL_COMPILER
#define NOXREFCHECK int __retAddr; __asm { __asm mov eax, [ebp + 4] __asm mov __retAddr, eax }; Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr)
#else
// For EBP based stack (older gcc) (uncomment version apropriate for your compiler)
//#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 4(%%ebp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr);
// For ESP based stack (newer gcc) (uncomment version apropriate for your compiler)
#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 16(%%esp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr);
#endif
#define BIT(n) (1<<(n))
// From engine/server.h
typedef enum sv_delta_s
{
sv_packet_nodelta,
sv_packet_delta,
} sv_delta_t;
#endif // MAINTYPES_H
......@@ -8,78 +8,61 @@ enum fwdstate
FSTATE_STOPPED
};
template <typename T = void>
class CAmxxHook
class CAmxxHookBase
{
public:
~CAmxxHook()
~CAmxxHookBase()
{
if (m_index != -1) {
g_amxxapi.UnregisterSPForward(m_index);
m_index = -1;
}
delete m_uniqueData;
}
CAmxxHook(AMX *amx, const char *funcname, int index, T *data = nullptr) :
CAmxxHookBase(AMX *amx, const char *funcname, int index) :
m_index(index),
m_state(FSTATE_ENABLED),
m_amx(amx),
m_uniqueData(data)
m_amx(amx)
{
Q_strlcpy(m_CallbackName, funcname);
};
}
T *GetUnique() const;
int GetIndex() const;
fwdstate GetState() const;
AMX *GetAmx() const;
const char *GetCallbackName() const;
int GetIndex() const { return m_index; }
fwdstate GetState() const { return m_state; }
AMX *GetAmx() const { return m_amx; }
const char *GetCallbackName() const { return m_CallbackName; }
void SetState(fwdstate st);
void SetState(fwdstate st) { m_state = st; }
private:
T *m_uniqueData;
int m_index;
char m_CallbackName[64];
fwdstate m_state;
AMX *m_amx;
};
// Inlines
template <typename T>
inline T *CAmxxHook<T>::GetUnique() const
{
return m_uniqueData;
}
template <typename T>
inline AMX *CAmxxHook<T>::GetAmx() const
class CAmxxHookUnique: public CAmxxHookBase
{
return m_amx;
}
public:
~CAmxxHookUnique()
{
if (m_uniqueData)
{
delete m_uniqueData;
m_uniqueData = nullptr;
}
}
template <typename T>
inline const char *CAmxxHook<T>::GetCallbackName() const
{
return m_CallbackName;
}
CAmxxHookUnique(AMX *amx, const char *funcname, int index, T *data = nullptr) :
CAmxxHookBase(amx, funcname, index),
m_uniqueData(data)
{
template <typename T>
inline int CAmxxHook<T>::GetIndex() const
{
return m_index;
}
}
template <typename T>
inline fwdstate CAmxxHook<T>::GetState() const
{
return m_state;
}
T *GetUnique() const { return m_uniqueData; }
template <typename T>
inline void CAmxxHook<T>::SetState(fwdstate st)
{
m_state = st;
}
private:
T *m_uniqueData;
};
......@@ -122,12 +122,12 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
{
if (!pFunctionTable)
{
ALERT(at_logged, __FUNCTION__ " called with null pFunctionTable");
ALERT(at_logged, "GetEntityAPI2 called with null pFunctionTable");
return FALSE;
}
else if (*interfaceVersion != INTERFACE_VERSION)
{
ALERT(at_logged, __FUNCTION__ " version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION);
ALERT(at_logged, "GetEntityAPI2 version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION);
//! Tell metamod what version we had, so it can figure out who is out of date.
*interfaceVersion = INTERFACE_VERSION;
......@@ -143,12 +143,12 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
{
if (!pFunctionTable)
{
ALERT(at_logged, __FUNCTION__ " called with null pFunctionTable");
ALERT(at_logged, "GetEntityAPI2_Post called with null pFunctionTable");
return FALSE;
}
else if (*interfaceVersion != INTERFACE_VERSION)
{
ALERT(at_logged, __FUNCTION__ " version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION);
ALERT(at_logged, "GetEntityAPI2_Post version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION);
//! Tell metamod what version we had, so it can figure out who is out of date.
*interfaceVersion = INTERFACE_VERSION;
......
......@@ -176,12 +176,12 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
{
if (!pengfuncsFromEngine)
{
ALERT(at_logged, __FUNCTION__ " called with null pengfuncsFromEngine");
ALERT(at_logged, "GetEngineFunctions_Post called with null pengfuncsFromEngine");
return FALSE;
}
else if (*interfaceVersion != ENGINE_INTERFACE_VERSION)
{
ALERT(at_logged, __FUNCTION__ " version mismatch; requested=%d ours=%d", *interfaceVersion, ENGINE_INTERFACE_VERSION);
ALERT(at_logged, "GetEngineFunctions_Post version mismatch; requested=%d ours=%d", *interfaceVersion, ENGINE_INTERFACE_VERSION);
// Tell metamod what version we had, so it can figure out who is out of date.
*interfaceVersion = ENGINE_INTERFACE_VERSION;
return FALSE;
......
......@@ -61,7 +61,7 @@ bool CEntityCallback::SetThink(AMX *amx, CBaseEntity *pEntity, const char *pszCa
return false;
}
m_callbacks.push_back(new CAmxxHook<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_Think)));
m_callbacks.push_back(new CAmxxHookUnique<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_Think)));
pEntity->SetThink(&CBaseEntity::SUB_Think);
return true;
}
......@@ -82,7 +82,7 @@ bool CEntityCallback::SetTouch(AMX *amx, CBaseEntity *pEntity, const char *pszCa
return false;
}
m_callbacks.push_back(new CAmxxHook<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_Touch)));
m_callbacks.push_back(new CAmxxHookUnique<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_Touch)));
pEntity->SetTouch(&CBaseEntity::SUB_Touch);
return true;
}
......@@ -103,7 +103,7 @@ bool CEntityCallback::SetUse(AMX *amx, CBaseEntity *pEntity, const char *pszCall
return false;
}
m_callbacks.push_back(new CAmxxHook<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_Use)));
m_callbacks.push_back(new CAmxxHookUnique<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_Use)));
pEntity->SetUse(&CBaseEntity::SUB_Use);
return true;
}
......@@ -124,7 +124,7 @@ bool CEntityCallback::SetBlocked(AMX *amx, CBaseEntity *pEntity, const char *psz
return false;
}
m_callbacks.push_back(new CAmxxHook<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_Blocked)));
m_callbacks.push_back(new CAmxxHookUnique<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_Blocked)));
pEntity->SetBlocked(&CBaseEntity::SUB_Blocked);
return true;
}
......@@ -145,7 +145,7 @@ bool CEntityCallback::SetMoveDone(AMX *amx, CBaseEntity *pEntity, const char *ps
return false;
}
m_callbacks.push_back(new CAmxxHook<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_MoveDone)));
m_callbacks.push_back(new CAmxxHookUnique<eCallback_t>(amx, pszCallback, fwdid, new eCallback_t(pEntity, pParams, iParamsLen, CType_MoveDone)));
// TODO: Make sure that the entity actually inherited from CBaseToggle
((CBaseToggle *)pEntity)->SetMoveDone(&CBaseToggle::SUB_MoveDone);
......
......@@ -72,7 +72,7 @@ private:
size_t m_iParamLen;
};
std::vector<CAmxxHook<eCallback_t> *> m_callbacks;
std::vector<CAmxxHookUnique<eCallback_t> *> m_callbacks;
};
extern CEntityCallback g_entCallback;
......@@ -130,7 +130,9 @@ struct hookctx_t
tempstrings_used++;
return ptr;
}
return "<reapi error>";
static char fatalErr[] = "<reapi error>";
return fatalErr;
}
void clear_temp_strings() const
......
......@@ -71,7 +71,7 @@ struct regfunc
int regfunc::current_cell = 1;
#define ENG(h,...) { {}, {}, #h, "ReHLDS", [](){ return api_cfg.hasReHLDS(); }, ((!(RH_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RH_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RehldsHookchains->##h##()->registerHook(&##h); }, [](){ g_RehldsHookchains->##h##()->unregisterHook(&##h); }}
#define ENG(h,...) { {}, {}, #h, "ReHLDS", [](){ return api_cfg.hasReHLDS(); }, ((!(RH_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RH_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RehldsHookchains->h()->registerHook(&h); }, [](){ g_RehldsHookchains->h()->unregisterHook(&h); }}
hook_t hooklist_engine[] = {
ENG(SV_StartSound),
ENG(SV_DropClient),
......@@ -80,7 +80,7 @@ hook_t hooklist_engine[] = {
ENG(SV_WriteFullClientUpdate, _AMXX)
};
#define DLL(h) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h) : regfunc(#h), [](){ g_ReGameHookchains->##h##()->registerHook(&##h); }, [](){ g_ReGameHookchains->##h##()->unregisterHook(&##h); }}
#define DLL(h) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h) : regfunc(#h), [](){ g_ReGameHookchains->h()->registerHook(&h); }, [](){ g_ReGameHookchains->h()->unregisterHook(&h); }}
hook_t hooklist_gamedll[] = {
DLL(GetForceCamera),
DLL(PlayerBlind),
......@@ -196,7 +196,7 @@ hook_t hooklist_weaponbox[] = {
DLL(CWeaponBox_SetModel),
};
#define RCHECK(h,...) { {}, {}, #h, "ReChecker", [](){ return api_cfg.hasRechecker(); }, ((!(RC_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RC_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RecheckerHookchains->##h##()->registerHook(&##h); }, [](){ g_RecheckerHookchains->##h##()->unregisterHook(&##h); }}
#define RCHECK(h,...) { {}, {}, #h, "ReChecker", [](){ return api_cfg.hasRechecker(); }, ((!(RC_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RC_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RecheckerHookchains->h()->registerHook(&h); }, [](){ g_RecheckerHookchains->h()->unregisterHook(&h); }}
hook_t hooklist_rechecker[] = {
RCHECK(FileConsistencyProcess, _AMXX),
RCHECK(FileConsistencyFinal),
......
......@@ -11,8 +11,8 @@ typedef void (*regchain_t)();
struct hook_t
{
std::vector<class CAmxxHook<> *> pre; // pre forwards
std::vector<class CAmxxHook<> *> post; // post forwards
std::vector<class CAmxxHookBase *> pre; // pre forwards
std::vector<class CAmxxHookBase *> post; // post forwards
const char *func_name; // function name
const char *depend_name; // platform dependency
......@@ -59,6 +59,8 @@ struct hooklist_t
CASE(weaponbox)
}
#undef CASE
return nullptr;
}
......@@ -74,9 +76,7 @@ struct hooklist_t
ht_gamerules,
ht_rechecker,
ht_grenade,
ht_weaponbox,
ht_end
ht_weaponbox
};
};
......
......@@ -13,7 +13,7 @@ int CHookManager::addHandler(AMX *amx, int func, const char *funcname, int forwa
}
auto& dest = post ? hook->post : hook->pre;
dest.push_back(new CAmxxHook<>(amx, funcname, forward));
dest.push_back(new CAmxxHookBase(amx, funcname, forward));
int id = func * MAX_HOOK_FORWARDS + dest.size();
return post ? -id : id; // use unsigned ids for post hooks
}
......@@ -28,7 +28,7 @@ hook_t *CHookManager::getHook(size_t func) const
return m_hooklist.getHookSafe(func);
}
CAmxxHook<> *CHookManager::getAmxxHook(cell handle) const
CAmxxHookBase *CHookManager::getAmxxHook(cell handle) const
{
bool post = handle < 0;
......
......@@ -9,7 +9,7 @@ public:
void Clear() const;
cell addHandler(AMX *amx, int func, const char *funcname, int forward, bool post) const;
hook_t *getHook(size_t func) const;
CAmxxHook<> *getAmxxHook(cell hook) const;
CAmxxHookBase *getAmxxHook(cell hook) const;
hook_t *getHookFast(size_t func) const {
return m_hooklist[func];
......
......@@ -7,62 +7,66 @@
#if _MSC_VER <= 1800 && __INTEL_COMPILER < 1500
// BUG BUG
// http://connect.microsoft.com/VisualStudio/feedbackdetail/view/797682/c-decltype-of-class-member-access-incompletely-implemented
#define decltypefx(cx, pref, dt, mx) decltype(std::declval<cx>()dt##pref##mx)
#define decltypefx(cx, pref, mx) decltype(std::declval<cx>().pref##mx)
#define decltypefxdot(cx, pref, mx) decltype(std::declval<cx>().pref.mx)
#else
#define decltypefx(cx, pref, dt, mx) decltype(cx::pref##mx)
#define decltypefx(cx, pref, mx) decltype(cx::pref##mx)
#define decltypefxdot(cx, pref, mx) decltype(cx::pref.mx)
#endif
#define CLASS_MEMBERS(cx, mx, postf, pref) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, pref, ., mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(##cx, ##pref##mx);ptr->type = getMemberType(f);ptr->name = #postf;}) : regmember(#pref#mx)
#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx,)
#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx, m_VoiceGameMgr.)
#define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx, mx,)
#define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx, mx,)
#define MONST_MEMBERS(mx) CLASS_MEMBERS(CBaseMonster, mx, mx,)
#define PL_MEMBERS(mx) CLASS_MEMBERS(CBasePlayer, mx, mx,)
#define EVAR_MEMBERS(mx) CLASS_MEMBERS(com_entvars, mx, var_##mx,)
#define PMOVE_MEMBERS(mx) CLASS_MEMBERS(com_playermove, mx, pm_##mx,)
#define MOVEVAR_MEMBERS(mx) CLASS_MEMBERS(movevars_t, mx, mv_##mx,)
#define UCMD_MEMBERS(mx) CLASS_MEMBERS(usercmd_s, mx, ucmd_##mx,)
#define PMTRACE_MEMBERS(mx) CLASS_MEMBERS(pmtrace_s, mx, pmt_##mx,)
#define CSPL_MEMBERS(mx) CLASS_MEMBERS(CCSPlayer, mx, mx,)
#define BASEITEM_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerItem, mx, mx,)
#define BASEWPN_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerWeapon, mx, m_Weapon_##mx, m_)
#define WPNBOX_MEMBERS(mx) CLASS_MEMBERS(CWeaponBox, mx, m_WeaponBox_##mx, m_)
#define ARMOURY_MEMBERS(mx) CLASS_MEMBERS(CArmoury, mx, m_Armoury_##mx, m_)
#define GRENADE_MEMBERS(mx) CLASS_MEMBERS(CGrenade, mx, m_Grenade_##mx, m_)
#define P228_MEMBERS(mx) CLASS_MEMBERS(CP228, mx, m_P228_##mx, m_)
#define SCOUT_MEMBERS(mx) CLASS_MEMBERS(CSCOUT, mx, m_SCOUT_##mx, m_)
#define HEGREN_MEMBERS(mx) CLASS_MEMBERS(CHEGrenade, mx, m_HEGrenade_##mx, m_)
#define XM1014_MEMBERS(mx) CLASS_MEMBERS(CXM1014, mx, m_XM1014_##mx, m_)
#define C4_MEMBERS(mx) CLASS_MEMBERS(CC4, mx, m_C4_##mx, m_)
#define MAC10_MEMBERS(mx) CLASS_MEMBERS(CMAC10, mx, m_MAC10_##mx, m_)
#define AUG_MEMBERS(mx) CLASS_MEMBERS(CAUG, mx, m_AUG_##mx, m_)
#define SMOKEGREN_MEMBERS(mx) CLASS_MEMBERS(CSmokeGrenade, mx, m_SmokeGrenade_##mx, m_)
#define ELITE_MEMBERS(mx) CLASS_MEMBERS(CELITE, mx, m_ELITE_##mx, m_)
#define FIVESEVEN_MEMBERS(mx) CLASS_MEMBERS(CFiveSeven, mx, m_FiveSeven_##mx, m_)
#define UMP45_MEMBERS(mx) CLASS_MEMBERS(CUMP45, mx, m_UMP45_##mx, m_)
#define SG550_MEMBERS(mx) CLASS_MEMBERS(CSG550, mx, m_SG550_##mx, m_)
#define GALIL_MEMBERS(mx) CLASS_MEMBERS(CGalil, mx, m_Galil_##mx, m_)
#define FAMAS_MEMBERS(mx) CLASS_MEMBERS(CFamas, mx, m_Famas_##mx, m_)
#define USP_MEMBERS(mx) CLASS_MEMBERS(CUSP, mx, m_USP_##mx, m_)
#define GLOCK18_MEMBERS(mx) CLASS_MEMBERS(CGLOCK18, mx, m_GLOCK18_##mx, m_)
#define AWP_MEMBERS(mx) CLASS_MEMBERS(CAWP, mx, m_AWP_##mx, m_)
#define MP5N_MEMBERS(mx) CLASS_MEMBERS(CMP5N, mx, m_MP5N_##mx, m_)
#define M249_MEMBERS(mx) CLASS_MEMBERS(CM249, mx, m_M249_##mx, m_)
#define M3_MEMBERS(mx) CLASS_MEMBERS(CM3, mx, m_M3_##mx, m_)
#define M4A1_MEMBERS(mx) CLASS_MEMBERS(CM4A1, mx, m_M4A1_##mx, m_)
#define TMP_MEMBERS(mx) CLASS_MEMBERS(CTMP, mx, m_TMP_##mx, m_)
#define G3SG1_MEMBERS(mx) CLASS_MEMBERS(CG3SG1, mx, m_G3SG1_##mx, m_)
#define DEAGLE_MEMBERS(mx) CLASS_MEMBERS(CDEAGLE, mx, m_DEAGLE_##mx, m_)
#define SG552_MEMBERS(mx) CLASS_MEMBERS(CSG552, mx, m_SG552_##mx, m_)
#define AK47_MEMBERS(mx) CLASS_MEMBERS(CAK47, mx, m_AK47_##mx, m_)
#define KNIFE_MEMBERS(mx) CLASS_MEMBERS(CKnife, mx, m_Knife_##mx, m_)
#define P90_MEMBERS(mx) CLASS_MEMBERS(CP90, mx, m_P90_##mx, m_)
#define SHIELD_MEMBERS(mx) CLASS_MEMBERS(CWShield, mx, m_Shield_##mx, m_)
#define REBUYSTRUCT_MEMBERS(mx) CLASS_MEMBERS(RebuyStruct, mx, mx,)
#define MAPINFO_MEMBERS(mx) CLASS_MEMBERS(CMapInfo, mx, m_MapInfo_##mx, m_)
#define CSPLWPN_MEMBERS(mx) CLASS_MEMBERS(CCSPlayerWeapon, mx, m_Weapon_##mx, m_)
#define CLASS_MEMBERS(cx, mx, postf) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, , mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, mx);ptr->type = getMemberType(f);ptr->name = #postf;}) : regmember(#mx)
#define CLASS_MEMBERS_PREF(cx, mx, postf, pref) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, pref, mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, pref##mx);ptr->type = getMemberType(f);ptr->name = #postf;}) : regmember(#pref#mx)
#define CLASS_MEMBERS_DOT(cx, mx, postf, pref) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefxdot(cx, pref, mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, pref.mx);ptr->type = getMemberType(f);ptr->name = #postf;}) : regmember(#pref"."#mx)
#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx)
#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS_DOT(CHalfLifeMultiplay, mx, mx, m_VoiceGameMgr)
#define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx, mx)
#define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx, mx)
#define MONST_MEMBERS(mx) CLASS_MEMBERS(CBaseMonster, mx, mx)
#define PL_MEMBERS(mx) CLASS_MEMBERS(CBasePlayer, mx, mx)
#define EVAR_MEMBERS(mx) CLASS_MEMBERS(com_entvars, mx, var_##mx)
#define PMOVE_MEMBERS(mx) CLASS_MEMBERS(com_playermove, mx, pm_##mx)
#define MOVEVAR_MEMBERS(mx) CLASS_MEMBERS(movevars_t, mx, mv_##mx)
#define UCMD_MEMBERS(mx) CLASS_MEMBERS(usercmd_s, mx, ucmd_##mx)
#define PMTRACE_MEMBERS(mx) CLASS_MEMBERS(pmtrace_s, mx, pmt_##mx)
#define CSPL_MEMBERS(mx) CLASS_MEMBERS(CCSPlayer, mx, mx)
#define BASEITEM_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerItem, mx, mx)
#define BASEWPN_MEMBERS(mx) CLASS_MEMBERS_PREF(CBasePlayerWeapon, mx, m_Weapon_##mx, m_)
#define WPNBOX_MEMBERS(mx) CLASS_MEMBERS_PREF(CWeaponBox, mx, m_WeaponBox_##mx, m_)
#define ARMOURY_MEMBERS(mx) CLASS_MEMBERS_PREF(CArmoury, mx, m_Armoury_##mx, m_)
#define GRENADE_MEMBERS(mx) CLASS_MEMBERS_PREF(CGrenade, mx, m_Grenade_##mx, m_)
#define P228_MEMBERS(mx) CLASS_MEMBERS_PREF(CP228, mx, m_P228_##mx, m_)
#define SCOUT_MEMBERS(mx) CLASS_MEMBERS_PREF(CSCOUT, mx, m_SCOUT_##mx, m_)
#define HEGREN_MEMBERS(mx) CLASS_MEMBERS_PREF(CHEGrenade, mx, m_HEGrenade_##mx, m_)
#define XM1014_MEMBERS(mx) CLASS_MEMBERS_PREF(CXM1014, mx, m_XM1014_##mx, m_)
#define C4_MEMBERS(mx) CLASS_MEMBERS_PREF(CC4, mx, m_C4_##mx, m_)
#define MAC10_MEMBERS(mx) CLASS_MEMBERS_PREF(CMAC10, mx, m_MAC10_##mx, m_)
#define AUG_MEMBERS(mx) CLASS_MEMBERS_PREF(CAUG, mx, m_AUG_##mx, m_)
#define SMOKEGREN_MEMBERS(mx) CLASS_MEMBERS_PREF(CSmokeGrenade, mx, m_SmokeGrenade_##mx, m_)
#define ELITE_MEMBERS(mx) CLASS_MEMBERS_PREF(CELITE, mx, m_ELITE_##mx, m_)
#define FIVESEVEN_MEMBERS(mx) CLASS_MEMBERS_PREF(CFiveSeven, mx, m_FiveSeven_##mx, m_)
#define UMP45_MEMBERS(mx) CLASS_MEMBERS_PREF(CUMP45, mx, m_UMP45_##mx, m_)
#define SG550_MEMBERS(mx) CLASS_MEMBERS_PREF(CSG550, mx, m_SG550_##mx, m_)
#define GALIL_MEMBERS(mx) CLASS_MEMBERS_PREF(CGalil, mx, m_Galil_##mx, m_)
#define FAMAS_MEMBERS(mx) CLASS_MEMBERS_PREF(CFamas, mx, m_Famas_##mx, m_)
#define USP_MEMBERS(mx) CLASS_MEMBERS_PREF(CUSP, mx, m_USP_##mx, m_)
#define GLOCK18_MEMBERS(mx) CLASS_MEMBERS_PREF(CGLOCK18, mx, m_GLOCK18_##mx, m_)
#define AWP_MEMBERS(mx) CLASS_MEMBERS_PREF(CAWP, mx, m_AWP_##mx, m_)
#define MP5N_MEMBERS(mx) CLASS_MEMBERS_PREF(CMP5N, mx, m_MP5N_##mx, m_)
#define M249_MEMBERS(mx) CLASS_MEMBERS_PREF(CM249, mx, m_M249_##mx, m_)
#define M3_MEMBERS(mx) CLASS_MEMBERS_PREF(CM3, mx, m_M3_##mx, m_)
#define M4A1_MEMBERS(mx) CLASS_MEMBERS_PREF(CM4A1, mx, m_M4A1_##mx, m_)
#define TMP_MEMBERS(mx) CLASS_MEMBERS_PREF(CTMP, mx, m_TMP_##mx, m_)
#define G3SG1_MEMBERS(mx) CLASS_MEMBERS_PREF(CG3SG1, mx, m_G3SG1_##mx, m_)
#define DEAGLE_MEMBERS(mx) CLASS_MEMBERS_PREF(CDEAGLE, mx, m_DEAGLE_##mx, m_)
#define SG552_MEMBERS(mx) CLASS_MEMBERS_PREF(CSG552, mx, m_SG552_##mx, m_)
#define AK47_MEMBERS(mx) CLASS_MEMBERS_PREF(CAK47, mx, m_AK47_##mx, m_)
#define KNIFE_MEMBERS(mx) CLASS_MEMBERS_PREF(CKnife, mx, m_Knife_##mx, m_)
#define P90_MEMBERS(mx) CLASS_MEMBERS_PREF(CP90, mx, m_P90_##mx, m_)
#define SHIELD_MEMBERS(mx) CLASS_MEMBERS_PREF(CWShield, mx, m_Shield_##mx, m_)
#define REBUYSTRUCT_MEMBERS(mx) CLASS_MEMBERS(RebuyStruct, mx, mx)
#define MAPINFO_MEMBERS(mx) CLASS_MEMBERS_PREF(CMapInfo, mx, m_MapInfo_##mx, m_)
#define CSPLWPN_MEMBERS(mx) CLASS_MEMBERS_PREF(CCSPlayerWeapon, mx, m_Weapon_##mx, m_)
inline MType getMemberType(float*) { return MEMBER_FLOAT; }
inline MType getMemberType(float) { return MEMBER_FLOAT; }
......@@ -118,8 +122,10 @@ inline MType getMemberType(RebuyStruct) { return MEBMER_REBUYSTRUCT; }
inline MType getMemberType(pmtrace_t) { return MEMBER_PMTRACE; }
inline MType getMemberType(usercmd_s) { return MEBMER_USERCMD; }
template<typename T> struct always_false: std::false_type {};
template<typename T>
inline MType getMemberType(T) { static_assert(false, "Not implemented overload"); }
inline MType getMemberType(T) { static_assert(always_false<T>::value, "Not implemented overload"); return MEMBER_NONE; }
template<typename T, size_t size>
inline size_t getTypeSize(T type[size]) { return sizeof(T); }
......@@ -141,6 +147,11 @@ struct regmember
int regmember::current_cell = 1;
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif // #ifdef __GNUC__
member_t memberlist_gamerules[] = {
GM_MEMBERS(m_bFreezePeriod),
GM_MEMBERS(m_bBombDropped),
......@@ -1004,6 +1015,10 @@ member_t memberlist_csplayerweapon[] = {
CSPLWPN_MEMBERS(flBaseDamage),
};
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // #ifdef __GNUC__
memberlist_t memberlist;
member_t *memberlist_t::operator[](size_t members) const
......@@ -1064,5 +1079,6 @@ member_t *memberlist_t::operator[](size_t members) const
CASE(csplayerweapon)
}
#undef CASE
return nullptr;
}
......@@ -5,7 +5,8 @@
// member types
enum MType
{
MEMBER_FLOAT = 0, // Any floating point value
MEMBER_NONE = 0,
MEMBER_FLOAT, // Any floating point value
MEMBER_DOUBLE, // double value
MEMBER_ENTITY, // An entity offset (EOFFSET)
MEMBER_CLASSPTR, // CBaseEntity *
......
......@@ -12,8 +12,8 @@ bool VTC_Api_Init()
if (!g_pVoiceTranscoderApi)
return false;
int majorVersion = g_pVoiceTranscoderApi->GetMajorVersion();
int minorVersion = g_pVoiceTranscoderApi->GetMinorVersion();
size_t majorVersion = g_pVoiceTranscoderApi->GetMajorVersion();
size_t minorVersion = g_pVoiceTranscoderApi->GetMinorVersion();
if (majorVersion != VOICETRANSCODER_API_VERSION_MAJOR)
{
......
......@@ -1202,7 +1202,8 @@ cell AMX_NATIVE_CALL rg_give_defusekit(AMX *amx, cell *params)
return FALSE;
}
pPlayer->m_bHasDefuser = pPlayer->pev->body = params[arg_def] != 0;
pPlayer->m_bHasDefuser = params[arg_def] ? true : false;
pPlayer->pev->body = params[arg_def] ? 1 : 0;
if (params[arg_def] != 0)
{
......@@ -1326,6 +1327,8 @@ cell AMX_NATIVE_CALL rg_set_user_team(AMX *amx, cell *params)
case CT:
CSGameRules()->m_iNumCT++;
break;
default:
break;
}
// previous team
......@@ -1359,6 +1362,8 @@ cell AMX_NATIVE_CALL rg_set_user_team(AMX *amx, cell *params)
pPlayer->CSPlayer()->SendItemStatus();
}
break;
default:
break;
}
}
......
......@@ -57,4 +57,4 @@ void GetBonePosition(CBaseEntity *pEntity, int iBone, Vector *vecOrigin, Vector
void GetAttachment(CBaseEntity *pEntity, int iBone, Vector *pVecOrigin, Vector *pVecAngles);
void RemoveOrDropItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, GiveType type);
extern void __declspec(noreturn) UTIL_SysError(const char *fmt, ...);
extern void NORETURN UTIL_SysError(const char *fmt, ...);
#include "precompiled.h"
void __declspec(noreturn) UTIL_SysError(const char *fmt, ...)
void NORETURN UTIL_SysError(const char *fmt, ...)
{
va_list argptr;
char string[8192];
......
......@@ -8,6 +8,7 @@ import org.gradle.nativeplatform.toolchain.VisualCpp
apply from: 'shared_msvc.gradle'
apply from: 'shared_icc.gradle'
apply from: 'shared_gcc.gradle'
rootProject.ext.createToolchainConfig = { NativeBinarySpec bin ->
BinaryKind binaryKind
......@@ -27,6 +28,8 @@ rootProject.ext.createToolchainConfig = { NativeBinarySpec bin ->
return rootProject.createMsvcConfig(releaseBuild, binaryKind)
} else if (bin.toolChain instanceof Icc) {
return rootProject.createIccConfig(releaseBuild, binaryKind)
} else if (bin.toolChain instanceof Gcc) {