diff --git a/regamedll/dlls/bot/cs_bot_event.cpp b/regamedll/dlls/bot/cs_bot_event.cpp index 9d6efbeb..45f575bb 100644 --- a/regamedll/dlls/bot/cs_bot_event.cpp +++ b/regamedll/dlls/bot/cs_bot_event.cpp @@ -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; diff --git a/regamedll/dlls/bot/cs_bot_init.cpp b/regamedll/dlls/bot/cs_bot_init.cpp index 85246d25..63a087c9 100644 --- a/regamedll/dlls/bot/cs_bot_init.cpp +++ b/regamedll/dlls/bot/cs_bot_init.cpp @@ -126,7 +126,7 @@ void Bot_RegisterCVars() } // Constructor -CCSBot::CCSBot() : m_chatter(this), m_gameState(this) +CCSBot::CCSBot() : m_gameState(this), m_chatter(this) { ; } diff --git a/regamedll/dlls/career_tasks.cpp b/regamedll/dlls/career_tasks.cpp index ff088479..f758e470 100644 --- a/regamedll/dlls/career_tasks.cpp +++ b/regamedll/dlls/career_tasks.cpp @@ -12,10 +12,9 @@ CCareerTask *CPreventDefuseTask::NewTask(const char *taskName, GameEventType eve return reinterpret_cast(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; } diff --git a/regamedll/dlls/career_tasks.h b/regamedll/dlls/career_tasks.h index 1daa2319..132a86be 100644 --- a/regamedll/dlls/career_tasks.h +++ b/regamedll/dlls/career_tasks.h @@ -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(); diff --git a/regamedll/dlls/hostage/hostage.cpp b/regamedll/dlls/hostage/hostage.cpp index 847f2b95..8276d295 100644 --- a/regamedll/dlls/hostage/hostage.cpp +++ b/regamedll/dlls/hostage/hostage.cpp @@ -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; diff --git a/regamedll/dlls/sound.cpp b/regamedll/dlls/sound.cpp index 1d535965..6c7379cd 100644 --- a/regamedll/dlls/sound.cpp +++ b/regamedll/dlls/sound.cpp @@ -918,72 +918,75 @@ void CEnvSound::Think() goto env_sound_Think_slow; } - CBasePlayer *pPlayer = GetClassPtr((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((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... diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index 35d98cc3..c38a85a1 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -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); diff --git a/regamedll/dlls/vehicle.cpp b/regamedll/dlls/vehicle.cpp index 6dadc17e..a40d6505 100644 --- a/regamedll/dlls/vehicle.cpp +++ b/regamedll/dlls/vehicle.cpp @@ -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); diff --git a/regamedll/dlls/weapontype.cpp b/regamedll/dlls/weapontype.cpp index fe912912..e59d46fb 100644 --- a/regamedll/dlls/weapontype.cpp +++ b/regamedll/dlls/weapontype.cpp @@ -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" }, diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp index f415547e..0d403934 100644 --- a/regamedll/pm_shared/pm_shared.cpp +++ b/regamedll/pm_shared/pm_shared.cpp @@ -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; } diff --git a/regamedll/regamedll/hookchains_impl.h b/regamedll/regamedll/hookchains_impl.h index f3a4a7af..922f8844 100644 --- a/regamedll/regamedll/hookchains_impl.h +++ b/regamedll/regamedll/hookchains_impl.h @@ -123,7 +123,7 @@ public: typedef t_ret(*hookfunc_t)(IHookChain*, 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__);