Fixed some GCC warnings

This commit is contained in:
s1lent 2019-06-06 01:26:02 +07:00
parent e9c41c33d2
commit 3abf4879e7
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
11 changed files with 85 additions and 70 deletions

View File

@ -291,7 +291,8 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOt
if ((pEntity->pev->origin - pev->origin).IsLengthGreaterThan(1000.0f)) if ((pEntity->pev->origin - pev->origin).IsLengthGreaterThan(1000.0f))
return; return;
if (IsVisible(&pEntity->Center())) Vector vecHostageOrigin = pEntity->Center();
if (IsVisible(&vecHostageOrigin))
{ {
m_task = COLLECT_HOSTAGES; m_task = COLLECT_HOSTAGES;
m_taskEntity = nullptr; m_taskEntity = nullptr;

View File

@ -126,7 +126,7 @@ void Bot_RegisterCVars()
} }
// Constructor // Constructor
CCSBot::CCSBot() : m_chatter(this), m_gameState(this) CCSBot::CCSBot() : m_gameState(this), m_chatter(this)
{ {
; ;
} }

View File

@ -12,10 +12,9 @@ CCareerTask *CPreventDefuseTask::NewTask(const char *taskName, GameEventType eve
return reinterpret_cast<CCareerTask *>(pNewTask); return reinterpret_cast<CCareerTask *>(pNewTask);
} }
CPreventDefuseTask::CPreventDefuseTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) CPreventDefuseTask::CPreventDefuseTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) :
CCareerTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete)
{ {
CCareerTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete);
m_bombPlantedThisRound = false; m_bombPlantedThisRound = false;
m_defuseStartedThisRound = false; m_defuseStartedThisRound = false;
} }

View File

@ -36,6 +36,8 @@ public:
CCareerTask() {}; CCareerTask() {};
CCareerTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete); CCareerTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete);
virtual ~CCareerTask() {}
public: public:
virtual void OnEvent(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim); virtual void OnEvent(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim);
virtual void Reset(); virtual void Reset();

View File

@ -381,7 +381,7 @@ void CHostage::IdleThink()
return; return;
} }
if (m_hTargetEnt && (m_bStuck && gpGlobals->time - m_flStuckTime > 5.0f || m_hTargetEnt->pev->deadflag != DEAD_NO)) if (m_hTargetEnt && ((m_bStuck && gpGlobals->time - m_flStuckTime > 5.0f) || m_hTargetEnt->pev->deadflag != DEAD_NO))
{ {
m_State = STAND; m_State = STAND;
m_hTargetEnt = nullptr; m_hTargetEnt = nullptr;

View File

@ -918,6 +918,7 @@ void CEnvSound::Think()
goto env_sound_Think_slow; goto env_sound_Think_slow;
} }
{
CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)VARS(pentPlayer)); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)VARS(pentPlayer));
float flRange; float flRange;
@ -980,10 +981,12 @@ void CEnvSound::Think()
// crank up nextthink rate for new active sound entity // crank up nextthink rate for new active sound entity
// by falling through to think_fast... // by falling through to think_fast...
} }
// player is not closer to the contending sound entity, // player is not closer to the contending sound entity,
// just fall through to think_fast. this effectively // just fall through to think_fast. this effectively
// cranks up the think_rate of entities near the player. // cranks up the think_rate of entities near the player.
} }
}
// player is in pvs of sound entity, but either not visible or // player is in pvs of sound entity, but either not visible or
// not in range. do nothing, fall through to think_fast... // not in range. do nothing, fall through to think_fast...

View File

