Fix compilation with GCC 8.2+ (#617)

* GCC 8.2 support

* Add GCC version check

* -Werror=class-memaccess fix in code

* Use assignment for Stats
This commit is contained in:
Vitaly Karpenko 2019-10-29 22:48:31 +02:00 committed by Vincent Herbet
parent c86813697a
commit 0ccba67006
9 changed files with 25 additions and 25 deletions

View File

@ -131,7 +131,7 @@ void CPlayer::restartStats(bool all)
memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats
memset(attackers,0,sizeof(attackers)); memset(attackers,0,sizeof(attackers));
memset(victims,0,sizeof(victims)); memset(victims,0,sizeof(victims));
memset(&life,0,sizeof(life)); life = {};
} }
void CPlayer::Init( int pi, edict_t* pe ) void CPlayer::Init( int pi, edict_t* pe )

View File

@ -95,14 +95,14 @@ void CPlayer::restartStats(bool all)
if ( all ) if ( all )
{ {
memset(weapons,0,sizeof(weapons)); memset(weapons,0,sizeof(weapons));
memset(&round,0,sizeof(round)); memset(static_cast<void *>(&round),0,sizeof(round));
memset(weaponsRnd,0,sizeof(weaponsRnd)); memset(weaponsRnd,0,sizeof(weaponsRnd));
} }
memset(weaponsLife,0,sizeof(weaponsLife)); //DEC-Weapon (Round) stats memset(weaponsLife,0,sizeof(weaponsLife)); //DEC-Weapon (Round) stats
memset(attackers,0,sizeof(attackers)); memset(attackers,0,sizeof(attackers));
memset(victims,0,sizeof(victims)); memset(victims,0,sizeof(victims));
memset(&life,0,sizeof(life)); life = {};
} }
void CPlayer::Init( int pi, edict_t* pe ) void CPlayer::Init( int pi, edict_t* pe )

View File

@ -172,7 +172,7 @@ void PlayerPreThink_Post(edict_t *pEntity)
if(pPlayer->clearRound && pPlayer->clearRound < gpGlobals->time) if(pPlayer->clearRound && pPlayer->clearRound < gpGlobals->time)
{ {
pPlayer->clearRound = 0.0f; pPlayer->clearRound = 0.0f;
memset(&pPlayer->round,0,sizeof(pPlayer->round)); memset(static_cast<void *>(&pPlayer->round),0,sizeof(pPlayer->round));
memset(pPlayer->weaponsRnd,0,sizeof(pPlayer->weaponsRnd)); memset(pPlayer->weaponsRnd,0,sizeof(pPlayer->weaponsRnd));
} }

View File

@ -1255,7 +1255,7 @@ static cell AMX_NATIVE_CALL create_tr2(AMX *amx, cell *params)
tr = g_FreeTRs.front(); tr = g_FreeTRs.front();
g_FreeTRs.pop(); g_FreeTRs.pop();
} }
memset(tr, 0, sizeof(TraceResult)); memset(static_cast<void *>(tr), 0, sizeof(TraceResult));
return reinterpret_cast<cell>(tr); return reinterpret_cast<cell>(tr);
} }

View File

