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))
return;
if (IsVisible(&pEntity->Center()))
Vector vecHostageOrigin = pEntity->Center();
if (IsVisible(&vecHostageOrigin))
{
m_task = COLLECT_HOSTAGES;
m_taskEntity = nullptr;

View File

@ -126,7 +126,7 @@ void Bot_RegisterCVars()
}
// 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);
}
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_defuseStartedThisRound = false;
}

View File

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

View File

@ -381,7 +381,7 @@ void CHostage::IdleThink()
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_hTargetEnt = nullptr;

View File

@ -918,72 +918,75 @@ void CEnvSound::Think()
goto env_sound_Think_slow;
}
CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)VARS(pentPlayer));
float flRange;
// check to see if this is the sound entity that is
// currently affecting this player
if (!FNullEnt(pPlayer->m_pentSndLast) && pPlayer->m_pentSndLast == ENT(pev))
{
// this is the entity currently affecting player, check
// for validity
if (pPlayer->m_flSndRoomtype != 0 && pPlayer->m_flSndRange != 0)
CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)VARS(pentPlayer));
float flRange;
// check to see if this is the sound entity that is
// currently affecting this player
if (!FNullEnt(pPlayer->m_pentSndLast) && pPlayer->m_pentSndLast == ENT(pev))
{
// we're looking at a valid sound entity affecting
// player, make sure it's still valid, update range
if (FEnvSoundInRange(pev, VARS(pentPlayer), &flRange))
// this is the entity currently affecting player, check
// for validity
if (pPlayer->m_flSndRoomtype != 0 && pPlayer->m_flSndRange != 0)
{
pPlayer->m_flSndRange = flRange;
goto env_sound_Think_fast;
// we're looking at a valid sound entity affecting
// player, make sure it's still valid, update range
if (FEnvSoundInRange(pev, VARS(pentPlayer), &flRange))
{
pPlayer->m_flSndRange = flRange;
goto env_sound_Think_fast;
}
else
{
// current sound entity affecting player is no longer valid,
// flag this state by clearing room_type and range.
// NOTE: we do not actually change the player's room_type
// NOTE: until we have a new valid room_type to change it to.
pPlayer->m_flSndRange = 0;
pPlayer->m_flSndRoomtype = 0;
goto env_sound_Think_slow;
}
}
else
{
// current sound entity affecting player is no longer valid,
// flag this state by clearing room_type and range.
// NOTE: we do not actually change the player's room_type
// NOTE: until we have a new valid room_type to change it to.
pPlayer->m_flSndRange = 0;
pPlayer->m_flSndRoomtype = 0;
// entity is affecting player but is out of range,
// wait passively for another entity to usurp it...
goto env_sound_Think_slow;
}
}
else
// if we got this far, we're looking at an entity that is contending
// for current player sound. the closest entity to player wins.
if (FEnvSoundInRange(pev, VARS(pentPlayer), &flRange))
{
// entity is affecting player but is out of range,
// wait passively for another entity to usurp it...
goto env_sound_Think_slow;
if (flRange < pPlayer->m_flSndRange || pPlayer->m_flSndRange == 0)
{
// new entity is closer to player, so it wins.
pPlayer->m_pentSndLast = ENT(pev);
pPlayer->m_flSndRoomtype = m_flRoomtype;
pPlayer->m_flSndRange = flRange;
// send room_type command to player's server.
// this should be a rare event - once per change of room_type
// only!
//CLIENT_COMMAND(pentPlayer, "room_type %f", m_flRoomtype);
MESSAGE_BEGIN(MSG_ONE, SVC_ROOMTYPE, nullptr, pentPlayer); // use the magic #1 for "one client"
WRITE_SHORT((short)m_flRoomtype); // sequence number
MESSAGE_END();
// crank up nextthink rate for new active sound entity
// by falling through to think_fast...
}
// player is not closer to the contending sound entity,
// just fall through to think_fast. this effectively
// cranks up the think_rate of entities near the player.
}
}
// if we got this far, we're looking at an entity that is contending
// for current player sound. the closest entity to player wins.
if (FEnvSoundInRange(pev, VARS(pentPlayer), &flRange))
{
if (flRange < pPlayer->m_flSndRange || pPlayer->m_flSndRange == 0)
{
// new entity is closer to player, so it wins.
pPlayer->m_pentSndLast = ENT(pev);
pPlayer->m_flSndRoomtype = m_flRoomtype;
pPlayer->m_flSndRange = flRange;
// send room_type command to player's server.
// this should be a rare event - once per change of room_type
// only!
//CLIENT_COMMAND(pentPlayer, "room_type %f", m_flRoomtype);
MESSAGE_BEGIN(MSG_ONE, SVC_ROOMTYPE, nullptr, pentPlayer); // use the magic #1 for "one client"
WRITE_SHORT((short)m_flRoomtype); // sequence number
MESSAGE_END();
// crank up nextthink rate for new active sound entity
// by falling through to think_fast...
}
// player is not closer to the contending sound entity,
// just fall through to think_fast. this effectively
// cranks up the think_rate of entities near the player.
}
}
// player is in pvs of sound entity, but either not visible or
// 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';
FILE *fp = fopen("regamedll.log", "at");
fprintf(fp, "%s", string);
fclose(fp);
if (fp)
{
fprintf(fp, "%s", string);
fclose(fp);
}
}
void UTIL_ServerPrint(const char *fmt, ...)
{
#ifdef PLAY_GAMEDLL
// Check is null, test the demo started before than searches pointer to refs
if (&g_engfuncs == nullptr || g_engfuncs.pfnServerPrint == nullptr)
return;
#endif
static char string[1024];
va_list ap;
@ -1762,8 +1767,11 @@ void NORETURN Sys_Error(const char *error, ...)
va_end(argptr);
FILE *fl = fopen("regamedll_error.txt", "w");
fprintf(fl, "%s\n", text);
fclose(fl);
if (fl)
{
fprintf(fl, "%s\n", text);
fclose(fl);
}
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.y < miny
|| pOther->pev->origin.y > maxy
|| pOther->pev->origin.z < pev->origin.z
|| pOther->pev->origin.z < minz
|| pOther->pev->origin.z > maxz)
{
pOther->TakeDamage(pev, pev, 150, DMG_CRUSH);

View File

@ -219,7 +219,6 @@ WeaponClassAliasInfo g_weaponClassAliasInfo[] =
{ nullptr, WEAPONCLASS_NONE },
};
WeaponInfoStruct g_weaponInfo[31];
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" },
@ -269,7 +268,8 @@ WeaponInfoStruct g_weaponInfo_default[] =
#endif
};
AmmoInfoStruct g_ammoInfo[14];
WeaponInfoStruct g_weaponInfo[ARRAYSIZE(g_weaponInfo_default)];
AmmoInfoStruct g_ammoInfo_default[] =
{
{ 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" },
};
AmmoInfoStruct g_ammoInfo[ARRAYSIZE(g_ammoInfo_default)];
WeaponSlotInfo g_weaponSlotInfo[] = {
{ WEAPON_C4, C4_SLOT, "weapon_c4" },
{ WEAPON_KNIFE, KNIFE_SLOT, "weapon_knife" },

View File

@ -1880,7 +1880,7 @@ void PM_Duck()
}
#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;
}

View File

@ -123,7 +123,7 @@ public:
typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, 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))
Sys_Error("%s: Non-void HookChain without original function.", __FUNC__);