@ -688,15 +688,20 @@ void UTIL_Log(const char *fmt, ...)
string[Q_strlen(string) - 1] = '\n'; string[Q_strlen(string) - 1] = '\n';
FILE *fp = fopen("regamedll.log", "at"); FILE *fp = fopen("regamedll.log", "at");
if (fp)
{
fprintf(fp, "%s", string); fprintf(fp, "%s", string);
fclose(fp); fclose(fp);
}
} }
void UTIL_ServerPrint(const char *fmt, ...) void UTIL_ServerPrint(const char *fmt, ...)
{ {
#ifdef PLAY_GAMEDLL
// Check is null, test the demo started before than searches pointer to refs // Check is null, test the demo started before than searches pointer to refs
if (&g_engfuncs == nullptr || g_engfuncs.pfnServerPrint == nullptr) if (&g_engfuncs == nullptr || g_engfuncs.pfnServerPrint == nullptr)
return; return;
#endif
static char string[1024]; static char string[1024];
va_list ap; va_list ap;
@ -1762,8 +1767,11 @@ void NORETURN Sys_Error(const char *error, ...)
va_end(argptr); va_end(argptr);
FILE *fl = fopen("regamedll_error.txt", "w"); FILE *fl = fopen("regamedll_error.txt", "w");
if (fl)
{
fprintf(fl, "%s\n", text); fprintf(fl, "%s\n", text);
fclose(fl); fclose(fl);
}
CONSOLE_ECHO("FATAL ERROR (shutting down): %s\n", text); CONSOLE_ECHO("FATAL ERROR (shutting down): %s\n", text);

View File

@ -127,7 +127,7 @@ void CFuncVehicle::Blocked(CBaseEntity *pOther)
|| pOther->pev->origin.x > maxx || pOther->pev->origin.x > maxx
|| pOther->pev->origin.y < miny || pOther->pev->origin.y < miny
|| pOther->pev->origin.y > maxy || pOther->pev->origin.y > maxy
|| pOther->pev->origin.z < pev->origin.z || pOther->pev->origin.z < minz
|| pOther->pev->origin.z > maxz) || pOther->pev->origin.z > maxz)
{ {
pOther->TakeDamage(pev, pev, 150, DMG_CRUSH); pOther->TakeDamage(pev, pev, 150, DMG_CRUSH);

View File

@ -219,7 +219,6 @@ WeaponClassAliasInfo g_weaponClassAliasInfo[] =
{ nullptr, WEAPONCLASS_NONE }, { nullptr, WEAPONCLASS_NONE },
}; };
WeaponInfoStruct g_weaponInfo[31];
WeaponInfoStruct g_weaponInfo_default[] = WeaponInfoStruct g_weaponInfo_default[] =
{ {
{ WEAPON_P228, P228_PRICE, AMMO_357SIG_PRICE, AMMO_357SIG_BUY, P228_MAX_CLIP, MAX_AMMO_357SIG, AMMO_357SIG, "weapon_p228", "ammo_357sig", "357SIG" }, { WEAPON_P228, P228_PRICE, AMMO_357SIG_PRICE, AMMO_357SIG_BUY, P228_MAX_CLIP, MAX_AMMO_357SIG, AMMO_357SIG, "weapon_p228", "ammo_357sig", "357SIG" },
@ -269,7 +268,8 @@ WeaponInfoStruct g_weaponInfo_default[] =
#endif #endif
}; };
AmmoInfoStruct g_ammoInfo[14]; WeaponInfoStruct g_weaponInfo[ARRAYSIZE(g_weaponInfo_default)];
AmmoInfoStruct g_ammoInfo_default[] = AmmoInfoStruct g_ammoInfo_default[] =
{ {
{ AMMO_338MAGNUM, AMMO_338MAG_PRICE, AMMO_338MAG_BUY, MAX_AMMO_338MAGNUM, "ammo_338magnum", "338Magnum" }, { AMMO_338MAGNUM, AMMO_338MAG_PRICE, AMMO_338MAG_BUY, MAX_AMMO_338MAGNUM, "ammo_338magnum", "338Magnum" },
@ -288,6 +288,8 @@ AmmoInfoStruct g_ammoInfo_default[] =
{ AMMO_C4, 0, 0, 0, nullptr, "C4" }, { AMMO_C4, 0, 0, 0, nullptr, "C4" },
}; };
AmmoInfoStruct g_ammoInfo[ARRAYSIZE(g_ammoInfo_default)];
WeaponSlotInfo g_weaponSlotInfo[] = { WeaponSlotInfo g_weaponSlotInfo[] = {
{ WEAPON_C4, C4_SLOT, "weapon_c4" }, { WEAPON_C4, C4_SLOT, "weapon_c4" },
{ WEAPON_KNIFE, KNIFE_SLOT, "weapon_knife" }, { WEAPON_KNIFE, KNIFE_SLOT, "weapon_knife" },

View File

@ -1880,7 +1880,7 @@ void PM_Duck()
} }
#endif #endif
if (pmove->dead || !(pmove->cmd.buttons & IN_DUCK) && !pmove->bInDuck && !(pmove->flags & FL_DUCKING)) if (pmove->dead || (!(pmove->cmd.buttons & IN_DUCK) && !pmove->bInDuck && !(pmove->flags & FL_DUCKING)))
{ {
return; return;
} }

View File

@ -123,7 +123,7 @@ public:
typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...); typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...);
typedef t_ret(t_class::*origfunc_t)(t_args...); typedef t_ret(t_class::*origfunc_t)(t_args...);
IHookChainClassEmptyImpl(void** hooks, origfunc_t orig, t_class *object) : m_Hooks(hooks), m_OriginalFunc(orig), m_Object(object) IHookChainClassEmptyImpl(void** hooks, origfunc_t orig, t_class *object) : m_Hooks(hooks), m_Object(object), m_OriginalFunc(orig)
{ {
if (orig == nullptr && !is_void(orig)) if (orig == nullptr && !is_void(orig))
Sys_Error("%s: Non-void HookChain without original function.", __FUNC__); Sys_Error("%s: Non-void HookChain without original function.", __FUNC__);