@ -136,7 +136,7 @@ extern bool gDoForwards;
#define CHECK_RETURN_VEC() \ #define CHECK_RETURN_VEC() \
if (thisresult < HAM_OVERRIDE) \ if (thisresult < HAM_OVERRIDE) \
{ \ { \
memcpy(out, &origret, sizeof(Vector)); \ memcpy(static_cast<void *>(out), &origret, sizeof(Vector)); \
return; \ return; \
} }
@ -852,8 +852,8 @@ void Hook_Vector_Float_Cbase_Int(Hook *hook, Vector *out, void *pthis, float f1,
MAKE_VECTOR() MAKE_VECTOR()
memset(&ret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&ret), 0x0, sizeof(Vector));
memset(&origret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&origret), 0x0, sizeof(Vector));
int iEnt = TypeConversion.cbase_to_id(cb); int iEnt = TypeConversion.cbase_to_id(cb);
@ -879,7 +879,7 @@ void Hook_Vector_Float_Cbase_Int(Hook *hook, Vector *out, void *pthis, float f1,
POP() POP()
CHECK_RETURN_VEC() CHECK_RETURN_VEC()
memcpy(out, &ret, sizeof(Vector)); memcpy(static_cast<void *>(out), &ret, sizeof(Vector));
} }
void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1, void *cb2, int i1, float f1) void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1, void *cb2, int i1, float f1)
@ -1038,8 +1038,8 @@ void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis)
MAKE_VECTOR() MAKE_VECTOR()
memset(&ret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&ret), 0x0, sizeof(Vector));
memset(&origret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&origret), 0x0, sizeof(Vector));
PRE_START() PRE_START()
PRE_END() PRE_END()
@ -1056,7 +1056,7 @@ void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis)
KILL_VECTOR() KILL_VECTOR()
POP() POP()
CHECK_RETURN_VEC() CHECK_RETURN_VEC()
memcpy(out, &ret, sizeof(Vector)); memcpy(static_cast<void *>(out), &ret, sizeof(Vector));
} }
@ -1074,8 +1074,8 @@ void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1)
MAKE_VECTOR() MAKE_VECTOR()
P_PTRVECTOR(v1) P_PTRVECTOR(v1)
memset(&ret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&ret), 0x0, sizeof(Vector));
memset(&origret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&origret), 0x0, sizeof(Vector));
PRE_START() PRE_START()
, MF_PrepareCellArrayA(reinterpret_cast<cell *>(v1), 3, false) , MF_PrepareCellArrayA(reinterpret_cast<cell *>(v1), 3, false)
@ -1094,7 +1094,7 @@ void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1)
KILL_VECTOR() KILL_VECTOR()
POP() POP()
CHECK_RETURN_VEC() CHECK_RETURN_VEC()
memcpy(out, &ret, sizeof(Vector)); memcpy(static_cast<void *>(out), &ret, sizeof(Vector));
} }
int Hook_Int_pVector(Hook *hook, void *pthis, Vector *v1) int Hook_Int_pVector(Hook *hook, void *pthis, Vector *v1)
@ -1476,8 +1476,8 @@ void Hook_Vector_Float(Hook *hook, Vector *out, void *pthis, float f1)
MAKE_VECTOR() MAKE_VECTOR()
P_FLOAT(f1) P_FLOAT(f1)
memset(&ret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&ret), 0x0, sizeof(Vector));
memset(&origret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&origret), 0x0, sizeof(Vector));
PRE_START() PRE_START()
, f1 , f1
@ -1496,7 +1496,7 @@ void Hook_Vector_Float(Hook *hook, Vector *out, void *pthis, float f1)
KILL_VECTOR() KILL_VECTOR()
POP() POP()
CHECK_RETURN_VEC() CHECK_RETURN_VEC()
memcpy(out, &ret, sizeof(Vector)); memcpy(static_cast<void *>(out), &ret, sizeof(Vector));
} }
@ -3269,8 +3269,8 @@ void Hook_Vector_Vector_Vector_Vector(Hook *hook, Vector *out, void *pthis, Vect
P_VECTOR(v2) P_VECTOR(v2)
P_VECTOR(v3) P_VECTOR(v3)
memset(&ret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&ret), 0x0, sizeof(Vector));
memset(&origret, 0x0, sizeof(Vector)); memset(static_cast<void *>(&origret), 0x0, sizeof(Vector));
PRE_START() PRE_START()
, MF_PrepareCellArrayA(reinterpret_cast<cell *>(&v1), 3, false) , MF_PrepareCellArrayA(reinterpret_cast<cell *>(&v1), 3, false)
@ -3294,7 +3294,7 @@ void Hook_Vector_Vector_Vector_Vector(Hook *hook, Vector *out, void *pthis, Vect
POP() POP()
CHECK_RETURN_VEC() CHECK_RETURN_VEC()
memcpy(out, &ret, sizeof(Vector)); memcpy(static_cast<void *>(out), &ret, sizeof(Vector));
} }
const char *Hook_Str_Str(Hook *hook, void *pthis, const char* str) const char *Hook_Str_Str(Hook *hook, void *pthis, const char* str)

View File

@ -178,7 +178,7 @@ void MysqlThread::RunThread(IThreadHandle *pHandle)
float save_time = m_qrInfo.queue_time; float save_time = m_qrInfo.queue_time;
memset(&m_qrInfo, 0, sizeof(m_qrInfo)); memset(static_cast<void *>(&m_qrInfo), 0, sizeof(m_qrInfo));
m_qrInfo.queue_time = save_time; m_qrInfo.queue_time = save_time;

View File

@ -162,7 +162,7 @@ void MysqlThread::RunThread(IThreadHandle *pHandle)
float save_time = m_qrInfo.queue_time; float save_time = m_qrInfo.queue_time;
memset(&m_qrInfo, 0, sizeof(m_qrInfo)); memset(static_cast<void *>(&m_qrInfo), 0, sizeof(m_qrInfo));
m_qrInfo.queue_time = save_time; m_qrInfo.queue_time = save_time;

View File

@ -130,7 +130,7 @@ void CPlayer::restartStats(bool all)
memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats
memset(attackers,0,sizeof(attackers)); memset(attackers,0,sizeof(attackers));
memset(victims,0,sizeof(victims)); memset(victims,0,sizeof(victims));
memset(&life,0,sizeof(life)); life = {};
} }
void CPlayer::Init( int pi, edict_t* pe ) void CPlayer::Init( int pi, edict_t* pe )

View File

@ -82,7 +82,7 @@ void CPlayer::restartStats(bool all)
memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats
memset(attackers,0,sizeof(attackers)); memset(attackers,0,sizeof(attackers));
memset(victims,0,sizeof(victims)); memset(victims,0,sizeof(victims));
memset(&life,0,sizeof(life)); life = {};
} }
void CPlayer::Init( int pi, edict_t* pe ) void CPlayer::Init( int pi, edict_t* pe )