Skip to content

Commit

Permalink
Fixed some GCC warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Jun 5, 2019
1 parent e9c41c3 commit 3abf487
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 68 deletions.
3 changes: 2 additions & 1 deletion regamedll/dlls/bot/cs_bot_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/bot/cs_bot_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void Bot_RegisterCVars()
}

// Constructor
CCSBot::CCSBot() : m_chatter(this), m_gameState(this)
CCSBot::CCSBot() : m_gameState(this), m_chatter(this)
{
;
}
Expand Down
5 changes: 2 additions & 3 deletions regamedll/dlls/career_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/career_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class CCareerTask
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();
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/hostage/hostage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
109 changes: 56 additions & 53 deletions regamedll/dlls/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,72 +918,75 @@ void CEnvSound::Think()
goto env_sound_Think_slow;
}

CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)VARS(pentPlayer));
float flRange;
{
CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)VARS(pentPlayer));
float flRange;

// check to see if this is the sound entity that is
// currently affecting this player
// 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)
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
{
// entity is affecting player but is out of range,
// wait passively for another entity to usurp it...
goto env_sound_Think_slow;
}
}

// 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)
// 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))
{
// 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...
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 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...
Expand Down
16 changes: 12 additions & 4 deletions regamedll/dlls/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions regamedll/dlls/weapontype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion regamedll/regamedll/hookchains_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class IHookChainClassEmptyImpl : public IHookChain<t_ret, t_args...> {
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__);
Expand Down

0 comments on commit 3abf487

Please sign in to comment.