diff --git a/.gitignore b/.gitignore index 6675c671..970a5c83 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ **/msvc/*.user **/msvc/*.suo **/msvc/*.txt +**/msvc/*.amplxeproj **/msvc/ipch regamedll/version/appversion.h diff --git a/README.md b/README.md index 3c3108b9..858c8aba 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Regamedll_CS is a result of reverse engineering of original library mods HLDS (b * Provide more stable (than official) version of Counter-Strike game with extended API for mods and plugins ## How can use it? -Regamedll_CS is fully compatible with official mod CS 1.6 by Valve. All you have to do is to download binaries and replace original mo.dll/cs.so +Regamedll_CS is fully compatible with official mod CS 1.6 / CZero by Valve. All you have to do is to download binaries and replace original mp.dll/cs.so Compiled binaries are available here: [link](http://nexus.rehlds.org/nexus/content/repositories/regamedll-snapshots/regamedll/regamedll/0.2-SNAPSHOT/) @@ -22,20 +22,22 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure' | CVar | Default | Min | Max | Description | | :---------------------------- | :-----: | :-: | :----------: | :--------------------------------------------- | | mp_freeforall | 0 | 0 | 1 | The style of gameplay where there aren't any teams (FFA mode)
`0` disabled
`1` enabled | +| mp_autoteambalance | 1 | 0 | 2 | Auto balancing of teams
`0` disabled
`1` on after next round
`2` on next round | | mp_buytime | 1.5 | 0.0 | - | Designate the desired amount of buy time for each round. (in minutes)
`-1` means no time limit
`0` disable buy | | mp_maxmoney | 16000 | 0 | `0x7FFFFFFF` | The maximum allowable amount of money in the game | | mp_round_infinite | 0 | 0 | 1 | Flags for fine grained control (choose as many as needed)
`0` disabled
`1` enabled

or flags
`a` block round time round end check
`b` block needed players round end check
`c` block VIP assassination/success round end check
`d` block prison escape round end check
`e` block bomb round end check
`f` block team extermination round end check
`g` block hostage rescue round end check

`Example setting:` "ae" blocks round time and bomb round end checks | | mp_hegrenade_penetration | 0 | 0 | 1 | Disable grenade damage through walls
`0` disabled
`1` enabled | -| mp_nadedrops | 0 | 0 | 2 | Drop a grenade after player death
`0` disabled
`1` drop one the grenade
`2` drop a everyone grenades | +| mp_nadedrops | 0 | 0 | 2 | Drop a grenade after player death
`0` disabled
`1` drop one the grenade
`2` drop an everyone grenades | | mp_roundrespawn_time | 20 | 0 | - | Player cannot respawn until next round if more than N seconds has elapsed since the beginning round | | mp_auto_reload_weapons | 0 | 0 | 1 | Automatically reload each weapon on player spawn
`0` disabled
`1` enabled | -| mp_refill_bpammo_weapons | 0 | 0 | 2 | Refill amount of backpack ammo up to the max
`0` disabled
`1` refill backpack ammo on player spawn
`2` refill backpack ammo on each weapon reload | +| mp_refill_bpammo_weapons | 0 | 0 | 3 | Refill amount of backpack ammo up to the max
`0` disabled
`1` refill backpack ammo on player spawn
`2` refill backpack ammo on player spawn and on the purchase of the item
`3` refill backpack ammo on each weapon reload | | mp_auto_join_team | 0 | 0 | 1 | Automatically joins the team
`0` disabled
`1` enable (Use in conjunction with the cvar humans_join_team any/CT/T) | | mp_max_teamkills | 3 | 0 | - | Maximum number of allowed teamkills before autokick. Used when enabled mp_autokick. | | mp_fragsleft | - | - | - | Is the number of frags left, if you have set mp_fraglimit. You just type mp_fragsleft in server console, and it tells you the number of frags left depending of mp_fraglimit. | | mp_fraglimit | 0 | - | - | If set to something other than 0, when anybody’s scored reaches mp_fraglimit the server changes map.
`0` means no limit | | mp_timeleft | - | - | - | Is the number of time left before the map changes, if you have set mp_timelimit. You just type mp_timeleft in server console, and it tells you the number of time left depending of mp_timelimit. | | mp_timelimit | 0 | - | - | Period between map rotations.
`0` means no limit | +| mp_roundover | 0 | - | - | The round by expired time will be over, if on a map it does not have the scenario of the game.
`0` disabled
`1` enabled | | showtriggers | 0 | 0 | 1 | Debug cvar shows triggers. | | bot_deathmatch | 0 | 0 | 1 | Set's the mode for the zBot
`0` disabled
`1` enable mode Deathmatch and not allow to do the scenario | diff --git a/dist/game.cfg b/dist/game.cfg index 0331fda4..97946788 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -8,6 +8,14 @@ echo Executing ReGameDLL Configuration File // Default value: "0" mp_freeforall 0 +// Auto balancing of teams +// 0 - disabled +// 1 - on after next round (default behaviour) +// 2 - on next round +// +// Default value: "1" +mp_autoteambalance 1 + // Designate the desired amount of buy time for each round. (in minutes) // -1 - means no time limit // 0 - disable buy @@ -37,6 +45,12 @@ mp_maxmoney 16000 // Default value: "0" mp_round_infinite 0 +// The round by expired time will be over, if on a map it does not have the scenario of the game. +// 0 - disabled (default behaviour) +// 1 - enabled +// Default value: "0" +mp_roundover 0 + // Disable grenade damage through walls // 0 - disabled // 1 - enabled @@ -46,7 +60,7 @@ mp_hegrenade_penetration 0 // Drop a grenade after player death // 0 - disabled // 1 - drop one the grenade -// 2 - drop a everyone grenades +// 2 - drop an everyone grenades // Default value: "0" mp_nadedrops 0 @@ -66,7 +80,8 @@ mp_auto_reload_weapons "0" // Refill amount of backpack ammo up to the max // 0 - disabled (default behaviour) // 1 - refill backpack ammo on player spawn -// 2 - refill backpack ammo on each weapon reload (NOTE: Useful for mods like DeathMatch, GunGame, ZombieMod etc.) +// 2 - refill backpack ammo on player spawn and on the purchase of the item +// 3 - refill backpack ammo on each weapon reload (NOTE: Useful for mods like DeathMatch, GunGame, ZombieMod etc.) // // Default value: "0" mp_refill_bpammo_weapons 0 diff --git a/regamedll/common/const.h b/regamedll/common/const.h index 49e32c12..df828e7f 100644 --- a/regamedll/common/const.h +++ b/regamedll/common/const.h @@ -122,7 +122,7 @@ #define DEAD_NO 0 // alive #define DEAD_DYING 1 // playing death animation or still falling off of a ledge waiting to hit ground #define DEAD_DEAD 2 // dead. lying still. -#define DEAD_RESPAWNABLE 3 +#define DEAD_RESPAWNABLE 3 // do respawn the entity #define DEAD_DISCARDBODY 4 #define DAMAGE_NO 0 diff --git a/regamedll/dlls/ammo.cpp b/regamedll/dlls/ammo.cpp index 2276a084..63a1befa 100644 --- a/regamedll/dlls/ammo.cpp +++ b/regamedll/dlls/ammo.cpp @@ -15,7 +15,7 @@ void C9MMAmmo::__MAKE_VHOOK(Precache)() BOOL C9MMAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_9MM_BUY, "9mm", MAX_AMMO_9MM) == -1) + if (pOther->GiveAmmo(AMMO_9MM_BUY, "9mm") == -1) { return FALSE; } @@ -41,7 +41,7 @@ void CBuckShotAmmo::__MAKE_VHOOK(Precache)() BOOL CBuckShotAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_BUCKSHOT_BUY, "buckshot", MAX_AMMO_BUCKSHOT) == -1) + if (pOther->GiveAmmo(AMMO_BUCKSHOT_BUY, "buckshot") == -1) { return FALSE; } @@ -67,7 +67,7 @@ void C556NatoAmmo::__MAKE_VHOOK(Precache)() BOOL C556NatoAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_556NATO_BUY, "556Nato", MAX_AMMO_556NATO) == -1) + if (pOther->GiveAmmo(AMMO_556NATO_BUY, "556Nato") == -1) { return FALSE; } @@ -93,7 +93,7 @@ void C556NatoBoxAmmo::__MAKE_VHOOK(Precache)() BOOL C556NatoBoxAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_556NATOBOX_BUY, "556NatoBox", MAX_AMMO_556NATOBOX) == -1) + if (pOther->GiveAmmo(AMMO_556NATOBOX_BUY, "556NatoBox") == -1) { return FALSE; } @@ -119,7 +119,7 @@ void C762NatoAmmo::__MAKE_VHOOK(Precache)() BOOL C762NatoAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_762NATO_BUY, "762Nato", MAX_AMMO_762NATO) == -1) + if (pOther->GiveAmmo(AMMO_762NATO_BUY, "762Nato") == -1) { return FALSE; } @@ -145,7 +145,7 @@ void C45ACPAmmo::__MAKE_VHOOK(Precache)() BOOL C45ACPAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_45ACP_BUY, "45acp", MAX_AMMO_45ACP) == -1) + if (pOther->GiveAmmo(AMMO_45ACP_BUY, "45acp") == -1) { return FALSE; } @@ -171,7 +171,7 @@ void C50AEAmmo::__MAKE_VHOOK(Precache)() BOOL C50AEAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_50AE_BUY, "50AE", MAX_AMMO_50AE) == -1) + if (pOther->GiveAmmo(AMMO_50AE_BUY, "50AE") == -1) { return FALSE; } @@ -197,7 +197,7 @@ void C338MagnumAmmo::__MAKE_VHOOK(Precache)() BOOL C338MagnumAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_338MAG_BUY, "338Magnum", MAX_AMMO_338MAGNUM) == -1) + if (pOther->GiveAmmo(AMMO_338MAG_BUY, "338Magnum") == -1) { return FALSE; } @@ -223,7 +223,7 @@ void C57MMAmmo::__MAKE_VHOOK(Precache)() BOOL C57MMAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_57MM_BUY, "57mm", MAX_AMMO_57MM) == -1) + if (pOther->GiveAmmo(AMMO_57MM_BUY, "57mm") == -1) { return FALSE; } @@ -249,7 +249,7 @@ void C357SIGAmmo::__MAKE_VHOOK(Precache)() BOOL C357SIGAmmo::__MAKE_VHOOK(AddAmmo)(CBaseEntity *pOther) { - if (pOther->GiveAmmo(AMMO_357SIG_BUY, "357SIG", MAX_AMMO_357SIG) == -1) + if (pOther->GiveAmmo(AMMO_357SIG_BUY, "357SIG") == -1) { return FALSE; } diff --git a/regamedll/dlls/bot/cs_bot.cpp b/regamedll/dlls/bot/cs_bot.cpp index 6b5e136e..e2e5b3c6 100644 --- a/regamedll/dlls/bot/cs_bot.cpp +++ b/regamedll/dlls/bot/cs_bot.cpp @@ -588,13 +588,13 @@ void CCSBot::UpdateHostageEscortCount() m_hostageEscortCount = 0; CHostage *hostage = NULL; - while ((hostage = static_cast(UTIL_FindEntityByClassname(hostage, "hostage_entity"))) != NULL) + while ((hostage = static_cast(UTIL_FindEntityByClassname(hostage, "hostage_entity")))) { if (FNullEnt(hostage->edict())) break; // skip dead or rescued hostages - if (!hostage->IsValid()) + if (!hostage->IsAlive()) continue; // check if hostage has targeted us, and is following diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp index f21cfd3e..e7cd2e7e 100644 --- a/regamedll/dlls/bot/cs_bot_manager.cpp +++ b/regamedll/dlls/bot/cs_bot_manager.cpp @@ -102,8 +102,7 @@ void CCSBotManager::__MAKE_VHOOK(RestartRound)() ResetRadioMessageTimestamps(); m_lastSeenEnemyTimestamp = -9999.9f; - - m_roundStartTimestamp = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime"); + m_roundStartTimestamp = gpGlobals->time + freezetime.value; // randomly decide if defensive team wants to "rush" as a whole const float defenseRushChance = 33.3f; // 25.0f; diff --git a/regamedll/dlls/bot/cs_gamestate.cpp b/regamedll/dlls/bot/cs_gamestate.cpp index db1956f8..ed2b656e 100644 --- a/regamedll/dlls/bot/cs_gamestate.cpp +++ b/regamedll/dlls/bot/cs_gamestate.cpp @@ -293,12 +293,12 @@ void CSGameState::InitializeHostageInfo() m_haveSomeHostagesBeenTaken = false; CBaseEntity *hostage = NULL; - while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity")) != NULL) + while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { if (m_hostageCount >= MAX_HOSTAGES) break; - if (hostage->pev->takedamage != DAMAGE_YES) + if (!hostage->IsAlive()) continue; m_hostage[m_hostageCount].hostage = static_cast(hostage); @@ -338,7 +338,7 @@ CHostage *CSGameState::GetNearestFreeHostage(Vector *knowPos) const if (m_owner->m_iTeam == CT) { // we know exactly where the hostages are, and if they are alive - if (!m_hostage[i].hostage || !m_hostage[i].hostage->IsValid()) + if (!m_hostage[i].hostage || !m_hostage[i].hostage->IsAlive()) continue; if (m_hostage[i].hostage->IsFollowingSomeone()) @@ -457,7 +457,7 @@ CSGameState::ValidateStatusType CSGameState::ValidateHostagePositions() // if we can see a hostage, update our knowledge of it if (m_owner->IsVisible(&info->hostage->pev->origin, CHECK_FOV)) { - if (info->hostage->pev->takedamage == DAMAGE_YES) + if (info->hostage->IsAlive()) { // live hostage // if hostage is being escorted by a CT, we don't "see" it, we see the CT @@ -494,7 +494,7 @@ CSGameState::ValidateStatusType CSGameState::ValidateHostagePositions() if (m_owner->IsVisible(&info->knownPos, CHECK_FOV)) { // we can see where we thought the hostage was - verify it is still there and alive - if (info->hostage->pev->takedamage != DAMAGE_YES) + if (!info->hostage->IsAlive()) { // since we have line of sight to an invalid hostage, it must be dead // discovered that hostage has been killed @@ -559,7 +559,7 @@ CHostage *CSGameState::GetNearestVisibleFreeHostage() const continue; // if the hostage is dead or rescued, its not free - if (info->hostage->pev->takedamage != DAMAGE_YES) + if (!info->hostage->IsAlive()) continue; // if this hostage is following someone, its not free @@ -591,7 +591,6 @@ bool CSGameState::AreAllHostagesBeingRescued() const return false; bool isAllDead = true; - for (int i = 0; i < m_hostageCount; ++i) { const HostageInfo *info = &m_hostage[i]; @@ -599,7 +598,7 @@ bool CSGameState::AreAllHostagesBeingRescued() const if (m_owner->m_iTeam == CT) { // CT's have perfect knowledge via their radar - if (info->hostage != NULL && info->hostage->IsValid()) + if (info->hostage && info->hostage->IsAlive()) { if (!info->hostage->IsFollowingSomeone()) return false; @@ -638,7 +637,7 @@ bool CSGameState::AreAllHostagesGone() const if (m_owner->m_iTeam == CT) { // CT's have perfect knowledge via their radar - if (info->hostage->IsAlive())// == DAMAGE_YES) + if (info->hostage->IsAlive()) return false; } else diff --git a/regamedll/dlls/bot/states/cs_bot_move_to.cpp b/regamedll/dlls/bot/states/cs_bot_move_to.cpp index efe3eb27..e13643f0 100644 --- a/regamedll/dlls/bot/states/cs_bot_move_to.cpp +++ b/regamedll/dlls/bot/states/cs_bot_move_to.cpp @@ -172,7 +172,7 @@ void MoveToState::__MAKE_VHOOK(OnUpdate)(CCSBot *me) // Since CT's have a radar, they can directly look at the actual hostage state // check if someone else collected our hostage, or the hostage died or was rescued CHostage *hostage = static_cast(me->GetGoalEntity()); - if (hostage == NULL || !hostage->IsValid() || hostage->IsFollowingSomeone()) + if (!hostage || !hostage->IsAlive() || hostage->IsFollowingSomeone()) { me->Idle(); return; diff --git a/regamedll/dlls/career_tasks.cpp b/regamedll/dlls/career_tasks.cpp index 00911ee1..f4c8a5f3 100644 --- a/regamedll/dlls/career_tasks.cpp +++ b/regamedll/dlls/career_tasks.cpp @@ -162,19 +162,17 @@ void CCareerTask::OnWeaponKill(int weaponId, int weaponClassId, bool headshot, b if (m_rescuer) { int hostages_ = 0; - CBaseEntity *hostageEntity = NULL; + CHostage *hostageEntity = NULL; - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) + while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) { - if (hostageEntity->pev->takedamage != DAMAGE_YES) + if (!hostageEntity->IsAlive()) continue; - CHostage *hostage = static_cast(hostageEntity); - - if (!hostage->IsFollowingSomeone()) + if (!hostageEntity->IsFollowingSomeone()) continue; - if (hostage->IsValid() && hostage->m_target == pVictim) + if (hostageEntity->m_target == pVictim) ++hostages_; } @@ -182,22 +180,22 @@ void CCareerTask::OnWeaponKill(int weaponId, int weaponClassId, bool headshot, b return; } - if (m_weaponId == WEAPON_SHIELDGUN) - { - if (!killerHasShield) - return; - } - else if (m_weaponId) - { - if (m_weaponId != weaponId) - return; - } - else - { - if (!m_weaponClassId || m_weaponClassId != weaponClassId) - return; - } - + if (m_weaponId == WEAPON_SHIELDGUN) + { + if (!killerHasShield) + return; + } + else if (m_weaponId) + { + if (m_weaponId != weaponId) + return; + } + else + { + if (!m_weaponClassId || m_weaponClassId != weaponClassId) + return; + } + ++m_eventsSeen; SendPartialNotification(); } @@ -240,19 +238,17 @@ void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVicti if (m_rescuer) { int hostages_ = 0; - CBaseEntity *hostageEntity = NULL; + CHostage *hostageEntity = NULL; - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) + while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) { - if (hostageEntity->pev->takedamage != DAMAGE_YES) + if (!hostageEntity->IsAlive()) continue; - CHostage *hostage = static_cast(hostageEntity); - - if (!hostage->IsFollowingSomeone()) + if (!hostageEntity->IsFollowingSomeone()) continue; - if (hostage->IsValid() && hostage->m_target == pAttacker) + if (hostageEntity->m_target == pAttacker) ++hostages_; } @@ -271,11 +267,11 @@ void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVicti if (!Q_strcmp(m_name, "defendhostages")) { int hostages_ = 0; - CBaseEntity *hostageEntity = NULL; + CHostage *hostageEntity = NULL; - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) + while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) { - if (hostageEntity->pev->takedamage != 1.0f && hostageEntity->pev->deadflag != DEAD_DEAD) + if (hostageEntity->pev->takedamage != DAMAGE_YES && hostageEntity->pev->deadflag != DEAD_DEAD) ++hostages_; } @@ -288,13 +284,11 @@ void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVicti else if (!Q_strcmp(m_name, "hostagessurvive")) { int hostages_ = 0; - CBaseEntity *hostageEntity = NULL; + CHostage *hostageEntity = NULL; - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) + while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) { - CHostage *hostage = (CHostage *)hostageEntity; - - if (hostage && hostage->IsDead()) + if (hostageEntity && hostageEntity->IsDead()) ++hostages_; } @@ -337,7 +331,7 @@ void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVicti WRITE_BYTE(m_id); MESSAGE_END(); - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_CAREER_TASK_DONE); } @@ -382,7 +376,7 @@ void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVicti UTIL_GetLocalPlayer()->SyncRoundTimer(); } - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_CAREER_TASK_DONE); } @@ -401,7 +395,7 @@ void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVicti void CCareerTaskManager::Create() { - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->Reset(); return; @@ -420,26 +414,23 @@ void CCareerTaskManager::Reset(bool deleteTasks) { if (deleteTasks) { - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - delete (*it); + for (auto task : m_tasks) + delete task; m_tasks.clear(); m_nextId = 0; } else { - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - CCareerTask *pTask = (*it); - pTask->Reset(); - } + for (auto task : m_tasks) + task->Reset(); } m_finishedTaskTime = 0; m_finishedTaskRound = 0; m_shouldLatchRoundEndMessage = false; - m_roundStartTime = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime"); + m_roundStartTime = gpGlobals->time + freezetime.value; } void CCareerTaskManager::SetFinishedTaskTime(int val) @@ -456,7 +447,7 @@ void CCareerTaskManager::AddTask(const char *taskName, const char *weaponName, i { const TaskInfo *pTaskInfo = &taskInfo[ i ]; - if (pTaskInfo->taskName != NULL) + if (pTaskInfo->taskName) { if (!Q_stricmp(pTaskInfo->taskName, taskName)) { @@ -509,17 +500,15 @@ void CCareerTaskManager::HandleEvent(GameEventType event, CBasePlayer *pAttacker return; } - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - (*it)->OnEvent(event, pAttacker, pVictim); + for (auto task : m_tasks) { + task->OnEvent(event, pAttacker, pVictim); } } void CCareerTaskManager::HandleWeaponKill(int weaponId, int weaponClassId, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim) { - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - (*it)->OnWeaponKill(weaponId, weaponClassId, headshot, killerHasShield, pAttacker, pVictim); + for (auto task : m_tasks) { + task->OnWeaponKill(weaponId, weaponClassId, headshot, killerHasShield, pAttacker, pVictim); } } @@ -540,9 +529,8 @@ void CCareerTaskManager::HandleEnemyKill(bool wasBlind, const char *weaponName, void CCareerTaskManager::HandleWeaponInjury(int weaponId, int weaponClassId, bool attackerHasShield, CBasePlayer *pAttacker) { - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - (*it)->OnWeaponInjury(weaponId, weaponClassId, attackerHasShield, pAttacker); + for (auto task : m_tasks) { + task->OnWeaponInjury(weaponId, weaponClassId, attackerHasShield, pAttacker); } } @@ -563,7 +551,6 @@ void CCareerTaskManager::HandleDeath(int team, CBasePlayer *pAttacker) for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer && pPlayer->m_iTeam == enemyTeam && pPlayer->IsAlive()) ++numEnemies; } @@ -576,9 +563,8 @@ void CCareerTaskManager::HandleDeath(int team, CBasePlayer *pAttacker) bool CCareerTaskManager::AreAllTasksComplete() { - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - if (!(*it)->IsComplete()) + for (auto task : m_tasks) { + if (!task->IsComplete()) return false; } @@ -587,14 +573,13 @@ bool CCareerTaskManager::AreAllTasksComplete() int CCareerTaskManager::GetNumRemainingTasks() { - int ret = 0; - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - if (!(*it)->IsComplete()) - ++ret; + int nCount = 0; + for (auto task : m_tasks) { + if (task->IsComplete()) + ++nCount; } - return ret; + return nCount; } float CCareerTaskManager::GetRoundElapsedTime() diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index 7795c16f..64b4a2c3 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -5,7 +5,7 @@ */ #ifndef HOOK_GAMEDLL -static DLL_FUNCTIONS gFunctionTable = +DLL_FUNCTIONS gFunctionTable = { &GameDLLInit, &DispatchSpawn, @@ -59,7 +59,7 @@ static DLL_FUNCTIONS gFunctionTable = &AllowLagCompensation }; -static NEW_DLL_FUNCTIONS gNewDLLFunctions = +NEW_DLL_FUNCTIONS gNewDLLFunctions = { &OnFreeEntPrivateData, NULL, @@ -79,7 +79,6 @@ TYPEDESCRIPTION CBaseEntity::m_SaveData[] = }; CMemoryPool hashItemMemPool(sizeof(hash_item_t), 64); -BOOL gTouchDisabled = FALSE; #endif // HOOK_GAMEDLL @@ -300,7 +299,7 @@ void REMOVE_ENTITY(edict_t *pEntity) { if (pEntity) { - (*g_engfuncs.pfnRemoveEntity)(pEntity); + g_engfuncs.pfnRemoveEntity(pEntity); } } @@ -329,16 +328,16 @@ void loopPerformance() for (i = 0; i < 100; ++i) { CBaseEntity *pSpot; - for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "info_player_start"); pSpot != NULL; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "info_player_start")) + for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "info_player_start"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "info_player_start")) ; - for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "info_player_deathmatch"); pSpot != NULL; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "info_player_deathmatch")) + for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "info_player_deathmatch"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "info_player_deathmatch")) ; - for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "player"); pSpot != NULL; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "player")) + for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "player"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "player")) ; - for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "bodyque"); pSpot != NULL; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "bodyque")) + for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "bodyque"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "bodyque")) ; } @@ -351,16 +350,16 @@ void loopPerformance() for (i = 0; i < 100; ++i) { CBaseEntity *pSpot; - for (pSpot = UTIL_FindEntityByString(NULL, "classname", "info_player_start"); pSpot != NULL; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_start")) + for (pSpot = UTIL_FindEntityByString(NULL, "classname", "info_player_start"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_start")) ; - for (pSpot = UTIL_FindEntityByString(NULL, "classname", "info_player_deathmatch"); pSpot != NULL; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_deathmatch")) + for (pSpot = UTIL_FindEntityByString(NULL, "classname", "info_player_deathmatch"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_deathmatch")) ; - for (pSpot = UTIL_FindEntityByString(NULL, "classname", "player"); pSpot != NULL; pSpot = UTIL_FindEntityByString(pSpot, "classname", "player")) + for (pSpot = UTIL_FindEntityByString(NULL, "classname", "player"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "player")) ; - for (pSpot = UTIL_FindEntityByString(NULL, "classname", "bodyque"); pSpot != NULL; pSpot = UTIL_FindEntityByString(pSpot, "classname", "bodyque")) + for (pSpot = UTIL_FindEntityByString(NULL, "classname", "bodyque"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "bodyque")) ; } @@ -482,7 +481,6 @@ void EXT_FUNC DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) // Get the actualy entity object CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentKeyvalue); - if (!pEntity) return; @@ -493,9 +491,6 @@ void EXT_FUNC DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) // while it builds the graph void EXT_FUNC DispatchTouch(edict_t *pentTouched, edict_t *pentOther) { - if (gTouchDisabled) - return; - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentTouched); CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); @@ -712,7 +707,6 @@ int EXT_FUNC DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int glob void EXT_FUNC DispatchObjectCollsionBox(edict_t *pent) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - if (pEntity) { pEntity->SetObjectCollisionBox(); @@ -865,7 +859,6 @@ CBaseEntity *CBaseEntity::__MAKE_VHOOK(GetNextTarget)() return NULL; edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target)); - if (FNullEnt(pTarget)) { return NULL; @@ -886,10 +879,7 @@ int CBaseEntity::__MAKE_VHOOK(Save)(CSave &save) int CBaseEntity::__MAKE_VHOOK(Restore)(CRestore &restore) { - int status; - - status = restore.ReadEntVars("ENTVARS", pev); - + int status = restore.ReadEntVars("ENTVARS", pev); if (status) { status = restore.ReadFields("BASE", this, IMPL(m_SaveData), ARRAYSIZE(IMPL(m_SaveData))); @@ -978,18 +968,10 @@ int CBaseEntity::Intersects(CBaseEntity *pOther) void CBaseEntity::MakeDormant() { pev->flags |= FL_DORMANT; - - // Don't touch - pev->solid = SOLID_NOT; - - // Don't move - pev->movetype = MOVETYPE_NONE; - - // Don't draw - pev->effects |= EF_NODRAW; - - // Don't think - pev->nextthink = 0; + pev->solid = SOLID_NOT; // Don't touch + pev->movetype = MOVETYPE_NONE; // Don't move + pev->effects |= EF_NODRAW; // Don't draw + pev->nextthink = 0; // Don't think // Relink UTIL_SetOrigin(pev, pev->origin); @@ -1069,7 +1051,7 @@ CBaseEntity *CBaseEntity::Create(char *szName, const Vector &vecOrigin, const Ve return pEntity; } -void OnFreeEntPrivateData(edict_t *pEnt) +void EXT_FUNC OnFreeEntPrivateData(edict_t *pEnt) { CBaseEntity *pEntity = CBaseEntity::Instance(pEnt); if (!pEntity) diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index 9f678661..db7066fa 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -252,7 +252,7 @@ public: virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) {} virtual BOOL AddPlayerItem(CBasePlayerItem *pItem) { return FALSE; } virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) { return FALSE; } - virtual int GiveAmmo(int iAmount, char *szName, int iMax) { return -1; } + virtual int GiveAmmo(int iAmount, char *szName, int iMax = -1) { return -1; } virtual float GetDelay() { return 0.0f; } virtual int IsMoving() { return (pev->velocity != g_vecZero); } virtual void OverrideReset() {} @@ -341,9 +341,17 @@ public: BOOL IsLockedByMaster() { return FALSE; } public: - static CBaseEntity *Instance(edict_t *pent) { return (CBaseEntity *)GET_PRIVATE(pent ? pent : ENT(0)); } + static CBaseEntity *Instance(edict_t *pent) + { + if (!pent) + pent = ENT(0); + + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); + return pEntity; + } + static CBaseEntity *Instance(entvars_t *pev) { return Instance(ENT(pev)); } - static CBaseEntity *Instance(int offset) { return Instance(ENT(offset)); } + static CBaseEntity *Instance(EOFFSET offset) { return Instance(ENT(offset)); } CBaseMonster *GetMonsterPointer(entvars_t *pevMonster) { @@ -698,13 +706,13 @@ T *GetClassPtr(T *a) entvars_t *pev = (entvars_t *)a; // allocate entity if necessary - if (pev == NULL) + if (pev == nullptr) pev = VARS(CREATE_ENTITY()); // get the private data a = (T *)GET_PRIVATE(ENT(pev)); - if (!a) + if (a == nullptr) { // allocate private data a = new(pev) T; diff --git a/regamedll/dlls/cdll_dll.h b/regamedll/dlls/cdll_dll.h index 678b056d..1a37e0d3 100644 --- a/regamedll/dlls/cdll_dll.h +++ b/regamedll/dlls/cdll_dll.h @@ -39,13 +39,14 @@ #define DEFAULT_FOV 90 // the default field of view -#define HIDEHUD_WEAPONS (1 << 0) -#define HIDEHUD_FLASHLIGHT (1 << 1) -#define HIDEHUD_ALL (1 << 2) -#define HIDEHUD_HEALTH (1 << 3) -#define HIDEHUD_TIMER (1 << 4) -#define HIDEHUD_MONEY (1 << 5) -#define HIDEHUD_CROSSHAIR (1 << 6) +#define HIDEHUD_WEAPONS (1<<0) +#define HIDEHUD_FLASHLIGHT (1<<1) +#define HIDEHUD_ALL (1<<2) +#define HIDEHUD_HEALTH (1<<3) +#define HIDEHUD_TIMER (1<<4) +#define HIDEHUD_MONEY (1<<5) +#define HIDEHUD_CROSSHAIR (1<<6) +#define HIDEHUD_OBSERVER_CROSSHAIR (1<<7) #define STATUSICON_HIDE 0 #define STATUSICON_SHOW 1 @@ -73,10 +74,11 @@ #define SIGNAL_ESCAPE (1<<3) #define SIGNAL_VIPSAFETY (1<<4) -#define DATA_IUSER3_CANSHOOT (1<<0) -#define DATA_IUSER3_FREEZETIMEOVER (1<<1) -#define DATA_IUSER3_INBOMBZONE (1<<2) -#define DATA_IUSER3_HOLDINGSHIELD (1<<3) +// player data iuser3 +#define PLAYER_CAN_SHOOT (1<<0) +#define PLAYER_FREEZE_TIME_OVER (1<<1) +#define PLAYER_IN_BOMB_ZONE (1<<2) +#define PLAYER_HOLDING_SHIELD (1<<3) #define MENU_KEY_1 (1<<0) #define MENU_KEY_2 (1<<1) @@ -104,15 +106,15 @@ enum VGUIMenu { VGUI_Menu_Team = 2, VGUI_Menu_MapBriefing = 4, - - VGUI_Menu_Class_T = 26, - VGUI_Menu_Class_CT, - VGUI_Menu_Buy, - VGUI_Menu_Buy_Pistol, - VGUI_Menu_Buy_ShotGun, - VGUI_Menu_Buy_Rifle, - VGUI_Menu_Buy_SubMachineGun, - VGUI_Menu_Buy_MachineGun, + + VGUI_Menu_Class_T = 26, + VGUI_Menu_Class_CT, + VGUI_Menu_Buy, + VGUI_Menu_Buy_Pistol, + VGUI_Menu_Buy_ShotGun, + VGUI_Menu_Buy_Rifle, + VGUI_Menu_Buy_SubMachineGun, + VGUI_Menu_Buy_MachineGun, VGUI_Menu_Buy_Item, }; diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index aa2628a4..b2088844 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -113,7 +113,7 @@ void EXT_FUNC ClientDisconnect(edict_t *pEntity) { CBasePlayer *pPlayer = CBasePlayer::Instance(pEntity); - if (!g_fGameOver) + if (!g_pGameRules->IsGameOver()) { UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_disconnected", STRING(pEntity->v.netname)); #ifndef REGAMEDLL_FIXES @@ -198,7 +198,7 @@ void EXT_FUNC ClientKill(edict_t *pEntity) LINK_HOOK_VOID_CHAIN(ShowMenu, (CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText), pPlayer, bitsValidSlots, nDisplayTime, fNeedMore, pszText); -void __API_HOOK(ShowMenu)(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText) +void EXT_FUNC __API_HOOK(ShowMenu)(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText) { MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pPlayer->pev); WRITE_SHORT(bitsValidSlots); @@ -210,7 +210,7 @@ void __API_HOOK(ShowMenu)(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplay LINK_HOOK_VOID_CHAIN(ShowVGUIMenu, (CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu), pPlayer, MenuType, BitMask, szOldMenu); -void __API_HOOK(ShowVGUIMenu)(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu) +void EXT_FUNC __API_HOOK(ShowVGUIMenu)(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu) { #ifdef REGAMEDLL_ADD if (CSGameRules()->ShouldSkipShowMenu()) { @@ -245,7 +245,7 @@ NOXREF int CountTeams() int iNumCT = 0, iNumTerrorist = 0; CBaseEntity *pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -276,7 +276,7 @@ void ListPlayers(CBasePlayer *current) char message[120] = "", cNumber[12]; CBaseEntity *pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -304,7 +304,7 @@ int CountTeamPlayers(int iTeam) CBaseEntity *pPlayer = NULL; int i = 0; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -340,7 +340,7 @@ void ProcessKickVote(CBasePlayer *pVotingPlayer, CBasePlayer *pKickPlayer) pTempEntity = NULL; iVoteID = pVotingPlayer->m_iCurrentKickVote; - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { if (FNullEnt(pTempEntity->edict())) break; @@ -369,7 +369,7 @@ void ProcessKickVote(CBasePlayer *pVotingPlayer, CBasePlayer *pKickPlayer) SERVER_COMMAND(UTIL_VarArgs("kick # %d\n", iVoteID)); pTempEntity = NULL; - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { if (FNullEnt(pTempEntity->edict())) break; @@ -466,16 +466,19 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity) pPlayer->SetThink(NULL); - CBaseEntity *pTarget = UTIL_FindEntityByClassname(NULL, "trigger_camera"); - pPlayer->m_pIntroCamera = pTarget; + CBaseEntity *pTarget = NULL; + pPlayer->m_pIntroCamera = UTIL_FindEntityByClassname(NULL, "trigger_camera"); - if (CSGameRules() && CSGameRules()->m_bMapHasCameras == MAP_HAS_CAMERAS_INIT) + if (g_pGameRules && g_pGameRules->IsMultiplayer()) { - CSGameRules()->m_bMapHasCameras = (pTarget != NULL); + CSGameRules()->m_bMapHasCameras = (pPlayer->m_pIntroCamera != NULL); } if (pPlayer->m_pIntroCamera) + { + // find the target (by default info_target) for the camera view direction. pTarget = UTIL_FindEntityByTargetname(NULL, STRING(pPlayer->m_pIntroCamera->pev->target)); + } if (pPlayer->m_pIntroCamera && pTarget) { @@ -495,7 +498,7 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity) { pPlayer->m_iTeam = CT; - if (g_pGameRules != NULL) + if (g_pGameRules) { g_pGameRules->GetPlayerSpawnSpot(pPlayer); } @@ -506,7 +509,7 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity) } #endif - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, (CBaseEntity *)pPlayer); } @@ -639,7 +642,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) pszFormat = "#Cstrike_Chat_CT_Dead"; pszConsoleFormat = "*DEAD*(Counter-Terrorist) %s : %s"; } - else if (placeName != NULL) + else if (placeName) { pszFormat = "#Cstrike_Chat_CT_Loc"; pszConsoleFormat = "*(Counter-Terrorist) %s @ %s : %s"; @@ -658,7 +661,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) pszFormat = "#Cstrike_Chat_T_Dead"; pszConsoleFormat = "*DEAD*(Terrorist) %s : %s"; } - else if (placeName != NULL) + else if (placeName) { pszFormat = "#Cstrike_Chat_T_Loc"; pszConsoleFormat = "(Terrorist) %s @ %s : %s"; @@ -704,7 +707,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) // -3 for /n and null terminator j = sizeof(text) - 3 - Q_strlen(text) - Q_strlen(pszFormat); - if (placeName != NULL) + if (placeName) { j -= Q_strlen(placeName) + 1; } @@ -712,7 +715,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) if ((signed int)Q_strlen(p) > j) p[j] = 0; - for (char *pAmpersand = p; pAmpersand != NULL && *pAmpersand != '\0'; pAmpersand++) + for (char *pAmpersand = p; pAmpersand && *pAmpersand != '\0'; pAmpersand++) { if (pAmpersand[0] == '%') { @@ -732,7 +735,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) // so check it, or it will infinite loop client = NULL; - while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player")) != NULL) + while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player"))) { if (FNullEnt(client->edict())) break; @@ -769,7 +772,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) WRITE_STRING(""); WRITE_STRING(text); - if (placeName != NULL) + if (placeName) { WRITE_STRING(placeName); } @@ -787,7 +790,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) WRITE_STRING(""); WRITE_STRING(text); - if (placeName != NULL) + if (placeName) { WRITE_STRING(placeName); } @@ -805,7 +808,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) else SERVER_PRINT(text); - if (CVAR_GET_FLOAT("mp_logmessages") != 0) + if (logmessages.value) { const char *temp = teamonly ? "say_team" : "say"; const char *deadText = (player->m_iTeam != SPECTATOR && bSenderDead) ? " (dead)" : ""; @@ -825,10 +828,10 @@ bool CanBuyThis(CBasePlayer *pPlayer, int iWeapon) if (pPlayer->HasShield() && iWeapon == WEAPON_SHIELDGUN) return false; - if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == WEAPON_ELITE && iWeapon == WEAPON_SHIELDGUN) + if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == WEAPON_ELITE && iWeapon == WEAPON_SHIELDGUN) return false; - if (pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]->m_iId == iWeapon) + if (pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ] && pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]->m_iId == iWeapon) { if (g_bClientPrintEnable) { @@ -838,7 +841,7 @@ bool CanBuyThis(CBasePlayer *pPlayer, int iWeapon) return false; } - if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == iWeapon) + if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == iWeapon) { if (g_bClientPrintEnable) { @@ -848,7 +851,7 @@ bool CanBuyThis(CBasePlayer *pPlayer, int iWeapon) return false; } - if (!CanBuyWeaponByMaptype(pPlayer->m_iTeam, (WeaponIdType)iWeapon, (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES))) + if (!CanBuyWeaponByMaptype(pPlayer->m_iTeam, (WeaponIdType)iWeapon, CSGameRules()->m_bMapHasVIPSafetyZone == TRUE)) { if (g_bClientPrintEnable) { @@ -1093,7 +1096,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot) if (pPlayer->HasRestrictItem(ITEM_FLASHBANG, ITEM_TYPE_BUYING)) return; #endif - if (pPlayer->AmmoInventory(pPlayer->GetAmmoIndex("Flashbang")) >= MaxAmmoCarry("Flashbang")) + if (pPlayer->AmmoInventory(AMMO_FLASHBANG) >= MaxAmmoCarry(WEAPON_FLASHBANG)) { if (g_bClientPrintEnable) { @@ -1118,7 +1121,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot) if (pPlayer->HasRestrictItem(ITEM_HEGRENADE, ITEM_TYPE_BUYING)) return; #endif - if (pPlayer->AmmoInventory(pPlayer->GetAmmoIndex("HEGrenade")) >= MaxAmmoCarry("HEGrenade")) + if (pPlayer->AmmoInventory(AMMO_HEGRENADE) >= MaxAmmoCarry(WEAPON_HEGRENADE)) { if (g_bClientPrintEnable) { @@ -1142,7 +1145,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot) if (pPlayer->HasRestrictItem(ITEM_SMOKEGRENADE, ITEM_TYPE_BUYING)) return; #endif - if (pPlayer->AmmoInventory(pPlayer->GetAmmoIndex("SmokeGrenade")) >= MaxAmmoCarry("SmokeGrenade")) + if (pPlayer->AmmoInventory(AMMO_SMOKEGRENADE) >= MaxAmmoCarry(WEAPON_SMOKEGRENADE)) { if (g_bClientPrintEnable) { @@ -1268,34 +1271,36 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot) return; } - if (pszItem != NULL) + if (pszItem) { pPlayer->GiveNamedItem(pszItem); pPlayer->AddAccount(-iItemPrice, RT_PLAYER_BOUGHT_SOMETHING); } - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); } } -void BuyWeaponByWeaponID(CBasePlayer *pPlayer, WeaponIdType weaponID) +LINK_HOOK_CHAIN(CBaseEntity *, BuyWeaponByWeaponID, (CBasePlayer *pPlayer, WeaponIdType weaponID), pPlayer, weaponID); + +CBaseEntity *EXT_FUNC __API_HOOK(BuyWeaponByWeaponID)(CBasePlayer *pPlayer, WeaponIdType weaponID) { if (!pPlayer->CanPlayerBuy(true)) - return; + return nullptr; #ifdef REGAMEDLL_ADD if (pPlayer->HasRestrictItem((ItemID)weaponID, ITEM_TYPE_BUYING)) - return; + return nullptr; #endif if (!CanBuyThis(pPlayer, weaponID)) - return; + return nullptr; WeaponInfoStruct *info = GetWeaponInfo(weaponID); if (!info || !info->entityName) - return; + return nullptr; if (pPlayer->m_iAccount < info->cost) { @@ -1305,7 +1310,7 @@ void BuyWeaponByWeaponID(CBasePlayer *pPlayer, WeaponIdType weaponID) BlinkAccount(pPlayer); } - return; + return nullptr; } if (IsPrimaryWeapon(weaponID)) @@ -1317,18 +1322,26 @@ void BuyWeaponByWeaponID(CBasePlayer *pPlayer, WeaponIdType weaponID) pPlayer->DropSecondary(); } - pPlayer->GiveNamedItem(info->entityName); + auto pEntity = pPlayer->GiveNamedItem(info->entityName); pPlayer->AddAccount(-info->cost, RT_PLAYER_BOUGHT_SOMETHING); - if (TheTutor != NULL) +#ifdef REGAMEDLL_ADD + if (refill_bpammo_weapons.value > 1 && info->ammoType >= AMMO_338MAGNUM && info->ammoType <= AMMO_9MM) { + pPlayer->m_rgAmmo[info->ammoType] = info->maxRounds; + } +#endif + + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); } + + return pEntity; } LINK_HOOK_VOID_CHAIN(HandleMenu_ChooseAppearance, (CBasePlayer *player, int slot), player, slot); -void __API_HOOK(HandleMenu_ChooseAppearance)(CBasePlayer *player, int slot) +void EXT_FUNC __API_HOOK(HandleMenu_ChooseAppearance)(CBasePlayer *player, int slot) { int numSkins = g_bIsCzeroGame ? CZ_NUM_SKIN : CS_NUM_SKIN; @@ -1466,15 +1479,7 @@ void __API_HOOK(HandleMenu_ChooseAppearance)(CBasePlayer *player, int slot) player->SetClientUserInfoModel(GET_INFO_BUFFER(player->edict()), appearance.model_name); player->SetNewPlayerModel(sPlayerModelFiles[ appearance.model_name_index ]); - if (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_VIP_SAFETYZONE_UNINITIALIZED) - { - if ((UTIL_FindEntityByClassname(NULL, "func_vip_safetyzone")) != NULL) - CSGameRules()->m_iMapHasVIPSafetyZone = MAP_HAVE_VIP_SAFETYZONE_YES; - else - CSGameRules()->m_iMapHasVIPSafetyZone = MAP_HAVE_VIP_SAFETYZONE_NO; - } - - if (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + if (CSGameRules()->m_bMapHasVIPSafetyZone) { if (!CSGameRules()->m_pVIP && player->m_iTeam == CT) { @@ -1487,7 +1492,7 @@ LINK_HOOK_CHAIN(BOOL, HandleMenu_ChooseTeam, (CBasePlayer *player, int slot), pl // returns true if the selection has been handled and the player's menu // can be closed...false if the menu should be displayed again -BOOL __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot) +BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot) { int oldTeam; char *szOldTeam; @@ -1527,7 +1532,7 @@ BOOL __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot) break; case MENU_SLOT_TEAM_VIP: { - if (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iTeam == CT) + if (CSGameRules()->m_bMapHasVIPSafetyZone && player->m_iTeam == CT) { CSGameRules()->AddToVIPQueue(player); CLIENT_COMMAND(ENT(player->pev), "slot10\n"); @@ -1637,7 +1642,7 @@ BOOL __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot) player->m_pIntroCamera = NULL; player->m_bTeamChanged = true; - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, player); } @@ -1820,7 +1825,7 @@ BOOL __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot) oldTeam = player->m_iTeam; player->m_iTeam = team; - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, player); } @@ -1871,7 +1876,7 @@ void Radio1(CBasePlayer *player, int slot) break; } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent((GameEventType)(EVENT_START_RADIO_1 + slot), player); } @@ -1910,7 +1915,7 @@ void Radio2(CBasePlayer *player, int slot) break; } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent((GameEventType)(EVENT_START_RADIO_2 + slot), player); } @@ -1962,13 +1967,15 @@ void Radio3(CBasePlayer *player, int slot) break; } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent((GameEventType)(EVENT_START_RADIO_3 + slot), player); } } -bool BuyGunAmmo(CBasePlayer *player, CBasePlayerItem *weapon, bool bBlinkMoney) +LINK_HOOK_CHAIN(bool, BuyGunAmmo, (CBasePlayer *player, CBasePlayerItem *weapon, bool bBlinkMoney), player, weapon, bBlinkMoney); + +bool EXT_FUNC __API_HOOK(BuyGunAmmo)(CBasePlayer *player, CBasePlayerItem *weapon, bool bBlinkMoney) { if (!player->CanPlayerBuy(true)) return false; @@ -2031,7 +2038,7 @@ bool BuyAmmo(CBasePlayer *player, int nSlot, bool bBlinkMoney) pItem = player->m_rgpPlayerItems[ PISTOL_SLOT ]; } - if (pItem != NULL) + if (pItem) { while (BuyGunAmmo(player, pItem, bBlinkMoney)) { @@ -2051,7 +2058,7 @@ CBaseEntity *EntityFromUserID(int userID) { CBaseEntity *pTempEntity = NULL; - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { if (FNullEnt(pTempEntity->edict())) break; @@ -2072,7 +2079,7 @@ NOXREF int CountPlayersInServer() int count = 0; CBaseEntity *pTempEntity = NULL; - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { if (FNullEnt(pTempEntity->edict())) break; @@ -2104,12 +2111,12 @@ BOOL HandleBuyAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) if (weaponID != WEAPON_NONE) { // assasination maps have a specific set of weapons that can be used in them. - if (CanBuyWeaponByMaptype(pPlayer->m_iTeam, weaponID, (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES))) + if (CanBuyWeaponByMaptype(pPlayer->m_iTeam, weaponID, CSGameRules()->m_bMapHasVIPSafetyZone == TRUE)) { bRetVal = TRUE; BuyWeaponByWeaponID(pPlayer, weaponID); } - else if (weaponFailName != NULL) + else if (weaponFailName) { bRetVal = TRUE; if (g_bClientPrintEnable) @@ -2141,7 +2148,7 @@ BOOL HandleBuyAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) while (BuyAmmo(pPlayer, PRIMARY_WEAPON_SLOT, false)) ; - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); } @@ -2160,7 +2167,7 @@ BOOL HandleBuyAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) while (BuyAmmo(pPlayer, PISTOL_SLOT, false)) ; - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); } @@ -2225,7 +2232,7 @@ BOOL HandleBuyAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) } } - if (g_bClientPrintEnable && pszFailItem != NULL) + if (g_bClientPrintEnable && pszFailItem) { ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Alias_Not_Avail", pszFailItem); } @@ -2280,6 +2287,10 @@ BOOL HandleRadioAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) return FALSE; } +bool InternalCommand(edict_t *pEntity, const char *cmd) { + return true; +} + // Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command. void EXT_FUNC ClientCommand(edict_t *pEntity) { @@ -2290,16 +2301,139 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) if (!pEntity->pvPrivateData) return; +#ifdef REGAMEDLL_API + if (!g_ReGameHookchains.m_InternalCommand.callChain(InternalCommand, pEntity, pcmd)) + return; +#endif + entvars_t *pev = &pEntity->v; CBasePlayer *player = GetClassPtr((CBasePlayer *)pev); + if (FStrEq(pcmd, "vip")) + { + /*for (int i = 0; i < MAX_VIP_QUEUES; ++i) + { + if (CSGameRules()->m_pVIPQueue[i]) + { + printf(" -> (%d) (%p)", i, CSGameRules()->m_pVIPQueue[i]); + printf(" -> (%s)", STRING(CSGameRules()->m_pVIPQueue[i]->pev->netname)); + printf(" -> index: (%d)\n", ENTINDEX(CSGameRules()->m_pVIPQueue[i]->edict())); + } + }*/ + + auto pEdict = FIND_ENTITY_BY_CLASSNAME(nullptr, "trigger_zone"); + if (pEdict) + { + printf(" -> pEdict: (%p) -> pEdict->v.solid: (%d)\n", pEdict, pEdict->v.solid); + } else { + + printf(" -> pEdict: (%p)\n", pEdict); + } + } else if (FStrEq(pcmd, "say")) { + + auto pcmd2 = CMD_ARGV_(1); + + if (FStrEq(pcmd2, "q")) // nety + { + //char szMessage[190]; + //Q_snprintf(szMessage, sizeof(szMessage), "\x1[\x4Tag\x1] Hey \x3%s\x1, welcome to join us on the server\x4.", STRING(pev->netname)); + + //MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, pev); + // WRITE_BYTE(player->entindex()); + /// WRITE_STRING(UTIL_VarArgs("\1[\4Aim Detector\1] Hey \3%s\1, welcome to join us on the server\4.", STRING(pev->netname))); + //MESSAGE_END(); + + + } else + if (FStrEq(pcmd2, "h")) // nety + { + //printf(" -> m_iHideHUD: (%d)", pPlayer->m_iHideHUD); + UTIL_SayText(UTIL_VarArgs(" -> m_iHideHUD: (%d)", player->m_iHideHUD), player); + + } else + if (FStrEq(pcmd2, "h_weapon")) // nety + { + player->m_iHideHUD |= HIDEHUD_WEAPONS; + + } else + if (FStrEq(pcmd2, "h_timer")) // ectb spec crosshair, ecli ectb npuLleJL + { + player->m_iHideHUD |= HIDEHUD_TIMER; + + } else + if (FStrEq(pcmd2, "h_money")) // ectb spec crosshair, ecli ectb npuLleJL + { + player->m_iHideHUD |= HIDEHUD_MONEY; + + } else + if (FStrEq(pcmd2, "h_all")) // nety + { + player->m_iHideHUD |= HIDEHUD_ALL; + + } else + if (FStrEq(pcmd2, "h_flash")) // ectb spec crosshair, ecli ectb npuLleJL + { + player->m_iHideHUD |= HIDEHUD_FLASHLIGHT; + + } else + if (FStrEq(pcmd2, "h_hp")) // ectb spec crosshair, ecli ectb npuLleJL + { + player->m_iHideHUD |= HIDEHUD_HEALTH; + + } else + if (FStrEq(pcmd2, "h_cross")) + { + player->m_iHideHUD |= HIDEHUD_CROSSHAIR; + + } else + if (FStrEq(pcmd2, "h_7")) + { + player->m_iHideHUD |= (1<<7); + + } else + if (FStrEq(pcmd2, "h_8")) + { + player->m_iHideHUD |= (1<<8); + + } else + if (FStrEq(pcmd2, "h_9")) + { + player->m_iHideHUD |= (1<<9); + + } else + if (FStrEq(pcmd2, "h_10")) + { + player->m_iHideHUD |= (1<<10); + + } else + if (FStrEq(pcmd2, "h_clear")) + { + player->m_iHideHUD = 0; + + } else + + + + + + + + + { + + if (gpGlobals->time >= player->m_flLastCommandTime[CMD_SAY]) { player->m_flLastCommandTime[CMD_SAY] = gpGlobals->time + 0.3f; Host_Say(pEntity, FALSE); } + } + + + + } else if (FStrEq(pcmd, "say_team")) { @@ -2364,7 +2498,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) } CBaseEntity *pKickEntity = EntityFromUserID(iVoteID); - if (pKickEntity != NULL) + if (pKickEntity) { CBasePlayer *pKickPlayer = GetClassPtr((CBasePlayer *)pKickEntity->pev); @@ -2481,19 +2615,18 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) ClientPrint(player->pev, HUD_PRINTTALK, "#Game_no_timelimit"); return; } -#ifndef REGAMEDLL_FIXES - int iTimeRemaining = (int)CSGameRules()->GetTimeLeft(); - if (iTimeRemaining < 0) - iTimeRemaining = 0; + int timeRemaining = (int)CSGameRules()->GetTimeLeft(); + if (timeRemaining < 0) + timeRemaining = 0; - int iMinutes = int(iTimeRemaining % 60); - int iSeconds = int(iTimeRemaining / 60); + int iMinutes = timeRemaining / 60; + int iSeconds = timeRemaining % 60; char secs[5]; - char *temp = UTIL_dtos2(iMinutes); + char *temp = UTIL_dtos2(iSeconds); - if (iMinutes >= 10) + if (iSeconds >= 10) { secs[0] = temp[0]; secs[1] = temp[1]; @@ -2506,11 +2639,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) secs[2] = '\0'; } - ClientPrint(player->pev, HUD_PRINTTALK, "#Game_timelimit", UTIL_dtos1(iSeconds), secs); -#else - int timeRemaining = (int)(timelimit.value ? CSGameRules()->GetTimeLeft() : 0); - ClientPrint(player->pev, HUD_PRINTTALK, "#Game_timelimit", UTIL_dtos1(timeRemaining / 60), UTIL_dtos2(timeRemaining % 60)); -#endif + ClientPrint(player->pev, HUD_PRINTTALK, "#Game_timelimit", UTIL_dtos1(iMinutes), secs); } } else if (FStrEq(pcmd, "listplayers")) @@ -2530,7 +2659,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) if (player->m_signals.GetState() & SIGNAL_BUY) { - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_TUTOR_BUY_MENU_OPENNED); } @@ -2624,7 +2753,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) case VGUI_MenuSlot_Buy_ShotGun: { player->m_iMenu = Menu_BuyShotgun; - if (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iTeam == TERRORIST) + if (CSGameRules()->m_bMapHasVIPSafetyZone && player->m_iTeam == TERRORIST) ShowVGUIMenu(player, VGUI_Menu_Buy_ShotGun, MENU_KEY_0, "#AS_BuyShotgun"); else ShowVGUIMenu(player, VGUI_Menu_Buy_ShotGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0), "#BuyShotgun"); @@ -2633,7 +2762,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) case VGUI_MenuSlot_Buy_SubMachineGun: { player->m_iMenu = Menu_BuySubMachineGun; - if (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + if (CSGameRules()->m_bMapHasVIPSafetyZone) { if (player->m_iTeam == CT) ShowVGUIMenu(player, VGUI_Menu_Buy_SubMachineGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0), "#AS_CT_BuySubMachineGun"); @@ -2652,7 +2781,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) case VGUI_MenuSlot_Buy_Rifle: { player->m_iMenu = Menu_BuyRifle; - if (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + if (CSGameRules()->m_bMapHasVIPSafetyZone) { if (player->m_iTeam == CT) ShowVGUIMenu(player, VGUI_Menu_Buy_Rifle, (MENU_KEY_1 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0), "#AS_CT_BuyRifle"); @@ -2671,7 +2800,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) case VGUI_MenuSlot_Buy_MachineGun: { player->m_iMenu = Menu_BuyMachineGun; - if (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iTeam == TERRORIST) + if (CSGameRules()->m_bMapHasVIPSafetyZone && player->m_iTeam == TERRORIST) ShowVGUIMenu(player, VGUI_Menu_Buy_MachineGun, MENU_KEY_0, "#AS_T_BuyMachineGun"); else ShowVGUIMenu(player, VGUI_Menu_Buy_MachineGun, (MENU_KEY_1 | MENU_KEY_0), "#BuyMachineGun"); @@ -2686,7 +2815,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) while (BuyAmmo(player, PRIMARY_WEAPON_SLOT, false)) ; - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); } @@ -2705,7 +2834,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) while (BuyAmmo(player, PISTOL_SLOT, false)) ; - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); } @@ -2820,7 +2949,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) if (!CSGameRules()->IsCareer()) { player->m_iMenu = Menu_ChooseTeam; - if (CSGameRules()->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iJoiningState == JOINED && player->m_iTeam == CT) + if (CSGameRules()->m_bMapHasVIPSafetyZone && player->m_iJoiningState == JOINED && player->m_iTeam == CT) { if (CSGameRules()->IsFreezePeriod() || player->pev->deadflag != DEAD_NO) ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#IG_VIP_Team_Select_Spect"); @@ -2931,7 +3060,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) if (g_pGameRules->ClientCommand_DeadOrAlive(GetClassPtr((CBasePlayer *)pev), pcmd)) return; - if (TheBots != NULL) + if (TheBots) { if (TheBots->ClientCommand(GetClassPtr((CBasePlayer *)pev), pcmd)) return; @@ -3004,7 +3133,6 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *pObserver = UTIL_PlayerByIndex(i); - if (pObserver && pObserver->IsObservingPlayer(player)) { EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); @@ -3030,7 +3158,6 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *pObserver = UTIL_PlayerByIndex(i); - if (pObserver && pObserver->IsObservingPlayer(player)) { EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); @@ -3066,7 +3193,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) // player is dropping an item. if (player->HasShield()) { - if (player->m_pActiveItem != NULL && player->m_pActiveItem->m_iId == WEAPON_C4) + if (player->m_pActiveItem && player->m_pActiveItem->m_iId == WEAPON_C4) { player->DropPlayerItem("weapon_c4"); } @@ -3089,7 +3216,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) { GetClassPtr((CBasePlayer *)pev)->SelectItem(CMD_ARGV_(1)); } - else if (((pstr = Q_strstr(pcmd, "weapon_")) != NULL) && (pstr == pcmd)) + else if (((pstr = Q_strstr(pcmd, "weapon_"))) && (pstr == pcmd)) { GetClassPtr((CBasePlayer *)pev)->SelectItem(pcmd); } @@ -3104,7 +3231,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) BuyAmmo(player, PRIMARY_WEAPON_SLOT, true); player->BuildRebuyStruct(); - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); } @@ -3117,7 +3244,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) BuyAmmo(player, PISTOL_SLOT, true); player->BuildRebuyStruct(); - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); } @@ -3152,7 +3279,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity) ShowVGUIMenu(player, VGUI_Menu_Buy, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0), "#Buy"); player->m_iMenu = Menu_Buy; - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_TUTOR_BUY_MENU_OPENNED); } @@ -3251,7 +3378,7 @@ void EXT_FUNC ClientUserInfoChanged(edict_t *pEntity, char *infobuffer) Q_snprintf(szName, sizeof(szName), "%s", szBufferName); // First parse the name and remove any %'s - for (char *pPct = szName; pPct != NULL && *pPct != '\0'; pPct++) + for (char *pPct = szName; pPct && *pPct != '\0'; pPct++) { // Replace it with a space if (*pPct == '%' || *pPct == '&') @@ -3261,8 +3388,12 @@ void EXT_FUNC ClientUserInfoChanged(edict_t *pEntity, char *infobuffer) if (szName[0] == '#') szName[0] = '*'; - // Set the name - pPlayer->SetClientUserInfoName(infobuffer, szName); + // Can set it a new name? + if (!pPlayer->SetClientUserInfoName(infobuffer, szName)) + { + // so to back old name into buffer + SET_CLIENT_KEY_VALUE(pPlayer->entindex(), infobuffer, "name", (char *)STRING(pPlayer->pev->netname)); + } } // was already checking on pvPrivateData @@ -3321,7 +3452,7 @@ void EXT_FUNC ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) pClass = CBaseEntity::Instance(pEdict); // Activate this entity if it's got a class & isn't dormant - if (pClass != NULL && !(pClass->pev->flags & FL_DORMANT)) + if (pClass && !(pClass->pev->flags & FL_DORMANT)) { AddEntityHashValue(&pEdict->v, STRING(pEdict->v.classname), CLASSNAME); pClass->Activate(); @@ -3334,17 +3465,17 @@ void EXT_FUNC ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) LinkUserMessages(); WriteSigonMessages(); - if (g_pGameRules != NULL) + if (g_pGameRules) { g_pGameRules->CheckMapConditions(); } - if (TheBots != NULL) + if (TheBots) { TheBots->ServerActivate(); } - if (g_pHostages != NULL) + if (g_pHostages) { g_pHostages->ServerActivate(); } @@ -3395,13 +3526,13 @@ void EXT_FUNC ParmsChangeLevel() void EXT_FUNC StartFrame() { - if (g_pGameRules) { + if (g_pGameRules) + { g_pGameRules->Think(); + if (g_pGameRules->IsGameOver()) + return; } - if (g_fGameOver) - return; - CLocalNav::Think(); static cvar_t *skill = NULL; @@ -3412,7 +3543,7 @@ void EXT_FUNC StartFrame() gpGlobals->teamplay = 1.0f; - if (skill != NULL) + if (skill) g_iSkillLevel = int(skill->value); else @@ -3627,7 +3758,6 @@ void ClientPrecache() for (i = FirstCustomSkin; i <= LastCustomSkin; ++i) { const char *fname = TheBotProfiles->GetCustomSkinFname(i); - if (!fname) break; @@ -4502,16 +4632,16 @@ void EXT_FUNC UpdateClientData(const struct edict_s *ent, int sendweapons, struc int iUser3 = 0; if (pPlayer->m_bCanShoot && !pPlayer->m_bIsDefusing) - iUser3 |= DATA_IUSER3_CANSHOOT; + iUser3 |= PLAYER_CAN_SHOOT; if (g_pGameRules->IsFreezePeriod()) - iUser3 |= DATA_IUSER3_FREEZETIMEOVER; + iUser3 |= PLAYER_FREEZE_TIME_OVER; if (pPlayer->m_signals.GetState() & SIGNAL_BOMB) - iUser3 |= DATA_IUSER3_INBOMBZONE; + iUser3 |= PLAYER_IN_BOMB_ZONE; if (pPlayer->HasShield()) - iUser3 |= DATA_IUSER3_HOLDINGSHIELD; + iUser3 |= PLAYER_HOLDING_SHIELD; if (pPlayer->pev->iuser1 == OBS_NONE && !pevOrg) { diff --git a/regamedll/dlls/client.h b/regamedll/dlls/client.h index c2dabca4..1f2c8fa0 100644 --- a/regamedll/dlls/client.h +++ b/regamedll/dlls/client.h @@ -134,7 +134,8 @@ bool CanBuyThis(CBasePlayer *pPlayer, int iWeapon); void BuyPistol(CBasePlayer *pPlayer, int iSlot); void BuyShotgun(CBasePlayer *pPlayer, int iSlot); void BuySubMachineGun(CBasePlayer *pPlayer, int iSlot); -void BuyWeaponByWeaponID(CBasePlayer *pPlayer, WeaponIdType weaponID); +CBaseEntity *BuyWeaponByWeaponID(CBasePlayer *pPlayer, WeaponIdType weaponID); +CBaseEntity *BuyWeaponByWeaponID_(CBasePlayer *pPlayer, WeaponIdType weaponID); void BuyRifle(CBasePlayer *pPlayer, int iSlot); void BuyMachineGun(CBasePlayer *pPlayer, int iSlot); void BuyItem(CBasePlayer *pPlayer, int iSlot); @@ -146,6 +147,7 @@ void Radio1(CBasePlayer *player, int slot); void Radio2(CBasePlayer *player, int slot); void Radio3(CBasePlayer *player, int slot); bool BuyGunAmmo(CBasePlayer *player, CBasePlayerItem *weapon, bool bBlinkMoney); +bool BuyGunAmmo_(CBasePlayer *player, CBasePlayerItem *weapon, bool bBlinkMoney); bool BuyAmmo(CBasePlayer *player, int nSlot, bool bBlinkMoney); CBaseEntity *EntityFromUserID(int userID); int CountPlayersInServer(); diff --git a/regamedll/dlls/combat.cpp b/regamedll/dlls/combat.cpp index dc3941fa..24a1588e 100644 --- a/regamedll/dlls/combat.cpp +++ b/regamedll/dlls/combat.cpp @@ -97,7 +97,7 @@ void CGib::SpawnHeadGib(entvars_t *pevVictim) edict_t *pentPlayer = FIND_CLIENT_IN_PVS(pGib->edict()); - if (RANDOM_LONG(0, 100) <= 5 && pentPlayer != NULL) + if (RANDOM_LONG(0, 100) <= 5 && pentPlayer) { // 5% chance head will be thrown at player's face. entvars_t *pevPlayer = VARS(pentPlayer); @@ -905,7 +905,6 @@ void EXT_FUNC PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *pObserver = UTIL_PlayerByIndex(i); - if (!pObserver || !pObserver->IsObservingPlayer(pPlayer)) continue; @@ -917,7 +916,7 @@ void EXT_FUNC PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars pPlayer->Blind(fadeTime * 0.33, fadeHold, fadeTime, alpha); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_BLINDED_BY_FLASHBANG, pPlayer); } @@ -940,7 +939,7 @@ void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, vecSrc.z += 1; - while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, 1500.0)) != NULL) + while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, 1500.0))) { TraceResult tr2; Vector vecLOS; @@ -1121,7 +1120,7 @@ void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker pevAttacker = pevInflictor; // iterate on all entities in the vicinity. - while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius)) != NULL) + while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius))) { if (pEntity->pev->takedamage != DAMAGE_NO) { @@ -1215,7 +1214,7 @@ void RadiusDamage2(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacke pevAttacker = pevInflictor; // iterate on all entities in the vicinity. - while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius)) != NULL) + while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius))) { if (pEntity->pev->takedamage != DAMAGE_NO) { @@ -1740,7 +1739,7 @@ Vector CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirShooting, float vec ClearMultiDamage(); UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr); - if (TheBots != NULL && tr.flFraction != 1.0f) + if (TheBots && tr.flFraction != 1.0f) { TheBots->OnEvent(EVENT_BULLET_IMPACT, this, (CBaseEntity *)&tr.vecEndPos); } diff --git a/regamedll/dlls/extdef.h b/regamedll/dlls/extdef.h index 25f52ff3..1ba12d7a 100644 --- a/regamedll/dlls/extdef.h +++ b/regamedll/dlls/extdef.h @@ -27,19 +27,30 @@ */ #pragma once +#undef DLLEXPORT #ifdef _WIN32 // Attributes to specify an "exported" function, visible from outside the // DLL. - #undef DLLEXPORT #define DLLEXPORT __declspec(dllexport) // WINAPI should be provided in the windows compiler headers. // It's usually defined to something like "__stdcall". + + #define NOINLINE __declspec(noinline) #else - #undef DLLEXPORT #define DLLEXPORT __attribute__((visibility("default"))) #define WINAPI /* */ + #define NOINLINE __attribute__((noinline)) #endif // _WIN32 +// Manual branch optimization for GCC 3.0.0 and newer +#if !defined(__GNUC__) || __GNUC__ < 3 + #define likely(x) (x) + #define unlikely(x) (x) +#else + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#endif + // Simplified macro for declaring/defining exported DLL functions. They // need to be 'extern "C"' so that the C++ compiler enforces parameter // type-matching, rather than considering routines with mis-matched diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index a934517e..632cad80 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -113,6 +113,10 @@ cvar_t fraglimit = { "mp_fraglimit", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t showtriggers = { "showtriggers", "0", 0, 0.0f, nullptr }; // debug cvar shows triggers // TODO: Maybe it's better to register in the engine? +cvar_t hostagehurtable = { "mp_hostage_hurtable", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t roundover = { "mp_roundover", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t forcerespawn = { "mp_forcerespawn", "1", FCVAR_SERVER, 0.0f, nullptr }; + void GameDLL_Version_f() { if (Q_stricmp(CMD_ARGV(1), "version") != 0) @@ -147,12 +151,20 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&friendlyfire); CVAR_REGISTER(&flashlight); CVAR_REGISTER(&decalfrequency); + +#ifndef REGAMEDLL_FIXES CVAR_REGISTER(&allowmonsters); +#endif + CVAR_REGISTER(&roundtime); CVAR_REGISTER(&buytime); CVAR_REGISTER(&freezetime); CVAR_REGISTER(&c4timer); + +#ifndef REGAMEDLL_FIXES CVAR_REGISTER(&ghostfrequency); +#endif + CVAR_REGISTER(&autokick); CVAR_REGISTER(&autokick_timeout); CVAR_REGISTER(&restartround); @@ -247,6 +259,9 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&fraglimit); CVAR_REGISTER(&showtriggers); + CVAR_REGISTER(&hostagehurtable); + CVAR_REGISTER(&roundover); + CVAR_REGISTER(&forcerespawn); // print version CONSOLE_ECHO("ReGameDLL build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 840d190f..755d074f 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -146,6 +146,9 @@ extern cvar_t max_teamkills; extern cvar_t fraglimit; extern cvar_t showtriggers; +extern cvar_t hostagehurtable; +extern cvar_t roundover; +extern cvar_t forcerespawn; #endif diff --git a/regamedll/dlls/gamerules.cpp b/regamedll/dlls/gamerules.cpp index 119f45c7..fd544b0f 100644 --- a/regamedll/dlls/gamerules.cpp +++ b/regamedll/dlls/gamerules.cpp @@ -12,6 +12,10 @@ CGameRules *g_pGameRules = NULL; CGameRules::CGameRules() : m_GameDesc() { + m_bFreezePeriod = FALSE; + m_bBombDropped = FALSE; + m_bGameOver = false; + m_GameDesc = new char[sizeof("Counter-Strike")]; Q_strcpy(m_GameDesc, AreRunningCZero() ? "Condition Zero" : "Counter-Strike"); } @@ -34,12 +38,9 @@ const char *CGameRules::GetGameDescription() BOOL CGameRules::__MAKE_VHOOK(CanHaveAmmo)(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry) { - int iAmmoIndex; - - if (pszAmmoName != NULL) + if (pszAmmoName) { - iAmmoIndex = pPlayer->GetAmmoIndex(pszAmmoName); - + auto iAmmoIndex = pPlayer->GetAmmoIndex(pszAmmoName); if (iAmmoIndex > -1) { if (pPlayer->AmmoInventory(iAmmoIndex) < iMaxCarry) @@ -138,7 +139,7 @@ void CGameRules::__MAKE_VHOOK(RefreshSkillData)() LINK_HOOK_CHAIN2(CGameRules *, InstallGameRules); -CGameRules *__API_HOOK(InstallGameRules)() +CGameRules *EXT_FUNC __API_HOOK(InstallGameRules)() { SERVER_COMMAND("exec game.cfg\n"); SERVER_EXECUTE(); diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index df25be33..cb27b567 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -40,13 +40,6 @@ #define MAX_BOMB_RADIUS 2048 -#define MAP_VIP_SAFETYZONE_UNINITIALIZED 0 // uninitialized -#define MAP_HAVE_VIP_SAFETYZONE_YES 1 // has VIP safety zone -#define MAP_HAVE_VIP_SAFETYZONE_NO 2 // does not have VIP safetyzone - -#define MAP_HAS_CAMERAS_INIT 2 // initial -#define MAP_HAS_CAMERAS_YES 1 // on map have of camera's - #define ITEM_RESPAWN_TIME 30 #define WEAPON_RESPAWN_TIME 20 #define AMMO_RESPAWN_TIME 20 @@ -100,6 +93,8 @@ enum ScenarioEventEndRound ROUND_TERRORISTS_NOT_ESCAPED, ROUND_VIP_NOT_ESCAPED, ROUND_GAME_COMMENCE, + ROUND_GAME_RESTART, + ROUND_GAME_OVER }; enum RewardRules @@ -207,13 +202,13 @@ enum // custom enum enum { - SCENARIO_BLOCK_TIME_EXPRIRED = (1 << 0), - SCENARIO_BLOCK_NEED_PLAYERS = (1 << 1), - SCENARIO_BLOCK_VIP_ESCAPRE = (1 << 2), - SCENARIO_BLOCK_PRISON_ESCAPRE = (1 << 3), - SCENARIO_BLOCK_BOMB = (1 << 4), - SCENARIO_BLOCK_TEAM_EXTERMINATION = (1 << 5), - SCENARIO_BLOCK_HOSTAGE_RESCUE = (1 << 6), + SCENARIO_BLOCK_TIME_EXPRIRED = (1 << 0), // flag "a" + SCENARIO_BLOCK_NEED_PLAYERS = (1 << 1), // flag "b" + SCENARIO_BLOCK_VIP_ESCAPE = (1 << 2), // flag "c" + SCENARIO_BLOCK_PRISON_ESCAPE = (1 << 3), // flag "d" + SCENARIO_BLOCK_BOMB = (1 << 4), // flag "e" + SCENARIO_BLOCK_TEAM_EXTERMINATION = (1 << 5), // flag "f" + SCENARIO_BLOCK_HOSTAGE_RESCUE = (1 << 6), // flag "g" }; // Player relationship return codes @@ -346,12 +341,17 @@ public: #endif + // inline function's + inline bool IsGameOver() const { return m_bGameOver; } + inline void SetGameOver() { m_bGameOver = true; } + public: BOOL m_bFreezePeriod; // TRUE at beginning of round, set to FALSE when the period expires BOOL m_bBombDropped; // custom char *m_GameDesc; + bool m_bGameOver; // intermission or finale (deprecated name g_fGameOver) }; // CHalfLifeRules - rules for the single player Half-Life game. @@ -676,7 +676,11 @@ public: bool TeamExterminationCheck(int NumAliveTerrorist, int NumAliveCT, int NumDeadTerrorist, int NumDeadCT); // for internal functions API + void OnRoundFreezeEnd(); + + bool RoundOver_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); bool NeededPlayersCheck_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); + bool RestartRoundCheck_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); bool VIP_Escaped_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); bool VIP_Died_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); @@ -763,9 +767,10 @@ public: bool IsFreeForAll() const; bool HasRoundInfinite(int flags = 0) const; -private: VFUNC bool HasRoundTimeExpired(); VFUNC bool IsBombPlanted(); + +private: void MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int iTeam); public: @@ -804,8 +809,8 @@ public: bool m_bMapHasRescueZone; bool m_bMapHasEscapeZone; - int m_iMapHasVIPSafetyZone; // 0 = uninitialized; 1 = has VIP safety zone; 2 = DOES not have VIP safetyzone - int m_bMapHasCameras; + BOOL m_bMapHasVIPSafetyZone; // TRUE = has VIP safety zone, FALSE = does not have VIP safetyzone + BOOL m_bMapHasCameras; int m_iC4Timer; int m_iC4Guy; // The current Terrorist who has the C4. int m_iLoserBonus; // the amount of money the losing team gets. This scales up as they lose more rounds in a row @@ -848,7 +853,7 @@ protected: float m_flIntermissionStartTime; BOOL m_iEndIntermissionButtonHit; float m_tmNextPeriodicThink; - bool m_bFirstConnected; + bool m_bGameStarted; // TRUE = the game commencing when there is at least one CT and T, FALSE = scoring will not start until both teams have players (deprecated name m_bFirstConnected) bool m_bInCareerGame; float m_fCareerRoundMenuTime; int m_iCareerMatchWins; diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp index da6cfb65..54dc6288 100644 --- a/regamedll/dlls/ggrenade.cpp +++ b/regamedll/dlls/ggrenade.cpp @@ -57,7 +57,7 @@ void CGrenade::Explode(TraceResult *pTrace, int bitsDamageType) #endif entvars_t *pevOwner = VARS(pev->owner); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_FLASHBANG_GRENADE_EXPLODED, CBaseEntity::Instance(pev->owner), (CBaseEntity *)&pev->origin); } @@ -109,7 +109,7 @@ void CGrenade::Explode2(TraceResult *pTrace, int bitsDamageType) if (CSGameRules()->IsCareer()) { - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->LatchRoundEndMessage(); } @@ -179,7 +179,7 @@ void CGrenade::Explode2(TraceResult *pTrace, int bitsDamageType) if (CSGameRules()->IsCareer()) { - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->UnlatchRoundEndMessage(); } @@ -266,7 +266,7 @@ void CGrenade::Explode3(TraceResult *pTrace, int bitsDamageType) #endif entvars_t *pevOwner = VARS(pev->owner); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_HE_GRENADE_EXPLODED, CBaseEntity::Instance(pev->owner)); } @@ -503,7 +503,7 @@ void CGrenade::SG_Smoke() { pev->effects |= EF_NODRAW; - if (TheBots != NULL) + if (TheBots) { TheBots->RemoveGrenade(this); } @@ -553,7 +553,7 @@ void CGrenade::SG_Detonate() UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -40), ignore_monsters, ENT(pev), &tr); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_SMOKE_GRENADE_EXPLODED, CBaseEntity::Instance(pev->owner)); TheBots->AddGrenade(WEAPON_SMOKEGRENADE, this); @@ -561,14 +561,13 @@ void CGrenade::SG_Detonate() EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/sg_explode.wav", VOL_NORM, ATTN_NORM); - while ((pentFind = FIND_ENTITY_BY_CLASSNAME(pentFind, "grenade")) != NULL) + while ((pentFind = FIND_ENTITY_BY_CLASSNAME(pentFind, "grenade"))) { if (FNullEnt(pentFind)) break; CBaseEntity *pEnt = CBaseEntity::Instance(pentFind); - - if (pEnt != NULL) + if (pEnt) { float fDistance = (pEnt->pev->origin - pev->origin).Length(); @@ -962,14 +961,14 @@ void CGrenade::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, // freeze the player in place while defusing SET_CLIENT_MAXSPEED(player->edict(), 1); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_BOMB_DEFUSING, pActivator); } if (CSGameRules()->IsCareer()) { - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->HandleEvent(EVENT_BOMB_DEFUSING); } @@ -1179,7 +1178,7 @@ void CGrenade::C4Think() // let the bots hear the bomb beeping // BOTPORT: Emit beep events at same time as client effects - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_BOMB_BEEP, this); } @@ -1204,7 +1203,7 @@ void CGrenade::C4Think() // If the timer has expired ! blow this bomb up! if (gpGlobals->time >= m_flC4Blow) { - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_BOMB_EXPLODED); } @@ -1231,7 +1230,7 @@ void CGrenade::C4Think() MESSAGE_BEGIN(MSG_ALL, gmsgBombPickup); MESSAGE_END(); - g_pGameRules->m_bBombDropped = false; + g_pGameRules->m_bBombDropped = FALSE; if (pev->waterlevel != 0) UTIL_Remove(this); @@ -1240,7 +1239,7 @@ void CGrenade::C4Think() } // if the defusing process has started - if (m_bStartDefuse && m_pBombDefuser != NULL) + if (m_bStartDefuse && m_pBombDefuser) { CBasePlayer *pPlayer = (CBasePlayer *)m_pBombDefuser; @@ -1268,7 +1267,7 @@ void CGrenade::C4Think() m_flDefuseCountDown = 0; // tell the bots someone has aborted defusing - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_BOMB_DEFUSE_ABORTED); } @@ -1279,7 +1278,7 @@ void CGrenade::C4Think() { Broadcast("BOMBDEF"); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_BOMB_DEFUSED, (CBaseEntity *)m_pBombDefuser); } @@ -1313,7 +1312,7 @@ void CGrenade::C4Think() if (CSGameRules()->IsCareer() && !pPlayer->IsBot()) { - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->HandleEvent(EVENT_BOMB_DEFUSED, pPlayer); } @@ -1343,7 +1342,7 @@ void CGrenade::C4Think() m_pBombDefuser = NULL; // tell the bots someone has aborted defusing - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_BOMB_DEFUSE_ABORTED); } @@ -1364,14 +1363,13 @@ NOXREF void CGrenade::UseSatchelCharges(entvars_t *pevOwner, SATCHELCODE code) edict_t *pentFind = NULL; CBaseEntity *pOwner = CBaseEntity::Instance(pevOwner); - while ((pentFind = FIND_ENTITY_BY_CLASSNAME(pentFind, "grenade")) != NULL) + while ((pentFind = FIND_ENTITY_BY_CLASSNAME(pentFind, "grenade"))) { if (FNullEnt(pentFind)) break; CBaseEntity *pEnt = Instance(pentFind); - - if (pEnt != NULL) + if (pEnt) { if ((pEnt->pev->spawnflags & SF_DETONATE) && pEnt->pev->owner == pOwner->edict()) { diff --git a/regamedll/dlls/globals.cpp b/regamedll/dlls/globals.cpp index e7ba5d4b..d48b4528 100644 --- a/regamedll/dlls/globals.cpp +++ b/regamedll/dlls/globals.cpp @@ -16,7 +16,6 @@ NOXREF u_long g_ulModelIndexEyes; Vector g_vecAttackDir; int g_iSkillLevel; int gDisplayTitle; -BOOL g_fGameOver; bool g_bIsCzeroGame = false; bool g_bAllowedCSBot = false; bool g_bHostageImprov = false; diff --git a/regamedll/dlls/globals.h b/regamedll/dlls/globals.h index 5e5e2a8b..874e024e 100644 --- a/regamedll/dlls/globals.h +++ b/regamedll/dlls/globals.h @@ -41,7 +41,6 @@ extern u_long g_ulModelIndexEyes; extern Vector g_vecAttackDir; extern int g_iSkillLevel; extern int gDisplayTitle; -extern BOOL g_fGameOver; extern bool g_bIsCzeroGame; extern bool g_bAllowedCSBot; extern bool g_bHostageImprov; diff --git a/regamedll/dlls/hostage/hostage.cpp b/regamedll/dlls/hostage/hostage.cpp index d12a6e75..fd04cbc4 100644 --- a/regamedll/dlls/hostage/hostage.cpp +++ b/regamedll/dlls/hostage/hostage.cpp @@ -411,7 +411,7 @@ void CHostage::IdleThink() { pSpot = NULL; - while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start")) != NULL) + while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"))) { if ((pSpot->pev->origin - pev->origin).Length() < RESCUE_HOSTAGES_RADIUS) { @@ -424,19 +424,19 @@ void CHostage::IdleThink() if (m_bRescueMe) { - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_HOSTAGE_RESCUED, player, this); } - if (TheCareerTasks != NULL && CSGameRules()->IsCareer() && player != NULL && !player->IsBot()) + if (TheCareerTasks && CSGameRules()->IsCareer() && player && !player->IsBot()) { TheCareerTasks->HandleEvent(EVENT_HOSTAGE_RESCUED, player); } pev->deadflag = DEAD_RESPAWNABLE; - if (player != NULL) + if (player) { player->AddAccount(REWARD_TAKEN_HOSTAGE, RT_HOSTAGE_RESCUED); UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Rescued_A_Hostage\"\n", STRING(player->pev->netname), @@ -564,6 +564,16 @@ void CHostage::RePosition() m_flNextFullThink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2); } +void CHostage::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +{ +#ifdef REGAMEDLL_ADD + if (hostagehurtable.value) +#endif + { + CBaseMonster::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType); + } +} + BOOL CHostage::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { float flActualDamage; @@ -634,7 +644,7 @@ BOOL CHostage::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevA pev->flags &= ~FL_ONGROUND; SetDeathActivity(); - if (pAttacker != NULL) + if (pAttacker) { pAttacker->AddAccount(20 * (-25 - int(flActualDamage)), RT_HOSTAGE_KILLED); AnnounceDeath(pAttacker); @@ -820,8 +830,13 @@ void CHostage::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, if (!pActivator->IsPlayer()) return; +#ifdef REGAMEDLL_FIXES + if (!IsAlive()) + return; +#else if (pev->takedamage == DAMAGE_NO) return; +#endif CBasePlayer *pPlayer = (CBasePlayer *)pActivator; @@ -1027,7 +1042,7 @@ void CHostage::DoFollow() MoveToward(vecNodes[nTargetNode]); m_bStuck = FALSE; } - else if (pev->takedamage == DAMAGE_YES) + else if (IsAlive()) { if (IsFollowingSomeone()) { @@ -1370,7 +1385,7 @@ void CHostageManager::ServerActivate() m_hostageCount = 0; CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname(pEntity, "hostage_entity")) != NULL) + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "hostage_entity"))) { AddHostage((CHostage *)pEntity); } diff --git a/regamedll/dlls/hostage/hostage.h b/regamedll/dlls/hostage/hostage.h index 2c583d58..65dbe4f7 100644 --- a/regamedll/dlls/hostage/hostage.h +++ b/regamedll/dlls/hostage/hostage.h @@ -32,9 +32,6 @@ #pragma once #endif -// Improved the hostages from CZero -#include "hostage/hostage_improv.h" - #define MAX_NODES 100 #define MAX_HOSTAGES 12 #define MAX_HOSTAGES_NAV 20 @@ -80,6 +77,9 @@ enum HostageChatterType NUM_HOSTAGE_CHATTER_TYPES, }; +// Improved the hostages from CZero +#include "hostage/hostage_improv.h" + extern CHostageManager *g_pHostages; extern int g_iHostageNumber; @@ -94,8 +94,14 @@ public: virtual void Precache(); virtual int ObjectCaps(); // make hostage "useable" virtual int Classify() { return CLASS_HUMAN_PASSIVE; } + virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); virtual int BloodColor() { return BLOOD_COLOR_RED; } + +#ifndef REGAMEDLL_FIXES + virtual BOOL IsAlive() { return (pev->takedamage == DAMAGE_YES); } +#endif + virtual void Touch(CBaseEntity *pOther); virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); @@ -160,10 +166,11 @@ public: return true; } - bool IsValid() { return (pev->takedamage == DAMAGE_YES); } - bool IsDead() { return (pev->deadflag == DEAD_DEAD); } - bool IsAtHome() { return (pev->origin - m_vStart).IsLengthGreaterThan(20) != true; } - const Vector *GetHomePosition() { return &m_vStart; } + + bool IsValid() const { return (pev->takedamage == DAMAGE_YES); } + bool IsDead() const { return (pev->deadflag == DEAD_DEAD); } + bool IsAtHome() const { return (pev->origin - m_vStart).IsLengthGreaterThan(20) != true; } + const Vector *GetHomePosition() const { return &m_vStart; } public: int m_Activity; diff --git a/regamedll/dlls/hostage/hostage_improv.cpp b/regamedll/dlls/hostage/hostage_improv.cpp index d68aa560..948c627b 100644 --- a/regamedll/dlls/hostage/hostage_improv.cpp +++ b/regamedll/dlls/hostage/hostage_improv.cpp @@ -42,7 +42,7 @@ bool CHostageImprov::__MAKE_VHOOK(GetSimpleGroundHeightWithFloor)(const Vector * if (GetSimpleGroundHeight(pos, height, normal)) { // our current nav area also serves as a ground polygon - if (m_lastKnownArea != NULL && m_lastKnownArea->IsOverlapping(pos)) + if (m_lastKnownArea && m_lastKnownArea->IsOverlapping(pos)) *height = Q_max((*height), m_lastKnownArea->GetZ(pos)); return true; @@ -314,11 +314,11 @@ bool CHostageImprov::__MAKE_VHOOK(IsFriendInTheWay)(const Vector &goalPos) const CheckWayFunctor check(this, goalPos); - if (g_pHostages != NULL) + if (g_pHostages) { g_pHostages->ForEachHostage(check); - if (check.m_blocker != NULL) + if (check.m_blocker) { return m_isFriendInTheWay = true; } @@ -329,7 +329,7 @@ bool CHostageImprov::__MAKE_VHOOK(IsFriendInTheWay)(const Vector &goalPos) const { CBasePlayer *player = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!player) continue; if (FNullEnt(player->pev)) @@ -646,7 +646,7 @@ void CHostageImprov::UpdateVision() { CBasePlayer *player = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!player) continue; if (FNullEnt(player->pev)) @@ -780,12 +780,12 @@ bool CHostageImprov::__MAKE_VHOOK(TraverseLadder)(const CNavLadder *ladder, NavT } else { - if (departPos != NULL) + if (departPos) { float closeRange = 1e6; float range; - if (ladder->m_topForwardArea != NULL) + if (ladder->m_topForwardArea) { range = (*departPos - *ladder->m_topForwardArea->GetCenter()).LengthSquared(); @@ -800,7 +800,7 @@ bool CHostageImprov::__MAKE_VHOOK(TraverseLadder)(const CNavLadder *ladder, NavT } } } - if (ladder->m_topLeftArea != NULL) + if (ladder->m_topLeftArea) { range = (*departPos - *ladder->m_topLeftArea->GetCenter()).LengthSquared(); @@ -814,7 +814,7 @@ bool CHostageImprov::__MAKE_VHOOK(TraverseLadder)(const CNavLadder *ladder, NavT } } } - if (ladder->m_topRightArea != NULL) + if (ladder->m_topRightArea) { range = (*departPos - *ladder->m_topRightArea->GetCenter()).LengthSquared(); @@ -845,7 +845,7 @@ void CHostageImprov::UpdatePosition(float deltaT) { CNavArea *area = TheNavAreaGrid.GetNavArea(&m_hostage->pev->origin); - if (area != NULL) + if (area) { m_lastKnownArea = area; } @@ -973,7 +973,7 @@ void CHostageImprov::UpdatePosition(float deltaT) KeepPersonalSpace spacer(this); ForEachPlayer(spacer); - if (g_pHostages != NULL) + if (g_pHostages) { g_pHostages->ForEachHostage(spacer); } @@ -1043,7 +1043,7 @@ void CHostageImprov::UpdateGrenadeReactions() m_grenadeTimer.Start(RANDOM_FLOAT(0.4f, 0.6f)); - while ((entity = UTIL_FindEntityInSphere(entity, GetCentroid(), watchGrenadeRadius)) != NULL) + while ((entity = UTIL_FindEntityInSphere(entity, GetCentroid(), watchGrenadeRadius))) { CGrenade *grenade = static_cast(entity); @@ -1281,7 +1281,7 @@ void CHostageImprov::__MAKE_VHOOK(OnGameEvent)(GameEventType event, CBaseEntity PriorityType priority; bool isHostile; - if (entity != NULL && IsGameEventAudible(event, entity, other, &range, &priority, &isHostile)) + if (entity && IsGameEventAudible(event, entity, other, &range, &priority, &isHostile)) { const float fudge = 0.4f; @@ -1467,12 +1467,12 @@ bool CHostageImprov::IsAtHome() const bool CHostageImprov::CanSeeRescueZone() const { - if (TheCSBots() == NULL) + if (!TheCSBots()) return false; const CCSBotManager::Zone *zone = TheCSBots()->GetClosestZone(&GetCentroid()); - if (zone != NULL) + if (zone) return IsVisible(zone->m_center); return false; @@ -1792,15 +1792,13 @@ void CHostageImprov::ClearPath() if (result.flFraction == 1.0f) return; - if (result.pHit != NULL) + if (result.pHit) { entvars_t *entity = VARS(result.pHit); - if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating")) { CBaseEntity *pObject = CBaseEntity::Instance(entity); - - if (pObject != NULL) + if (pObject) { pObject->Touch(m_hostage); } @@ -1808,8 +1806,7 @@ void CHostageImprov::ClearPath() else if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES) { CBaseEntity *pObject = CBaseEntity::Instance(entity); - - if (pObject != NULL) + if (pObject) { pObject->TakeDamage(m_hostage->pev, m_hostage->pev, 9999.9, DMG_BULLET); } diff --git a/regamedll/dlls/maprules.cpp b/regamedll/dlls/maprules.cpp index 3d80b810..3f36cdf3 100644 --- a/regamedll/dlls/maprules.cpp +++ b/regamedll/dlls/maprules.cpp @@ -386,7 +386,7 @@ void CGamePlayerZone::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pC { CBaseEntity *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer == nullptr) + if (!pPlayer) continue; TraceResult trace; @@ -576,7 +576,7 @@ void CGamePlayerEquip::EquipPlayer(CBaseEntity *pEntity) for (int j = 0; j < m_weaponCount[i]; ++j) { - pPlayer->GiveNamedItem(STRING(m_weaponNames[i])); + pPlayer->GiveNamedItemEx(STRING(m_weaponNames[i])); } } } diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 0e19de56..f9c56872 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -43,7 +43,7 @@ bool IsBotSpeaking() { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer == NULL || !pPlayer->IsBot()) + if (!pPlayer || !pPlayer->IsBot()) continue; CCSBot *pBot = static_cast(pPlayer); @@ -102,8 +102,7 @@ void SV_Career_EndRound_f() } CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer != NULL) + if (localPlayer) { SERVER_COMMAND("kill\n"); @@ -140,7 +139,7 @@ void SV_CareerAddTask_f() bool crossRounds = Q_atoi(CMD_ARGV(5)) != 0; bool isComplete = Q_atoi(CMD_ARGV(6)) != 0; - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->AddTask(taskName, weaponName, reps, mustLive, crossRounds, isComplete); } @@ -180,7 +179,7 @@ BOOL CHalfLifeMultiplay::IsCareer() LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, ServerDeactivate); -void CHalfLifeMultiplay::__API_VHOOK(ServerDeactivate)() +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(ServerDeactivate)() { if (!IsCareer()) { @@ -275,7 +274,7 @@ void CHalfLifeMultiplay::EndRoundMessage(const char *sentence, int event) case ROUND_VIP_NOT_ESCAPED: team = GetTeam(TERRORIST); // tell bots the terrorists won the round - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_TERRORISTS_WIN); } @@ -290,7 +289,7 @@ void CHalfLifeMultiplay::EndRoundMessage(const char *sentence, int event) case ROUND_TERRORISTS_NOT_ESCAPED: team = GetTeam(CT); // tell bots the CTs won the round - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_CTS_WIN); } @@ -298,7 +297,7 @@ void CHalfLifeMultiplay::EndRoundMessage(const char *sentence, int event) default: bTeamTriggered = false; // tell bots the round was a draw - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_ROUND_DRAW); } @@ -409,6 +408,8 @@ void CHalfLifeMultiplay::ReadMultiplayCvars() CHalfLifeMultiplay::CHalfLifeMultiplay() { + m_bFreezePeriod = TRUE; + m_VoiceGameMgr.Init(&g_GameMgrHelper, gpGlobals->maxClients); RefreshSkillData(); @@ -427,8 +428,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() m_iNumTerrorist = 0; m_iNumSpawnableCT = 0; m_iNumSpawnableTerrorist = 0; - m_bMapHasCameras = MAP_HAS_CAMERAS_INIT; - g_fGameOver = FALSE; + m_bMapHasCameras = FALSE; m_iLoserBonus = m_rgRewardAccountRules[RR_LOSER_BONUS_DEFAULT]; m_iNumConsecutiveCTLoses = 0; @@ -436,10 +436,9 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() m_iC4Guy = 0; m_bBombDefused = false; m_bTargetBombed = false; - m_bFreezePeriod = TRUE; m_bLevelInitialized = false; m_tmNextPeriodicThink = 0; - m_bFirstConnected = 0; + m_bGameStarted = false; m_bCompleteReset = false; m_flRequiredEscapeRatio = 0.5; m_iNumEscapers = 0; @@ -458,7 +457,6 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() m_bRoundTerminating = false; g_iHostageNumber = 0; - m_bBombDropped = FALSE; m_iMaxRounds = int(CVAR_GET_FLOAT("mp_maxrounds")); @@ -481,7 +479,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() m_iLastPick = 1; m_bMapHasEscapeZone = false; - m_iMapHasVIPSafetyZone = 0; + m_bMapHasVIPSafetyZone = FALSE; m_bMapHasBombZone = false; m_bMapHasRescueZone = false; m_iStoredSpectValue = int(allow_spectators.value); @@ -491,7 +489,14 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() m_pVIPQueue[j] = NULL; } - CVAR_SET_FLOAT("cl_himodels", 0); +#ifdef REGAMEDLL_FIXES + if (!IS_DEDICATED_SERVER()) +#endif + { + // NOTE: cvar cl_himodels refers for the client side + CVAR_SET_FLOAT("cl_himodels", 0); + } + ReadMultiplayCvars(); m_iIntroRoundTime += 2; @@ -531,7 +536,6 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() CVAR_SET_FLOAT("pausable", 0); const char *lservercfgfile = CVAR_GET_STRING("lservercfgfile"); - if (lservercfgfile && lservercfgfile[0] != '\0') { char szCommand[256]; @@ -554,7 +558,6 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() m_bSkipSpawn = m_bInCareerGame; static bool installedCommands = false; - if (!installedCommands) { installedCommands = true; @@ -632,16 +635,16 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RefreshSkillData)() LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, RemoveGuns); -void CHalfLifeMultiplay::__API_VHOOK(RemoveGuns)() +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(RemoveGuns)() { CBaseEntity *toremove = NULL; - while ((toremove = UTIL_FindEntityByClassname(toremove, "weaponbox")) != NULL) + while ((toremove = UTIL_FindEntityByClassname(toremove, "weaponbox"))) ((CWeaponBox *)toremove)->Kill(); toremove = NULL; - while ((toremove = UTIL_FindEntityByClassname(toremove, "weapon_shield")) != NULL) + while ((toremove = UTIL_FindEntityByClassname(toremove, "weapon_shield"))) { toremove->SetThink(&CBaseEntity::SUB_Remove); toremove->pev->nextthink = gpGlobals->time + 0.1; @@ -663,7 +666,7 @@ void CHalfLifeMultiplay::UpdateTeamScores() LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, CleanUpMap); -void CHalfLifeMultiplay::__API_VHOOK(CleanUpMap)() +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(CleanUpMap)() { #ifdef REGAMEDLL_FIXES // Release or reset everything entities in depending of flags ObjectCaps @@ -700,7 +703,7 @@ void CHalfLifeMultiplay::__API_VHOOK(CleanUpMap)() #else int icount = 0; CBaseEntity *toremove = UTIL_FindEntityByClassname(NULL, "grenade"); - while (toremove != NULL && icount < 20) + while (toremove && icount < 20) { UTIL_Remove(toremove); toremove = UTIL_FindEntityByClassname(toremove, "grenade"); @@ -723,7 +726,7 @@ void CHalfLifeMultiplay::__API_VHOOK(CleanUpMap)() LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, GiveC4); -void CHalfLifeMultiplay::__API_VHOOK(GiveC4)() +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(GiveC4)() { int iTeamCount; int iTemp = 0; @@ -764,7 +767,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GiveC4)() // Give the C4 to the specified T player.. CBaseEntity *pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -776,23 +779,18 @@ void CHalfLifeMultiplay::__API_VHOOK(GiveC4)() continue; CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); - if (player->pev->deadflag != DEAD_NO || player->m_iTeam != TERRORIST || (giveToHumans && player->IsBot())) continue; if (++iTemp == m_iC4Guy) { - player->m_bHasC4 = true; - player->GiveNamedItem("weapon_c4"); - player->SetBombIcon(); - player->pev->body = 1; - - player->m_flDisplayHistory |= DHF_BOMB_RETRIEVED; - player->HintMessage("#Hint_you_have_the_bomb", FALSE, TRUE); - - // Log this information - UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Spawned_With_The_Bomb\"\n", STRING(player->pev->netname), GETPLAYERUSERID(player->edict()), GETPLAYERAUTHID(player->edict())); - m_bBombDropped = FALSE; + if (player->MakeBomber()) + { +#ifdef REGAMEDLL_FIXES + // we already have bomber + return; +#endif + } } } @@ -802,7 +800,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GiveC4)() m_iC4Guy = 0; pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -818,17 +816,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GiveC4)() if (player->pev->deadflag != DEAD_NO || player->m_iTeam != TERRORIST) continue; - player->m_bHasC4 = true; - player->GiveNamedItem("weapon_c4"); - player->SetBombIcon(); - player->pev->body = 1; - - player->m_flDisplayHistory |= DHF_BOMB_RETRIEVED; - player->HintMessage("#Hint_you_have_the_bomb", FALSE, TRUE); - - // Log this information - UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Spawned_With_The_Bomb\"\n", STRING(player->pev->netname), GETPLAYERUSERID(player->edict()), GETPLAYERAUTHID(player->edict())); - m_bBombDropped = FALSE; + player->MakeBomber(); return; } } @@ -836,7 +824,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GiveC4)() void CHalfLifeMultiplay::QueueCareerRoundEndMenu(float tmDelay, int iWinStatus) { - if (TheCareerTasks == NULL) + if (!TheCareerTasks) return; if (m_fCareerMatchMenuTime != 0.0f) @@ -853,16 +841,13 @@ void CHalfLifeMultiplay::QueueCareerRoundEndMenu(float tmDelay, int iWinStatus) int numHostagesFollowingHumans = 0; int numHostagesAlive = 0; - while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity")) != NULL) + while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { ++numHostagesInMap; CHostage *pHostage = static_cast(hostage); - - if (pHostage->pev->takedamage != DAMAGE_YES) - { + if (!pHostage->IsAlive()) continue; - } CBasePlayer *pLeader = NULL; @@ -935,13 +920,13 @@ void CHalfLifeMultiplay::QueueCareerRoundEndMenu(float tmDelay, int iWinStatus) LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, CheckWinConditions); // Check if the scenario has been won/lost. -void CHalfLifeMultiplay::__API_VHOOK(CheckWinConditions)() +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(CheckWinConditions)() { if (HasRoundInfinite()) return; // If a winner has already been determined and game of started.. then get the heck out of here - if (m_bFirstConnected && m_iRoundWinStatus != WINNER_NONE) + if (m_bGameStarted && m_iRoundWinStatus != WINNER_NONE) return; #ifdef REGAMEDLL_ADD @@ -961,11 +946,11 @@ void CHalfLifeMultiplay::__API_VHOOK(CheckWinConditions)() return; // Assasination/VIP scenarion check - if (!(scenarioFlags & SCENARIO_BLOCK_VIP_ESCAPRE) && VIPRoundEndCheck()) + if (!(scenarioFlags & SCENARIO_BLOCK_VIP_ESCAPE) && VIPRoundEndCheck()) return; // Prison escape check - if (!(scenarioFlags & SCENARIO_BLOCK_PRISON_ESCAPRE) && PrisonRoundEndCheck(NumAliveTerrorist, NumAliveCT, NumDeadTerrorist, NumDeadCT)) + if (!(scenarioFlags & SCENARIO_BLOCK_PRISON_ESCAPE) && PrisonRoundEndCheck(NumAliveTerrorist, NumAliveCT, NumDeadTerrorist, NumDeadCT)) return; // Bomb check @@ -994,7 +979,7 @@ void CHalfLifeMultiplay::InitializePlayerCounts(int &NumAliveTerrorist, int &Num // Count how many dead players there are on each team. CBaseEntity *pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) { @@ -1077,8 +1062,8 @@ bool CHalfLifeMultiplay::NeededPlayersCheck_internal(int winStatus, ScenarioEven EndRoundMessage("#Game_Commencing", event); TerminateRound(tmDelay, winStatus); - m_bFirstConnected = true; - if (TheBots != NULL) + m_bGameStarted = true; + if (TheBots) { TheBots->OnEvent(EVENT_GAME_COMMENCE); } @@ -1095,15 +1080,14 @@ bool CHalfLifeMultiplay::NeededPlayersCheck() { UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_scoring"); m_bNeededPlayers = true; - m_bFirstConnected = false; + m_bGameStarted = false; } - if (!m_bFirstConnected && m_iNumSpawnableTerrorist != 0 && m_iNumSpawnableCT != 0) + if (!m_bGameStarted && m_iNumSpawnableTerrorist != 0 && m_iNumSpawnableCT != 0) { if (IsCareer()) { CBasePlayer *player = UTIL_PlayerByIndex(gpGlobals->maxClients); - if (!player || !player->IsBot()) { return true; @@ -1139,7 +1123,7 @@ bool CHalfLifeMultiplay::VIP_Escaped_internal(int winStatus, ScenarioEventEndRou EndRoundMessage("#VIP_Escaped", event); // tell the bots the VIP got out - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_VIP_ESCAPED); } @@ -1168,7 +1152,7 @@ bool CHalfLifeMultiplay::VIP_Died_internal(int winStatus, ScenarioEventEndRound EndRoundMessage("#VIP_Assassinated", event); // tell the bots the VIP was killed - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_VIP_ASSASSINATED); } @@ -1185,7 +1169,7 @@ bool CHalfLifeMultiplay::VIP_Died_internal(int winStatus, ScenarioEventEndRound bool CHalfLifeMultiplay::VIPRoundEndCheck() { // checks to scenario Escaped VIP on map with vip safety zones - if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && m_pVIP != NULL) + if (m_bMapHasVIPSafetyZone && m_pVIP) { if (m_pVIP->m_bEscaped) { @@ -1422,7 +1406,7 @@ bool CHalfLifeMultiplay::TeamExterminationCheck(int NumAliveTerrorist, int NumAl CBaseEntity *temp = NULL; bool nowin = false; - while ((temp = UTIL_FindEntityByClassname(temp, "grenade")) != NULL) + while ((temp = UTIL_FindEntityByClassname(temp, "grenade"))) { CGrenade *C4 = static_cast(temp); @@ -1470,14 +1454,14 @@ bool CHalfLifeMultiplay::Hostage_Rescue_internal(int winStatus, ScenarioEventEnd EndRoundMessage("#All_Hostages_Rescued", event); // tell the bots all the hostages have been rescued - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_ALL_HOSTAGES_RESCUED); } if (IsCareer()) { - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->HandleEvent(EVENT_ALL_HOSTAGES_RESCUED); } @@ -1501,12 +1485,12 @@ bool CHalfLifeMultiplay::HostageRescueRoundEndCheck() // Assume that all hostages are either rescued or dead.. bool bHostageAlive = false; - while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity")) != NULL) + while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { ++iHostages; // We've found a live hostage. don't end the round - if (hostage->pev->takedamage == DAMAGE_YES) + if (hostage->IsAlive()) { bHostageAlive = true; } @@ -1528,7 +1512,7 @@ void CHalfLifeMultiplay::SwapAllPlayers() { CBaseEntity *pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -1549,13 +1533,13 @@ void CHalfLifeMultiplay::SwapAllPlayers() LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, BalanceTeams); -void CHalfLifeMultiplay::__API_HOOK(BalanceTeams)() +void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(BalanceTeams)() { int iTeamToSwap = UNASSIGNED; int iNumToSwap; // The ratio for teams is different for Assasination maps - if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + if (m_bMapHasVIPSafetyZone) { int iDesiredNumCT, iDesiredNumTerrorist; @@ -1615,7 +1599,9 @@ void CHalfLifeMultiplay::__API_HOOK(BalanceTeams)() toSwap = NULL; CBaseEntity *pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + + // search for player with highest UserID = most recently joined to switch over + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -1640,7 +1626,7 @@ void CHalfLifeMultiplay::__API_HOOK(BalanceTeams)() LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, CheckMapConditions); -void CHalfLifeMultiplay::__API_VHOOK(CheckMapConditions)() +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(CheckMapConditions)() { // Check to see if this map has a bomb target in it if (UTIL_FindEntityByClassname(NULL, "func_bomb_target")) @@ -1670,23 +1656,20 @@ void CHalfLifeMultiplay::__API_VHOOK(CheckMapConditions)() m_bMapHasEscapeZone = (UTIL_FindEntityByClassname(NULL, "func_escapezone") != NULL); // Check to see if this map has VIP safety zones - if ((UTIL_FindEntityByClassname(NULL, "func_vip_safetyzone")) != NULL) - m_iMapHasVIPSafetyZone = MAP_HAVE_VIP_SAFETYZONE_YES; - else - m_iMapHasVIPSafetyZone = MAP_HAVE_VIP_SAFETYZONE_NO; + m_bMapHasVIPSafetyZone = (UTIL_FindEntityByClassname(NULL, "func_vip_safetyzone") != NULL); } LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, RestartRound); -void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(RestartRound)() { // tell bots that the round is restarting - if (TheBots != NULL) + if (TheBots) { TheBots->RestartRound(); } - if (g_pHostages != NULL) + if (g_pHostages) { g_pHostages->RestartRound(); } @@ -1709,8 +1692,13 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() MESSAGE_BEGIN(MSG_ALL, gmsgBombPickup); MESSAGE_END(); - MESSAGE_BEGIN(MSG_ALL, gmsgShowTimer); - MESSAGE_END(); +#ifdef REGAMEDLL_FIXES + if (m_iRoundTime > 0) +#endif + { + MESSAGE_BEGIN(MSG_ALL, gmsgShowTimer); + MESSAGE_END(); + } } m_bBombDropped = FALSE; @@ -1727,7 +1715,16 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() WRITE_BYTE(0); // to default FOV value MESSAGE_END(); - if (autoteambalance.value != 0.0f && m_iUnBalancedRounds >= 1) + auto shouldBalancedOnNextRound = []() -> bool + { +#ifdef REGAMEDLL_ADD + return autoteambalance.value == 1; +#else + return autoteambalance.value > 0; +#endif + }; + + if (shouldBalancedOnNextRound() && m_iUnBalancedRounds >= 1) { BalanceTeams(); } @@ -1740,10 +1737,16 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() m_iUnBalancedRounds = 0; // Warn the players of an impending auto-balance next round... - if (autoteambalance.value != 0.0f && m_iUnBalancedRounds == 1) + if (shouldBalancedOnNextRound() && m_iUnBalancedRounds == 1) { UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Auto_Team_Balance_Next_Round"); } +#ifdef REGAMEDLL_ADD + else if (autoteambalance.value > 1 && m_iUnBalancedRounds >= 1) + { + BalanceTeams(); + } +#endif if (m_bCompleteReset) { @@ -1795,7 +1798,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() plr->Reset(); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_NEW_MATCH); } @@ -1838,7 +1841,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() ++m_iNumEscapeRounds; } - if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + if (m_bMapHasVIPSafetyZone) { PickNextVIP(); ++m_iConsecutiveVIP; @@ -1847,7 +1850,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() int acct_tmp = 0; CBaseEntity *hostage = NULL; - while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity")) != NULL) + while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { if (acct_tmp >= 2000) break; @@ -1951,7 +1954,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() // tell bots that the round is restarting CBaseEntity *pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -1964,10 +1967,13 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() player->m_iNumSpawns = 0; player->m_bTeamChanged = false; +#ifndef REGAMEDLL_FIXES + // NOTE: unreachable code if (!player->IsPlayer()) { player->SyncRoundTimer(); } +#endif if (player->m_iTeam == CT) { @@ -2027,7 +2033,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)() GiveC4(); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_BUY_TIME_START); } @@ -2049,7 +2055,7 @@ BOOL CHalfLifeMultiplay::IsThereABomber() { CBasePlayer *pPlayer = NULL; - while ((pPlayer = (CBasePlayer *)UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = (CBasePlayer *)UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -2071,7 +2077,7 @@ BOOL CHalfLifeMultiplay::IsThereABomb() CBaseEntity *pWeaponC4 = NULL; bool bFoundBomb = false; - while ((pWeaponC4 = UTIL_FindEntityByClassname(pWeaponC4, "grenade")) != NULL) + while ((pWeaponC4 = UTIL_FindEntityByClassname(pWeaponC4, "grenade"))) { if (!pWeaponC4) continue; @@ -2085,7 +2091,7 @@ BOOL CHalfLifeMultiplay::IsThereABomb() } } - if (bFoundBomb || (UTIL_FindEntityByClassname(NULL, "weapon_c4")) != NULL) + if (bFoundBomb || (UTIL_FindEntityByClassname(NULL, "weapon_c4"))) return TRUE; return FALSE; @@ -2159,15 +2165,14 @@ bool CHalfLifeMultiplay::IsVIPQueueEmpty() for (int i = 0; i < MAX_VIP_QUEUES; ++i) { CBasePlayer *toCheck = m_pVIPQueue[i]; - - if (toCheck != NULL && toCheck->m_iTeam != CT) + if (toCheck && toCheck->m_iTeam != CT) { m_pVIPQueue[i] = NULL; } } StackVIPQueue(); - return (m_pVIPQueue[0] == NULL && m_pVIPQueue[1] == NULL && m_pVIPQueue[2] == NULL && m_pVIPQueue[3] == NULL && m_pVIPQueue[4] == NULL); + return (!m_pVIPQueue[0] && !m_pVIPQueue[1] && !m_pVIPQueue[2] && !m_pVIPQueue[3] && !m_pVIPQueue[4]); } bool CHalfLifeMultiplay::AddToVIPQueue(CBasePlayer *toAdd) @@ -2175,8 +2180,7 @@ bool CHalfLifeMultiplay::AddToVIPQueue(CBasePlayer *toAdd) for (int i = 0; i < MAX_VIP_QUEUES; ++i) { CBasePlayer *toCheck = m_pVIPQueue[i]; - - if (toCheck != NULL && toCheck->m_iTeam != CT) + if (toCheck && toCheck->m_iTeam != CT) { m_pVIPQueue[i] = NULL; } @@ -2255,14 +2259,14 @@ void CHalfLifeMultiplay::PickNextVIP() if (!IsVIPQueueEmpty()) { // Remove the current VIP from his VIP status and make him a regular CT. - if (m_pVIP != NULL) + if (m_pVIP) { ResetCurrentVIP(); } for (int i = 0; i < MAX_VIP_QUEUES; ++i) { - if (m_pVIPQueue[i] != NULL) + if (m_pVIPQueue[i]) { m_pVIP = m_pVIPQueue[i]; m_pVIP->MakeVIP(); @@ -2288,7 +2292,7 @@ void CHalfLifeMultiplay::PickNextVIP() pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); - while ((pPlayer != NULL) && (!FNullEnt(pPlayer->edict()))) + while (pPlayer && !FNullEnt(pPlayer->edict())) { if (!(pPlayer->pev->flags & FL_DORMANT)) { @@ -2296,11 +2300,11 @@ void CHalfLifeMultiplay::PickNextVIP() if (player->m_iTeam == CT && iCount == m_iLastPick) { - if (player == m_pVIP && pLastPlayer != NULL) + if (player == m_pVIP && pLastPlayer) player = pLastPlayer; // Remove the current VIP from his VIP status and make him a regular CT. - if (m_pVIP != NULL) + if (m_pVIP) { ResetCurrentVIP(); } @@ -2327,7 +2331,7 @@ void CHalfLifeMultiplay::PickNextVIP() CBasePlayer *player = NULL; pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); - while ((pPlayer != NULL) && (!FNullEnt(pPlayer->edict()))) + while (pPlayer && !FNullEnt(pPlayer->edict())) { if (pPlayer->pev->flags != FL_DORMANT) { @@ -2349,7 +2353,6 @@ void CHalfLifeMultiplay::PickNextVIP() void CHalfLifeMultiplay::__MAKE_VHOOK(Think)() { MonitorTutorStatus(); - m_VoiceGameMgr.Update(gpGlobals->frametime); if (sv_clienttrace->value != 1.0f) @@ -2427,7 +2430,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)() { RestartRound(); } - else if (TheCareerTasks != NULL) + else if (TheCareerTasks) { bool isBotSpeaking = false; @@ -2476,7 +2479,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)() { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer != NULL && !pPlayer->IsBot()) + if (pPlayer && !pPlayer->IsBot()) { MESSAGE_BEGIN(MSG_ONE, gmsgCZCareerHUD, NULL, pPlayer->pev); WRITE_STRING("ROUND"); @@ -2499,7 +2502,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)() } } - if (TheTutor != NULL) + if (TheTutor) { TheTutor->PurgeMessages(); } @@ -2574,7 +2577,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)() bool CHalfLifeMultiplay::CheckGameOver() { // someone else quit the game already - if (g_fGameOver) + if (m_bGameOver) { // bounds check int time = int(CVAR_GET_FLOAT("mp_chattime")); @@ -2718,11 +2721,8 @@ bool CHalfLifeMultiplay::CheckFragLimit() return false; } -void CHalfLifeMultiplay::CheckFreezePeriodExpired() +void CHalfLifeMultiplay::OnRoundFreezeEnd() { - if (GetRoundRemainingTime() > 0) - return; - // Log this information UTIL_LogPrintf("World triggered \"Round_Start\"\n"); @@ -2758,7 +2758,7 @@ void CHalfLifeMultiplay::CheckFreezePeriodExpired() Q_strncpy(CT_sentence, "%!MRAD_ELIM", sizeof(CT_sentence)); Q_strncpy(T_sentence, "%!MRAD_GETOUT", sizeof(T_sentence)); } - else if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + else if (m_bMapHasVIPSafetyZone) { Q_strncpy(CT_sentence, "%!MRAD_VIP", sizeof(CT_sentence)); Q_strncpy(T_sentence, "%!MRAD_LOCKNLOAD", sizeof(T_sentence)); @@ -2773,7 +2773,7 @@ void CHalfLifeMultiplay::CheckFreezePeriodExpired() bool bCTPlayed = false; bool bTPlayed = false; - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->HandleEvent(EVENT_ROUND_START); } @@ -2781,11 +2781,8 @@ void CHalfLifeMultiplay::CheckFreezePeriodExpired() for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *plr = UTIL_PlayerByIndex(i); - if (!plr || plr->pev->flags == FL_DORMANT) - { continue; - } if (plr->m_iJoiningState == JOINED) { @@ -2810,17 +2807,25 @@ void CHalfLifeMultiplay::CheckFreezePeriodExpired() plr->SyncRoundTimer(); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_ROUND_START); } - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->HandleEvent(EVENT_ROUND_START); } } +void CHalfLifeMultiplay::CheckFreezePeriodExpired() +{ + if (GetRoundRemainingTime() > 0) + return; + + g_ReGameHookchains.m_CSGameRules_OnRoundFreezeEnd.callChain(&CHalfLifeMultiplay::OnRoundFreezeEnd, this); +} + bool CHalfLifeMultiplay::Target_Saved_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { Broadcast("ctwin"); @@ -2895,6 +2900,14 @@ bool CHalfLifeMultiplay::VIP_NotEscaped_internal(int winStatus, ScenarioEventEnd return true; } +bool CHalfLifeMultiplay::RoundOver_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) +{ + EndRoundMessage("Round is Over!", event); + Broadcast("rounddraw"); + TerminateRound(tmDelay, winStatus); + return true; +} + void CHalfLifeMultiplay::CheckRoundTimeExpired() { if (HasRoundInfinite(SCENARIO_BLOCK_TIME_EXPRIRED)) @@ -2925,7 +2938,7 @@ void CHalfLifeMultiplay::CheckRoundTimeExpired() if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Saved_internal, this, WINSTATUS_CTS, ROUND_TARGET_SAVED, 5)) return; } - else if (UTIL_FindEntityByClassname(NULL, "hostage_entity") != NULL) + else if (UTIL_FindEntityByClassname(NULL, "hostage_entity")) { if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Hostage_NotRescued_internal, this, WINSTATUS_TERRORISTS, ROUND_HOSTAGE_NOT_RESCUED, 5)) return; @@ -2935,11 +2948,19 @@ void CHalfLifeMultiplay::CheckRoundTimeExpired() if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_NotEscaped_internal, this, WINSTATUS_CTS, ROUND_TERRORISTS_NOT_ESCAPED, 5)) return; } - else if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + else if (m_bMapHasVIPSafetyZone) { if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_NotEscaped_internal, this, WINSTATUS_TERRORISTS, ROUND_VIP_NOT_ESCAPED, 5)) return; } +#ifdef REGAMEDLL_ADD + else if (roundover.value) + { + // round is over + if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::RoundOver_internal, this, WINSTATUS_DRAW, ROUND_GAME_OVER, 5)) + return; + } +#endif // This is done so that the portion of code has enough time to do it's thing. m_fRoundStartTime = gpGlobals->time + 60.0f; @@ -2956,16 +2977,20 @@ void CHalfLifeMultiplay::CheckLevelInitialized() m_iSpawnPointCount_Terrorist = 0; m_iSpawnPointCount_CT = 0; - while ((ent = UTIL_FindEntityByClassname(ent, "info_player_deathmatch")) != NULL) + while ((ent = UTIL_FindEntityByClassname(ent, "info_player_deathmatch"))) ++m_iSpawnPointCount_Terrorist; - while ((ent = UTIL_FindEntityByClassname(ent, "info_player_start")) != NULL) + while ((ent = UTIL_FindEntityByClassname(ent, "info_player_start"))) ++m_iSpawnPointCount_CT; m_bLevelInitialized = true; } } +bool CHalfLifeMultiplay::RestartRoundCheck_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { + return true; +} + void CHalfLifeMultiplay::CheckRestartRound() { // Restart the round if specified by the server @@ -2982,6 +3007,8 @@ void CHalfLifeMultiplay::CheckRestartRound() if (iRestartDelay > 60) iRestartDelay = 60; #endif + if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::RestartRoundCheck_internal, this, 0, ROUND_GAME_RESTART, iRestartDelay)) + return; // log the restart UTIL_LogPrintf("World triggered \"Restart_Round_(%i_%s)\"\n", iRestartDelay, (iRestartDelay == 1) ? "second" : "seconds"); @@ -3004,6 +3031,11 @@ void CHalfLifeMultiplay::CheckRestartRound() bool CHalfLifeMultiplay::HasRoundTimeExpired() { +#ifdef REGAMEDLL_ADD + if (!m_iRoundTime) + return false; +#endif + // We haven't completed other objectives, so go for this!. if (GetRoundRemainingTime() > 0 || m_iRoundWinStatus != WINNER_NONE) { @@ -3027,9 +3059,8 @@ bool CHalfLifeMultiplay::IsBombPlanted() { if (m_bMapHasBombTarget) { - CGrenade *bomb = NULL; - - while ((bomb = (CGrenade *)UTIL_FindEntityByClassname(bomb, "grenade")) != NULL) + CGrenade *bomb = nullptr; + while ((bomb = (CGrenade *)UTIL_FindEntityByClassname(bomb, "grenade"))) { if (bomb->m_bIsC4) { @@ -3064,7 +3095,7 @@ void CHalfLifeMultiplay::MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int void CHalfLifeMultiplay::CareerRestart() { - g_fGameOver = FALSE; + m_bGameOver = false; if (m_flRestartRoundTime == 0.0f) { @@ -3076,7 +3107,7 @@ void CHalfLifeMultiplay::CareerRestart() m_fCareerRoundMenuTime = 0; m_fCareerMatchMenuTime = 0; - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->Reset(false); } @@ -3114,7 +3145,7 @@ BOOL CHalfLifeMultiplay::__MAKE_VHOOK(IsCoOp)() LINK_HOOK_CLASS_CUSTOM_CHAIN(BOOL, CHalfLifeMultiplay, CSGameRules, FShouldSwitchWeapon, (CBasePlayer *pPlayer, CBasePlayerItem *pWeapon), pPlayer, pWeapon); -BOOL CHalfLifeMultiplay::__API_VHOOK(FShouldSwitchWeapon)(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) +BOOL EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(FShouldSwitchWeapon)(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) { if (!pWeapon->CanDeploy()) return FALSE; @@ -3136,7 +3167,7 @@ BOOL CHalfLifeMultiplay::__API_VHOOK(FShouldSwitchWeapon)(CBasePlayer *pPlayer, LINK_HOOK_CLASS_CUSTOM_CHAIN(BOOL, CHalfLifeMultiplay, CSGameRules, GetNextBestWeapon, (CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon), pPlayer, pCurrentWeapon); -BOOL CHalfLifeMultiplay::__API_VHOOK(GetNextBestWeapon)(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) +BOOL EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(GetNextBestWeapon)(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) { CBasePlayerItem *pCheck; CBasePlayerItem *pBest; // this will be used in the event that we don't find a weapon in the same category. @@ -3156,7 +3187,7 @@ BOOL CHalfLifeMultiplay::__API_VHOOK(GetNextBestWeapon)(CBasePlayer *pPlayer, CB { pCheck = pPlayer->m_rgpPlayerItems[i]; - while (pCheck != NULL) + while (pCheck) { // don't reselect the weapon we're trying to get rid of if (pCheck->iWeight() > iBestWeight && pCheck != pCurrentWeapon) @@ -3183,7 +3214,7 @@ BOOL CHalfLifeMultiplay::__API_VHOOK(GetNextBestWeapon)(CBasePlayer *pPlayer, CB // if pBest is null, we didn't find ANYTHING. Shouldn't be possible- should always // at least get the crowbar, but ya never know. - if (pBest == NULL) + if (!pBest) { return FALSE; } @@ -3259,17 +3290,20 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) { // FIXME: Probably don't need to cast this just to read m_iDeaths CBasePlayer *plr = UTIL_PlayerByIndex(i); + if (!plr) + continue; - if (plr) - { - MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, NULL, pl->edict()); - WRITE_BYTE(i); // client number - WRITE_SHORT(int(plr->pev->frags)); - WRITE_SHORT(plr->m_iDeaths); - WRITE_SHORT(0); - WRITE_SHORT(plr->m_iTeam); - MESSAGE_END(); - } +#ifdef REGAMEDLL_FIXES + if (plr->IsDormant()) + continue; +#endif + MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, NULL, pl->edict()); + WRITE_BYTE(i); // client number + WRITE_SHORT(int(plr->pev->frags)); + WRITE_SHORT(plr->m_iDeaths); + WRITE_SHORT(0); + WRITE_SHORT(plr->m_iTeam); + MESSAGE_END(); } MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, NULL, pl->edict()); @@ -3292,7 +3326,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) WRITE_BYTE(fadetoblack.value != 0); MESSAGE_END(); - if (g_fGameOver) + if (m_bGameOver) { MESSAGE_BEGIN(MSG_ONE, SVC_INTERMISSION, NULL, pl->edict()); MESSAGE_END(); @@ -3301,48 +3335,85 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) for (i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *plr = UTIL_PlayerByIndex(i); + if (!plr) + continue; - if (plr) +#ifdef REGAMEDLL_FIXES + if (plr->IsDormant()) + continue; +#endif + + MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, NULL, pl->edict()); + WRITE_BYTE(plr->entindex()); + WRITE_STRING(GetTeamName(plr->m_iTeam)); + MESSAGE_END(); + + plr->SetScoreboardAttributes(pl); + + if (i != pl->entindex()) { - MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, NULL, pl->edict()); - WRITE_BYTE(plr->entindex()); - WRITE_STRING(GetTeamName(plr->m_iTeam)); - MESSAGE_END(); - - plr->SetScoreboardAttributes(pl); - - if (i != pl->entindex()) +#ifndef REGAMEDLL_FIXES + if (plr->pev->flags == FL_DORMANT) + continue; +#endif + if (plr->pev->deadflag == DEAD_NO) { - if (plr->pev->flags == FL_DORMANT) - continue; - - if (plr->pev->deadflag == DEAD_NO) - { - MESSAGE_BEGIN(MSG_ONE, gmsgRadar, NULL, pl->edict()); - WRITE_BYTE(plr->entindex()); - WRITE_COORD(plr->pev->origin.x); - WRITE_COORD(plr->pev->origin.y); - WRITE_COORD(plr->pev->origin.z); - MESSAGE_END(); - } + MESSAGE_BEGIN(MSG_ONE, gmsgRadar, NULL, pl->edict()); + WRITE_BYTE(plr->entindex()); + WRITE_COORD(plr->pev->origin.x); + WRITE_COORD(plr->pev->origin.y); + WRITE_COORD(plr->pev->origin.z); + MESSAGE_END(); } } } + auto SendMsgBombDrop = [&pl](const int iFlag, const Vector& pos) + { + MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, NULL, pl->edict()); + WRITE_COORD(pos.x); + WRITE_COORD(pos.y); + WRITE_COORD(pos.z); + WRITE_BYTE(iFlag); + MESSAGE_END(); + }; + if (m_bBombDropped) { CBaseEntity *pWeaponC4 = UTIL_FindEntityByClassname(NULL, "weapon_c4"); - if (pWeaponC4) { - MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, NULL, pl->edict()); - WRITE_COORD(pWeaponC4->pev->origin.x); - WRITE_COORD(pWeaponC4->pev->origin.y); - WRITE_COORD(pWeaponC4->pev->origin.z); - WRITE_BYTE(0); - MESSAGE_END(); + SendMsgBombDrop(BOMB_FLAG_DROPPED, pWeaponC4->pev->origin); } } +#ifdef REGAMEDLL_FIXES + else + { + CGrenade *bomb = nullptr; + while ((bomb = (CGrenade *)UTIL_FindEntityByClassname(bomb, "grenade"))) + { + if (bomb->m_bIsC4) + { + // if the bomb was planted, which will trigger the round timer to hide. + SendMsgBombDrop(BOMB_FLAG_PLANTED, bomb->pev->origin); + + if (m_iRoundTime > 0 || GetRoundRemainingTime() >= 1.0f) + { + MESSAGE_BEGIN(MSG_ONE, gmsgShowTimer, NULL, pl->pev); + MESSAGE_END(); + } + else + { + // HACK HACK, we need to hide only the timer. + SendMsgBombDrop(BOMB_FLAG_PLANTED, g_vecZero); + MESSAGE_BEGIN(MSG_ONE, gmsgBombPickup, NULL, pl->pev); + MESSAGE_END(); + } + break; + } + } + } +#endif } void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient) @@ -3417,7 +3488,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient) CBasePlayer *client = NULL; - while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player")) != NULL) + while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player"))) { if (FNullEnt(client->edict())) break; @@ -3441,7 +3512,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient) LINK_HOOK_CLASS_CUSTOM_CHAIN(float, CHalfLifeMultiplay, CSGameRules, FlPlayerFallDamage, (CBasePlayer *pPlayer), pPlayer); -float CHalfLifeMultiplay::__API_VHOOK(FlPlayerFallDamage)(CBasePlayer *pPlayer) +float EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(FlPlayerFallDamage)(CBasePlayer *pPlayer) { pPlayer->m_flFallVelocity -= PLAYER_MAX_SAFE_FALL_SPEED; return pPlayer->m_flFallVelocity * DAMAGE_FOR_FALL_SPEED * 1.25; @@ -3449,7 +3520,7 @@ float CHalfLifeMultiplay::__API_VHOOK(FlPlayerFallDamage)(CBasePlayer *pPlayer) LINK_HOOK_CLASS_CUSTOM_CHAIN(BOOL, CHalfLifeMultiplay, CSGameRules, FPlayerCanTakeDamage, (CBasePlayer *pPlayer, CBaseEntity *pAttacker), pPlayer, pAttacker); -BOOL CHalfLifeMultiplay::__API_VHOOK(FPlayerCanTakeDamage)(CBasePlayer *pPlayer, CBaseEntity *pAttacker) +BOOL EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(FPlayerCanTakeDamage)(CBasePlayer *pPlayer, CBaseEntity *pAttacker) { if (!pAttacker || PlayerRelationship(pPlayer, pAttacker) != GR_TEAMMATE) { @@ -3466,7 +3537,7 @@ BOOL CHalfLifeMultiplay::__API_VHOOK(FPlayerCanTakeDamage)(CBasePlayer *pPlayer, void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerThink)(CBasePlayer *pPlayer) { - if (g_fGameOver) + if (m_bGameOver) { // check for button presses if (!IsCareer() && (pPlayer->m_afButtonPressed & (IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP))) @@ -3551,40 +3622,26 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerThink)(CBasePlayer *pPlayer) LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(CHalfLifeMultiplay, CSGameRules, PlayerSpawn, (CBasePlayer *pPlayer), pPlayer); // Purpose: Player has just spawned. Equip them. -void CHalfLifeMultiplay::__API_VHOOK(PlayerSpawn)(CBasePlayer *pPlayer) +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(PlayerSpawn)(CBasePlayer *pPlayer) { // This is tied to the joining state (m_iJoiningState).. add it when the joining state is there. if (pPlayer->m_bJustConnected) - { return; - } pPlayer->pev->weapons |= (1 << WEAPON_SUIT); - - bool addDefault = true; - CBaseEntity *pWeaponEntity = NULL; - - while ((pWeaponEntity = UTIL_FindEntityByClassname(pWeaponEntity, "game_player_equip")) != NULL) - { - pWeaponEntity->Touch(pPlayer); - addDefault = false; - } - - if (pPlayer->m_bNotKilled) - addDefault = false; - - if (addDefault || pPlayer->m_bIsVIP) - { - pPlayer->GiveDefaultItems(); - } - + pPlayer->OnSpawnEquip(); pPlayer->SetPlayerModel(false); } LINK_HOOK_CLASS_CUSTOM_CHAIN(BOOL, CHalfLifeMultiplay, CSGameRules, FPlayerCanRespawn, (CBasePlayer *pPlayer), pPlayer); -BOOL CHalfLifeMultiplay::__API_VHOOK(FPlayerCanRespawn)(CBasePlayer *pPlayer) +BOOL EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(FPlayerCanRespawn)(CBasePlayer *pPlayer) { +#ifdef REGAMEDLL_ADD + if (forcerespawn.value) + return TRUE; +#endif + // Player cannot respawn twice in a round if (pPlayer->m_iNumSpawns > 0) { @@ -3599,16 +3656,24 @@ BOOL CHalfLifeMultiplay::__API_VHOOK(FPlayerCanRespawn)(CBasePlayer *pPlayer) if (m_iNumTerrorist > 0 && m_iNumCT > 0) { - if (gpGlobals->time > m_fRoundStartTime + GetRoundRespawnTime()) +#ifdef REGAMEDLL_ADD + // means no time limit + if (GetRoundRespawnTime() != -1) +#endif { - // If this player just connected and fadetoblack is on, then maybe - // the server admin doesn't want him peeking around. - if (fadetoblack.value != 0.0f) + // TODO: to be correct, need use m_fIntroRoundCount instead of it. + // m_fRoundStartTime able to extend the time to 60 seconds when there is a remaining time of round. + if (gpGlobals->time > m_fRoundStartTime + GetRoundRespawnTime()) { - UTIL_ScreenFade(pPlayer, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT)); - } + // If this player just connected and fadetoblack is on, then maybe + // the server admin doesn't want him peeking around. + if (fadetoblack.value != 0.0f) + { + UTIL_ScreenFade(pPlayer, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT)); + } - return FALSE; + return FALSE; + } } } @@ -3640,7 +3705,7 @@ int CHalfLifeMultiplay::__MAKE_VHOOK(IPointsForKill)(CBasePlayer *pAttacker, CBa LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(CHalfLifeMultiplay, CSGameRules, PlayerKilled, (CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor), pVictim, pKiller, pInflictor); -void CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) { DeathNotice(pVictim, pKiller, pInflictor); @@ -3661,8 +3726,7 @@ void CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars else if (ktmp && ktmp->Classify() == CLASS_VEHICLE) { CBasePlayer *pDriver = static_cast(((CFuncVehicle *)ktmp)->m_pDriver); - - if (pDriver != NULL) + if (pDriver) { pKiller = pDriver->pev; peKiller = static_cast(pDriver); @@ -3793,7 +3857,7 @@ void CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(CHalfLifeMultiplay, CSGameRules, DeathNotice, (CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor), pVictim, pKiller, pevInflictor); -void CHalfLifeMultiplay::__API_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor) +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor) { // Work out what killed the player, and send a message to all clients about it // CBaseEntity *Killer = CBaseEntity::Instance(pKiller); @@ -3854,7 +3918,7 @@ void CHalfLifeMultiplay::__API_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars_ else if (!Q_strncmp(killer_weapon_name, cut_func, sizeof(cut_func) - 1)) killer_weapon_name += sizeof(cut_func) - 1; - if (TheTutor == nullptr) + if (!TheTutor) { MESSAGE_BEGIN(MSG_ALL, gmsgDeathMsg); WRITE_BYTE(killer_index); // the killer @@ -3967,7 +4031,7 @@ int CHalfLifeMultiplay::__MAKE_VHOOK(WeaponShouldRespawn)(CBasePlayerItem *pWeap LINK_HOOK_CLASS_CUSTOM_CHAIN(BOOL, CHalfLifeMultiplay, CSGameRules, CanHavePlayerItem, (CBasePlayer *pPlayer, CBasePlayerItem *pItem), pPlayer, pItem); -BOOL CHalfLifeMultiplay::__API_VHOOK(CanHavePlayerItem)(CBasePlayer *pPlayer, CBasePlayerItem *pItem) +BOOL EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(CanHavePlayerItem)(CBasePlayer *pPlayer, CBasePlayerItem *pItem) { return CGameRules::CanHavePlayerItem(pPlayer, pItem); } @@ -4044,7 +4108,7 @@ float CHalfLifeMultiplay::__MAKE_VHOOK(FlHEVChargerRechargeTime)() LINK_HOOK_CLASS_CUSTOM_CHAIN(int, CHalfLifeMultiplay, CSGameRules, DeadPlayerWeapons, (CBasePlayer *pPlayer), pPlayer); -int CHalfLifeMultiplay::__API_VHOOK(DeadPlayerWeapons)(CBasePlayer *pPlayer) +int EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(DeadPlayerWeapons)(CBasePlayer *pPlayer) { return GR_PLR_DROP_GUN_ACTIVE; } @@ -4056,7 +4120,7 @@ int CHalfLifeMultiplay::__MAKE_VHOOK(DeadPlayerAmmo)(CBasePlayer *pPlayer) LINK_HOOK_CLASS_CUSTOM_CHAIN(edict_t *, CHalfLifeMultiplay, CSGameRules, GetPlayerSpawnSpot, (CBasePlayer *pPlayer), pPlayer); -edict_t *CHalfLifeMultiplay::__API_VHOOK(GetPlayerSpawnSpot)(CBasePlayer *pPlayer) +edict_t *EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(GetPlayerSpawnSpot)(CBasePlayer *pPlayer) { // gat valid spawn point edict_t *pentSpawnSpot = CGameRules::GetPlayerSpawnSpot(pPlayer); @@ -4117,14 +4181,18 @@ BOOL CHalfLifeMultiplay::__MAKE_VHOOK(FAllowFlashlight)() BOOL CHalfLifeMultiplay::__MAKE_VHOOK(FAllowMonsters)() { +#ifdef REGAMEDLL_FIXES + return FALSE; +#else return allowmonsters.value != 0.0f; +#endif } LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, GoToIntermission); -void CHalfLifeMultiplay::__API_VHOOK(GoToIntermission)() +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(GoToIntermission)() { - if (g_fGameOver) + if (m_bGameOver) return; UTIL_LogPrintf("Team \"CT\" scored \"%i\" with \"%i\" players\n", m_iNumCTWins, m_iNumCT); @@ -4147,7 +4215,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GoToIntermission)() WRITE_BYTE(m_iRoundWinStatus); MESSAGE_END(); - if (TheCareerTasks != NULL) + if (TheCareerTasks) { UTIL_LogPrintf("Career Match %d %d %d %d\n", m_iRoundWinStatus, m_iNumCTWins, m_iNumTerroristWins, TheCareerTasks->AreAllTasksComplete()); } @@ -4172,7 +4240,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GoToIntermission)() m_flIntermissionEndTime = gpGlobals->time + int(mp_chattime.value); m_flIntermissionStartTime = gpGlobals->time; - g_fGameOver = TRUE; + m_bGameOver = true; m_iEndIntermissionButtonHit = FALSE; m_iSpawnPointCount_Terrorist = 0; m_iSpawnPointCount_CT = 0; @@ -4185,7 +4253,7 @@ void DestroyMapCycle(mapcycle_t *cycle) mapcycle_item_t *p, *n, *start; p = cycle->items; - if (p != NULL) + if (p) { start = p; p = p->next; @@ -4411,7 +4479,7 @@ int ReloadMapCycleFile(char *filename, mapcycle_t *cycle) return 0; } - while (item->next != NULL) + while (item->next) { item = item->next; } @@ -4425,18 +4493,17 @@ int ReloadMapCycleFile(char *filename, mapcycle_t *cycle) // Determine the current # of active players on the server for map cycling logic int CountPlayers() { - int num = 0; - + int nCount = 0; for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer != NULL) + if (pPlayer) { - num = num + 1; + nCount++; } } - return num; + return nCount; } // Parse commands/key value pairs to issue right after map xxx command is issued on server level transition @@ -4503,7 +4570,7 @@ void CHalfLifeMultiplay::ResetAllMapVotes() { CBaseEntity *pTempEntity = NULL; - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { if (FNullEnt(pTempEntity->edict())) break; @@ -4555,14 +4622,14 @@ void CHalfLifeMultiplay::DisplayMaps(CBasePlayer *player, int iVote) ReloadMapCycleFile(mapcfile, &mapcycle2); mapcycle_item_s *item = mapcycle2.next_item; - while (!done && item != NULL) + while (!done && item) { if (item->next == mapcycle2.next_item) done = 1; ++iCount; - if (player != NULL) + if (player) { if (m_iMapVotes[iCount] == 1) { @@ -4605,7 +4672,7 @@ void CHalfLifeMultiplay::ProcessMapVote(CBasePlayer *player, int iVote) CBaseEntity *pTempEntity = NULL; int iValidVotes = 0, iNumPlayers = 0; - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { if (FNullEnt(pTempEntity->edict())) break; @@ -4653,7 +4720,7 @@ void CHalfLifeMultiplay::ProcessMapVote(CBasePlayer *player, int iVote) LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, ChangeLevel); // Server is changing to a new level, check mapcycle.txt for map name and setup info -void CHalfLifeMultiplay::__API_VHOOK(ChangeLevel)() +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(ChangeLevel)() { static char szPreviousMapCycleFile[256]; static mapcycle_t mapcycle; @@ -4769,7 +4836,7 @@ void CHalfLifeMultiplay::__API_VHOOK(ChangeLevel)() Q_strcpy(szNextMap, szFirstMapInList); } - g_fGameOver = TRUE; + m_bGameOver = true; ALERT(at_console, "CHANGE LEVEL: %s\n", szNextMap); if (minplayers || maxplayers) @@ -4836,7 +4903,7 @@ void CHalfLifeMultiplay::SendMOTDToClient(edict_t *client) LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(CHalfLifeMultiplay, CSGameRules, ClientUserInfoChanged, (CBasePlayer *pPlayer, char *infobuffer), pPlayer, infobuffer); -void CHalfLifeMultiplay::__API_VHOOK(ClientUserInfoChanged)(CBasePlayer *pPlayer, char *infobuffer) +void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(ClientUserInfoChanged)(CBasePlayer *pPlayer, char *infobuffer) { pPlayer->SetPlayerModel(pPlayer->m_bHasC4); pPlayer->SetPrefsFromUserinfo(infobuffer); diff --git a/regamedll/dlls/observer.cpp b/regamedll/dlls/observer.cpp index f21769b0..08278d81 100644 --- a/regamedll/dlls/observer.cpp +++ b/regamedll/dlls/observer.cpp @@ -2,7 +2,7 @@ LINK_HOOK_CHAIN(int, GetForceCamera, (CBasePlayer *pObserver), pObserver); -int __API_HOOK(GetForceCamera)(CBasePlayer *pObserver) +int EXT_FUNC __API_HOOK(GetForceCamera)(CBasePlayer *pObserver) { int retVal; @@ -21,7 +21,7 @@ int __API_HOOK(GetForceCamera)(CBasePlayer *pObserver) LINK_HOOK_CLASS_CHAIN(CBasePlayer *, CBasePlayer, Observer_IsValidTarget, (int iPlayerIndex, bool bSameTeam), iPlayerIndex, bSameTeam); -CBasePlayer *CBasePlayer::__API_HOOK(Observer_IsValidTarget)(int iPlayerIndex, bool bSameTeam) +CBasePlayer *EXT_FUNC CBasePlayer::__API_HOOK(Observer_IsValidTarget)(int iPlayerIndex, bool bSameTeam) { if (iPlayerIndex > gpGlobals->maxClients || iPlayerIndex < 1) return NULL; @@ -266,8 +266,7 @@ void CBasePlayer::Observer_CheckTarget() if (m_hObserverTarget) { - int iPlayerIndex = ENTINDEX(m_hObserverTarget->edict()); - CBasePlayer *target = UTIL_PlayerByIndex(iPlayerIndex); + CBasePlayer *target = UTIL_PlayerByIndex(m_hObserverTarget->entindex()); // check taget if (!target || target->pev->deadflag == DEAD_RESPAWNABLE || (target->pev->effects & EF_NODRAW)) @@ -301,7 +300,7 @@ void CBasePlayer::Observer_CheckTarget() void CBasePlayer::Observer_CheckProperties() { // try to find a traget if we have no current one - if (pev->iuser1 == OBS_IN_EYE && m_hObserverTarget != NULL) + if (pev->iuser1 == OBS_IN_EYE && m_hObserverTarget) { CBasePlayer *target = UTIL_PlayerByIndex(m_hObserverTarget->entindex()); @@ -488,9 +487,11 @@ void CBasePlayer::Observer_SetMode(int iMode) if (m_hObserverTarget != NULL) UTIL_SetOrigin(pev, m_hObserverTarget->pev->origin); +#ifndef REGAMEDLL_FIXES MESSAGE_BEGIN(MSG_ONE, gmsgCrosshair, NULL, pev); WRITE_BYTE((iMode == OBS_ROAMING) != 0); MESSAGE_END(); +#endif UpdateClientEffects(this, oldMode); diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 4ea63c2f..2e123325 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -88,7 +88,6 @@ int gmsgFog = 0; int gmsgShowTimer = 0; BOOL gInitHUD = TRUE; -cvar_t *sv_aim = NULL; TYPEDESCRIPTION CRevertSaved::m_SaveData[] = { @@ -151,7 +150,6 @@ char *CDeadHEV::m_szPoses[] = #endif // HOOK_GAMEDLL int gEvilImpulse101; -char g_szMapBriefingText[512]; entvars_t *g_pevLastInflictor; CBaseEntity *g_pLastSpawn; @@ -341,9 +339,9 @@ const char *GetCSModelName(int item_id) return modelName; } -LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, SetClientUserInfoName, (char *infobuffer, char *szNewName), infobuffer, szNewName); +LINK_HOOK_CLASS_CHAIN(bool, CBasePlayer, SetClientUserInfoName, (char *infobuffer, char *szNewName), infobuffer, szNewName); -void EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, char *szNewName) +bool EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, char *szNewName) { int nClientIndex = entindex(); if (pev->deadflag != DEAD_NO) @@ -351,22 +349,21 @@ void EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, c m_bHasChangedName = true; Q_snprintf(m_szNewName, sizeof(m_szNewName), "%s", szNewName); ClientPrint(pev, HUD_PRINTTALK, "#Name_change_at_respawn"); - SET_CLIENT_KEY_VALUE(nClientIndex, infobuffer, "name", (char *)STRING(pev->netname)); + return false; } - else - { - // Set the name - SET_CLIENT_KEY_VALUE(nClientIndex, infobuffer, "name", szNewName); - MESSAGE_BEGIN(MSG_BROADCAST, gmsgSayText); - WRITE_BYTE(nClientIndex); - WRITE_STRING("#Cstrike_Name_Change"); - WRITE_STRING(STRING(pev->netname)); - WRITE_STRING(szNewName); - MESSAGE_END(); + // Set the name + SET_CLIENT_KEY_VALUE(nClientIndex, infobuffer, "name", szNewName); - UTIL_LogPrintf("\"%s<%i><%s><%s>\" changed name to \"%s\"\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict()), GetTeam(m_iTeam), szNewName); - } + MESSAGE_BEGIN(MSG_BROADCAST, gmsgSayText); + WRITE_BYTE(nClientIndex); + WRITE_STRING("#Cstrike_Name_Change"); + WRITE_STRING(STRING(pev->netname)); + WRITE_STRING(szNewName); + MESSAGE_END(); + + UTIL_LogPrintf("\"%s<%i><%s><%s>\" changed name to \"%s\"\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict()), GetTeam(m_iTeam), szNewName); + return true; } void EXT_FUNC CBasePlayer::SetClientUserInfoModel_api(char *infobuffer, char *szNewModel) @@ -482,7 +479,7 @@ void CBasePlayer::SetPlayerModel(BOOL HasC4) CBasePlayer *CBasePlayer::GetNextRadioRecipient(CBasePlayer *pStartPlayer) { CBaseEntity *pEntity = static_cast(pStartPlayer); - while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player"))) { if (FNullEnt(pEntity->edict())) break; @@ -509,7 +506,7 @@ CBasePlayer *CBasePlayer::GetNextRadioRecipient(CBasePlayer *pStartPlayer) continue; CBasePlayer *pTarget = CBasePlayer::Instance(pPlayer->m_hObserverTarget->pev); - if (pTarget != NULL && pTarget->m_iTeam == m_iTeam) + if (pTarget && pTarget->m_iTeam == m_iTeam) { bSend = true; } @@ -524,7 +521,9 @@ CBasePlayer *CBasePlayer::GetNextRadioRecipient(CBasePlayer *pStartPlayer) return NULL; } -void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch, bool showIcon) +LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, Radio, (const char *msg_id, const char *msg_verbose, short pitch, bool showIcon), msg_id, msg_verbose, pitch, showIcon); + +void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg_verbose, short pitch, bool showIcon) { // Spectators don't say radio messages. if (!IsPlayer()) @@ -535,7 +534,7 @@ void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch return; CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player"))) { if (FNullEnt(pEntity->edict())) break; @@ -588,11 +587,11 @@ void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch MESSAGE_END(); // radio message icon - if (msg_verbose != NULL) + if (msg_verbose) { // search the place name where is located the player const char *placeName = NULL; - if (g_bIsCzeroGame && TheBotPhrases != NULL) + if (g_bIsCzeroGame && TheBotPhrases) { Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); @@ -606,7 +605,7 @@ void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch } } } - if (placeName != NULL) + if (placeName) ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio_location", STRING(pev->netname), placeName, msg_verbose); else ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio", STRING(pev->netname), msg_verbose); @@ -726,7 +725,7 @@ LINK_HOOK_CLASS_CHAIN(BOOL, CBasePlayer, TakeHealth, (float flHealth, int bitsDa // override takehealth // bitsDamageType indicates type of damage healed. -BOOL CBasePlayer::__API_VHOOK(TakeHealth)(float flHealth, int bitsDamageType) +BOOL EXT_FUNC CBasePlayer::__API_VHOOK(TakeHealth)(float flHealth, int bitsDamageType) { return CBaseMonster::TakeHealth(flHealth, bitsDamageType); } @@ -738,7 +737,7 @@ Vector CBasePlayer::__MAKE_VHOOK(GetGunPosition)() bool CBasePlayer::IsHittingShield(Vector &vecDirection, TraceResult *ptr) { - if ((m_pActiveItem != NULL && m_pActiveItem->m_iId == WEAPON_C4) || !HasShield()) + if ((m_pActiveItem && m_pActiveItem->m_iId == WEAPON_C4) || !HasShield()) return false; if (ptr->iHitgroup == HITGROUP_SHIELD) @@ -752,7 +751,7 @@ bool CBasePlayer::IsHittingShield(Vector &vecDirection, TraceResult *ptr) LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, TraceAttack, (entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType), pevAttacker, flDamage, vecDir, ptr, bitsDamageType); -void CBasePlayer::__API_VHOOK(TraceAttack)(entvars_t *pevAttacker, float flDamage, VectorRef vecDir, TraceResult *ptr, int bitsDamageType) +void EXT_FUNC CBasePlayer::__API_VHOOK(TraceAttack)(entvars_t *pevAttacker, float flDamage, VectorRef vecDir, TraceResult *ptr, int bitsDamageType) { bool bShouldBleed = true; bool bShouldSpark = false; @@ -763,7 +762,7 @@ void CBasePlayer::__API_VHOOK(TraceAttack)(entvars_t *pevAttacker, float flDamag if (pAttacker && pAttacker->IsPlayer() && !CSGameRules()->FPlayerCanTakeDamage(this, pAttacker)) bShouldBleed = false; #else - if (pAttacker && pAttacker->IsPlayer() && m_iTeam == pAttacker->m_iTeam && CVAR_GET_FLOAT("mp_friendlyfire") == 0) + if (pAttacker && pAttacker->IsPlayer() && m_iTeam == pAttacker->m_iTeam && !friendlyfire.value) bShouldBleed = false; #endif @@ -983,7 +982,7 @@ LINK_HOOK_CLASS_CHAIN(BOOL, CBasePlayer, TakeDamage, (entvars_t *pevInflictor, e // NOTE: each call to TakeDamage with bitsDamageType set to a time-based damage // type will cause the damage time countdown to be reset. Thus the ongoing effects of poison, radiation // etc are implemented with subsequent calls to TakeDamage using DMG_GENERIC. -BOOL CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, FloatRef flDamage, int bitsDamageType) +BOOL EXT_FUNC CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, FloatRef flDamage, int bitsDamageType) { BOOL bTookDamage; float flRatio = ARMOR_RATIO; @@ -1020,13 +1019,19 @@ BOOL CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pe { CGrenade *pGrenade = GetClassPtr((CGrenade *)pevInflictor); - if (CVAR_GET_FLOAT("mp_friendlyfire")) + if (friendlyfire.value) { if (pGrenade->m_iTeam == m_iTeam) bTeamAttack = TRUE; pAttack = CBasePlayer::Instance(pevAttacker); } +#ifdef REGAMEDLL_ADD + else if (CSGameRules()->IsFreeForAll()) + { + pAttack = CBasePlayer::Instance(pevAttacker); + } +#endif else if (pGrenade->m_iTeam == m_iTeam && (&edict()->v != pevAttacker)) { return FALSE; @@ -1091,7 +1096,7 @@ BOOL CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pe if (bTookDamage) { - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); } @@ -1108,7 +1113,7 @@ BOOL CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pe bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); if (killedByHumanPlayer) { - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); } @@ -1163,7 +1168,7 @@ BOOL CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pe return FALSE; } - if (bitsDamageType & DMG_BLAST && g_pGameRules->IsMultiplayer()) + if ((bitsDamageType & DMG_BLAST) && g_pGameRules->IsMultiplayer()) { // blasts damage armor more. flBonus *= 2; @@ -1203,7 +1208,7 @@ BOOL CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pe if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6f) { CBaseEntity *pBasePlayer = NULL; - while ((pBasePlayer = UTIL_FindEntityByClassname(pBasePlayer, "player")) != NULL) + while ((pBasePlayer = UTIL_FindEntityByClassname(pBasePlayer, "player"))) { if (FNullEnt(pBasePlayer->edict())) break; @@ -1327,7 +1332,7 @@ BOOL CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pe if (bTookDamage) { - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); } @@ -1342,10 +1347,9 @@ BOOL CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pe continue; bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); - if (killedByHumanPlayer) { - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); } @@ -1407,7 +1411,7 @@ void packPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) return; const char *modelName = GetCSModelName(pItem->m_iId); - if (modelName != NULL) + if (modelName) { // create a box to pack the stuff into. CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create("weaponbox", pPlayer->pev->origin, pPlayer->pev->angles, ENT(pPlayer->pev)); @@ -1588,7 +1592,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() } if (!HasRestrictItem(ITEM_USP, ITEM_TYPE_EQUIPPED)) { GiveNamedItem("weapon_usp"); - GiveAmmo(m_bIsVIP ? 12 : 24, "45acp", MAX_AMMO_45ACP); + GiveAmmo(m_bIsVIP ? 12 : 24, "45acp"); } break; @@ -1600,7 +1604,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() } if (!HasRestrictItem(ITEM_GLOCK18, ITEM_TYPE_EQUIPPED)) { GiveNamedItem("weapon_glock18"); - GiveAmmo(40, "9mm", MAX_AMMO_9MM); + GiveAmmo(40, "9mm"); } break; @@ -1612,15 +1616,16 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() case CT: GiveNamedItem("weapon_knife"); GiveNamedItem("weapon_usp"); - GiveAmmo(m_bIsVIP ? 12 : 24, "45acp", MAX_AMMO_45ACP); + GiveAmmo(m_bIsVIP ? 12 : 24, "45acp"); break; case TERRORIST: GiveNamedItem("weapon_knife"); GiveNamedItem("weapon_glock18"); - GiveAmmo(40, "9mm", MAX_AMMO_9MM); + GiveAmmo(40, "9mm"); break; } #endif + } void CBasePlayer::RemoveAllItems(BOOL removeSuit) @@ -1660,7 +1665,7 @@ void CBasePlayer::RemoveAllItems(BOOL removeSuit) if (bKillProgBar) SetProgressBarTime(0); - if (m_pActiveItem != NULL) + if (m_pActiveItem) { ResetAutoaim(); @@ -1690,10 +1695,6 @@ void CBasePlayer::RemoveAllItems(BOOL removeSuit) pev->viewmodel = 0; pev->weaponmodel = 0; -#ifdef REGAMEDLL_FIXES - m_iHideHUD |= HIDEHUD_WEAPONS; -#endif - if (removeSuit) pev->weapons = 0; else @@ -1704,6 +1705,10 @@ void CBasePlayer::RemoveAllItems(BOOL removeSuit) UpdateClientData(); +#ifdef REGAMEDLL_FIXES + m_iHideHUD |= HIDEHUD_WEAPONS; +#endif + // send Selected Weapon Message to our client MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); WRITE_BYTE(0); @@ -1755,7 +1760,7 @@ void CBasePlayer::SetProgressBarTime(int time) CBaseEntity *pPlayer = NULL; int myIndex = entindex(); - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -1795,7 +1800,7 @@ void CBasePlayer::SetProgressBarTime2(int time, float timeElapsed) CBaseEntity *pPlayer = NULL; int myIndex = entindex(); - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) break; @@ -1997,7 +2002,7 @@ void CBasePlayer::SendFOV(int fov) LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, Killed, (entvars_t *pevAttacker, int iGib), pevAttacker, iGib); -void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) +void EXT_FUNC CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) { m_canSwitchObserverModes = false; @@ -2006,7 +2011,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) CBaseEntity *pAttackerEntity = CBaseEntity::Instance(pevAttacker); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_DIED, this, pAttackerEntity); } @@ -2016,7 +2021,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) bool killerHasShield = false; bool wasBlind = false; - if (TheCareerTasks != NULL) + if (TheCareerTasks) { if (!IsBot()) { @@ -2048,7 +2053,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); if (killedByHumanPlayer) { - if (TheCareerTasks != NULL) + if (TheCareerTasks) { TheCareerTasks->HandleEnemyKill(wasBlind, GetWeaponName(g_pevLastInflictor, pevAttacker), m_bHeadshotKilled, killerHasShield, this, pPlayer); } @@ -2094,7 +2099,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) #ifndef REGAMEDLL_FIXES CSound *pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(edict())); - if (pSound != NULL) + if (pSound) { pSound->Reset(); } @@ -2152,7 +2157,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) pev->iuser2 = ENTINDEX(edict()); pev->iuser3 = ENTINDEX(ENT(pevAttacker)); - m_hObserverTarget = UTIL_PlayerByIndex(pev->iuser3); + m_hObserverTarget = UTIL_PlayerByIndexSafe(pev->iuser3); MESSAGE_BEGIN(MSG_ONE, gmsgADStop, NULL, pev); MESSAGE_END(); @@ -2269,7 +2274,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) BuyZoneIcon_Clear(this); SetThink(&CBasePlayer::PlayerDeathThink); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->solid = SOLID_NOT; if (m_bPunishedForTK) @@ -2309,7 +2314,7 @@ BOOL CBasePlayer::IsBombGuy() LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, SetAnimation, (PLAYER_ANIM playerAnim), playerAnim); -void CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim) +void EXT_FUNC CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim) { int animDesired; float speed; @@ -2346,7 +2351,7 @@ void CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim) else { m_IdealActivity = ACT_HOP; - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_JUMPED, this); } @@ -2374,7 +2379,7 @@ void CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim) else { m_IdealActivity = ACT_RANGE_ATTACK1; - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED, this); } @@ -2388,7 +2393,7 @@ void CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim) else { m_IdealActivity = ACT_RANGE_ATTACK2; - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED, this); } @@ -2402,7 +2407,7 @@ void CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim) else { m_IdealActivity = ACT_RELOAD; - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_RELOADED, this); } @@ -2605,7 +2610,7 @@ void CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim) //if (speed > 150.0f) if (pev->velocity.Length2D() > 150.0f) { - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_FOOTSTEP, this); } @@ -3006,7 +3011,7 @@ NOXREF void CBasePlayer::ThrowWeapon(char *pszItemName) { CBasePlayerItem *pWeapon = m_rgpPlayerItems[i]; - while (pWeapon != NULL) + while (pWeapon) { if (!Q_strcmp(pszItemName, STRING(pWeapon->pev->classname))) { @@ -3040,7 +3045,7 @@ void CWShield::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) if (pPlayer->pev->deadflag != DEAD_NO) return; - if (m_hEntToIgnoreTouchesFrom != NULL && pPlayer == (CBasePlayer *)m_hEntToIgnoreTouchesFrom) + if (m_hEntToIgnoreTouchesFrom && pPlayer == (CBasePlayer *)m_hEntToIgnoreTouchesFrom) { if (m_flTimeToIgnoreTouches > gpGlobals->time) return; @@ -3050,7 +3055,7 @@ void CWShield::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) if (!pPlayer->m_bHasPrimary) { - if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == WEAPON_ELITE) + if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == WEAPON_ELITE) return; if (pPlayer->m_pActiveItem) @@ -3077,12 +3082,12 @@ void CWShield::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, GiveShield, (bool bDeploy), bDeploy); -void CBasePlayer::__API_HOOK(GiveShield)(bool bDeploy) +void EXT_FUNC CBasePlayer::__API_HOOK(GiveShield)(bool bDeploy) { m_bOwnsShield = true; m_bHasPrimary = true; - if (m_pActiveItem != NULL) + if (m_pActiveItem) { CBasePlayerWeapon *pWeapon = static_cast(m_pActiveItem); @@ -3112,17 +3117,19 @@ void CBasePlayer::RemoveShield() } } -void CBasePlayer::DropShield(bool bDeploy) +LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, DropShield, (bool bDeploy), bDeploy); + +void EXT_FUNC CBasePlayer::__API_HOOK(DropShield)(bool bDeploy) { if (!HasShield()) return; - if (m_pActiveItem != NULL && !m_pActiveItem->CanHolster()) + if (m_pActiveItem && !m_pActiveItem->CanHolster()) return; CBasePlayerWeapon *pWeapon = static_cast(m_pActiveItem); - if (pWeapon != NULL) + if (pWeapon) { if (pWeapon->m_iId == WEAPON_HEGRENADE || pWeapon->m_iId == WEAPON_FLASHBANG || pWeapon->m_iId == WEAPON_SMOKEGRENADE) { @@ -3131,7 +3138,7 @@ void CBasePlayer::DropShield(bool bDeploy) } } - if (m_pActiveItem != NULL) + if (m_pActiveItem) { if (m_pActiveItem->m_flStartThrow != 0.0f) m_pActiveItem->Holster(); @@ -3143,14 +3150,14 @@ void CBasePlayer::DropShield(bool bDeploy) m_flNextAttack = 0; } - if (m_pActiveItem != NULL && IsProtectedByShield()) + if (m_pActiveItem && IsProtectedByShield()) ((CBasePlayerWeapon *)m_pActiveItem)->SecondaryAttack(); m_bShieldDrawn = false; RemoveShield(); - if (m_pActiveItem != NULL && bDeploy) + if (m_pActiveItem && bDeploy) m_pActiveItem->Deploy(); UTIL_MakeVectors(pev->angles); @@ -3193,7 +3200,7 @@ NOXREF void CBasePlayer::ThrowPrimary() LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, AddAccount, (int amount, RewardType type, bool bTrackChange), amount, type, bTrackChange); #ifdef REGAMEDLL_ADD -void CBasePlayer::__API_HOOK(AddAccount)(int amount, RewardType type, bool bTrackChange) +void EXT_FUNC CBasePlayer::__API_HOOK(AddAccount)(int amount, RewardType type, bool bTrackChange) { bool bSendMoney = true; switch (type) @@ -3226,7 +3233,7 @@ void CBasePlayer::__API_HOOK(AddAccount)(int amount, RewardType type, bool bTrac } } #else -void CBasePlayer::__API_HOOK(AddAccount)(int amount, RewardType type, bool bTrackChange) +void EXT_FUNC CBasePlayer::__API_HOOK(AddAccount)(int amount, RewardType type, bool bTrackChange) { m_iAccount += amount; @@ -3261,12 +3268,28 @@ void CBasePlayer::ResetMenu() void CBasePlayer::SyncRoundTimer() { - float tmRemaining; + float tmRemaining = 0; + BOOL bFreezePeriod = g_pGameRules->IsFreezePeriod(); - if (CSGameRules()->IsMultiplayer()) + if (g_pGameRules->IsMultiplayer()) + { tmRemaining = CSGameRules()->GetRoundRemainingTime(); - else - tmRemaining = 0; + +#ifdef REGAMEDLL_FIXES + // hide timer HUD because it is useless. + if (tmRemaining <= 0.0f && CSGameRules()->m_iRoundTime <= 0) { + m_iHideHUD |= HIDEHUD_TIMER; + return; + } + + if (m_iHideHUD & HIDEHUD_TIMER) + { + m_iHideHUD &= ~HIDEHUD_TIMER; + MESSAGE_BEGIN(MSG_ONE, gmsgShowTimer, NULL, pev); + MESSAGE_END(); + } +#endif + } if (tmRemaining < 0) tmRemaining = 0; @@ -3275,17 +3298,17 @@ void CBasePlayer::SyncRoundTimer() WRITE_SHORT(int(tmRemaining)); MESSAGE_END(); - if (!CSGameRules()->IsMultiplayer()) + if (!g_pGameRules->IsMultiplayer()) return; - if (CSGameRules()->IsFreezePeriod() && TheTutor != NULL && !IsObserver()) + if (bFreezePeriod && TheTutor && !IsObserver()) { MESSAGE_BEGIN(MSG_ONE, gmsgBlinkAcct, NULL, pev); WRITE_BYTE(MONEY_BLINK_AMOUNT); MESSAGE_END(); } - if (TheCareerTasks != NULL && CSGameRules()->IsCareer()) + if (TheCareerTasks && CSGameRules()->IsCareer()) { int remaining = 0; bool shouldCountDown = false; @@ -3299,17 +3322,17 @@ void CBasePlayer::SyncRoundTimer() if (remaining < 0) remaining = 0; - if (CSGameRules()->IsFreezePeriod()) + if (bFreezePeriod) remaining = -1; if (TheCareerTasks->GetFinishedTaskTime()) remaining = -TheCareerTasks->GetFinishedTaskTime(); - if (!CSGameRules()->IsFreezePeriod() && !TheCareerTasks->GetFinishedTaskTime()) + if (!bFreezePeriod && !TheCareerTasks->GetFinishedTaskTime()) { shouldCountDown = true; } - if (!CSGameRules()->IsFreezePeriod()) + if (!bFreezePeriod) { if (TheCareerTasks->GetFinishedTaskTime() || (TheCareerTasks->GetTaskTime() <= TheCareerTasks->GetRoundElapsedTime())) { @@ -3370,7 +3393,9 @@ void CBasePlayer::MenuPrint(const char *msg) MESSAGE_END(); } -void CBasePlayer::MakeVIP() +LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, MakeVIP); + +void EXT_FUNC CBasePlayer::__API_HOOK(MakeVIP)() { pev->body = 0; m_iModelName = MODEL_VIP; @@ -3424,105 +3449,34 @@ void CBasePlayer::JoiningThink() } case GETINTOGAME: { - m_bNotKilled = false; - m_iIgnoreGlobalChat = IGNOREMSG_NONE; - - m_iTeamKills = 0; - m_iFOV = DEFAULT_FOV; - - Q_memset(&m_rebuyStruct, 0, sizeof(m_rebuyStruct)); - - m_bIsInRebuy = false; - m_bJustConnected = false; - m_fLastMovement = gpGlobals->time; - - ResetMaxSpeed(); - m_iJoiningState = JOINED; - - if (CSGameRules()->m_bMapHasEscapeZone && m_iTeam == CT) - { -#ifndef REGAMEDLL_ADD - m_iAccount = 0; -#endif - CheckStartMoney(); - AddAccount(startmoney.value, RT_INTO_GAME); + if (GetIntoGame()) { + return; } - if (g_pGameRules->FPlayerCanRespawn(this)) - { - Spawn(); - CSGameRules()->CheckWinConditions(); - - if (!CSGameRules()->m_flRestartRoundTime && CSGameRules()->m_bMapHasBombTarget && !CSGameRules()->IsThereABomber() && !CSGameRules()->IsThereABomb()) - { - CSGameRules()->GiveC4(); - } - if (m_iTeam == TERRORIST) - { - CSGameRules()->m_iNumEscapers++; - } - } - else - { - pev->deadflag = DEAD_RESPAWNABLE; - - MAKE_STRING_CLASS("player", pev); - - pev->flags &= (FL_PROXY | FL_FAKECLIENT); - pev->flags |= (FL_SPECTATOR | FL_CLIENT); - - edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot(this); - StartObserver(pev->origin, pentSpawnSpot->v.angles); - - CSGameRules()->CheckWinConditions(); - - MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); - WRITE_BYTE(entindex()); - WRITE_STRING(GetTeamName(m_iTeam)); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_ALL, gmsgLocation); - WRITE_BYTE(entindex()); - WRITE_STRING(""); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_SHORT(int(pev->frags)); - WRITE_SHORT(m_iDeaths); - WRITE_SHORT(0); - WRITE_SHORT(m_iTeam); - MESSAGE_END(); - - if (!(m_flDisplayHistory & DHF_SPEC_DUCK)) - { - HintMessage("#Spec_Duck", TRUE, TRUE); - m_flDisplayHistory |= DHF_SPEC_DUCK; - } - } - return; + break; } } - if (m_pIntroCamera != NULL && gpGlobals->time >= m_fIntroCamTime) + if (m_pIntroCamera && gpGlobals->time >= m_fIntroCamTime) { + // find the next another camera m_pIntroCamera = UTIL_FindEntityByClassname(m_pIntroCamera, "trigger_camera"); + // could not find, go back to the start if (!m_pIntroCamera) { m_pIntroCamera = UTIL_FindEntityByClassname(NULL, "trigger_camera"); } CBaseEntity *Target = UTIL_FindEntityByTargetname(NULL, STRING(m_pIntroCamera->pev->target)); - - if (Target != NULL) + if (Target) { - Vector CamAngles = UTIL_VecToAngles((Target->pev->origin - m_pIntroCamera->pev->origin).Normalize()); + Vector vecAngles = UTIL_VecToAngles((Target->pev->origin - m_pIntroCamera->pev->origin).Normalize()); - CamAngles.x = -CamAngles.x; + vecAngles.x = -vecAngles.x; UTIL_SetOrigin(pev, m_pIntroCamera->pev->origin); - pev->angles = CamAngles; + pev->angles = vecAngles; pev->v_angle = pev->angles; pev->velocity = g_vecZero; @@ -3537,9 +3491,11 @@ void CBasePlayer::JoiningThink() } } -void CBasePlayer::Disappear() +LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, Disappear); + +void EXT_FUNC CBasePlayer::__API_HOOK(Disappear)() { - if (m_pTank != NULL) + if (m_pTank) { m_pTank->Use(this, this, USE_OFF, 0); m_pTank = NULL; @@ -3657,27 +3613,42 @@ void CBasePlayer::PlayerDeathThink() BOOL fAnyButtonDown = (pev->button & ~IN_SCORE); - // if the player has been dead for one second longer than allowed by forcerespawn, - // forcerespawn isn't on. Send the player off to an intermission camera until they - // choose to respawn. - if (g_pGameRules->IsMultiplayer()) +#ifdef REGAMEDLL_FIXES + // do not make a corpse if the player goes to respawn. + if (pev->deadflag != DEAD_RESPAWNABLE && forcerespawn.value <= 0) +#endif { - if (gpGlobals->time > m_fDeadTime + 3.0f && !(m_afPhysicsFlags & PFLAG_OBSERVER)) + // if the player has been dead for one second longer than allowed by forcerespawn, + // forcerespawn isn't on. Send the player off to an intermission camera until they choose to respawn. + if (g_pGameRules->IsMultiplayer()) { - // Send message to everybody to spawn a corpse. - SpawnClientSideCorpse(); + if (gpGlobals->time > m_fDeadTime + 3.0f && !(m_afPhysicsFlags & PFLAG_OBSERVER)) + { + // Send message to everybody to spawn a corpse. + SpawnClientSideCorpse(); - // go to dead camera. - StartDeathCam(); + // go to dead camera. + StartDeathCam(); + } } } // wait for all buttons released if (pev->deadflag == DEAD_DEAD && m_iTeam != UNASSIGNED && m_iTeam != SPECTATOR) { - // wait for any button down, or mp_forcerespawn is set and the respawn time is up +#ifdef REGAMEDLL_ADD + // wait for any button down, or mp_forcerespawn is set and the respawn time is up + if (forcerespawn.value > 0 && (fAnyButtonDown || (gpGlobals->time > (m_fDeadTime + forcerespawn.value)))) + { + respawn(pev, FALSE); + pev->button = 0; + pev->nextthink = -1; + return; + } +#else if (fAnyButtonDown) return; +#endif if (g_pGameRules->FPlayerCanRespawn(this)) { @@ -3688,8 +3659,10 @@ void CBasePlayer::PlayerDeathThink() } pev->nextthink = gpGlobals->time + 0.1f; + return; } - else if (pev->deadflag == DEAD_RESPAWNABLE) + + if (pev->deadflag == DEAD_RESPAWNABLE) { // don't copy a corpse if we're in deathcam. respawn(pev, FALSE); @@ -3705,20 +3678,17 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(RoundRespawn)() m_canSwitchObserverModes = true; // teamkill punishment.. - if (m_bJustKilledTeammate && CVAR_GET_FLOAT("mp_tkpunish")) + if (m_bJustKilledTeammate && tkpunish.value) { + m_bPunishedForTK = true; m_bJustKilledTeammate = false; + #ifndef REGAMEDLL_FIXES // TODO: wtf? CLIENT_COMMAND(edict(), "kill\n"); -#else - if (pev->health > 0.0f) - { - ClientKill(ENT(pev)); - } #endif - m_bPunishedForTK = true; } + if (m_iMenu != Menu_ChooseAppearance) { respawn(pev); @@ -3736,6 +3706,14 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(RoundRespawn)() } m_lastLocation[0] = '\0'; + +#ifdef REGAMEDLL_FIXES + if (m_bPunishedForTK && pev->health > 0) + { + ClientKill(ENT(pev)); + } +#endif + } // StartDeathCam - find an intermission spot and send the @@ -3750,13 +3728,15 @@ void CBasePlayer::StartDeathCam() StartObserver(pev->origin, pev->angles); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_DEATH_CAMERA_START, this); } } -void CBasePlayer::StartObserver(Vector vecPosition, Vector vecViewAngle) +LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, StartObserver, (Vector &vecPosition, Vector &vecViewAngle), vecPosition, vecViewAngle); + +void EXT_FUNC CBasePlayer::__API_HOOK(StartObserver)(Vector &vecPosition, Vector &vecViewAngle) { // clear any clientside entities attached to this player MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); @@ -3765,17 +3745,17 @@ void CBasePlayer::StartObserver(Vector vecPosition, Vector vecViewAngle) MESSAGE_END(); // Holster weapon immediately, to allow it to cleanup - if (m_pActiveItem != NULL) + if (m_pActiveItem) m_pActiveItem->Holster(); - if (m_pTank != NULL) + if (m_pTank) { - m_pTank->Use(this, this); + m_pTank->Use(this, this, USE_OFF, 0); m_pTank = NULL; } // clear out the suit message cache so we don't keep chattering - SetSuitUpdate(); + SetSuitUpdate(NULL, FALSE, 0); // Tell Ammo Hud that the player is dead MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); @@ -3790,16 +3770,13 @@ void CBasePlayer::StartObserver(Vector vecPosition, Vector vecViewAngle) // Setup flags m_iHideHUD = (HIDEHUD_WEAPONS | HIDEHUD_HEALTH); m_afPhysicsFlags |= PFLAG_OBSERVER; - pev->effects = EF_NODRAW; + // set position and viewangle pev->view_ofs = g_vecZero; - pev->angles = pev->v_angle = vecViewAngle; - pev->fixangle = 1; pev->solid = SOLID_NOT; - pev->takedamage = DAMAGE_NO; pev->movetype = MOVETYPE_NONE; @@ -3812,15 +3789,15 @@ void CBasePlayer::StartObserver(Vector vecPosition, Vector vecViewAngle) m_iObserverC4State = 0; m_bObserverHasDefuser = false; - m_iObserverWeapon = 0; + + // Find a player to watch m_flNextObserverInput = 0; pev->iuser1 = OBS_NONE; static int iFirstTime = 1; - - if (iFirstTime != 0 && CSGameRules() != NULL && CSGameRules()->IsCareer() && !IsBot()) + if (iFirstTime != 0 && CSGameRules() && CSGameRules()->IsCareer() && !IsBot()) { Observer_SetMode(OBS_CHASE_LOCKED); CLIENT_COMMAND(edict(), "spec_autodirector_internal 1\n"); @@ -3876,7 +3853,7 @@ void CBasePlayer::PlayerUse() // Hit Use on a train? if (m_afButtonPressed & IN_USE) { - if (m_pTank != NULL) + if (m_pTank) { // Stop controlling the tank // TODO: Send HUD Update @@ -3945,13 +3922,13 @@ void CBasePlayer::PlayerUse() if (result.flFraction < 1.0f) { CBaseEntity *hit = Instance(result.pHit); - if (hit != NULL && FClassnameIs(hit->pev, "hostage_entity") && CanSeeUseable(this, hit)) + if (hit && FClassnameIs(hit->pev, "hostage_entity") && CanSeeUseable(this, hit)) pClosest = hit; } if (!pClosest) { - while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, useHostageRange)) != NULL) + while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, useHostageRange))) { if (!FClassnameIs(pObject->pev, "hostage_entity")) continue; @@ -3972,7 +3949,7 @@ void CBasePlayer::PlayerUse() if (!pClosest) { - while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, PLAYER_USE_RADIUS)) != NULL) + while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, PLAYER_USE_RADIUS))) { if (pObject->ObjectCaps() & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE)) { @@ -3997,7 +3974,7 @@ void CBasePlayer::PlayerUse() pObject = pClosest; // Found an object - if (pObject != NULL) + if (pObject) { if (!useNewHostages || CanSeeUseable(this, pObject)) { @@ -4126,7 +4103,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Duck)() LINK_HOOK_CLASS_CHAIN2(int, CBasePlayer, ObjectCaps); -int CBasePlayer::__API_VHOOK(ObjectCaps)() +int EXT_FUNC CBasePlayer::__API_VHOOK(ObjectCaps)() { return (CBaseMonster::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } @@ -4134,14 +4111,14 @@ int CBasePlayer::__API_VHOOK(ObjectCaps)() LINK_HOOK_CLASS_CHAIN2(int, CBasePlayer, Classify); // ID's player as such. -int CBasePlayer::__API_VHOOK(Classify)() +int EXT_FUNC CBasePlayer::__API_VHOOK(Classify)() { return CLASS_PLAYER; } LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, AddPoints, (int score, BOOL bAllowNegativeScore), score, bAllowNegativeScore); -void CBasePlayer::__API_VHOOK(AddPoints)(int score, BOOL bAllowNegativeScore) +void EXT_FUNC CBasePlayer::__API_VHOOK(AddPoints)(int score, BOOL bAllowNegativeScore) { // Positive score always adds if (score < 0 && !bAllowNegativeScore) @@ -4174,15 +4151,14 @@ void CBasePlayer::__API_VHOOK(AddPoints)(int score, BOOL bAllowNegativeScore) LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, AddPointsToTeam, (int score, BOOL bAllowNegativeScore), score, bAllowNegativeScore); -void CBasePlayer::__API_VHOOK(AddPointsToTeam)(int score, BOOL bAllowNegativeScore) +void EXT_FUNC CBasePlayer::__API_VHOOK(AddPointsToTeam)(int score, BOOL bAllowNegativeScore) { int index = entindex(); - for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer != NULL && i != index) + if (pPlayer && i != index) { if (g_pGameRules->PlayerRelationship(this, pPlayer) == GR_TEAMMATE) { @@ -4211,25 +4187,26 @@ bool CBasePlayer::CanPlayerBuy(bool display) return false; } - int buyTime = int(CVAR_GET_FLOAT("mp_buytime") * 60.0f); - if (buyTime < MIN_BUY_TIME) - { - buyTime = MIN_BUY_TIME; - CVAR_SET_FLOAT("mp_buytime", (MIN_BUY_TIME / 60.0f)); - } - - if (gpGlobals->time - CSGameRules()->m_fRoundStartTime > buyTime #ifdef REGAMEDLL_ADD - && buytime.value != -1.0f + if (buytime.value != -1.0f) #endif -) { - if (display) + int buyTime = int(buytime.value * 60.0f); + if (buyTime < MIN_BUY_TIME) { - ClientPrint(pev, HUD_PRINTCENTER, "#Cant_buy", UTIL_dtos1(buyTime)); + buyTime = MIN_BUY_TIME; + CVAR_SET_FLOAT("mp_buytime", (MIN_BUY_TIME / 60.0f)); } - return false; + if (gpGlobals->time - CSGameRules()->m_fRoundStartTime > buyTime) + { + if (display) + { + ClientPrint(pev, HUD_PRINTCENTER, "#Cant_buy", UTIL_dtos1(buyTime)); + } + + return false; + } } if (m_bIsVIP) @@ -4287,7 +4264,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(PreThink)() m_hintMessageQueue.Update(this); g_pGameRules->PlayerThink(this); - if (g_fGameOver) + if (g_pGameRules->IsGameOver()) { // intermission or finale return; @@ -4350,7 +4327,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(PreThink)() } } - if (g_pGameRules != NULL && g_pGameRules->FAllowFlashlight()) + if (g_pGameRules && g_pGameRules->FAllowFlashlight()) m_iHideHUD &= ~HIDEHUD_FLASHLIGHT; else m_iHideHUD |= HIDEHUD_FLASHLIGHT; @@ -4823,7 +4800,7 @@ void CBasePlayer::UpdatePlayerSound() m_iExtraSoundTypes = 0; } - if (pSound != NULL) + if (pSound) { pSound->m_vecOrigin = pev->origin; pSound->m_iVolume = iVolume; @@ -4845,14 +4822,14 @@ LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, PostThink); void EXT_FUNC CBasePlayer::__API_VHOOK(PostThink)() { // intermission or finale - if (g_fGameOver) + if (g_pGameRules->IsGameOver()) goto pt_end; if (!IsAlive()) goto pt_end; // Handle Tank controlling - if (m_pTank != NULL) + if (m_pTank) { // if they've moved too far from the gun, or selected a weapon, unuse the gun if (m_pTank->OnControls(pev) && !pev->weaponmodel) @@ -4896,7 +4873,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(PostThink)() m_LastHitGroup = HITGROUP_GENERIC; TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), flFallDamage, DMG_FALL); pev->punchangle.x = 0; - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_LANDED_FROM_HEIGHT, this); } @@ -4951,7 +4928,7 @@ pt_end: { CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; - while (pPlayerItem != NULL) + while (pPlayerItem) { CBasePlayerWeapon *gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); @@ -4992,7 +4969,7 @@ BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot) if (!pSpot->IsTriggered(pPlayer)) return FALSE; - while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64)) != NULL) + while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64))) { // if ent is a client, don't spawn on 'em if (ent->IsPlayer() && ent != pPlayer) @@ -5009,7 +4986,7 @@ NOXREF void InitZombieSpawns() g_pSelectedZombieSpawn = NULL; zombieSpawnCount = 0; - while ((spot = UTIL_FindEntityByClassname(spot, "info_player_start")) != NULL) + while ((spot = UTIL_FindEntityByClassname(spot, "info_player_start"))) { if (spot->pev->origin != Vector(0, 0, 0)) { @@ -5043,7 +5020,7 @@ bool CBasePlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity *&pSpot do { - if (pSpot != NULL) + if (pSpot) { // check if pSpot is valid if (IsSpawnPointValid(this, pSpot)) @@ -5069,7 +5046,7 @@ bool CBasePlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity *&pSpot if (!FNullEnt(pSpot)) { CBaseEntity *ent = NULL; - while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64)) != NULL) + while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64))) { // if ent is a client, kill em (unless they are ourselves) if (ent->IsPlayer() && ent->edict() != player) @@ -5340,7 +5317,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Spawn)() for (i = 0; i < MAX_RECENT_PATH; ++i) m_vRecentPath[ i ] = Vector(0, 0, 0); - if (m_pActiveItem != NULL && !pev->viewmodel) + if (m_pActiveItem && !pev->viewmodel) { switch (m_pActiveItem->m_iId) { @@ -5420,7 +5397,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Spawn)() ALERT(at_console, "Couldn't alloc player sound slot!\n"); } - m_iHideHUD &= ~(HIDEHUD_WEAPONS | HIDEHUD_HEALTH | HIDEHUD_TIMER | HIDEHUD_MONEY); + m_iHideHUD &= ~(HIDEHUD_WEAPONS | HIDEHUD_HEALTH | HIDEHUD_TIMER | HIDEHUD_MONEY | HIDEHUD_CROSSHAIR); m_fNoPlayerSound = FALSE; m_pLastItem = NULL; m_fWeapon = FALSE; @@ -5428,9 +5405,15 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Spawn)() m_iClientBattery = -1; m_fInitHUD = TRUE; +#ifdef REGAMEDLL_FIXES + m_iClientHideHUD = -1; +#endif + if (!m_bNotKilled) { +#ifndef REGAMEDLL_FIXES m_iClientHideHUD = -1; +#endif for (i = 0; i < MAX_AMMO_SLOTS; ++i) m_rgAmmo[i] = 0; @@ -5519,15 +5502,13 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Spawn)() UTIL_ScreenFade(this, Vector(0, 0, 0), 0.001); SyncRoundTimer(); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_SPAWNED, this); } m_allowAutoFollowTime = false; - sv_aim = CVAR_GET_POINTER("sv_aim"); - for (i = 0; i < COMMANDS_TO_TRACK; ++i) m_flLastCommandTime[i] = -1; @@ -5594,7 +5575,7 @@ int CBasePlayer::__MAKE_VHOOK(Save)(CSave &save) void CBasePlayer::SetScoreboardAttributes(CBasePlayer *destination) { - if (destination != NULL) + if (destination) { SetScoreAttrib(destination); return; @@ -5604,7 +5585,7 @@ void CBasePlayer::SetScoreboardAttributes(CBasePlayer *destination) { CBasePlayer *player = UTIL_PlayerByIndex(i); - if (player != NULL && !FNullEnt(player->edict())) + if (player && !FNullEnt(player->edict())) SetScoreboardAttributes(player); } } @@ -5708,7 +5689,7 @@ NOXREF void CBasePlayer::SelectNextItem(int iItem) CBasePlayerItem *pLast = pItem; - while (pLast->m_pNext != NULL) + while (pLast->m_pNext) pLast = pLast->m_pNext; pLast->m_pNext = m_pActiveItem; @@ -5718,7 +5699,7 @@ NOXREF void CBasePlayer::SelectNextItem(int iItem) ResetAutoaim(); - if (m_pActiveItem != NULL) + if (m_pActiveItem) { m_pActiveItem->Holster(); } @@ -5733,7 +5714,7 @@ NOXREF void CBasePlayer::SelectNextItem(int iItem) m_pLastItem = m_pActiveItem; m_pActiveItem = pItem; - if (m_pActiveItem != NULL) + if (m_pActiveItem) { UpdateShieldCrosshair(true); @@ -5751,17 +5732,14 @@ void CBasePlayer::SelectItem(const char *pstr) return; } - auto pItem = ForEachItem([this, pstr](CBasePlayerItem *item) { - return FClassnameIs(item->pev, pstr); - }); - + auto pItem = GetItemByName(pstr); if (!pItem || pItem == m_pActiveItem) return; ResetAutoaim(); // FIX, this needs to queue them up and delay - if (m_pActiveItem != NULL) + if (m_pActiveItem) { m_pActiveItem->Holster(); } @@ -5769,7 +5747,7 @@ void CBasePlayer::SelectItem(const char *pstr) m_pLastItem = m_pActiveItem; m_pActiveItem = pItem; - if (m_pActiveItem != NULL) + if (m_pActiveItem) { CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; pWeapon->m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; @@ -5928,9 +5906,9 @@ void CBloodSplat::Spray() pev->nextthink = gpGlobals->time + 0.1f; } -LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, GiveNamedItem, (const char *pszName), pszName); +LINK_HOOK_CLASS_CHAIN(CBaseEntity *, CBasePlayer, GiveNamedItem, (const char *pszName), pszName); -void CBasePlayer::__API_HOOK(GiveNamedItem)(const char *pszName) +CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(GiveNamedItem)(const char *pszName) { string_t istr = MAKE_STRING(pszName); edict_t *pent = CREATE_NAMED_ENTITY(istr); @@ -5938,7 +5916,7 @@ void CBasePlayer::__API_HOOK(GiveNamedItem)(const char *pszName) if (FNullEnt(pent)) { ALERT(at_console, "NULL Ent in GiveNamedItem!\n"); - return; + return nullptr; } pent->v.origin = pev->origin; @@ -5946,18 +5924,20 @@ void CBasePlayer::__API_HOOK(GiveNamedItem)(const char *pszName) DispatchSpawn(pent); DispatchTouch(pent, ENT(pev)); + + return (CBaseEntity *)GET_PRIVATE(pent); } // external function for 3rd-party -void CBasePlayer::GiveNamedItemEx(const char *pszName) +CBaseEntity *CBasePlayer::GiveNamedItemEx(const char *pszName) { string_t istr = ALLOC_STRING(pszName); edict_t *pent = CREATE_NAMED_ENTITY(istr); if (FNullEnt(pent)) { - ALERT(at_console, "NULL Ent in GiveNamedItem!\n"); - return; + ALERT(at_console, "NULL Ent in GiveNamedItemEx!\n"); + return nullptr; } pent->v.origin = pev->origin; @@ -5968,11 +5948,14 @@ void CBasePlayer::GiveNamedItemEx(const char *pszName) #ifdef REGAMEDLL_FIXES // not allow the item to fall to the ground. - if (FNullEnt(pent->v.owner)) + if (FNullEnt(pent->v.owner) || pent->v.owner != edict()) { pent->v.flags |= FL_KILLME; + return nullptr; } #endif + + return (CBaseEntity *)GET_PRIVATE(pent); } CBaseEntity *FindEntityForward(CBaseEntity *pMe) @@ -6029,6 +6012,8 @@ void CBasePlayer::FlashlightTurnOff() m_flFlashLightTime = gpGlobals->time + FLASH_CHARGE_TIME; } +// When recording a demo, we need to have the server tell us the entire client state so that the client side .dll can behave correctly. +// Reset stuff so that the state is transmitted. void CBasePlayer::ForceClientDllUpdate() { #ifdef REGAMEDLL_FIXES @@ -6039,10 +6024,11 @@ void CBasePlayer::ForceClientDllUpdate() m_iClientHealth = -1; m_iClientBattery = -1; - m_fWeapon = FALSE; - m_fInitHUD = TRUE; - m_iTrain |= TRAIN_NEW; + m_fWeapon = FALSE; // Force weapon send + m_fInitHUD = TRUE; // Force HUD gmsgResetHUD message + m_iTrain |= TRAIN_NEW; // Force new train message. + // Now force all the necessary messages to be sent. UpdateClientData(); HandleSignals(); } @@ -6215,12 +6201,12 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse) Vector end = start + gpGlobals->v_forward * 1024; UTIL_TraceLine(start, end, ignore_monsters, edict(), &tr); - if (tr.pHit != NULL) + if (tr.pHit) pWorld = tr.pHit; const char *pszTextureName = TRACE_TEXTURE(pWorld, start, end); - if (pszTextureName != NULL) + if (pszTextureName) ALERT(at_console, "Texture: %s\n", pszTextureName); break; @@ -6263,7 +6249,7 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse) // remove creature. pEntity = FindEntityForward(this); - if (pEntity != NULL && pEntity->pev->takedamage != DAMAGE_NO) + if (pEntity && pEntity->pev->takedamage != DAMAGE_NO) { pEntity->SetThink(&CBaseEntity::SUB_Remove); } @@ -6312,10 +6298,10 @@ void OLD_CheckBuyZone(CBasePlayer *player) else if (player->m_iTeam == CT) pszSpawnClass = "info_player_start"; - if (pszSpawnClass != NULL) + if (pszSpawnClass) { CBaseEntity *pSpot = NULL; - while ((pSpot = UTIL_FindEntityByClassname(pSpot, pszSpawnClass)) != NULL) + while ((pSpot = UTIL_FindEntityByClassname(pSpot, pszSpawnClass))) { if ((pSpot->pev->origin - player->pev->origin).Length() < 200.0f) player->m_signals.Signal(SIGNAL_BUY); @@ -6326,7 +6312,7 @@ void OLD_CheckBuyZone(CBasePlayer *player) void OLD_CheckBombTarget(CBasePlayer *player) { CBaseEntity *pSpot = NULL; - while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_bomb_target")) != NULL) + while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_bomb_target"))) { if ((pSpot->pev->origin - player->pev->origin).Length() <= 256.0f) player->m_signals.Signal(SIGNAL_BOMB); @@ -6336,7 +6322,7 @@ void OLD_CheckBombTarget(CBasePlayer *player) void OLD_CheckRescueZone(CBasePlayer *player) { CBaseEntity *pSpot = NULL; - while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue")) != NULL) + while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue"))) { if ((pSpot->pev->origin - player->pev->origin).Length() <= 256.0f) player->m_signals.Signal(SIGNAL_RESCUE); @@ -6402,7 +6388,7 @@ void CBasePlayer::HandleSignals() LINK_HOOK_CLASS_CHAIN(BOOL, CBasePlayer, AddPlayerItem, (CBasePlayerItem *pItem), pItem); // Add a weapon to the player (Item == Weapon == Selectable Object) -BOOL CBasePlayer::__API_VHOOK(AddPlayerItem)(CBasePlayerItem *pItem) +BOOL EXT_FUNC CBasePlayer::__API_VHOOK(AddPlayerItem)(CBasePlayerItem *pItem) { CBasePlayerItem *pInsert = m_rgpPlayerItems[ pItem->iItemSlot() ]; while (pInsert) @@ -6469,7 +6455,7 @@ BOOL CBasePlayer::__API_VHOOK(AddPlayerItem)(CBasePlayerItem *pItem) LINK_HOOK_CLASS_CHAIN(BOOL, CBasePlayer, RemovePlayerItem, (CBasePlayerItem *pItem), pItem); -BOOL CBasePlayer::__API_VHOOK(RemovePlayerItem)(CBasePlayerItem *pItem) +BOOL EXT_FUNC CBasePlayer::__API_VHOOK(RemovePlayerItem)(CBasePlayerItem *pItem) { if (m_pActiveItem == pItem) { @@ -6495,7 +6481,7 @@ BOOL CBasePlayer::__API_VHOOK(RemovePlayerItem)(CBasePlayerItem *pItem) while (pPrev && pPrev->m_pNext != pItem) pPrev = pPrev->m_pNext; - if (pPrev != NULL) + if (pPrev) { pPrev->m_pNext = pItem->m_pNext; return TRUE; @@ -6507,7 +6493,7 @@ BOOL CBasePlayer::__API_VHOOK(RemovePlayerItem)(CBasePlayerItem *pItem) LINK_HOOK_CLASS_CHAIN(int, CBasePlayer, GiveAmmo, (int iCount, char *szName, int iMax), iCount, szName, iMax); // Returns the unique ID for the ammo, or -1 if error -int CBasePlayer::__API_VHOOK(GiveAmmo)(int iCount, char *szName, int iMax) +int EXT_FUNC CBasePlayer::__API_VHOOK(GiveAmmo)(int iCount, char *szName, int iMax) { if (pev->flags & FL_SPECTATOR) return -1; @@ -6518,6 +6504,9 @@ int CBasePlayer::__API_VHOOK(GiveAmmo)(int iCount, char *szName, int iMax) return -1; } + if (iMax == -1) + iMax = MaxAmmoCarry(szName); + if (!g_pGameRules->CanHaveAmmo(this, szName, iMax)) { // game rules say I can't have any more of this ammo type. @@ -6571,10 +6560,10 @@ void CBasePlayer::ItemPostFrame() static int fInSelect = FALSE; // check if the player is using a tank - if (m_pTank != NULL) + if (m_pTank) return; - if (m_pActiveItem != NULL) + if (m_pActiveItem) { if (HasShield() && IsReloading()) { @@ -6592,7 +6581,7 @@ void CBasePlayer::ItemPostFrame() ImpulseCommands(); - if (m_pActiveItem != NULL) + if (m_pActiveItem) m_pActiveItem->ItemPostFrame(); } @@ -6642,7 +6631,7 @@ void CBasePlayer::SendHostagePos() { CBaseEntity *pHostage = NULL; - while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")) != NULL) + while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) { MESSAGE_BEGIN(MSG_ONE, gmsgHostagePos, NULL, pev); WRITE_BYTE(1); @@ -6665,9 +6654,9 @@ void CBasePlayer::SendHostageIcons() if (!g_bIsCzeroGame) return; - while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")) != NULL) + while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) { - if (pHostage && pHostage->pev->deadflag == DEAD_NO) + if (pHostage->IsAlive()) ++numHostages; } @@ -6697,7 +6686,7 @@ void CBasePlayer::SendWeatherInfo() CBaseEntity *pPoint = UTIL_FindEntityByClassname(NULL, "env_rain"); CBaseEntity *pPoint2 = UTIL_FindEntityByClassname(NULL, "func_rain"); - if (pPoint != NULL || pPoint2 != NULL) + if (pPoint || pPoint2) { MESSAGE_BEGIN(MSG_ONE, gmsgReceiveW, NULL, pev); WRITE_BYTE(1); // rainy weather @@ -6708,7 +6697,7 @@ void CBasePlayer::SendWeatherInfo() pPoint = UTIL_FindEntityByClassname(NULL, "env_snow"); pPoint2 = UTIL_FindEntityByClassname(NULL, "func_snow"); - if (pPoint != NULL || pPoint2 != NULL) + if (pPoint || pPoint2) { MESSAGE_BEGIN(MSG_ONE, gmsgReceiveW, NULL, pev); WRITE_BYTE(2); // snowy weather @@ -6741,8 +6730,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(UpdateClientData)() MESSAGE_END(); CBaseEntity *pEntity = UTIL_FindEntityByClassname(NULL, "env_fog"); - - if (pEntity != NULL) + if (pEntity) { CClientFog *pFog = static_cast(pEntity); @@ -6839,6 +6827,22 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(UpdateClientData)() WRITE_BYTE(m_iHideHUD); MESSAGE_END(); +#ifdef REGAMEDLL_FIXES + if (m_iHideHUD && !(m_iHideHUD & HIDEHUD_OBSERVER_CROSSHAIR)) + { + if (m_iClientHideHUD < 0) + m_iClientHideHUD = 0; + + int hudChanged = m_iClientHideHUD ^ m_iHideHUD; + if (hudChanged & (HIDEHUD_FLASHLIGHT | HIDEHUD_HEALTH | HIDEHUD_TIMER | HIDEHUD_MONEY)) + { + MESSAGE_BEGIN(MSG_ONE, gmsgCrosshair, NULL, pev); + WRITE_BYTE(0); + MESSAGE_END(); + } + } +#endif + m_iClientHideHUD = m_iHideHUD; } @@ -6903,11 +6907,11 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(UpdateClientData)() // causes screen to flash, and pain compass to show direction of damage edict_t *other = pev->dmg_inflictor; - if (other != NULL) + if (other) { CBaseEntity *pEntity = CBaseEntity::Instance(other); - if (pEntity != NULL) + if (pEntity) { damageOrigin = pEntity->Center(); } @@ -7120,11 +7124,11 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(ResetMaxSpeed)() speed = 1; } // VIP is slow due to the armour he's wearing - else if (m_bIsVIP != NULL) + else if (m_bIsVIP) { speed = 227; } - else if (m_pActiveItem != NULL) + else if (m_pActiveItem) { // Get player speed from selected weapon speed = m_pActiveItem->GetMaxSpeed(); @@ -7199,7 +7203,7 @@ Vector CBasePlayer::__MAKE_VHOOK(GetAutoaimVector)(float flDelta) else m_vecAutoAim = angles * 0.9f; - if (sv_aim && sv_aim->value > 0.0f) + if (g_psv_aim && g_psv_aim->value > 0.0f) { if (m_vecAutoAim.x != m_lastx || m_vecAutoAim.y != m_lasty) { @@ -7248,7 +7252,7 @@ int CBasePlayer::GetCustomDecalFrames() LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, Blind, (float duration, float holdTime, float fadeTime, int alpha), duration, holdTime, fadeTime, alpha); -void CBasePlayer::__API_VHOOK(Blind)(float duration, float holdTime, float fadeTime, int alpha) +void EXT_FUNC CBasePlayer::__API_VHOOK(Blind)(float duration, float holdTime, float fadeTime, int alpha) { m_blindUntilTime = gpGlobals->time + duration; m_blindStartTime = gpGlobals->time; @@ -7397,7 +7401,7 @@ void CBasePlayer::UpdateStatusBar() LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, DropPlayerItem, (const char *pszItemName), pszItemName); // DropPlayerItem - drop the named item, or if no name, the active item. -void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) +void EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) { if (!Q_strlen(pszItemName)) { @@ -7474,7 +7478,7 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) g_pGameRules->m_bBombDropped = TRUE; CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player"))) { if (FNullEnt(pEntity->edict())) break; @@ -7494,7 +7498,7 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) WRITE_COORD(pev->origin.x); WRITE_COORD(pev->origin.y); WRITE_COORD(pev->origin.z); - WRITE_BYTE(0); + WRITE_BYTE(BOMB_FLAG_DROPPED); MESSAGE_END(); } } @@ -7516,7 +7520,7 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) pWeaponBox->SetThink(&CWeaponBox::BombThink); pWeaponBox->pev->nextthink = gpGlobals->time + 1.0f; - if (TheCSBots() != NULL) + if (TheCSBots()) { // tell the bots about the dropped bomb TheCSBots()->SetLooseBomb(pWeaponBox); @@ -7540,7 +7544,7 @@ void CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) } const char *modelname = GetCSModelName(pWeapon->m_iId); - if (modelname != NULL) + if (modelname) { SET_MODEL(ENT(pWeaponBox->pev), modelname); } @@ -7668,7 +7672,7 @@ void CBasePlayer::SwitchTeam() WRITE_STRING(GetTeamName(m_iTeam)); MESSAGE_END(); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, this); } @@ -7728,7 +7732,7 @@ void CBasePlayer::SwitchTeam() { const BotProfile *pProfile = pBot->GetProfile(); - if (pProfile != NULL) + if (pProfile) { bool bKick = false; @@ -7851,7 +7855,7 @@ void CStripWeapons::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCal { CBasePlayer *pPlayer = NULL; - if (pActivator != NULL && pActivator->IsPlayer()) + if (pActivator && pActivator->IsPlayer()) { pPlayer = (CBasePlayer *)pActivator; } @@ -7860,7 +7864,7 @@ void CStripWeapons::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCal pPlayer = (CBasePlayer *)Instance(INDEXENT(1)); } - if (pPlayer != NULL) + if (pPlayer) { pPlayer->RemoveAllItems(FALSE); } @@ -8506,7 +8510,7 @@ void CBasePlayer::InitRebuyData(const char *str) return; } - if (m_rebuyString != NULL) + if (m_rebuyString) { delete[] m_rebuyString; m_rebuyString = NULL; @@ -8526,21 +8530,21 @@ void CBasePlayer::AutoBuy() c = PickFlashKillWeaponString(); - if (c != NULL) + if (c) { ParseAutoBuyString(c, boughtPrimary, boughtSecondary); } c = PickGrenadeKillWeaponString(); - if (c != NULL) + if (c) { ParseAutoBuyString(c, boughtPrimary, boughtSecondary); } c = PickPrimaryCareerTaskWeapon(); - if (c != NULL) + if (c) { Q_strcpy(prioritizedString, c); @@ -8550,7 +8554,7 @@ void CBasePlayer::AutoBuy() c = PickSecondaryCareerTaskWeapon(); - if (c != NULL) + if (c) { Q_strcpy(prioritizedString, c); @@ -8562,12 +8566,12 @@ void CBasePlayer::AutoBuy() c = PickFlashKillWeaponString(); - if (c != NULL) + if (c) { ParseAutoBuyString(c, boughtPrimary, boughtSecondary); } - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_LEFT_BUY_ZONE); } @@ -8583,7 +8587,7 @@ bool IsPrimaryWeaponId(int id) int classId = WEAPONCLASS_NONE; const char *alias = WeaponIDToAlias(id); - if (alias != NULL) + if (alias) { classId = AliasToWeaponClass(alias); } @@ -8601,7 +8605,7 @@ bool IsSecondaryWeaponId(int id) int classId = WEAPONCLASS_NONE; const char *alias = WeaponIDToAlias(id); - if (alias != NULL) + if (alias) { classId = AliasToWeaponClass(alias); } @@ -8666,7 +8670,7 @@ const char *CBasePlayer::PickPrimaryCareerTaskWeapon() } } - if (primary != NULL) + if (primary) { if (CurrentWeaponSatisfies(primary, pTask->GetWeaponId(), pTask->GetWeaponClassId())) { @@ -8742,7 +8746,7 @@ const char *CBasePlayer::PickSecondaryCareerTaskWeapon() } } - if (secondary != NULL) + if (secondary) { if (CurrentWeaponSatisfies(secondary, pTask->GetWeaponId(), pTask->GetWeaponClassId())) { @@ -8877,7 +8881,7 @@ void CBasePlayer::PrioritizeAutoBuyString(char *autobuyString, const char *prior // if it is, copy that token to the new string and blank out // that token in the autobuy string. char *autoBuyPosition = Q_strstr(autobuyString, priorityToken); - if (autoBuyPosition != NULL) + if (autoBuyPosition) { while (*autoBuyPosition != '\0' && *autoBuyPosition != ' ') { @@ -8964,7 +8968,6 @@ void CBasePlayer::ParseAutoBuyString(const char *string, bool &boughtPrimary, bo } AutoBuyInfoStruct *commandInfo = GetAutoBuyCommandInfo(command); - if (ShouldExecuteAutoBuyCommand(commandInfo, boughtPrimary, boughtSecondary)) { ClientCommand(commandInfo->m_command); @@ -8999,25 +9002,17 @@ bool CBasePlayer::ShouldExecuteAutoBuyCommand(AutoBuyInfoStruct *commandInfo, bo AutoBuyInfoStruct *CBasePlayer::GetAutoBuyCommandInfo(const char *command) { - int i = 0; - AutoBuyInfoStruct *ret = NULL; - AutoBuyInfoStruct *temp = NULL; - // loop through all the commands till we find the one that matches. - while (ret == NULL) + for (auto& buyInfo : g_autoBuyInfo) { - temp = &(g_autoBuyInfo[ i ]); + if (buyInfo.m_class == AUTOBUYCLASS_NONE) + continue; - if (!temp->m_class) - break; - - if (Q_stricmp(temp->m_command, command) == 0) - ret = temp; - - ++i; + if (FStrEq(buyInfo.m_command, command)) + return &buyInfo; } - return ret; + return nullptr; } void CBasePlayer::PostAutoBuyCommandProcessing(AutoBuyInfoStruct *commandInfo, bool &boughtPrimary, bool &boughtSecondary) @@ -9030,7 +9025,7 @@ void CBasePlayer::PostAutoBuyCommandProcessing(AutoBuyInfoStruct *commandInfo, b CBasePlayerWeapon *primary = static_cast(m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]); CBasePlayerWeapon *secondary = static_cast(m_rgpPlayerItems[ PISTOL_SLOT ]); - if (primary != NULL && (Q_stricmp(STRING(primary->pev->classname), commandInfo->m_classname) == 0)) + if (primary && FClassnameIs(primary->pev, commandInfo->m_classname)) { // I just bought the gun I was trying to buy. boughtPrimary = true; @@ -9040,7 +9035,7 @@ void CBasePlayer::PostAutoBuyCommandProcessing(AutoBuyInfoStruct *commandInfo, b // the shield is a primary weapon even though it isn't a "real" weapon. boughtPrimary = true; } - else if (secondary != NULL && (Q_stricmp(STRING(secondary->pev->classname), commandInfo->m_classname) == 0)) + else if (secondary && FClassnameIs(secondary->pev, commandInfo->m_classname)) { // I just bought the pistol I was trying to buy. boughtSecondary = true; @@ -9161,7 +9156,7 @@ void CBasePlayer::Rebuy() // after we're done buying, the user is done with their equipment purchasing experience. // so we are effectively out of the buy zone. - if (TheTutor != NULL) + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_LEFT_BUY_ZONE); } @@ -9174,8 +9169,7 @@ void CBasePlayer::RebuyPrimaryWeapon() if (m_rebuyStruct.m_primaryWeapon) { const char *alias = WeaponIDToAlias(m_rebuyStruct.m_primaryWeapon); - - if (alias != NULL) + if (alias) ClientCommand(alias); } } @@ -9185,7 +9179,7 @@ void CBasePlayer::RebuyPrimaryAmmo() { CBasePlayerWeapon *primary = static_cast(m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]); - if (primary != NULL) + if (primary) { // if we had more ammo before than we have now, buy more. if (m_rebuyStruct.m_primaryAmmo > m_rgAmmo[ primary->m_iPrimaryAmmoType ]) @@ -9198,8 +9192,7 @@ void CBasePlayer::RebuySecondaryWeapon() if (m_rebuyStruct.m_secondaryWeapon) { const char *alias = WeaponIDToAlias(m_rebuyStruct.m_secondaryWeapon); - - if (alias != NULL) + if (alias) ClientCommand(alias); } } @@ -9218,12 +9211,10 @@ void CBasePlayer::RebuySecondaryAmmo() void CBasePlayer::RebuyHEGrenade() { int iAmmoIndex = GetAmmoIndex("HEGrenade"); - if (iAmmoIndex == -1) return; int numToBuy = m_rebuyStruct.m_heGrenade - m_rgAmmo[ iAmmoIndex ]; - for (int i = 0; i < numToBuy; ++i) ClientCommand("hegren"); } @@ -9231,12 +9222,10 @@ void CBasePlayer::RebuyHEGrenade() void CBasePlayer::RebuyFlashbang() { int iAmmoIndex = GetAmmoIndex("Flashbang"); - if (iAmmoIndex == -1) return; int numToBuy = m_rebuyStruct.m_flashbang - m_rgAmmo[ iAmmoIndex ]; - for (int i = 0; i < numToBuy; ++i) ClientCommand("flash"); } @@ -9244,12 +9233,10 @@ void CBasePlayer::RebuyFlashbang() void CBasePlayer::RebuySmokeGrenade() { int iAmmoIndex = GetAmmoIndex("SmokeGrenade"); - if (iAmmoIndex == -1) return; int numToBuy = m_rebuyStruct.m_smokeGrenade - m_rgAmmo[ iAmmoIndex ]; - for (int i = 0; i < numToBuy; ++i) ClientCommand("sgren"); } @@ -9373,7 +9360,7 @@ void CBasePlayer::ReloadWeapons(CBasePlayerItem *pWeapon, bool bForceReload, boo for (int i = PRIMARY_WEAPON_SLOT; i <= PISTOL_SLOT; ++i) { auto item = m_rgpPlayerItems[i]; - while (item != nullptr) + while (item) { if (pWeapon == nullptr || pWeapon == item) { @@ -9391,7 +9378,7 @@ void CBasePlayer::ReloadWeapons(CBasePlayerItem *pWeapon, bool bForceReload, boo item = item->m_pNext; } - if (pWeapon != nullptr && pWeapon == item) + if (pWeapon && pWeapon == item) break; } #endif @@ -9465,13 +9452,13 @@ void CBasePlayer::DropPrimary() } CBasePlayerItem *CBasePlayer::GetItemByName(const char *itemName) { - return ForEachItem([this, itemName](CBasePlayerItem *item) { + return ForEachItem([itemName](CBasePlayerItem *item) { return FClassnameIs(item->pev, itemName); }); } CBasePlayerItem *CBasePlayer::GetItemById(WeaponIdType weaponID) { - return ForEachItem([this, weaponID](CBasePlayerItem *item) { + return ForEachItem([weaponID](CBasePlayerItem *item) { return item->m_iId == weaponID; }); } @@ -9512,3 +9499,149 @@ void CBasePlayer::UpdateOnRemove() } } #endif + +LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, OnSpawnEquip, (bool addDefault, bool equipGame), addDefault, equipGame); + +void EXT_FUNC CBasePlayer::__API_HOOK(OnSpawnEquip)(bool addDefault, bool equipGame) +{ + if (equipGame) + { + CBaseEntity *pWeaponEntity = nullptr; + while ((pWeaponEntity = UTIL_FindEntityByClassname(pWeaponEntity, "game_player_equip"))) + { + pWeaponEntity->Touch(this); + addDefault = false; + } + } + + if (m_bNotKilled) + addDefault = false; + + if (addDefault || m_bIsVIP) + { + GiveDefaultItems(); + } +} + +void CBasePlayer::HideTimer() +{ + // HACK HACK, we need to hide only the timer. + MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, NULL, pev); + WRITE_COORD(0); + WRITE_COORD(0); + WRITE_COORD(0); + WRITE_BYTE(BOMB_FLAG_PLANTED); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ONE, gmsgBombPickup, NULL, pev); + MESSAGE_END(); +} + +LINK_HOOK_CLASS_CHAIN2(bool, CBasePlayer, MakeBomber); + +bool EXT_FUNC CBasePlayer::__API_HOOK(MakeBomber)() +{ + if (!GiveNamedItem("weapon_c4")) + { + // something happened? + // C4 failed to attach to the player + return false; + } + + m_bHasC4 = true; + SetBombIcon(); + pev->body = 1; + + m_flDisplayHistory |= DHF_BOMB_RETRIEVED; + HintMessage("#Hint_you_have_the_bomb", FALSE, TRUE); + + // Log this information + UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Spawned_With_The_Bomb\"\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict())); + g_pGameRules->m_bBombDropped = FALSE; + + return true; +} + +LINK_HOOK_CLASS_CHAIN2(bool, CBasePlayer, GetIntoGame); + +bool EXT_FUNC CBasePlayer::__API_HOOK(GetIntoGame)() +{ + m_bNotKilled = false; + m_iIgnoreGlobalChat = IGNOREMSG_NONE; + + m_iTeamKills = 0; + m_iFOV = DEFAULT_FOV; + + Q_memset(&m_rebuyStruct, 0, sizeof(m_rebuyStruct)); + + m_bIsInRebuy = false; + m_bJustConnected = false; + m_fLastMovement = gpGlobals->time; + + ResetMaxSpeed(); + m_iJoiningState = JOINED; + + if (CSGameRules()->m_bMapHasEscapeZone && m_iTeam == CT) + { +#ifndef REGAMEDLL_ADD + m_iAccount = 0; +#endif + CheckStartMoney(); + AddAccount(startmoney.value, RT_INTO_GAME); + } + + if (g_pGameRules->FPlayerCanRespawn(this)) + { + Spawn(); + CSGameRules()->CheckWinConditions(); + + if (!CSGameRules()->m_flRestartRoundTime && CSGameRules()->m_bMapHasBombTarget && !CSGameRules()->IsThereABomber() && !CSGameRules()->IsThereABomb()) + { + CSGameRules()->GiveC4(); + } + if (m_iTeam == TERRORIST) + { + CSGameRules()->m_iNumEscapers++; + } + } + else + { + pev->deadflag = DEAD_RESPAWNABLE; + + MAKE_STRING_CLASS("player", pev); + + pev->flags &= (FL_PROXY | FL_FAKECLIENT); + pev->flags |= (FL_SPECTATOR | FL_CLIENT); + + edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot(this); + StartObserver(pev->origin, pentSpawnSpot->v.angles); + + CSGameRules()->CheckWinConditions(); + + MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); + WRITE_BYTE(entindex()); + WRITE_STRING(GetTeamName(m_iTeam)); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ALL, gmsgLocation); + WRITE_BYTE(entindex()); + WRITE_STRING(""); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_SHORT(int(pev->frags)); + WRITE_SHORT(m_iDeaths); + WRITE_SHORT(0); + WRITE_SHORT(m_iTeam); + MESSAGE_END(); + + if (!(m_flDisplayHistory & DHF_SPEC_DUCK)) + { + HintMessage("#Spec_Duck", TRUE, TRUE); + m_flDisplayHistory |= DHF_SPEC_DUCK; + } + } + + return true; +} diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 97d382c2..3aab91a0 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -365,7 +365,7 @@ public: virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore); virtual BOOL AddPlayerItem(CBasePlayerItem *pItem); virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem); - virtual int GiveAmmo(int iAmount, char *szName, int iMax); + virtual int GiveAmmo(int iAmount, char *szName, int iMax = -1); virtual void StartSneaking() { m_tSneaking = gpGlobals->time - 1; } #ifndef REGAMEDLL_FIXES @@ -412,7 +412,7 @@ public: void AddPointsToTeam_(int score, BOOL bAllowNegativeScore); BOOL AddPlayerItem_(CBasePlayerItem *pItem); BOOL RemovePlayerItem_(CBasePlayerItem *pItem); - int GiveAmmo_(int iAmount,char *szName,int iMax); + int GiveAmmo_(int iAmount, char *szName, int iMax); void ResetMaxSpeed_(); void Jump_(); void Duck_(); @@ -447,6 +447,7 @@ public: int IsObserver() { return pev->iuser1; } void PlantC4(); void Radio(const char *msg_id, const char *msg_verbose = NULL, short pitch = 100, bool showIcon = true); + void Radio_(const char *msg_id, const char *msg_verbose = NULL, short pitch = 100, bool showIcon = true); CBasePlayer *GetNextRadioRecipient(CBasePlayer *pStartPlayer); void SmartRadio(); void ThrowWeapon(char *pszItemName); @@ -454,7 +455,9 @@ public: void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true); void AddAccount_(int amount, RewardType type = RT_NONE, bool bTrackChange = true); void Disappear(); + void Disappear_(); void MakeVIP(); + void MakeVIP_(); bool CanPlayerBuy(bool display = false); void SwitchTeam(); void TabulateAmmo(); @@ -472,8 +475,8 @@ public: void SetProgressBarTime(int time); void SetProgressBarTime2(int time, float timeElapsed); void SetPlayerModel(BOOL HasC4); - void SetClientUserInfoName(char *infobuffer, char *szNewName); - void SetClientUserInfoName_(char *infobuffer, char *szNewName); + bool SetClientUserInfoName(char *infobuffer, char *szNewName); + bool SetClientUserInfoName_(char *infobuffer, char *szNewName); void SetClientUserInfoModel(char *infobuffer, char *szNewModel); void SetClientUserInfoModel_api(char *infobuffer, char *szNewModel); void SetNewPlayerModel(const char *modelName); @@ -501,7 +504,8 @@ public: void SetWeaponAnimType(const char *szExtention) { Q_strcpy(m_szAnimExtention, szExtention); } void CheatImpulseCommands(int iImpulse); void StartDeathCam(); - void StartObserver(Vector vecPosition, Vector vecViewAngle); + void StartObserver(Vector &vecPosition, Vector &vecViewAngle); + void StartObserver_(Vector &vecPosition, Vector &vecViewAngle); void HandleSignals(); void DropPlayerItem(const char *pszItemName); void DropPlayerItem_(const char *pszItemName); @@ -514,9 +518,9 @@ public: void SelectItem(const char *pstr); void ItemPreFrame(); void ItemPostFrame(); - void GiveNamedItem(const char *pszName); - void GiveNamedItem_(const char *pszName); - void GiveNamedItemEx(const char *pszName); + CBaseEntity *GiveNamedItem(const char *pszName); + CBaseEntity *GiveNamedItem_(const char *pszName); + CBaseEntity *GiveNamedItemEx(const char *pszName); void EnableControl(BOOL fControl); bool HintMessage(const char *pMessage, BOOL bDisplayIfPlayerDead = FALSE, BOOL bOverride = FALSE); void SendAmmoUpdate(); @@ -563,6 +567,7 @@ public: bool IsProtectedByShield() { return HasShield() && m_bShieldDrawn; } void RemoveShield(); void DropShield(bool bDeploy = true); + void DropShield_(bool bDeploy = true); void GiveShield(bool bDeploy = true); void GiveShield_(bool bDeploy = true); bool IsHittingShield(Vector &vecDirection, TraceResult *ptr); @@ -612,7 +617,17 @@ public: void DropSecondary(); void DropPrimary(); + void OnSpawnEquip(bool addDefault = true, bool equipGame = true); + void OnSpawnEquip_(bool addDefault = true, bool equipGame = true); + void RemoveBomb(); + void HideTimer(); + bool MakeBomber(); + bool MakeBomber_(); + + bool GetIntoGame(); + bool GetIntoGame_(); + CBasePlayerItem *GetItemByName(const char *itemName); CBasePlayerItem *GetItemById(WeaponIdType weaponID); @@ -875,8 +890,7 @@ public: inline bool CBasePlayer::IsReloading() const { CBasePlayerWeapon *weapon = static_cast(m_pActiveItem); - - if (weapon != NULL && weapon->m_fInReload) + if (weapon && weapon->m_fInReload) return true; return false; @@ -888,8 +902,27 @@ inline CCSPlayer *CBasePlayer::CSPlayer() const { } #endif +#ifdef REGAMEDLL_FIXES + +// returns a CBaseEntity pointer to a player by index. Only returns if the player is spawned and connected otherwise returns NULL +// Index is 1 based +inline CBasePlayer *UTIL_PlayerByIndex(int playerIndex) +{ + return (CBasePlayer *)GET_PRIVATE(INDEXENT(playerIndex)); +} + +#endif + +inline CBasePlayer *UTIL_PlayerByIndexSafe(int playerIndex) +{ + CBasePlayer *player = nullptr; + if (likely(playerIndex > 0 && playerIndex <= gpGlobals->maxClients)) + player = UTIL_PlayerByIndex(playerIndex); + + return player; +} + extern int gEvilImpulse101; -extern char g_szMapBriefingText[512]; extern entvars_t *g_pevLastInflictor; extern CBaseEntity *g_pLastSpawn; extern CBaseEntity *g_pLastCTSpawn; diff --git a/regamedll/dlls/singleplay_gamerules.cpp b/regamedll/dlls/singleplay_gamerules.cpp index d05b29df..cdc2bffd 100644 --- a/regamedll/dlls/singleplay_gamerules.cpp +++ b/regamedll/dlls/singleplay_gamerules.cpp @@ -79,8 +79,8 @@ void CHalfLifeRules::__MAKE_VHOOK(PlayerSpawn)(CBasePlayer *pPlayer) pPlayer->GiveNamedItem("weapon_mp5navy"); pPlayer->GiveNamedItem("weapon_hegrenade"); - pPlayer->GiveAmmo(60, "9mm", 120); - pPlayer->GiveAmmo(24, "45acp", 100); + pPlayer->GiveAmmo(60, "9mm"); + pPlayer->GiveAmmo(24, "45acp"); } BOOL CHalfLifeRules::__MAKE_VHOOK(AllowAutoTargetCrosshair)() diff --git a/regamedll/dlls/training_gamerules.cpp b/regamedll/dlls/training_gamerules.cpp index 24332a2c..7a693b0b 100644 --- a/regamedll/dlls/training_gamerules.cpp +++ b/regamedll/dlls/training_gamerules.cpp @@ -95,7 +95,7 @@ void CHalfLifeTraining::__MAKE_VHOOK(PlayerThink)(CBasePlayer *pPlayer) m_iHostagesRescued = 0; m_iRoundTimeSecs = int(gpGlobals->time + 1.0f); m_bFreezePeriod = FALSE; - g_fGameOver = FALSE; + m_bGameOver = false; pPlayer->m_iTeam = CT; pPlayer->m_bCanShoot = true; @@ -253,8 +253,6 @@ void CHalfLifeTraining::__MAKE_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars void CHalfLifeTraining::__MAKE_VHOOK(CheckWinConditions)() { - CBaseEntity *pHostage = NULL; - if (m_bBombDefused) { CGrenade *pBomb = NULL; @@ -289,42 +287,26 @@ void CHalfLifeTraining::__MAKE_VHOOK(CheckWinConditions)() } } - pHostage = CBaseEntity::Instance(FIND_ENTITY_BY_CLASSNAME(NULL, "hostage_entity")); - - while (pHostage) + CBaseEntity *pHostage = NULL; + while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) { if (pHostage->pev->deadflag != DEAD_RESPAWNABLE || !FStringNull(pHostage->pev->noise1)) continue; UTIL_SetSize(pHostage->pev, Vector(-16, -16, 0), Vector(16, 16, 72)); - CBaseEntity *pRescueArea; - CBaseEntity *pFirstRescueArea; - - pFirstRescueArea = CBaseEntity::Instance(FIND_ENTITY_BY_CLASSNAME(NULL, "func_hostage_rescue")); - pRescueArea = pFirstRescueArea; - - if (pFirstRescueArea) + CBaseEntity *pRescueArea = NULL; + while ((pRescueArea = UTIL_FindEntityByClassname(pRescueArea, "func_hostage_rescue"))) { - while (pRescueArea != pFirstRescueArea) - { - if (!pRescueArea->Intersects(pHostage)) - break; - - pRescueArea = UTIL_FindEntityByClassname(pRescueArea, "func_hostage_rescue"); - - if (!pRescueArea) - break; - } - - if (pRescueArea != NULL) - { - pHostage->pev->noise1 = 1; - FireTargets(STRING(pRescueArea->pev->target), NULL, NULL, USE_TOGGLE, 0); - } + if (!pRescueArea->Intersects(pHostage)) + break; } - pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity"); + if (pRescueArea) + { + pHostage->pev->noise1 = 1; + FireTargets(STRING(pRescueArea->pev->target), NULL, NULL, USE_TOGGLE, 0); + } } } diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index 5bf87b70..c3a6e3ba 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -1520,7 +1520,7 @@ NOXREF void NextLevel() pChange = GetClassPtr((CChangeLevel *)VARS(pent)); Q_strcpy(st_szNextMap, pChange->m_szMapName); - g_fGameOver = TRUE; + g_pGameRules->SetGameOver(); if (pChange->pev->nextthink < gpGlobals->time) { @@ -1817,7 +1817,7 @@ void CEscapeZone::EscapeTouch(CBaseEntity *pOther) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer == NULL || FNullEnt(pPlayer->pev)) + if (!pPlayer || FNullEnt(pPlayer->pev)) continue; if (pPlayer->m_iTeam == p->m_iTeam) diff --git a/regamedll/dlls/tutor.cpp b/regamedll/dlls/tutor.cpp index a8c4ad23..493d611c 100644 --- a/regamedll/dlls/tutor.cpp +++ b/regamedll/dlls/tutor.cpp @@ -82,7 +82,7 @@ void MonitorTutorStatus() { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer != NULL && !pPlayer->IsBot()) + if (pPlayer && !pPlayer->IsBot()) ++numHumans; } diff --git a/regamedll/dlls/tutor_cs_tutor.cpp b/regamedll/dlls/tutor_cs_tutor.cpp index cdf8cf72..60f8c27f 100644 --- a/regamedll/dlls/tutor_cs_tutor.cpp +++ b/regamedll/dlls/tutor_cs_tutor.cpp @@ -181,19 +181,19 @@ CCSTutor::CCSTutor() CCSTutor::~CCSTutor() { - if (m_stateSystem != NULL) + if (m_stateSystem) { delete m_stateSystem; m_stateSystem = NULL; } - if (m_currentMessageEvent != NULL) + if (m_currentMessageEvent) { DeleteEvent(m_currentMessageEvent); m_currentMessageEvent = NULL; } - if (m_lastScenarioEvent != NULL) + if (m_lastScenarioEvent) { DeleteEvent(m_lastScenarioEvent); m_lastScenarioEvent = NULL; @@ -443,11 +443,9 @@ void CCSTutor::ApplyPersistentDecay() for (TutorMessageID mid = YOU_FIRED_A_SHOT; mid < TUTOR_NUM_MESSAGES; mid++) { TutorMessage *definition = GetTutorMessageDefinition(mid); - - if (definition != NULL) + if (definition) { int timesShown = GET_TIMES_TUTOR_MESSAGE_SHOWN(mid); - if (timesShown != -1) { definition->m_timesShown = timesShown; @@ -510,10 +508,7 @@ void CCSTutor::CheckForInterruptingMessageEvent(float time) TutorMessage *oldMessage = GetTutorMessageDefinition(m_currentlyShownMessageID); TutorMessageEvent *oldEvent = m_currentMessageEvent; - if (event == NULL) - return; - - while (event != NULL) + while (event) { if (ShouldShowMessageEvent(event, time)) { @@ -529,14 +524,14 @@ void CCSTutor::CheckForInterruptingMessageEvent(float time) return; } - if (oldEvent != NULL) + if (oldEvent) { ProcessShownDeathsForEvent(event); DeleteEvent(oldEvent); } CloseCurrentWindow(); - if (oldMessage != NULL) + if (oldMessage) { oldMessage->m_lastCloseTime = time; } @@ -614,8 +609,7 @@ void CCSTutor::CheckForContentUpdate() return; TutorMessageEvent *event = GetTutorMessageUpdateEvent(); - - if (event != NULL) + if (event) { UpdateCurrentMessage(event); DeleteEventFromEventList(event); @@ -625,8 +619,7 @@ void CCSTutor::CheckForContentUpdate() void CCSTutor::ClearCurrentEvent(bool closeWindow, bool processDeathsForEvent) { TutorMessage *oldMessage = GetTutorMessageDefinition(m_currentlyShownMessageID); - - if (oldMessage != NULL) + if (oldMessage) { oldMessage->m_lastCloseTime = gpGlobals->time; } @@ -645,7 +638,7 @@ void CCSTutor::ClearCurrentEvent(bool closeWindow, bool processDeathsForEvent) m_currentlyShownMessageCloseTime = 0; m_currentlyShownMessageMinimumCloseTime = 0; - if (m_currentMessageEvent != NULL) + if (m_currentMessageEvent) { DeleteEvent(m_currentMessageEvent); m_currentMessageEvent = NULL; @@ -674,7 +667,7 @@ TutorMessageEvent *CCSTutor::GetTutorMessageUpdateEvent() if (definition == NULL || definition->m_keepOld == TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD) return NULL; - for (TutorMessageEvent *event = m_eventList; event != NULL; event = event->GetNext()) + for (TutorMessageEvent *event = m_eventList; event; event = event->GetNext()) { if (DoMessagesHaveSameID(event->GetID(), m_currentlyShownMessageID)) { @@ -687,9 +680,9 @@ TutorMessageEvent *CCSTutor::GetTutorMessageUpdateEvent() bool CCSTutor::GetDuplicateMessagesFromEventList(TutorMessageEvent *&event1, TutorMessageEvent *&event2) { - for (event1 = m_eventList; event1 != NULL; event1 = event1->GetNext()) + for (event1 = m_eventList; event1; event1 = event1->GetNext()) { - for (event2 = event1->GetNext(); event2 != NULL; event2 = event2->GetNext()) + for (event2 = event1->GetNext(); event2; event2 = event2->GetNext()) { if (DoMessagesHaveSameID(event1->GetID(), event2->GetID())) { @@ -704,8 +697,7 @@ bool CCSTutor::GetDuplicateMessagesFromEventList(TutorMessageEvent *&event1, Tut void CCSTutor::CheckForInactiveEvents(float time) { TutorMessageEvent *event = m_eventList; - - while (event != NULL) + while (event) { if (!event->IsActive(time)) { @@ -746,8 +738,7 @@ void CCSTutor::CancelEvent(TutorMessageID mid) ClearCurrentEvent(); TutorMessageEvent *event = m_eventList; - - while (event != NULL) + while (event) { TutorMessageEvent *temp = event->GetNext(); @@ -760,7 +751,7 @@ void CCSTutor::CancelEvent(TutorMessageID mid) event = temp; } - if (m_lastScenarioEvent != NULL && m_lastScenarioEvent->GetID() == mid) + if (m_lastScenarioEvent && m_lastScenarioEvent->GetID() == mid) { DeleteEvent(m_lastScenarioEvent); m_lastScenarioEvent = NULL; @@ -802,7 +793,7 @@ TutorMessageEvent *CCSTutor::CreateTutorMessageEvent(TutorMessageID mid, CBaseEn message->m_priority ); - if (event != NULL) + if (event) { switch (mid) { @@ -861,7 +852,7 @@ TutorMessageEvent *CCSTutor::CreateTutorMessageEvent(TutorMessageID mid, CBaseEn char numLeftStr[16]; int numtasks = 0; - if (TheCareerTasks != NULL) + if (TheCareerTasks) { numtasks = TheCareerTasks->GetNumRemainingTasks(); } @@ -889,12 +880,8 @@ TutorMessageEvent *CCSTutor::CreateTutorMessageEvent(TutorMessageID mid, CBaseEn { switch (localPlayer->m_iTeam) { - case CT: - numCT--; - break; - case TERRORIST: - numT--; - break; + case CT: numCT--; break; + case TERRORIST: numT--; break; } } @@ -923,7 +910,7 @@ TutorMessageEvent *CCSTutor::CreateTutorMessageEvent(TutorMessageID mid, CBaseEn void CCSTutor::AddToEventList(TutorMessageEvent *event) { - if (event != NULL) + if (event) { event->SetNext(m_eventList); m_eventList = event; @@ -932,18 +919,13 @@ void CCSTutor::AddToEventList(TutorMessageEvent *event) void CCSTutor::CreateAndAddEventToList(TutorMessageID mid, CBaseEntity *entity, CBaseEntity *other) { - TutorMessageEvent *event; - TutorMessage *message; - - event = CreateTutorMessageEvent(mid, entity, other); - - if (event != NULL) + auto event = CreateTutorMessageEvent(mid, entity, other); + if (event) { - message = GetTutorMessageDefinition(mid); - - if (message != NULL && message->m_type == TUTORMESSAGETYPE_SCENARIO) + auto message = GetTutorMessageDefinition(mid); + if (message && message->m_type == TUTORMESSAGETYPE_SCENARIO) { - if (m_lastScenarioEvent != NULL) + if (m_lastScenarioEvent) { DeleteEvent(m_lastScenarioEvent); m_lastScenarioEvent = NULL; @@ -965,7 +947,7 @@ void CCSTutor::DeleteEventFromEventList(TutorMessageEvent *event) if (temp != event) { - if (temp != NULL) + if (temp) { while (event != temp->GetNext()) { @@ -977,7 +959,7 @@ void CCSTutor::DeleteEventFromEventList(TutorMessageEvent *event) } } - if (temp != NULL && temp->GetNext() == event) + if (temp && temp->GetNext() == event) { temp->SetNext(temp->GetNext()->GetNext()); } @@ -989,7 +971,7 @@ void CCSTutor::DeleteEventFromEventList(TutorMessageEvent *event) void CCSTutor::ClearEventList() { - while (m_eventList != NULL) + while (m_eventList) { TutorMessageEvent *temp = m_eventList; m_eventList = m_eventList->GetNext(); @@ -1000,11 +982,10 @@ void CCSTutor::ClearEventList() void CCSTutor::DeleteEvent(TutorMessageEvent *event) { - for (int i = 0; i < ARRAYSIZE(m_playerDeathInfo); ++i) + for (auto& playerDeathInfo : m_playerDeathInfo) { - if (m_playerDeathInfo[i].m_event == event) - { - m_playerDeathInfo[i].m_event = NULL; + if (playerDeathInfo.m_event == event) { + playerDeathInfo.m_event = nullptr; } } @@ -1016,7 +997,7 @@ void CCSTutor::__MAKE_VHOOK(PurgeMessages)() ClearCurrentEvent(); ClearEventList(); - if (m_lastScenarioEvent != NULL) + if (m_lastScenarioEvent) { DeleteEvent(m_lastScenarioEvent); m_lastScenarioEvent = NULL; @@ -1063,8 +1044,7 @@ NOXREF bool CCSTutor::ShouldUpdateCurrentMessage(TutorMessageID messageID) if (DoMessagesHaveSameID(messageID, m_currentlyShownMessageID)) { TutorMessage *definition = GetTutorMessageDefinition(messageID); - - if (definition != NULL && definition->m_keepOld != TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD) + if (definition && definition->m_keepOld != TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD) { return true; } @@ -1077,7 +1057,7 @@ void CCSTutor::UpdateCurrentMessage(TutorMessageEvent *event) { TransferDeathEvents(m_currentMessageEvent, event); - if (m_currentMessageEvent != NULL) + if (m_currentMessageEvent) { DeleteEvent(m_currentMessageEvent); m_currentMessageEvent = NULL; @@ -1087,12 +1067,10 @@ void CCSTutor::UpdateCurrentMessage(TutorMessageEvent *event) m_currentMessageEvent = event; TutorMessage *definition = GetTutorMessageDefinition(event->GetID()); - - if (definition != NULL) + if (definition) { CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer != NULL) + if (localPlayer) { m_currentlyShownMessageCloseTime = definition->m_duration + gpGlobals->time; @@ -1113,8 +1091,7 @@ void CCSTutor::__MAKE_VHOOK(ShowTutorMessage)(TutorMessageEvent *event) return; TutorMessage *message = GetTutorMessageDefinition(mid); - - if (message != NULL) + if (message) { m_currentlyShownMessageID = mid; m_currentMessageEvent = event; @@ -1127,8 +1104,7 @@ void CCSTutor::__MAKE_VHOOK(ShowTutorMessage)(TutorMessageEvent *event) void CCSTutor::ConstructMessageAndDisplay() { CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer != NULL && !localPlayer->IsBot()) + if (localPlayer && !localPlayer->IsBot()) { TutorMessageID mid = static_cast(m_currentMessageEvent->GetID()); @@ -1136,8 +1112,7 @@ void CCSTutor::ConstructMessageAndDisplay() return; TutorMessage *message = GetTutorMessageDefinition(mid); - - if (message != NULL) + if (message) { message->m_timesShown++; ComputeDisplayTimesForMessage(); @@ -1320,12 +1295,10 @@ void CCSTutor::__MAKE_VHOOK(CallEventHandler)(GameEventType event, CBaseEntity * void CCSTutor::HandleWeaponFired(CBaseEntity *entity, CBaseEntity *other) { CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer != NULL && localPlayer->IsAlive()) + if (localPlayer && localPlayer->IsAlive()) { CBasePlayer *player = static_cast(entity); - - if (player != NULL && player == localPlayer) + if (player && player == localPlayer) { CheckForNeedToReload(); } @@ -1340,16 +1313,13 @@ void CCSTutor::HandleWeaponFiredOnEmpty(CBaseEntity *entity, CBaseEntity *other) return; CBasePlayer *player = static_cast(entity); - - if (player != NULL && player->IsPlayer() && player == localPlayer) + if (player && player->IsPlayer() && player == localPlayer) { CBasePlayerWeapon *currentWeapon = static_cast(player->m_pActiveItem); - - if (currentWeapon != NULL && player->m_rgAmmo[currentWeapon->m_iPrimaryAmmoType] <= 0) + if (currentWeapon && player->m_rgAmmo[currentWeapon->m_iPrimaryAmmoType] <= 0) { TutorMessage *message = GetTutorMessageDefinition(YOU_ARE_OUT_OF_AMMO); - - if (message != NULL) + if (message) { message->m_lastCloseTime = 0; } @@ -1362,8 +1332,7 @@ void CCSTutor::HandleWeaponFiredOnEmpty(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleWeaponReloaded(CBaseEntity *entity, CBaseEntity *other) { CBasePlayer *player = static_cast(entity); - - if (player != NULL && player->IsPlayer() && player == UTIL_GetLocalPlayer()) + if (player && player->IsPlayer() && player == UTIL_GetLocalPlayer()) { CancelEvent(YOU_SHOULD_RELOAD); } @@ -1379,10 +1348,10 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) CBasePlayer *victim = static_cast(entity); CBasePlayer *attacker = static_cast(other); - if (victim != NULL && !victim->IsPlayer()) + if (victim && !victim->IsPlayer()) victim = NULL; - if (attacker != NULL && !attacker->IsPlayer()) + if (attacker && !attacker->IsPlayer()) attacker = NULL; if (victim == localPlayer && !attacker) @@ -1425,15 +1394,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) { switch (numT) { - case 0: - CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); - break; - case 1: - CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); - break; - default: - CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); - break; + case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); break; + case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); break; } break; } @@ -1441,15 +1404,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) { switch (numCT) { - case 0: - CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); - break; - case 1: - CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); - break; - default: - CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); - break; + case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); break; + case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); break; } break; } @@ -1463,15 +1420,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) { switch (numT) { - case 0: - CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); - break; - case 1: - CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); - break; - default: - CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); - break; + case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); break; + case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); break; } break; } @@ -1479,15 +1430,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) { switch (numCT) { - case 0: - CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); - break; - case 1: - CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); - break; - default: - CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); - break; + case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); break; + case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); break; } break; } @@ -1572,15 +1517,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) { switch (numT) { - case 0: - CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); - break; - case 1: - CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); - break; - default: - CreateAndAddEventToList(ENEMY_KILLED, entity, other); - break; + case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); break; + case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(ENEMY_KILLED, entity, other); break; } break; } @@ -1588,15 +1527,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) { switch (numCT) { - case 0: - CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); - break; - case 1: - CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); - break; - default: - CreateAndAddEventToList(ENEMY_KILLED, entity, other); - break; + case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); break; + case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(ENEMY_KILLED, entity, other); break; } break; } @@ -1614,21 +1547,21 @@ void CCSTutor::HandlePlayerTookDamage(CBaseEntity *entity, CBaseEntity *other) CBasePlayer *victim = static_cast(entity); CBasePlayer *attacker = static_cast(other); - if (victim != NULL && !victim->IsPlayer()) + if (victim && !victim->IsPlayer()) { victim = NULL; } - if (attacker != NULL && !attacker->IsPlayer()) + if (attacker && !attacker->IsPlayer()) { attacker = NULL; } - if (victim != NULL && victim == localPlayer) + if (victim && victim == localPlayer) { CreateAndAddEventToList(YOU_WERE_JUST_HURT); } - else if (attacker != NULL && victim != NULL && attacker == localPlayer && victim->m_iTeam == localPlayer->m_iTeam) + else if (attacker && victim && attacker == localPlayer && victim->m_iTeam == localPlayer->m_iTeam) { CreateAndAddEventToList(YOU_ATTACKED_TEAMMATE); } @@ -1642,8 +1575,7 @@ void CCSTutor::HandlePlayerBlindedByFlashbang(CBaseEntity *entity, CBaseEntity * return; CBasePlayer *player = static_cast(entity); - - if (player != NULL && player->IsPlayer() && player == localPlayer) + if (player && player->IsPlayer() && player == localPlayer) { CreateAndAddEventToList(YOU_ARE_BLIND_FROM_FLASHBANG); } @@ -1705,7 +1637,7 @@ void CCSTutor::HandlePlayerLeftBuyZone(CBaseEntity *entity, CBaseEntity *other) ClearEventList(); ClearCurrentEvent(); - if (m_lastScenarioEvent != NULL) + if (m_lastScenarioEvent) { m_lastScenarioEvent->SetActivationTime(gpGlobals->time); AddToEventList(m_lastScenarioEvent); @@ -1738,8 +1670,7 @@ void CCSTutor::HandleBombDefused(CBaseEntity *entity, CBaseEntity *other) return; CBasePlayer *defuser = static_cast(entity); - - if (defuser != NULL && defuser->IsPlayer() && defuser == localPlayer) + if (defuser && defuser->IsPlayer() && defuser == localPlayer) { CreateAndAddEventToList(YOU_DEFUSED_BOMB); } @@ -1747,15 +1678,9 @@ void CCSTutor::HandleBombDefused(CBaseEntity *entity, CBaseEntity *other) { switch (localPlayer->m_iTeam) { - case CT: - CreateAndAddEventToList(BOMB_DEFUSED_CT); - break; - case TERRORIST: - CreateAndAddEventToList(BOMB_DEFUSED_T); - break; - default: - CreateAndAddEventToList(ROUND_OVER); - break; + case CT: CreateAndAddEventToList(BOMB_DEFUSED_CT); break; + case TERRORIST: CreateAndAddEventToList(BOMB_DEFUSED_T); break; + default: CreateAndAddEventToList(ROUND_OVER); break; } } } @@ -1768,8 +1693,7 @@ void CCSTutor::HandleBombDefusing(CBaseEntity *entity, CBaseEntity *other) return; CBasePlayer *player = static_cast(entity); - - if (player != NULL && player->IsPlayer() && player == localPlayer && !player->m_bHasDefuser) + if (player && player->IsPlayer() && player == localPlayer && !player->m_bHasDefuser) { CreateAndAddEventToList(DEFUSING_WITHOUT_KIT); } @@ -1784,14 +1708,9 @@ void CCSTutor::HandleBombExploded(CBaseEntity *entity, CBaseEntity *other) switch (localPlayer->m_iTeam) { - case CT: - CreateAndAddEventToList(BOMB_EXPLODED_CT); - break; - case TERRORIST: - CreateAndAddEventToList(BOMB_EXPLODED_T); - break; - default: - break; + case CT: CreateAndAddEventToList(BOMB_EXPLODED_CT); break; + case TERRORIST: CreateAndAddEventToList(BOMB_EXPLODED_T); break; + default: break; } } @@ -1824,12 +1743,8 @@ void CCSTutor::HandleRoundStart(CBaseEntity *entity, CBaseEntity *other) { switch (player->m_iTeam) { - case CT: - CreateAndAddEventToList(ROUND_START_CS_CT); - break; - case TERRORIST: - CreateAndAddEventToList(ROUND_START_CS_T); - break; + case CT: CreateAndAddEventToList(ROUND_START_CS_CT); break; + case TERRORIST: CreateAndAddEventToList(ROUND_START_CS_T); break; } } } @@ -1842,8 +1757,7 @@ void CCSTutor::HandleBeingShotAt(CBaseEntity *entity, CBaseEntity *other) return; CBasePlayer *player = static_cast(entity); - - if (player != NULL && player->IsPlayer() && player == localPlayer && localPlayer->IsAlive()) + if (player && player->IsPlayer() && player == localPlayer && localPlayer->IsAlive()) { CreateAndAddEventToList(YOU_HAVE_BEEN_SHOT_AT, entity, other); } @@ -1857,7 +1771,7 @@ void CCSTutor::HandleHostageUsed(CBaseEntity *entity, CBaseEntity *other) return; CBasePlayer *activator = static_cast(entity); - if (activator != NULL && activator->IsPlayer()) + if (activator && activator->IsPlayer()) { bool unusedHostages = !CheckForAllHostagesFollowingSomeone(); @@ -1869,12 +1783,8 @@ void CCSTutor::HandleHostageUsed(CBaseEntity *entity, CBaseEntity *other) { switch (localPlayer->m_iTeam) { - case CT: - CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); - break; - case TERRORIST: - CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_T); - break; + case CT: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); break; + case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_T); break; } } } @@ -1888,16 +1798,12 @@ void CCSTutor::HandleHostageRescued(CBaseEntity *entity, CBaseEntity *other) return; CBasePlayer *rescuer = static_cast(entity); - if (rescuer != NULL && rescuer->IsPlayer()) + if (rescuer && rescuer->IsPlayer()) { switch (localPlayer->m_iTeam) { - case CT: - CreateAndAddEventToList((localPlayer == rescuer) ? YOU_RESCUED_HOSTAGE : HOSTAGE_RESCUED_CT); - break; - case TERRORIST: - CreateAndAddEventToList(HOSTAGE_RESCUED_T); - break; + case CT: CreateAndAddEventToList((localPlayer == rescuer) ? YOU_RESCUED_HOSTAGE : HOSTAGE_RESCUED_CT); break; + case TERRORIST: CreateAndAddEventToList(HOSTAGE_RESCUED_T); break; } } } @@ -1911,12 +1817,8 @@ void CCSTutor::HandleAllHostagesRescued(CBaseEntity *entity, CBaseEntity *other) switch (localPlayer->m_iTeam) { - case CT: - CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_CT); - break; - case TERRORIST: - CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_T); - break; + case CT: CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_CT); break; + case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_T); break; } } @@ -1928,7 +1830,7 @@ void CCSTutor::HandleHostageDamaged(CBaseEntity *entity, CBaseEntity *other) return; CBasePlayer *attacker = static_cast(other); - if (entity != NULL && attacker != NULL && attacker->IsPlayer() && localPlayer == attacker) + if (entity && attacker && attacker->IsPlayer() && localPlayer == attacker) { CreateAndAddEventToList(YOU_DAMAGED_HOSTAGE); } @@ -1944,10 +1846,9 @@ void CCSTutor::HandleHostageKilled(CBaseEntity *entity, CBaseEntity *other) CheckForAllHostagesDead(); CBasePlayer *attacker = static_cast(other); - if (entity != NULL && attacker != NULL && attacker->IsPlayer()) + if (entity && attacker && attacker->IsPlayer()) { bool unusedHostages = CheckForAllHostagesFollowingSomeone(); - if (localPlayer == attacker) { CreateAndAddEventToList(YOU_KILLED_HOSTAGE); @@ -1957,12 +1858,8 @@ void CCSTutor::HandleHostageKilled(CBaseEntity *entity, CBaseEntity *other) { switch (localPlayer->m_iTeam) { - case CT: - CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); - break; - case TERRORIST: - CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_T); - break; + case CT: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); break; + case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_T); break; } } } @@ -1998,8 +1895,7 @@ void CCSTutor::HandleDeathCameraStart(CBaseEntity *entity, CBaseEntity *other) return; CBasePlayer *player = static_cast(entity); - - if (player != NULL && player->IsPlayer() && player == localPlayer) + if (player && player->IsPlayer() && player == localPlayer) { m_messageTypeMask = (TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_HINT | TUTORMESSAGETYPE_END_GAME); CreateAndAddEventToList(DEATH_CAMERA_START); @@ -2150,7 +2046,7 @@ void CCSTutor::HandleCareerTaskDone(CBaseEntity *entity, CBaseEntity *other) { int numTasksRemaining = 0; - if (TheCareerTasks != NULL && (numTasksRemaining = TheCareerTasks->GetNumRemainingTasks()) > 0) + if (TheCareerTasks && (numTasksRemaining = TheCareerTasks->GetNumRemainingTasks()) > 0) CreateAndAddEventToList((numTasksRemaining == 1) ? CAREER_TASK_DONE_ONE_LEFT : CAREER_TASK_DONE_MORE_LEFT); else CreateAndAddEventToList(CAREER_TASK_DONE_ALL_DONE); @@ -2183,24 +2079,19 @@ void CCSTutor::__MAKE_VHOOK(HandleShotFired)(Vector source, Vector target) void CCSTutor::GetNumPlayersAliveOnTeams(int &numT, int &numCT) { - numT = 0; - numCT = 0; + numT = numCT = 0; for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *player = UTIL_PlayerByIndex(i); - if (player == NULL || !player->IsAlive()) + if (!player || !player->IsAlive()) continue; switch (player->m_iTeam) { - case CT: - ++numCT; - break; - case TERRORIST: - ++numT; - break; + case CT: ++numCT; break; + case TERRORIST: ++numT; break; } } } @@ -2213,11 +2104,11 @@ void CCSTutor::CheckForLooseWeaponViewable() return; TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_WEAPON); - if (message != NULL && message->m_class == TUTORMESSAGECLASS_EXAMINE) + if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE) return; CBaseEntity *weapon = NULL; - while ((weapon = UTIL_FindEntityByClassname(weapon, "weaponbox")) != NULL) + while ((weapon = UTIL_FindEntityByClassname(weapon, "weaponbox"))) { if (IsEntityInViewOfPlayer(weapon, localPlayer)) { @@ -2235,11 +2126,11 @@ void CCSTutor::CheckForLooseDefuserViewable() return; TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_DEFUSER); - if (message != NULL && message->m_class == TUTORMESSAGECLASS_EXAMINE) + if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE) return; CBaseEntity *defuser = NULL; - while ((defuser = UTIL_FindEntityByClassname(defuser, "item_thighpack")) != NULL) + while ((defuser = UTIL_FindEntityByClassname(defuser, "item_thighpack"))) { if (IsEntityInViewOfPlayer(defuser, localPlayer)) { @@ -2257,14 +2148,13 @@ void CCSTutor::CheckForBombViewable() return; CBaseEntity *bomb = UTIL_FindEntityByClassname(NULL, "grenade"); - if (bomb != NULL && ((CGrenade *)bomb)->m_bIsC4 && IsEntityInViewOfPlayer(bomb, localPlayer)) + if (bomb && ((CGrenade *)bomb)->m_bIsC4 && IsEntityInViewOfPlayer(bomb, localPlayer)) { switch (localPlayer->m_iTeam) { case CT: { TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_PLANTED_BOMB_CT); - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) { CreateAndAddEventToList(YOU_SEE_PLANTED_BOMB_CT); @@ -2274,7 +2164,6 @@ void CCSTutor::CheckForBombViewable() case TERRORIST: { TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_PLANTED_BOMB_T); - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) { CreateAndAddEventToList(YOU_SEE_PLANTED_BOMB_T); @@ -2286,12 +2175,11 @@ void CCSTutor::CheckForBombViewable() else { CBasePlayer *bombCarrier = NULL; - for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *player = UTIL_PlayerByIndex(i); - if (player != NULL && player->m_bHasC4) + if (player && player->m_bHasC4) { bombCarrier = player; break; @@ -2300,34 +2188,32 @@ void CCSTutor::CheckForBombViewable() bomb = UTIL_FindEntityByClassname(NULL, "weapon_c4"); - if (bomb != NULL && IsEntityInViewOfPlayer(bomb, localPlayer)) + if (bomb && IsEntityInViewOfPlayer(bomb, localPlayer)) { - if (bombCarrier != NULL) + if (bombCarrier) { if (bombCarrier != localPlayer) { switch (localPlayer->m_iTeam) { - case CT: + case CT: + { + TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_BOMB_CARRIER_CT); + if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE) { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_BOMB_CARRIER_CT); - - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) - { - CreateAndAddEventToList(YOU_SEE_BOMB_CARRIER_CT); - } - break; + CreateAndAddEventToList(YOU_SEE_BOMB_CARRIER_CT); } - case TERRORIST: + break; + } + case TERRORIST: + { + TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_BOMB_CARRIER_T); + if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE) { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_BOMB_CARRIER_T); - - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) - { - CreateAndAddEventToList(YOU_SEE_BOMB_CARRIER_T); - } - break; + CreateAndAddEventToList(YOU_SEE_BOMB_CARRIER_T); } + break; + } } } } @@ -2338,7 +2224,6 @@ void CCSTutor::CheckForBombViewable() case CT: { TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_BOMB_CT); - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) { CreateAndAddEventToList(YOU_SEE_LOOSE_BOMB_CT); @@ -2348,7 +2233,6 @@ void CCSTutor::CheckForBombViewable() case TERRORIST: { TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_BOMB_T); - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) { CreateAndAddEventToList(YOU_SEE_LOOSE_BOMB_T); @@ -2398,7 +2282,7 @@ void CCSTutor::CheckForBombsiteViewable() bool sawFirst = false; CBaseEntity *bombTarget = NULL; - while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "func_bomb_target")) != NULL) + while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "func_bomb_target"))) { if (IsBombPlantedInBombsite(bombTarget)) { @@ -2410,7 +2294,7 @@ void CCSTutor::CheckForBombsiteViewable() if (!sawFirst) { - while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "info_bomb_target")) != NULL) + while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "info_bomb_target"))) { if (IsBombPlantedInBombsite(bombTarget)) { @@ -2430,11 +2314,11 @@ TutorMessageID CCSTutor::CheckForInBombZone() CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); TutorMessageID mid = TUTOR_NUM_MESSAGES; - if (localPlayer != NULL && localPlayer->m_iTeam == CT) + if (localPlayer && localPlayer->m_iTeam == CT) { CBaseEntity *bombTarget = NULL; - while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "func_bomb_target")) != NULL) + while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "func_bomb_target"))) { if (IsBombPlantedInBombsite(bombTarget)) { @@ -2442,7 +2326,7 @@ TutorMessageID CCSTutor::CheckForInBombZone() } } - while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "info_bomb_target")) != NULL) + while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "info_bomb_target"))) { if (IsBombPlantedInBombsite(bombTarget)) { @@ -2457,8 +2341,7 @@ TutorMessageID CCSTutor::CheckForInBombZone() bool CCSTutor::IsBombPlantedInBombsite(CBaseEntity *bombTarget) { CGrenade *bomb = NULL; - - while ((bomb = (CGrenade *)UTIL_FindEntityByClassname(bomb, "grenade")) != NULL) + while ((bomb = (CGrenade *)UTIL_FindEntityByClassname(bomb, "grenade"))) { if (bomb->m_bIsC4 && IsEntityInBombsite(bomb, bombTarget)) { @@ -2477,45 +2360,39 @@ void CCSTutor::CheckForHostageViewable() return; CBaseEntity *hostageEntity = NULL; - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) + while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) { bool validHostage = false; CHostage *hostage = static_cast(hostageEntity); - if (hostage->pev->takedamage == DAMAGE_YES) + if (hostage->IsAlive()) { if (!hostage->IsFollowingSomeone()) validHostage = true; } - if (hostage->IsValid() && validHostage && IsEntityInViewOfPlayer(hostage, localPlayer)) + if (validHostage && IsEntityInViewOfPlayer(hostage, localPlayer)) { switch (localPlayer->m_iTeam) { - case CT: - { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_HOSTAGE_CT); + case CT: + { + TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_HOSTAGE_CT); + if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE) + return; - if (message != NULL && message->m_class == TUTORMESSAGECLASS_EXAMINE) - { - return; - } + CreateAndAddEventToList(YOU_SEE_HOSTAGE_CT); + break; + } + case TERRORIST: + { + TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_HOSTAGE_T); + if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE) + return; - CreateAndAddEventToList(YOU_SEE_HOSTAGE_CT); - break; - } - case TERRORIST: - { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_HOSTAGE_T); - - if (message != NULL && message->m_class == TUTORMESSAGECLASS_EXAMINE) - { - return; - } - - CreateAndAddEventToList(YOU_SEE_HOSTAGE_T); - break; - } + CreateAndAddEventToList(YOU_SEE_HOSTAGE_T); + break; + } } break; @@ -2561,7 +2438,7 @@ void CCSTutor::CheckForAllHostagesDead() bool foundLiveOne = false; CHostage *hostage = NULL; - while ((hostage = (CHostage *)UTIL_FindEntityByClassname(hostage, "hostage_entity")) != NULL) + while ((hostage = (CHostage *)UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { if (hostage->IsAlive()) { @@ -2581,9 +2458,9 @@ bool CCSTutor::CheckForAllHostagesFollowingSomeone() bool foundUnusedOne = false; CHostage *hostage = NULL; - while ((hostage = (CHostage *)UTIL_FindEntityByClassname(hostage, "hostage_entity")) != NULL) + while ((hostage = (CHostage *)UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { - if (hostage->pev->takedamage == DAMAGE_YES) + if (hostage->IsAlive()) { if (!hostage->IsFollowingSomeone()) { @@ -2628,7 +2505,7 @@ CBaseEntity *CCSTutor::GetEntityForMessageID(int messageID, CBaseEntity *last) #if 1 CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - if (localPlayer != NULL) + if (localPlayer) { if (m_clientCorpseList.empty()) return NULL; @@ -2636,7 +2513,7 @@ CBaseEntity *CCSTutor::GetEntityForMessageID(int messageID, CBaseEntity *last) ClientCorpseStruct *lastCorpse = NULL; ClientCorpseListIter iter; - if (last != NULL) + if (last) { iter = m_clientCorpseList.begin(); @@ -2738,8 +2615,7 @@ void CCSTutor::CheckHintMessages(float time) } TutorMessage *message = GetTutorMessageDefinition(m_lastHintShown); - - if (message != NULL) + if (message) { CreateAndAddEventToList(m_lastHintShown); } @@ -2756,8 +2632,7 @@ void CCSTutor::CheckInGameHintMessages(float time) return; TutorMessage *message = GetTutorMessageDefinition(m_lastInGameHintShown); - - if (message != NULL) + if (message) { CreateAndAddEventToList(m_lastInGameHintShown); } @@ -2791,18 +2666,17 @@ void CCSTutor::CheckForNeedToReload(bool isPassiveCheck) { if (isPassiveCheck) { - if (2 * currentWeapon->m_iClip < currentItem->iMaxClip() && !currentWeapon->m_fInReload) + if ((2 * currentWeapon->m_iClip) < currentItem->iMaxClip() && !currentWeapon->m_fInReload) { CreateAndAddEventToList(YOU_SHOULD_RELOAD); } } else { - if (5 * currentWeapon->m_iClip < currentItem->iMaxClip() && !currentWeapon->m_fInReload) + if ((5 * currentWeapon->m_iClip) < currentItem->iMaxClip() && !currentWeapon->m_fInReload) { TutorMessage *message = GetTutorMessageDefinition(YOU_SHOULD_RELOAD); - - if (message != NULL) + if (message) { message->m_lastCloseTime = 0; } @@ -2812,8 +2686,7 @@ void CCSTutor::CheckForNeedToReload(bool isPassiveCheck) else { TutorMessage *message = GetTutorMessageDefinition(YOU_SHOULD_RELOAD); - - if (message != NULL) + if (message) { message->m_lastCloseTime = gpGlobals->time; } @@ -2825,8 +2698,7 @@ void CCSTutor::CheckForNeedToReload(bool isPassiveCheck) if (!isPassiveCheck) { TutorMessage *message = GetTutorMessageDefinition(YOU_ARE_OUT_OF_AMMO); - - if (message != NULL) + if (message) { message->m_lastCloseTime = 0; } @@ -2853,7 +2725,7 @@ void CCSTutor::CheckExamineMessages(float time) CBaseEntity *entity = NULL; bool isPlayerLooking = false; - while ((entity = GetEntityForMessageID(i, entity)) != NULL) + while ((entity = GetEntityForMessageID(i, entity))) { if (i == YOU_SEE_FRIEND_CORPSE || i == YOU_SEE_ENEMY_CORPSE) { @@ -2907,15 +2779,11 @@ void CCSTutor::CheckExamineMessages(float time) else if (i == YOU_SEE_HOSTAGE_CT_EXAMINE) { CHostage *hostage = static_cast(entity); - - if (entity->pev->takedamage == DAMAGE_YES) + if (entity->IsAlive()) { if (!hostage->IsFollowingSomeone()) validEntity = true; } - - if (!hostage->IsValid() || !validEntity) - continue; } if (validEntity) @@ -2931,8 +2799,7 @@ void CCSTutor::CheckExamineMessages(float time) bool CCSTutor::CanLocalPlayerBuyStuff() { CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer != NULL) + if (localPlayer) { return localPlayer->CanPlayerBuy(); } @@ -2950,7 +2817,7 @@ void CCSTutor::CheckBuyZoneMessages() CBasePlayerWeapon *primary = static_cast(localPlayer->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]); CBasePlayerWeapon *secondary = static_cast(localPlayer->m_rgpPlayerItems[PISTOL_SLOT]); - if (primary != NULL) + if (primary) { if (localPlayer->NeedsPrimaryAmmo() && localPlayer->CanAffordPrimaryAmmo()) { @@ -2967,7 +2834,7 @@ void CCSTutor::CheckBuyZoneMessages() } } - if (secondary != NULL && localPlayer->NeedsSecondaryAmmo() && localPlayer->CanAffordSecondaryAmmo()) + if (secondary && localPlayer->NeedsSecondaryAmmo() && localPlayer->CanAffordSecondaryAmmo()) { TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_SECONDARY_AMMO); } @@ -2999,10 +2866,9 @@ bool CCSTutor::IsBombMap() void CCSTutor::ResetPlayerDeathInfo() { - for (int i = 0; i < ARRAYSIZE(m_playerDeathInfo); ++i) - { - m_playerDeathInfo[i].m_hasBeenShown = false; - m_playerDeathInfo[i].m_event = NULL; + for (auto& playerDeathInfo : m_playerDeathInfo) { + playerDeathInfo.m_hasBeenShown = false; + playerDeathInfo.m_event = nullptr; } } @@ -3018,7 +2884,7 @@ void CCSTutor::ConstructRecentDeathsList(TeamName team, char *buf, int buflen, T { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer == NULL) + if (!pPlayer) continue; // ignore alive players @@ -3038,11 +2904,10 @@ void CCSTutor::ConstructRecentDeathsList(TeamName team, char *buf, int buflen, T void CCSTutor::TransferDeathEvents(TutorMessageEvent *oldEvent, TutorMessageEvent *newEvent) { - for (int i = 0; i < ARRAYSIZE(m_playerDeathInfo); ++i) + for (auto& playerDeathInfo : m_playerDeathInfo) { - if (m_playerDeathInfo[i].m_event == oldEvent) - { - m_playerDeathInfo[i].m_event = newEvent; + if (playerDeathInfo.m_event == oldEvent) { + playerDeathInfo.m_event = newEvent; } } } diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index d3b09d89..593b183d 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -522,6 +522,7 @@ CBaseEntity *UTIL_FindEntityGeneric(const char *szWhatever, const Vector &vecSrc return pEntity; } +#ifndef REGAMEDLL_FIXES CBasePlayer *EXT_FUNC UTIL_PlayerByIndex(int playerIndex) { CBasePlayer *pPlayer = nullptr; @@ -534,6 +535,7 @@ CBasePlayer *EXT_FUNC UTIL_PlayerByIndex(int playerIndex) return pPlayer; } +#endif void UTIL_MakeVectors(const Vector &vecAngles) { @@ -737,7 +739,7 @@ void UTIL_HudMessageAll(const hudtextparms_t &textparms, const char *pMessage) for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBaseEntity *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer != NULL) + if (pPlayer) UTIL_HudMessage(pPlayer, textparms, pMessage); } } @@ -866,7 +868,7 @@ void UTIL_ShowMessageAll(const char *pString, bool isHint) for (int i = 1; i <= gpGlobals->maxClients; ++i) { CBaseEntity *pPlayer = UTIL_PlayerByIndex(i); - if (pPlayer != NULL) + if (pPlayer) UTIL_ShowMessage(pString, pPlayer, isHint); } } @@ -2332,8 +2334,8 @@ char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd) NOXREF int GetPlayerTeam(int index) { - CBasePlayer *pPlayer = UTIL_PlayerByIndex(index); - if (pPlayer != NULL) + CBasePlayer *pPlayer = UTIL_PlayerByIndexSafe(index); + if (pPlayer) { return pPlayer->m_iTeam; } @@ -2358,7 +2360,7 @@ bool UTIL_IsGame(const char *gameName) float_precision UTIL_GetPlayerGaitYaw(int playerIndex) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(playerIndex); - if (pPlayer != NULL) + if (pPlayer) { return pPlayer->m_flGaityaw; } diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index fca3a565..72b98820 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -191,9 +191,20 @@ inline entvars_t *VARS(edict_t *pent) return &pent->v; } -inline entvars_t *VARS(EOFFSET eoffset) { return VARS(ENT(eoffset)); } +inline entvars_t *VARS(EOFFSET eoffset) +{ + return VARS(ENT(eoffset)); +} + +#ifndef ENTINDEX inline int ENTINDEX(const edict_t *pEdict) { return (*g_engfuncs.pfnIndexOfEdict)(pEdict); } +inline int ENTINDEX(const entvars_t *pev) { return (*g_engfuncs.pfnIndexOfEdict)(ENT(pev)); } +#endif // ENTINDEX + +#ifndef INDEXENT inline edict_t *INDEXENT(int iEdictNum) { return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); } +#endif // INDEXENT + inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent) { MESSAGE_BEGIN(msg_dest, msg_type, pOrigin, ENT(ent)); } inline BOOL FNullEnt(EOFFSET eoffset) { return (eoffset == 0); } inline BOOL FNullEnt(entvars_t *pev) { return (pev == NULL || FNullEnt(OFFSET(pev))); } @@ -246,7 +257,9 @@ CBaseEntity *UTIL_FindEntityByString(CBaseEntity *pStartEntity, const char *szKe CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName); CBaseEntity *UTIL_FindEntityByTargetname(CBaseEntity *pStartEntity, const char *szName); CBaseEntity *UTIL_FindEntityGeneric(const char *szWhatever, const Vector &vecSrc, float flRadius); +#ifndef REGAMEDLL_FIXES CBasePlayer *UTIL_PlayerByIndex(int playerIndex); +#endif void UTIL_MakeVectors(const Vector &vecAngles); void UTIL_MakeAimVectors(const Vector &vecAngles); void UTIL_MakeInvVectors(const Vector &vec, globalvars_t *pgv); diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index c8ff5e09..f73eefeb 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -68,7 +68,6 @@ int MaxAmmoCarry(const char *szName) for (int i = 0; i < MAX_WEAPONS; ++i) { ItemInfo *info = &IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[ i ]; - if (info->pszAmmo1 && !Q_strcmp(szName, info->pszAmmo1)) { return info->iMaxAmmo1; @@ -84,6 +83,11 @@ int MaxAmmoCarry(const char *szName) return -1; } +int MaxAmmoCarry(WeaponIdType weaponId) +{ + return IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[ weaponId ].iMaxAmmo1; +} + int MaxAmmoCarry(int iszName) { return MaxAmmoCarry(STRING(iszName)); @@ -152,7 +156,6 @@ void DecalGunshot(TraceResult *pTrace, int iBulletType, bool ClientOnly, entvars // EjectBrass - tosses a brass shell from passed origin at passed velocity void EjectBrass(const Vector &vecOrigin, const Vector &vecLeft, const Vector &vecVelocity, float rotation, int model, int soundtype, int entityIndex) { - //CBaseEntity *ent = UTIL_PlayerByIndex(entityIndex); // unused bool useNewBehavior = g_bIsCzeroGame; MESSAGE_BEGIN(MSG_PVS, gmsgBrass, vecOrigin); @@ -652,7 +655,9 @@ void CBasePlayerItem::DefaultTouch(CBaseEntity *pOther) if (pOther->AddPlayerItem(this)) { AttachToPlayer(pPlayer); +#ifndef REGAMEDLL_FIXES SetThink(NULL); +#endif EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); } @@ -945,7 +950,7 @@ void CBasePlayerWeapon::__MAKE_VHOOK(ItemPostFrame)() #ifdef REGAMEDLL_ADD // Do not remove bpammo of the player, // if cvar allows to refill bpammo on during reloading the weapons - if (refill_bpammo_weapons.value < 2.0f) { + if (refill_bpammo_weapons.value < 3.0f) { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j; } #else @@ -1119,7 +1124,14 @@ void CBasePlayerItem::__MAKE_VHOOK(AttachToPlayer)(CBasePlayer *pPlayer) pev->modelindex = 0; pev->model = 0; pev->owner = pPlayer->edict(); + +#ifndef REGAMEDLL_FIXES pev->nextthink = gpGlobals->time + 0.1f; +#else + // Remove think - prevents futher attempts to materialize + pev->nextthink = 0; + SetThink(NULL); +#endif SetTouch(NULL); } @@ -1630,7 +1642,7 @@ void CWeaponBox::BombThink() WRITE_COORD(pev->origin.x); WRITE_COORD(pev->origin.y); WRITE_COORD(pev->origin.z); - WRITE_BYTE(0); + WRITE_BYTE(BOMB_FLAG_DROPPED); MESSAGE_END(); } } @@ -1986,7 +1998,6 @@ int CWeaponBox::PackAmmo(int iszName, int iCount) } int iMaxCarry = MaxAmmoCarry(iszName); - if (iMaxCarry != -1 && iCount > 0) { GiveAmmo(iCount, (char *)STRING(iszName), iMaxCarry); @@ -2345,7 +2356,7 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther) { case ARMOURY_FLASHBANG: { - if (p->AmmoInventory(p->GetAmmoIndex("Flashbang")) >= MaxAmmoCarry("Flashbang")) + if (p->AmmoInventory(AMMO_FLASHBANG) >= MaxAmmoCarry(WEAPON_FLASHBANG)) return; p->GiveNamedItem("weapon_flashbang"); @@ -2354,7 +2365,7 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther) } case ARMOURY_HEGRENADE: { - if (p->AmmoInventory(p->GetAmmoIndex("HEGrenade")) >= MaxAmmoCarry("HEGrenade")) + if (p->AmmoInventory(AMMO_HEGRENADE) >= MaxAmmoCarry(WEAPON_HEGRENADE)) return; p->GiveNamedItem("weapon_hegrenade"); @@ -2381,7 +2392,7 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther) } case ARMOURY_SMOKEGRENADE: { - if (p->AmmoInventory(p->GetAmmoIndex("SmokeGrenade")) >= MaxAmmoCarry("SmokeGrenade")) + if (p->AmmoInventory(AMMO_SMOKEGRENADE) >= MaxAmmoCarry(WEAPON_SMOKEGRENADE)) return; p->GiveNamedItem("weapon_smokegrenade"); diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index da5c9b11..1bb9b1a5 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -793,6 +793,10 @@ private: unsigned short m_usFireAWP; }; +// for usermsg BombDrop +#define BOMB_FLAG_DROPPED 0 // if the bomb was dropped due to voluntary dropping or death/disconnect +#define BOMB_FLAG_PLANTED 1 // if the bomb has been planted will also trigger the round timer to hide will also show where the dropped bomb on the Terrorist team's radar. + class CC4: public CBasePlayerWeapon { public: @@ -1863,6 +1867,7 @@ void AnnounceFlashInterval(float interval, float offset = 0); int MaxAmmoCarry(int iszName); int MaxAmmoCarry(const char *szName); +int MaxAmmoCarry(WeaponIdType ammoType); void ClearMultiDamage(); void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker); diff --git a/regamedll/dlls/world.cpp b/regamedll/dlls/world.cpp index a0b7ed4e..7f6411b2 100644 --- a/regamedll/dlls/world.cpp +++ b/regamedll/dlls/world.cpp @@ -69,6 +69,8 @@ TYPEDESCRIPTION gGlobalEntitySaveData[] = #endif // HOOK_GAMEDLL +char g_szMapBriefingText[512]; + class CDecal: public CBaseEntity { public: @@ -414,9 +416,45 @@ LINK_ENTITY_TO_CLASS(worldspawn, CWorld, CCSWorld); void CWorld::__MAKE_VHOOK(Spawn)() { - EmptyEntityHashTable(); - g_fGameOver = FALSE; +#ifdef REGAMEDLL_FIXES + static char szMapBriefingFile[64] = ""; + EmptyEntityHashTable(); + Precache(); + + g_flWeaponCheat = CVAR_GET_FLOAT("sv_cheats"); + g_szMapBriefingText[0] = '\0'; + Q_sprintf(szMapBriefingFile, "maps/%s.txt", STRING(gpGlobals->mapname)); + + int flength = 0; + char *pFile = (char *)LOAD_FILE_FOR_ME(szMapBriefingFile, &flength); + + if (pFile && flength) + { + Q_strncpy(g_szMapBriefingText, pFile, ARRAYSIZE(g_szMapBriefingText) - 2); + g_szMapBriefingText[ ARRAYSIZE(g_szMapBriefingText) - 2 ] = '\0'; + + PRECACHE_GENERIC(szMapBriefingFile); + } + else + { + pFile = (char *)LOAD_FILE_FOR_ME("maps/default.txt", &flength); + if (pFile && flength) + { + Q_strncpy(g_szMapBriefingText, pFile, ARRAYSIZE(g_szMapBriefingText) - 2); + g_szMapBriefingText[ ARRAYSIZE(g_szMapBriefingText) - 2 ] = '\0'; + + PRECACHE_GENERIC("maps/default.txt"); + } + } + + if (pFile) + { + FREE_FILE(pFile); + } + +#else + EmptyEntityHashTable(); Precache(); g_flWeaponCheat = CVAR_GET_FLOAT("sv_cheats"); @@ -425,14 +463,9 @@ void CWorld::__MAKE_VHOOK(Spawn)() int flength = 0; char *pFile = (char *)LOAD_FILE_FOR_ME(UTIL_VarArgs("maps/%s.txt", STRING(gpGlobals->mapname)), &flength); - if (pFile != NULL && flength) + if (pFile && flength) { Q_strncpy(g_szMapBriefingText, pFile, ARRAYSIZE(g_szMapBriefingText) - 2); - -#ifdef REGAMEDLL_FIXES - g_szMapBriefingText[ ARRAYSIZE(g_szMapBriefingText) - 2 ] = '\0'; -#endif - PRECACHE_GENERIC(UTIL_VarArgs("maps/%s.txt", STRING(gpGlobals->mapname))); FREE_FILE(pFile); } @@ -440,18 +473,14 @@ void CWorld::__MAKE_VHOOK(Spawn)() { pFile = (char *)LOAD_FILE_FOR_ME(UTIL_VarArgs("maps/default.txt"), &flength); - if (pFile != NULL && flength) + if (pFile && flength) { Q_strncpy(g_szMapBriefingText, pFile, ARRAYSIZE(g_szMapBriefingText) - 2); -#ifdef REGAMEDLL_FIXES - g_szMapBriefingText[ ARRAYSIZE(g_szMapBriefingText) - 2 ] = '\0'; -#endif - PRECACHE_GENERIC(UTIL_VarArgs("maps/default.txt")); + FREE_FILE(pFile); } - - FREE_FILE(pFile); } +#endif } void CWorld::__MAKE_VHOOK(Precache)() @@ -468,7 +497,7 @@ void CWorld::__MAKE_VHOOK(Precache)() CVAR_SET_STRING("room_type", "0"); // Set up game rules - if (g_pGameRules != NULL) + if (g_pGameRules) { delete g_pGameRules; } @@ -642,11 +671,11 @@ void CWorld::__MAKE_VHOOK(Precache)() } } -#ifndef REGAMEDLL_FIXES +#ifdef REGAMEDLL_FIXES if (!IS_DEDICATED_SERVER()) #endif { - // TODO: cvar v_dark there is only the client side + // NOTE: cvar v_dark refers for the client side if (pev->spawnflags & SF_WORLD_DARK) CVAR_SET_FLOAT("v_dark", 1); else diff --git a/regamedll/dlls/world.h b/regamedll/dlls/world.h index f1eeece3..4d6eda30 100644 --- a/regamedll/dlls/world.h +++ b/regamedll/dlls/world.h @@ -42,5 +42,6 @@ void ResetGlobalState(); extern CGlobalState gGlobalState; extern float g_flWeaponCheat; +extern char g_szMapBriefingText[512]; #endif // WORLD_H diff --git a/regamedll/dlls/wpn_shared/wpn_ak47.cpp b/regamedll/dlls/wpn_shared/wpn_ak47.cpp index effad9c0..8b7eded8 100644 --- a/regamedll/dlls/wpn_shared/wpn_ak47.cpp +++ b/regamedll/dlls/wpn_shared/wpn_ak47.cpp @@ -166,7 +166,7 @@ void CAK47::__MAKE_VHOOK(Reload)() return; #endif - if (DefaultReload(AK47_MAX_CLIP, AK47_RELOAD, AK47_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), AK47_RELOAD, AK47_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_aug.cpp b/regamedll/dlls/wpn_shared/wpn_aug.cpp index dd0a924c..db7c7018 100644 --- a/regamedll/dlls/wpn_shared/wpn_aug.cpp +++ b/regamedll/dlls/wpn_shared/wpn_aug.cpp @@ -173,7 +173,7 @@ void CAUG::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_556nato <= 0) return; - if (DefaultReload(AUG_MAX_CLIP, AUG_RELOAD, AUG_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), AUG_RELOAD, AUG_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_awp.cpp b/regamedll/dlls/wpn_shared/wpn_awp.cpp index 071544de..188b81a1 100644 --- a/regamedll/dlls/wpn_shared/wpn_awp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_awp.cpp @@ -183,7 +183,7 @@ void CAWP::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_338mag <= 0) return; - if (DefaultReload(AWP_MAX_CLIP, AWP_RELOAD, AWP_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), AWP_RELOAD, AWP_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_c4.cpp b/regamedll/dlls/wpn_shared/wpn_c4.cpp index 276a8633..c8475108 100644 --- a/regamedll/dlls/wpn_shared/wpn_c4.cpp +++ b/regamedll/dlls/wpn_shared/wpn_c4.cpp @@ -143,7 +143,7 @@ void CC4::__MAKE_VHOOK(PrimaryAttack)() Broadcast("BOMBPL"); m_pPlayer->m_bHasC4 = false; - if (pev->speed != 0 && CSGameRules() != NULL) + if (pev->speed != 0 && CSGameRules()) { CSGameRules()->m_iC4Timer = int(pev->speed); } @@ -162,16 +162,16 @@ void CC4::__MAKE_VHOOK(PrimaryAttack)() WRITE_COORD(pBomb->pev->origin.x); WRITE_COORD(pBomb->pev->origin.y); WRITE_COORD(pBomb->pev->origin.z); - WRITE_BYTE(1); + WRITE_BYTE(BOMB_FLAG_PLANTED); MESSAGE_END(); UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Bomb_Planted"); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_BOMB_PLANTED, m_pPlayer, pBomb); } - if (TheCareerTasks != NULL && CSGameRules()->IsCareer() && !m_pPlayer->IsBot()) + if (TheCareerTasks && CSGameRules()->IsCareer() && !m_pPlayer->IsBot()) { TheCareerTasks->HandleEvent(EVENT_BOMB_PLANTED, m_pPlayer); } @@ -302,19 +302,16 @@ void CC4::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) void CC4::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - if (m_pPlayer != NULL) - { + if (m_pPlayer) return; - } CBasePlayer *pPlayer = UTIL_PlayerByIndex(1); - - if (pPlayer != NULL) + if (pPlayer) { edict_t *m_pentOldCurBombTarget = pPlayer->m_pentCurBombTarget; pPlayer->m_pentCurBombTarget = NULL; - if (pev->speed != 0 && CSGameRules() != NULL) + if (pev->speed != 0 && CSGameRules()) { CSGameRules()->m_iC4Timer = int(pev->speed); } @@ -324,7 +321,7 @@ void CC4::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0)); CGrenade *pC4 = NULL; - while ((pC4 = (CGrenade *)UTIL_FindEntityByClassname(pC4, "grenade")) != NULL) + while ((pC4 = (CGrenade *)UTIL_FindEntityByClassname(pC4, "grenade"))) { if (pC4->m_bIsC4 && pC4->m_flNextFreq == gpGlobals->time) { diff --git a/regamedll/dlls/wpn_shared/wpn_deagle.cpp b/regamedll/dlls/wpn_shared/wpn_deagle.cpp index 10d757e2..54370348 100644 --- a/regamedll/dlls/wpn_shared/wpn_deagle.cpp +++ b/regamedll/dlls/wpn_shared/wpn_deagle.cpp @@ -173,7 +173,7 @@ void CDEAGLE::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_50ae <= 0) return; - if (DefaultReload(DEAGLE_MAX_CLIP, DEAGLE_RELOAD, DEAGLE_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), DEAGLE_RELOAD, DEAGLE_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); m_flAccuracy = 0.9f; diff --git a/regamedll/dlls/wpn_shared/wpn_elite.cpp b/regamedll/dlls/wpn_shared/wpn_elite.cpp index bdc50108..d1012f2d 100644 --- a/regamedll/dlls/wpn_shared/wpn_elite.cpp +++ b/regamedll/dlls/wpn_shared/wpn_elite.cpp @@ -192,7 +192,7 @@ void CELITE::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_9mm <= 0) return; - if (DefaultReload(ELITE_MAX_CLIP, ELITE_RELOAD, ELITE_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), ELITE_RELOAD, ELITE_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); m_flAccuracy = 0.88f; diff --git a/regamedll/dlls/wpn_shared/wpn_famas.cpp b/regamedll/dlls/wpn_shared/wpn_famas.cpp index 6db12335..3c9683ae 100644 --- a/regamedll/dlls/wpn_shared/wpn_famas.cpp +++ b/regamedll/dlls/wpn_shared/wpn_famas.cpp @@ -206,7 +206,7 @@ void CFamas::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_556nato <= 0) return; - if (DefaultReload(FAMAS_MAX_CLIP, FAMAS_RELOAD, FAMAS_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), FAMAS_RELOAD, FAMAS_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp index 17152ffe..dc2aee1a 100644 --- a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp +++ b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp @@ -172,7 +172,7 @@ void CFiveSeven::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_57mm <= 0) return; - if (DefaultReload(FIVESEVEN_MAX_CLIP, FIVESEVEN_RELOAD, FIVESEVEN_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), FIVESEVEN_RELOAD, FIVESEVEN_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); m_flAccuracy = 0.92f; diff --git a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp index 3b6c930f..b97d2b71 100644 --- a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp +++ b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp @@ -181,7 +181,7 @@ void CG3SG1::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_762nato <= 0) return; - if (DefaultReload(G3SG1_MAX_CLIP, G3SG1_RELOAD, G3SG1_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), G3SG1_RELOAD, G3SG1_RELOAD_TIME)) { m_flAccuracy = 0.2f; m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_galil.cpp b/regamedll/dlls/wpn_shared/wpn_galil.cpp index d2307d4e..64f93cc2 100644 --- a/regamedll/dlls/wpn_shared/wpn_galil.cpp +++ b/regamedll/dlls/wpn_shared/wpn_galil.cpp @@ -171,7 +171,7 @@ void CGalil::__MAKE_VHOOK(Reload)() return; #endif - if (DefaultReload(GALIL_MAX_CLIP, GALIL_RELOAD, GALIL_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), GALIL_RELOAD, GALIL_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_glock18.cpp b/regamedll/dlls/wpn_shared/wpn_glock18.cpp index fab09cc8..f3943a84 100644 --- a/regamedll/dlls/wpn_shared/wpn_glock18.cpp +++ b/regamedll/dlls/wpn_shared/wpn_glock18.cpp @@ -256,7 +256,7 @@ void CGLOCK18::__MAKE_VHOOK(Reload)() else iResult = GLOCK18_RELOAD2; - if (DefaultReload(GLOCK18_MAX_CLIP, iResult, GLOCK18_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), iResult, GLOCK18_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); m_flAccuracy = 0.9; diff --git a/regamedll/dlls/wpn_shared/wpn_m249.cpp b/regamedll/dlls/wpn_shared/wpn_m249.cpp index 46a22bc6..0d527293 100644 --- a/regamedll/dlls/wpn_shared/wpn_m249.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m249.cpp @@ -163,7 +163,7 @@ void CM249::__MAKE_VHOOK(Reload)() return; #endif - if (DefaultReload(M249_MAX_CLIP, M249_RELOAD, M249_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), M249_RELOAD, M249_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_m3.cpp b/regamedll/dlls/wpn_shared/wpn_m3.cpp index 7ad4794d..0448b165 100644 --- a/regamedll/dlls/wpn_shared/wpn_m3.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m3.cpp @@ -135,7 +135,7 @@ void CM3::__MAKE_VHOOK(PrimaryAttack)() void CM3::__MAKE_VHOOK(Reload)() { - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == M3_MAX_CLIP) + if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == iMaxClip()) return; // don't reload until recoil is done @@ -168,7 +168,7 @@ void CM3::__MAKE_VHOOK(Reload)() ++m_iClip; #ifdef REGAMEDLL_ADD - if (refill_bpammo_weapons.value < 2.0f) + if (refill_bpammo_weapons.value < 3.0f) #endif { --m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]; @@ -197,7 +197,7 @@ void CM3::__MAKE_VHOOK(WeaponIdle)() } else if (m_fInSpecialReload != 0) { - if (m_iClip != M3_MAX_CLIP && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) + if (m_iClip != iMaxClip() && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) { Reload(); } diff --git a/regamedll/dlls/wpn_shared/wpn_m4a1.cpp b/regamedll/dlls/wpn_shared/wpn_m4a1.cpp index 33b19ac9..ece5a1ef 100644 --- a/regamedll/dlls/wpn_shared/wpn_m4a1.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m4a1.cpp @@ -218,7 +218,7 @@ void CM4A1::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_556nato <= 0) return; - if (DefaultReload(M4A1_MAX_CLIP, ((m_iWeaponState & WPNSTATE_M4A1_SILENCED) == WPNSTATE_M4A1_SILENCED) ? M4A1_RELOAD : M4A1_UNSIL_RELOAD, M4A1_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), ((m_iWeaponState & WPNSTATE_M4A1_SILENCED) == WPNSTATE_M4A1_SILENCED) ? M4A1_RELOAD : M4A1_UNSIL_RELOAD, M4A1_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_mac10.cpp b/regamedll/dlls/wpn_shared/wpn_mac10.cpp index c3407dd6..7471c786 100644 --- a/regamedll/dlls/wpn_shared/wpn_mac10.cpp +++ b/regamedll/dlls/wpn_shared/wpn_mac10.cpp @@ -153,7 +153,7 @@ void CMAC10::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_45acp <= 0) return; - if (DefaultReload(MAC10_MAX_CLIP, MAC10_RELOAD, MAC10_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), MAC10_RELOAD, MAC10_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp b/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp index f2ae3e1e..1d85f541 100644 --- a/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp +++ b/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp @@ -154,7 +154,7 @@ void CMP5N::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_9mm <= 0) return; - if (DefaultReload(MP5N_MAX_CLIP, MP5N_RELOAD, MP5N_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), MP5N_RELOAD, MP5N_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_p228.cpp b/regamedll/dlls/wpn_shared/wpn_p228.cpp index 572b093f..df69db19 100644 --- a/regamedll/dlls/wpn_shared/wpn_p228.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p228.cpp @@ -172,7 +172,7 @@ void CP228::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_357sig <= 0) return; - if (DefaultReload(P228_MAX_CLIP, m_pPlayer->HasShield() ? P228_SHIELD_RELOAD : P228_RELOAD, P228_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), m_pPlayer->HasShield() ? P228_SHIELD_RELOAD : P228_RELOAD, P228_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); m_flAccuracy = 0.9f; diff --git a/regamedll/dlls/wpn_shared/wpn_p90.cpp b/regamedll/dlls/wpn_shared/wpn_p90.cpp index b24ba502..5b1941d6 100644 --- a/regamedll/dlls/wpn_shared/wpn_p90.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p90.cpp @@ -160,7 +160,7 @@ void CP90::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_57mm <= 0) return; - if (DefaultReload(P90_MAX_CLIP, P90_RELOAD, P90_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), P90_RELOAD, P90_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_scout.cpp b/regamedll/dlls/wpn_shared/wpn_scout.cpp index a438b863..a965c18e 100644 --- a/regamedll/dlls/wpn_shared/wpn_scout.cpp +++ b/regamedll/dlls/wpn_shared/wpn_scout.cpp @@ -179,7 +179,7 @@ void CSCOUT::__MAKE_VHOOK(Reload)() return; #endif - if (DefaultReload(SCOUT_MAX_CLIP, SCOUT_RELOAD, SCOUT_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), SCOUT_RELOAD, SCOUT_RELOAD_TIME)) { if (m_pPlayer->pev->fov != DEFAULT_FOV) { diff --git a/regamedll/dlls/wpn_shared/wpn_sg550.cpp b/regamedll/dlls/wpn_shared/wpn_sg550.cpp index 690f8b42..ad93e9f3 100644 --- a/regamedll/dlls/wpn_shared/wpn_sg550.cpp +++ b/regamedll/dlls/wpn_shared/wpn_sg550.cpp @@ -176,7 +176,7 @@ void CSG550::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_556nato <= 0) return; - if (DefaultReload(SG550_MAX_CLIP, SG550_RELOAD, SG550_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), SG550_RELOAD, SG550_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_sg552.cpp b/regamedll/dlls/wpn_shared/wpn_sg552.cpp index a65c7fdf..ba72db23 100644 --- a/regamedll/dlls/wpn_shared/wpn_sg552.cpp +++ b/regamedll/dlls/wpn_shared/wpn_sg552.cpp @@ -172,7 +172,7 @@ void CSG552::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_556nato <= 0) return; - if (DefaultReload(SG552_MAX_CLIP, SG552_RELOAD, SG552_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), SG552_RELOAD, SG552_RELOAD_TIME)) { if (m_pPlayer->m_iFOV != DEFAULT_FOV) { diff --git a/regamedll/dlls/wpn_shared/wpn_tmp.cpp b/regamedll/dlls/wpn_shared/wpn_tmp.cpp index e034448e..2ae7f6e9 100644 --- a/regamedll/dlls/wpn_shared/wpn_tmp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_tmp.cpp @@ -154,7 +154,7 @@ void CTMP::__MAKE_VHOOK(Reload)() return; #endif - if (DefaultReload(TMP_MAX_CLIP, TMP_RELOAD, TMP_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), TMP_RELOAD, TMP_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_ump45.cpp b/regamedll/dlls/wpn_shared/wpn_ump45.cpp index 65e14363..cb84d8fe 100644 --- a/regamedll/dlls/wpn_shared/wpn_ump45.cpp +++ b/regamedll/dlls/wpn_shared/wpn_ump45.cpp @@ -157,7 +157,7 @@ void CUMP45::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_45acp <= 0) return; - if (DefaultReload(UMP45_MAX_CLIP, UMP45_RELOAD, UMP45_RELOAD_TIME)) + if (DefaultReload(iMaxClip(), UMP45_RELOAD, UMP45_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); diff --git a/regamedll/dlls/wpn_shared/wpn_usp.cpp b/regamedll/dlls/wpn_shared/wpn_usp.cpp index 1e279039..67cd67e0 100644 --- a/regamedll/dlls/wpn_shared/wpn_usp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_usp.cpp @@ -237,19 +237,15 @@ void CUSP::__MAKE_VHOOK(Reload)() if (m_pPlayer->ammo_45acp <= 0) return; - int iResult; + int iAnim; if (m_pPlayer->HasShield()) - { - iResult = DefaultReload(USP_MAX_CLIP, USP_SHIELD_RELOAD, USP_RELOAD_TIME); - } + iAnim = USP_SHIELD_RELOAD; else if (m_iWeaponState & WPNSTATE_USP_SILENCED) - { - iResult = DefaultReload(USP_MAX_CLIP, USP_RELOAD, USP_RELOAD_TIME); - } + iAnim = USP_RELOAD; else - iResult = DefaultReload(USP_MAX_CLIP, USP_UNSIL_RELOAD, USP_RELOAD_TIME); + iAnim = USP_UNSIL_RELOAD; - if (iResult) + if (DefaultReload(iMaxClip(), iAnim, USP_RELOAD_TIME)) { m_pPlayer->SetAnimation(PLAYER_RELOAD); m_flAccuracy = 0.92f; diff --git a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp index 86cacdae..aee8712d 100644 --- a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp +++ b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp @@ -133,7 +133,7 @@ void CXM1014::__MAKE_VHOOK(PrimaryAttack)() void CXM1014::__MAKE_VHOOK(Reload)() { - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == XM1014_MAX_CLIP) + if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == iMaxClip()) return; // don't reload until recoil is done @@ -172,7 +172,7 @@ void CXM1014::__MAKE_VHOOK(Reload)() ++m_iClip; #ifdef REGAMEDLL_ADD - if (refill_bpammo_weapons.value < 2.0f) + if (refill_bpammo_weapons.value < 3.0f) #endif { --m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]; @@ -201,7 +201,7 @@ void CXM1014::__MAKE_VHOOK(WeaponIdle)() } else if (m_fInSpecialReload != 0) { - if (m_iClip != XM1014_MAX_CLIP && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) + if (m_iClip != iMaxClip() && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) { Reload(); } diff --git a/regamedll/extra/cssdk/dlls/cbase.h b/regamedll/extra/cssdk/dlls/cbase.h index b187a08b..c7852437 100644 --- a/regamedll/extra/cssdk/dlls/cbase.h +++ b/regamedll/extra/cssdk/dlls/cbase.h @@ -81,7 +81,7 @@ public: virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) = 0; virtual BOOL AddPlayerItem(CBasePlayerItem *pItem) = 0; virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) = 0; - virtual int GiveAmmo(int iAmount, char *szName, int iMax) = 0; + virtual int GiveAmmo(int iAmount, char *szName, int iMax = -1) = 0; virtual float GetDelay() = 0; virtual int IsMoving() = 0; virtual void OverrideReset() = 0; diff --git a/regamedll/extra/cssdk/dlls/cdll_dll.h b/regamedll/extra/cssdk/dlls/cdll_dll.h index 0a033cc1..cb0a2253 100644 --- a/regamedll/extra/cssdk/dlls/cdll_dll.h +++ b/regamedll/extra/cssdk/dlls/cdll_dll.h @@ -41,6 +41,7 @@ #define HIDEHUD_TIMER (1<<4) #define HIDEHUD_MONEY (1<<5) #define HIDEHUD_CROSSHAIR (1<<6) +#define HIDEHUD_OBSERVER_CROSSHAIR (1<<7) #define STATUSICON_HIDE 0 #define STATUSICON_SHOW 1 @@ -68,10 +69,11 @@ #define SIGNAL_ESCAPE (1<<3) #define SIGNAL_VIPSAFETY (1<<4) -#define DATA_IUSER3_CANSHOOT (1<<0) -#define DATA_IUSER3_FREEZETIMEOVER (1<<1) -#define DATA_IUSER3_INBOMBZONE (1<<2) -#define DATA_IUSER3_HOLDINGSHIELD (1<<3) +// player data iuser3 +#define PLAYER_CAN_SHOOT (1<<0) +#define PLAYER_FREEZE_TIME_OVER (1<<1) +#define PLAYER_IN_BOMB_ZONE (1<<2) +#define PLAYER_HOLDING_SHIELD (1<<3) #define MENU_KEY_1 (1<<0) #define MENU_KEY_2 (1<<1) diff --git a/regamedll/extra/cssdk/dlls/extdef.h b/regamedll/extra/cssdk/dlls/extdef.h index 21355588..383a668e 100644 --- a/regamedll/extra/cssdk/dlls/extdef.h +++ b/regamedll/extra/cssdk/dlls/extdef.h @@ -29,19 +29,30 @@ #include "regamedll_const.h" +#undef DLLEXPORT #ifdef _WIN32 // Attributes to specify an "exported" function, visible from outside the // DLL. - #undef DLLEXPORT #define DLLEXPORT __declspec(dllexport) // WINAPI should be provided in the windows compiler headers. // It's usually defined to something like "__stdcall". + + #define NOINLINE __declspec(noinline) #else - #undef DLLEXPORT #define DLLEXPORT __attribute__((visibility("default"))) #define WINAPI /* */ + #define NOINLINE __attribute__((noinline)) #endif // _WIN32 +// Manual branch optimization for GCC 3.0.0 and newer +#if !defined(__GNUC__) || __GNUC__ < 3 + #define likely(x) (x) + #define unlikely(x) (x) +#else + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#endif + // Simplified macro for declaring/defining exported DLL functions. They // need to be 'extern "C"' so that the C++ compiler enforces parameter // type-matching, rather than considering routines with mis-matched diff --git a/regamedll/extra/cssdk/dlls/gamerules.h b/regamedll/extra/cssdk/dlls/gamerules.h index a7da3322..16181554 100644 --- a/regamedll/extra/cssdk/dlls/gamerules.h +++ b/regamedll/extra/cssdk/dlls/gamerules.h @@ -35,13 +35,6 @@ #define MAX_BOMB_RADIUS 2048 -#define MAP_VIP_SAFETYZONE_UNINITIALIZED 0 // uninitialized -#define MAP_HAVE_VIP_SAFETYZONE_YES 1 // has VIP safety zone -#define MAP_HAVE_VIP_SAFETYZONE_NO 2 // does not have VIP safetyzone - -#define MAP_HAS_CAMERAS_INIT 2 // initial -#define MAP_HAS_CAMERAS_YES 1 // on map have of camera's - #define ITEM_RESPAWN_TIME 30 #define WEAPON_RESPAWN_TIME 20 #define AMMO_RESPAWN_TIME 20 @@ -88,6 +81,8 @@ enum ScenarioEventEndRound ROUND_TERRORISTS_NOT_ESCAPED, ROUND_VIP_NOT_ESCAPED, ROUND_GAME_COMMENCE, + ROUND_GAME_RESTART, + ROUND_GAME_OVER }; enum RewardRules @@ -195,13 +190,13 @@ enum // custom enum enum { - SCENARIO_BLOCK_TIME_EXPRIRED = (1 << 0), - SCENARIO_BLOCK_NEED_PLAYERS = (1 << 1), - SCENARIO_BLOCK_VIP_ESCAPRE = (1 << 2), - SCENARIO_BLOCK_PRISON_ESCAPRE = (1 << 3), - SCENARIO_BLOCK_BOMB = (1 << 4), - SCENARIO_BLOCK_TEAM_EXTERMINATION = (1 << 5), - SCENARIO_BLOCK_HOSTAGE_RESCUE = (1 << 6), + SCENARIO_BLOCK_TIME_EXPRIRED = (1 << 0), // flag "a" + SCENARIO_BLOCK_NEED_PLAYERS = (1 << 1), // flag "b" + SCENARIO_BLOCK_VIP_ESCAPE = (1 << 2), // flag "c" + SCENARIO_BLOCK_PRISON_ESCAPE = (1 << 3), // flag "d" + SCENARIO_BLOCK_BOMB = (1 << 4), // flag "e" + SCENARIO_BLOCK_TEAM_EXTERMINATION = (1 << 5), // flag "f" + SCENARIO_BLOCK_HOSTAGE_RESCUE = (1 << 6), // flag "g" }; // Player relationship return codes @@ -323,12 +318,18 @@ public: virtual BOOL IsFreezePeriod() = 0; virtual void ServerDeactivate() = 0; virtual void CheckMapConditions() = 0; + + // inline function's + inline bool IsGameOver() const { return m_bGameOver; } + inline void SetGameOver() { m_bGameOver = true; } + public: BOOL m_bFreezePeriod; // TRUE at beginning of round, set to FALSE when the period expires BOOL m_bBombDropped; // custom char *m_GameDesc; + bool m_bGameOver; // intermission or finale (deprecated name g_fGameOver) }; // CHalfLifeRules - rules for the single player Half-Life game. @@ -590,8 +591,8 @@ public: bool m_bMapHasRescueZone; bool m_bMapHasEscapeZone; - int m_iMapHasVIPSafetyZone; // 0 = uninitialized; 1 = has VIP safety zone; 2 = DOES not have VIP safetyzone - int m_bMapHasCameras; + BOOL m_bMapHasVIPSafetyZone; // TRUE = has VIP safety zone, FALSE = does not have VIP safetyzone + BOOL m_bMapHasCameras; int m_iC4Timer; int m_iC4Guy; // The current Terrorist who has the C4. int m_iLoserBonus; // the amount of money the losing team gets. This scales up as they lose more rounds in a row @@ -632,7 +633,7 @@ public: float m_flIntermissionStartTime; BOOL m_iEndIntermissionButtonHit; float m_tmNextPeriodicThink; - bool m_bFirstConnected; + bool m_bGameStarted; // TRUE = the game commencing when there is at least one CT and T, FALSE = scoring will not start until both teams have players (deprecated name m_bFirstConnected) bool m_bInCareerGame; float m_fCareerRoundMenuTime; int m_iCareerMatchWins; diff --git a/regamedll/extra/cssdk/dlls/hostage/hostage.h b/regamedll/extra/cssdk/dlls/hostage/hostage.h index 28193397..a0be24c8 100644 --- a/regamedll/extra/cssdk/dlls/hostage/hostage.h +++ b/regamedll/extra/cssdk/dlls/hostage/hostage.h @@ -27,9 +27,6 @@ */ #pragma once -// Improved the hostages from CZero -#include "hostage/hostage_improv.h" - #define MAX_NODES 100 #define MAX_HOSTAGES 12 #define MAX_HOSTAGES_NAV 20 @@ -75,6 +72,9 @@ enum HostageChatterType NUM_HOSTAGE_CHATTER_TYPES, }; +// Improved the hostages from CZero +#include "hostage/hostage_improv.h" + extern CHostageManager *g_pHostages; extern int g_iHostageNumber; @@ -85,6 +85,7 @@ public: virtual void Precache() = 0; virtual int ObjectCaps() = 0; // make hostage "useable" virtual int Classify() = 0; + virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; virtual int BloodColor() = 0; virtual void Touch(CBaseEntity *pOther) = 0; @@ -118,10 +119,10 @@ public: return true; } - bool IsValid() { return (pev->takedamage == DAMAGE_YES); } - bool IsDead() { return (pev->deadflag == DEAD_DEAD); } - bool IsAtHome() { return (pev->origin - m_vStart).IsLengthGreaterThan(20) != true; } - const Vector *GetHomePosition() { return &m_vStart; } + bool IsValid() const { return (pev->takedamage == DAMAGE_YES); } + bool IsDead() const { return (pev->deadflag == DEAD_DEAD); } + bool IsAtHome() const { return (pev->origin - m_vStart).IsLengthGreaterThan(20) != true; } + const Vector *GetHomePosition() const { return &m_vStart; } public: int m_Activity; BOOL m_bTouched; diff --git a/regamedll/extra/cssdk/dlls/player.h b/regamedll/extra/cssdk/dlls/player.h index 40a3416d..365d6635 100644 --- a/regamedll/extra/cssdk/dlls/player.h +++ b/regamedll/extra/cssdk/dlls/player.h @@ -320,7 +320,7 @@ public: virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) = 0; virtual BOOL AddPlayerItem(CBasePlayerItem *pItem) = 0; virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) = 0; - virtual int GiveAmmo(int iAmount, char *szName, int iMax) = 0; + virtual int GiveAmmo(int iAmount, char *szName, int iMax = -1) = 0; virtual void StartSneaking() = 0; virtual void UpdateOnRemove() = 0; virtual BOOL IsSneaking() = 0; @@ -598,8 +598,7 @@ public: inline bool CBasePlayer::IsReloading() const { CBasePlayerWeapon *weapon = static_cast(m_pActiveItem); - - if (weapon != NULL && weapon->m_fInReload) + if (weapon && weapon->m_fInReload) return true; return false; @@ -608,3 +607,19 @@ inline bool CBasePlayer::IsReloading() const inline CCSPlayer *CBasePlayer::CSPlayer() const { return reinterpret_cast(this->m_pEntity); } + +// returns a CBaseEntity pointer to a player by index. Only returns if the player is spawned and connected otherwise returns NULL +// Index is 1 based +inline CBasePlayer *UTIL_PlayerByIndex(int playerIndex) +{ + return (CBasePlayer *)GET_PRIVATE(INDEXENT(playerIndex)); +} + +inline CBasePlayer *UTIL_PlayerByIndexSafe(int playerIndex) +{ + CBasePlayer *player = nullptr; + if (likely(playerIndex > 0 && playerIndex <= gpGlobals->maxClients)) + player = UTIL_PlayerByIndex(playerIndex); + + return player; +} diff --git a/regamedll/extra/cssdk/dlls/regamedll_api.h b/regamedll/extra/cssdk/dlls/regamedll_api.h index 21655509..2272edcd 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_api.h +++ b/regamedll/extra/cssdk/dlls/regamedll_api.h @@ -139,8 +139,8 @@ typedef IVoidHookChainClass IReGameHook_CBasePlayer_GiveDefau typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveDefaultItems; // CBasePlayer::GiveNamedItem hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_GiveNamedItem; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveNamedItem; +typedef IHookChainClass IReGameHook_CBasePlayer_GiveNamedItem; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveNamedItem; // CBasePlayer::AddAccount hook typedef IVoidHookChainClass IReGameHook_CBasePlayer_AddAccount; @@ -155,8 +155,8 @@ typedef IVoidHookChainClass IReGameHook_CBase typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel; // CBasePlayer:SetClientUserInfoName hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoName; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoName; +typedef IHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoName; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoName; // CBasePlayer::HasRestrictItem hook typedef IHookChainClass IReGameHook_CBasePlayer_HasRestrictItem; @@ -166,6 +166,38 @@ typedef IHookChainRegistryClass I typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropPlayerItem; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropPlayerItem; +// CBasePlayer::DropShield hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropShield; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropShield; + +// CBasePlayer::OnSpawnEquip hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_OnSpawnEquip; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_OnSpawnEquip; + +// CBasePlayer::Radio hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Radio; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Radio; + +// CBasePlayer::Disappear hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Disappear; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Disappear; + +// CBasePlayer::MakeVIP hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_MakeVIP; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_MakeVIP; + +// CBasePlayer::MakeBomber hook +typedef IHookChainClass IReGameHook_CBasePlayer_MakeBomber; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_MakeBomber; + +// CBasePlayer::StartObserver hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_StartObserver; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_StartObserver; + +// CBasePlayer::GetIntoGame hook +typedef IHookChainClass IReGameHook_CBasePlayer_GetIntoGame; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GetIntoGame; + // CBaseAnimating::ResetSequenceInfo hook typedef IVoidHookChainClass IReGameHook_CBaseAnimating_ResetSequenceInfo; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo; @@ -218,6 +250,18 @@ typedef IVoidHookChainRegistry IReG typedef IVoidHookChain IReGameHook_ShowVGUIMenu; typedef IVoidHookChainRegistry IReGameHookRegistry_ShowVGUIMenu; +// BuyGunAmmo hook +typedef IHookChain IReGameHook_BuyGunAmmo; +typedef IHookChainRegistry IReGameHookRegistry_BuyGunAmmo; + +// BuyWeaponByWeaponID hook +typedef IHookChain IReGameHook_BuyWeaponByWeaponID; +typedef IHookChainRegistry IReGameHookRegistry_BuyWeaponByWeaponID; + +// InternalCommand hook +typedef IHookChain IReGameHook_InternalCommand; +typedef IHookChainRegistry IReGameHookRegistry_InternalCommand; + // CHalfLifeMultiplay::FShouldSwitchWeapon hook typedef IHookChain IReGameHook_CSGameRules_FShouldSwitchWeapon; typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon; @@ -306,9 +350,14 @@ typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GoToIntermissio typedef IVoidHookChain<> IReGameHook_CSGameRules_BalanceTeams; typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams; +// CHalfLifeMultiplay::OnRoundFreezeEnd hook +typedef IVoidHookChain<> IReGameHook_CSGameRules_OnRoundFreezeEnd; +typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} + // CBasePlayer virtual virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn() = 0; virtual IReGameHookRegistry_CBasePlayer_Precache* CBasePlayer_Precache() = 0; @@ -343,6 +392,15 @@ public: virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName() = 0; virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem* CBasePlayer_HasRestrictItem() = 0; virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0; + virtual IReGameHookRegistry_CBasePlayer_DropShield* CBasePlayer_DropShield() = 0; + virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip* CBasePlayer_OnSpawnEquip() = 0; + virtual IReGameHookRegistry_CBasePlayer_Radio* CBasePlayer_Radio() = 0; + virtual IReGameHookRegistry_CBasePlayer_Disappear* CBasePlayer_Disappear() = 0; + virtual IReGameHookRegistry_CBasePlayer_MakeVIP* CBasePlayer_MakeVIP() = 0; + virtual IReGameHookRegistry_CBasePlayer_MakeBomber* CBasePlayer_MakeBomber() = 0; + virtual IReGameHookRegistry_CBasePlayer_StartObserver* CBasePlayer_StartObserver() = 0; + virtual IReGameHookRegistry_CBasePlayer_GetIntoGame* CBasePlayer_GetIntoGame() = 0; + virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0; virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0; @@ -357,6 +415,9 @@ public: virtual IReGameHookRegistry_HandleMenu_ChooseTeam* HandleMenu_ChooseTeam() = 0; virtual IReGameHookRegistry_ShowMenu* ShowMenu() = 0; virtual IReGameHookRegistry_ShowVGUIMenu* ShowVGUIMenu() = 0; + virtual IReGameHookRegistry_BuyGunAmmo* BuyGunAmmo() = 0; + virtual IReGameHookRegistry_BuyWeaponByWeaponID* BuyWeaponByWeaponID() = 0; + virtual IReGameHookRegistry_InternalCommand* InternalCommand() = 0; virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon* CSGameRules_FShouldSwitchWeapon() = 0; virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon* CSGameRules_GetNextBestWeapon() = 0; @@ -380,10 +441,10 @@ public: virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel() = 0; virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0; virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0; + virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd* CSGameRules_OnRoundFreezeEnd() = 0; }; struct ReGameFuncs_t { - class CBasePlayer *(*UTIL_PlayerByIndex)(int playerIndex); struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass); void (*ChangeString)(char *&dest, const char *source); void (*RadiusDamage)(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType); @@ -393,6 +454,8 @@ struct ReGameFuncs_t { class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue); void (*AddEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType); void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType); + int (*Cmd_Argc)(); + const char *(*Cmd_Argv)(int i); }; class IReGameApi { diff --git a/regamedll/extra/cssdk/dlls/regamedll_common.h b/regamedll/extra/cssdk/dlls/regamedll_common.h index 638d5dcb..826b6ded 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_common.h +++ b/regamedll/extra/cssdk/dlls/regamedll_common.h @@ -85,6 +85,7 @@ #define Q_pow pow #define Q_fmod fmod #define Q_fopen fopen +#define Q_fwrite fwrite #define Q_fprintf fprintf #define Q_fclose fclose diff --git a/regamedll/extra/cssdk/dlls/regamedll_const.h b/regamedll/extra/cssdk/dlls/regamedll_const.h index 87945b05..36d038b9 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_const.h +++ b/regamedll/extra/cssdk/dlls/regamedll_const.h @@ -37,8 +37,6 @@ #define FCAP_ONOFF_USE 0x00000020 // can be used by the player #define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) #define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) -#define FCAP_MUST_RESET 0x00000100 // should reset on the new round -#define FCAP_MUST_RELEASE 0x00000200 // should release on the new round // UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! #define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions diff --git a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h b/regamedll/extra/cssdk/dlls/regamedll_interfaces.h index 84a749fd..38486f63 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h +++ b/regamedll/extra/cssdk/dlls/regamedll_interfaces.h @@ -59,8 +59,8 @@ public: virtual bool IsConnected() const; virtual void SetAnimation(PLAYER_ANIM playerAnim); virtual void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true); - virtual void GiveNamedItem(const char *pszName); - virtual void GiveNamedItemEx(const char *pszName); + virtual CBaseEntity *GiveNamedItem(const char *pszName); + virtual CBaseEntity *GiveNamedItemEx(const char *pszName); virtual void GiveDefaultItems(); virtual void GiveShield(bool bDeploy = true); virtual void DropShield(bool bDeploy = true); @@ -90,6 +90,11 @@ public: virtual void DropPrimary(); virtual bool HasPlayerItem(CBasePlayerItem *pCheckItem); virtual bool HasNamedPlayerItem(const char *pszItemName); + virtual CBasePlayerItem *GetItemById(WeaponIdType weaponID); + virtual CBasePlayerItem *GetItemByName(const char *itemName); + virtual void Disappear(); + virtual void MakeVIP(); + virtual bool MakeBomber(); CBasePlayer *BasePlayer() const; public: diff --git a/regamedll/extra/cssdk/dlls/util.h b/regamedll/extra/cssdk/dlls/util.h index 63174df0..8e36d48f 100644 --- a/regamedll/extra/cssdk/dlls/util.h +++ b/regamedll/extra/cssdk/dlls/util.h @@ -128,10 +128,20 @@ inline entvars_t *VARS(edict_t *pent) return &pent->v; } -inline entvars_t *VARS(EOFFSET eoffset) { return VARS(ENT(eoffset)); } +inline entvars_t *VARS(EOFFSET eoffset) +{ + return VARS(ENT(eoffset)); +} + +#ifndef ENTINDEX inline int ENTINDEX(const edict_t *pEdict) { return (*g_engfuncs.pfnIndexOfEdict)(pEdict); } inline int ENTINDEX(const entvars_t *pev) { return (*g_engfuncs.pfnIndexOfEdict)(ENT(pev)); } +#endif // ENTINDEX + +#ifndef INDEXENT inline edict_t *INDEXENT(int iEdictNum) { return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); } +#endif // INDEXENT + inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent) { MESSAGE_BEGIN(msg_dest, msg_type, pOrigin, ENT(ent)); } inline BOOL FNullEnt(EOFFSET eoffset) { return (eoffset == 0); } inline BOOL FNullEnt(entvars_t *pev) { return (pev == NULL || FNullEnt(OFFSET(pev))); } diff --git a/regamedll/extra/cssdk/dlls/weapons.h b/regamedll/extra/cssdk/dlls/weapons.h index e3eddd81..c4da5013 100644 --- a/regamedll/extra/cssdk/dlls/weapons.h +++ b/regamedll/extra/cssdk/dlls/weapons.h @@ -442,6 +442,10 @@ private: unsigned short m_usFireAWP; }; +// for usermsg BombDrop +#define BOMB_FLAG_DROPPED 0 // if the bomb was dropped due to voluntary dropping or death/disconnect +#define BOMB_FLAG_PLANTED 1 // if the bomb has been planted will also trigger the round timer to hide will also show where the dropped bomb on the Terrorist team's radar. + class CC4: public CBasePlayerWeapon { public: virtual void Spawn() = 0; diff --git a/regamedll/extra/cssdk/engine/eiface.h b/regamedll/extra/cssdk/engine/eiface.h index e1461330..5d8f3000 100644 --- a/regamedll/extra/cssdk/engine/eiface.h +++ b/regamedll/extra/cssdk/engine/eiface.h @@ -298,8 +298,12 @@ typedef struct enginefuncs_s // Added 2005/11/21 (no SDK update): void(*pfnQueryClientCvarValue2) (const edict_t *player, const char *cvarName, int requestID); +// Comment out this, for compatibility with older versions metamod - s1lent +#if !defined(CSSDK_COMPAT_OLD_METAMOD) // Added 2009/06/19 (no SDK update): - // int(*pfnEngCheckParm) (const char *pchCmdLineToken, char **ppnext); // s1lent: comment out this, for compatibility with older versions metamod + int(*pfnEngCheckParm) (const char *pchCmdLineToken, char **ppnext); +#endif + } enginefuncs_t; diff --git a/regamedll/game_shared/bot/bot.cpp b/regamedll/game_shared/bot/bot.cpp index 33861347..dd7a036c 100644 --- a/regamedll/game_shared/bot/bot.cpp +++ b/regamedll/game_shared/bot/bot.cpp @@ -12,7 +12,7 @@ float g_flBotCommandInterval = 1.0 / 30.0; float g_flBotFullThinkInterval = 1.0 / 10.0; // Nasty Hack. See client.cpp/ClientCommand() -const char *BotArgs[4] = { NULL }; +const char *BotArgs[4] = {}; bool UseBotArgs = false; #endif @@ -319,6 +319,7 @@ byte CBot::ThrottledMsec() const return byte(iNewMsec); } +#ifndef REGAMEDLL_FIXES // Do a "client command" - useful for invoking menu choices, etc. void CBot::ClientCommand(const char *cmd, const char *arg1, const char *arg2, const char *arg3) { @@ -331,6 +332,7 @@ void CBot::ClientCommand(const char *cmd, const char *arg1, const char *arg2, co ::ClientCommand(ENT(pev)); UseBotArgs = false; } +#endif // Returns TRUE if given entity is our enemy bool CBot::IsEnemy(CBaseEntity *ent) const diff --git a/regamedll/game_shared/bot/bot.h b/regamedll/game_shared/bot/bot.h index 2d620e30..ae2c073c 100644 --- a/regamedll/game_shared/bot/bot.h +++ b/regamedll/game_shared/bot/bot.h @@ -262,8 +262,11 @@ public: #ifndef HOOK_GAMEDLL protected: #endif + +#ifndef REGAMEDLL_FIXES // Do a "client command" - useful for invoking menu choices, etc. void ClientCommand(const char *cmd, const char *arg1 = NULL, const char *arg2 = NULL, const char *arg3 = NULL); +#endif // the "personality" profile of this bot const BotProfile *m_profile; diff --git a/regamedll/game_shared/bot/nav_area.h b/regamedll/game_shared/bot/nav_area.h index 08cb9ba5..9a54cda2 100644 --- a/regamedll/game_shared/bot/nav_area.h +++ b/regamedll/game_shared/bot/nav_area.h @@ -142,6 +142,7 @@ public: }; typedef std::STD_LIST NavLadderList; +extern NavLadderList TheNavLadderList; class HidingSpot { @@ -189,6 +190,7 @@ private: }; typedef std::STD_LIST HidingSpotList; +extern HidingSpotList TheHidingSpotList; struct SpotOrder { @@ -552,6 +554,8 @@ private: } }; +extern CNavAreaGrid TheNavAreaGrid; + class ShortestPathCost { public: @@ -1167,9 +1171,4 @@ void BuildLadders(); void MarkJumpAreas(); void GenerateNavigationAreaMesh(); -extern NavLadderList TheNavLadderList; -extern HidingSpotList TheHidingSpotList; -extern NavAreaList TheNavAreaList; -extern CNavAreaGrid TheNavAreaGrid; - #endif // NAV_AREA_H diff --git a/regamedll/game_shared/bot/nav_file.cpp b/regamedll/game_shared/bot/nav_file.cpp index 8d58cda0..5da24794 100644 --- a/regamedll/game_shared/bot/nav_file.cpp +++ b/regamedll/game_shared/bot/nav_file.cpp @@ -816,7 +816,6 @@ void SanityCheckNavigationMap(const char *mapName) } unsigned int bspSize = (unsigned int)GET_FILE_SIZE(bspFilename); - if (bspSize != saveBspSize) { // this nav file is out of date for this bsp file diff --git a/regamedll/hookers/6153_hooker.cpp b/regamedll/hookers/6153_hooker.cpp index 55ce72e9..4ebc0ce1 100644 --- a/regamedll/hookers/6153_hooker.cpp +++ b/regamedll/hookers/6153_hooker.cpp @@ -283,7 +283,7 @@ FunctionHook g_FunctionHooks[] = { 0x01D65850, "_Z9BuyPistolP11CBasePlayeri", (size_t)&BuyPistol }, { 0x01D65A30, "_Z10BuyShotgunP11CBasePlayeri", (size_t)&BuyShotgun }, { 0x01D65B70, "_Z16BuySubMachineGunP11CBasePlayeri", (size_t)&BuySubMachineGun }, - { 0x01D65D00, "_Z19BuyWeaponByWeaponIDP11CBasePlayer12WeaponIdType", (size_t)&BuyWeaponByWeaponID }, + //{ 0x01D65D00, "_Z19BuyWeaponByWeaponIDP11CBasePlayer12WeaponIdType", (size_t)&BuyWeaponByWeaponID }, { 0x01D65E80, "_Z8BuyRifleP11CBasePlayeri", (size_t)&BuyRifle }, { 0x01D66070, "_Z13BuyMachineGunP11CBasePlayeri", (size_t)&BuyMachineGun }, { 0x01D66170, "_Z7BuyItemP11CBasePlayeri", (size_t)&BuyItem }, @@ -719,7 +719,7 @@ FunctionHook g_FunctionHooks[] = { 0x01DA67A0, "_ZN11CBasePlayer14SelectLastItemEv", mfunc_ptr_cast(&CBasePlayer::SelectLastItem) }, //{ 0x01DA8BB0, "_ZN11CBasePlayer12ItemPreFrameEv", mfunc_ptr_cast(&CBasePlayer::ItemPreFrame) }, // NOXREF //{ 0x01DA8BE0, "_ZN11CBasePlayer13ItemPostFrameEv", mfunc_ptr_cast(&CBasePlayer::ItemPostFrame) }, // NOXREF - { 0x01DA6CC0, "_ZN11CBasePlayer13GiveNamedItemEPKc", mfunc_ptr_cast(&CBasePlayer::GiveNamedItem) }, + //{ 0x01DA6CC0, "_ZN11CBasePlayer13GiveNamedItemEPKc", mfunc_ptr_cast(&CBasePlayer::GiveNamedItem) }, { 0x01DA9C80, "_ZN11CBasePlayer13EnableControlEi", mfunc_ptr_cast(&CBasePlayer::EnableControl) }, { 0x01DA9D50, "_ZN11CBasePlayer11HintMessageEPKcii", mfunc_ptr_cast(&CBasePlayer::HintMessage) }, { 0x01DA8CC0, "_ZN11CBasePlayer14SendAmmoUpdateEv", mfunc_ptr_cast(&CBasePlayer::SendAmmoUpdate) }, @@ -2399,7 +2399,7 @@ FunctionHook g_FunctionHooks[] = { 0x01DC2FB0, "_Z26UTIL_FindEntityByClassnameP11CBaseEntityPKc", (size_t)&UTIL_FindEntityByClassname }, { 0x01DC2FD0, "_Z27UTIL_FindEntityByTargetnameP11CBaseEntityPKc", (size_t)&UTIL_FindEntityByTargetname }, //{ 0x01DC2FF0, "_Z22UTIL_FindEntityGenericPKcR6Vectorf", (size_t)&UTIL_FindEntityGeneric }, // NOXREF - { 0x01DC30A0, "_Z18UTIL_PlayerByIndexi", (size_t)&UTIL_PlayerByIndex }, + //{ 0x01DC30A0, "_Z18UTIL_PlayerByIndexi", (size_t)&UTIL_PlayerByIndex }, { 0x01DC30E0, "_Z16UTIL_MakeVectorsRK6Vector", (size_t)&UTIL_MakeVectors }, { 0x01DC30F0, "_Z19UTIL_MakeAimVectorsRK6Vector", (size_t)&UTIL_MakeAimVectors }, { 0x01DC3120, "_Z19UTIL_MakeInvVectorsRK6VectorP12globalvars_t", (size_t)&UTIL_MakeInvVectors }, @@ -5766,7 +5766,7 @@ AddressRef g_DataRefs[] = { 0x01E22C50, "gDecals", (size_t)&pgDecals }, { 0x01E31748, "stringsHashTable", (size_t)&pstringsHashTable }, { 0x01E312E8, "hashItemMemPool", (size_t)&phashItemMemPool }, - { 0x01E3175C, "gTouchDisabled", (size_t)&pgTouchDisabled }, + //{ 0x01E3175C, "gTouchDisabled", (size_t)&pgTouchDisabled }, { 0x01E6359C, "giPrecacheGrunt", (size_t)&pgiPrecacheGrunt }, { 0x01E6360C, "gmsgWeapPickup", (size_t)&pgmsgWeapPickup }, { 0x01E635E0, "gmsgHudText", (size_t)&pgmsgHudText }, diff --git a/regamedll/hookers/hooker_impl.cpp b/regamedll/hookers/hooker_impl.cpp index 36e4e32e..99ec81e0 100644 --- a/regamedll/hookers/hooker_impl.cpp +++ b/regamedll/hookers/hooker_impl.cpp @@ -214,6 +214,7 @@ CCareerTaskManager *TheCareerTasks; const TaskInfo taskInfo[21]; // globals client.cpp +BOOL g_fGameOver; // moved from gamerules float g_flTimeLimit; // moved from gamerules float g_flResetTime; // moved from gamerules bool g_bClientPrintEnable; diff --git a/regamedll/hookers/hooker_impl.h b/regamedll/hookers/hooker_impl.h index da3b8563..dcd1d1bb 100644 --- a/regamedll/hookers/hooker_impl.h +++ b/regamedll/hookers/hooker_impl.h @@ -925,6 +925,7 @@ extern char pm_grgszTextureName[1024][17]; extern char pm_grgchTextureType[1024]; extern char *BotDifficultyName[5]; +extern BOOL g_fGameOver; extern float g_flResetTime; C_DLLEXPORT float g_flTimeLimit; diff --git a/regamedll/msvc/PostBuild_mp.bat b/regamedll/msvc/PostBuild_mp.bat index b0a94b59..9c6aaea3 100644 --- a/regamedll/msvc/PostBuild_mp.bat +++ b/regamedll/msvc/PostBuild_mp.bat @@ -4,21 +4,27 @@ :: Create and fill PublishPath_mp.txt file with path to deployment folder :: I.e. PublishPath_mp.txt should contain one line with a folder path :: Call it so: -:: IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") +:: IF EXIST "$(ProjectDir)PostBuild_mp.bat" (CALL "$(ProjectDir)PostBuild_mp.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") :: SET targetDir=%~1 +SET targetDirPlay=%targetDir:Play=% + SET targetName=%~2 SET targetExt=%~3 SET projectDir=%~4 -SET destination= +SET destination=PublishPath_mp -IF NOT EXIST "%projectDir%\PublishPath_mp.txt" ( - ECHO No deployment path specified. Create PublishPath_mp.txt near PostBuild.bat with paths on separate lines for auto deployment. +IF NOT "%targetDir%"=="%targetDirPlay%" ( + SET destination=PublishPath_mp_play +) + +IF NOT EXIST "%projectDir%\%destination%.txt" ( + ECHO No deployment path specified. Create %destination%.txt near PostBuild_mp.bat with paths on separate lines for auto deployment. exit /B 0 ) -FOR /f "tokens=* delims= usebackq" %%a IN ("%projectDir%\PublishPath_mp.txt") DO ( +FOR /f "tokens=* delims= usebackq" %%a IN ("%projectDir%\%destination%.txt") DO ( ECHO Deploying to: %%a IF NOT "%%a" == "" ( copy /Y "%targetDir%%targetName%%targetExt%" "%%a" @@ -27,7 +33,7 @@ FOR /f "tokens=* delims= usebackq" %%a IN ("%projectDir%\PublishPath_mp.txt") DO copy /Y "%targetDir%%targetName%.pdb" "%%a" ) ) ELSE ( - ECHO PostBuild.bat ^(27^) : warning : Can't copy '%targetName%%targetExt%' to deploy path '%%a' + ECHO PostBuild_mp.bat ^(27^) : warning : Can't copy '%targetName%%targetExt%' to deploy path '%%a' ) ) ) diff --git a/regamedll/msvc/PreBuild.bat b/regamedll/msvc/PreBuild.bat index 7b994817..bb4b2fc5 100644 --- a/regamedll/msvc/PreBuild.bat +++ b/regamedll/msvc/PreBuild.bat @@ -131,9 +131,9 @@ IF NOT %errlvl% == "1" ( :: append extra string If NOT "%url_commit%"=="%url_commit:bitbucket.org=%" ( - set url_commit=!url_commit!/commits/ - ) ELSE ( set url_commit=!url_commit!/commit/ + ) ELSE ( + set url_commit=!url_commit!/commits/ ) ) ELSE ( @@ -146,9 +146,9 @@ IF NOT %errlvl% == "1" ( :: append extra string If NOT "%url_commit%"=="%url_commit:bitbucket.org=%" ( - set url_commit=https://!url_commit!/commits/ - ) ELSE ( set url_commit=https://!url_commit!/commit/ + ) ELSE ( + set url_commit=https://!url_commit!/commits/ ) ) ) diff --git a/regamedll/msvc/ReGameDLL.vcxproj b/regamedll/msvc/ReGameDLL.vcxproj index 44481d2d..2436287e 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj +++ b/regamedll/msvc/ReGameDLL.vcxproj @@ -1533,7 +1533,7 @@ Level3 Disabled true - REGAMEDLL_SELF;PLAY_GAMEDLL;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + REGAMEDLL_SELF;PLAY_GAMEDLL;REGAMEDLL_CHECKS;REGAMEDLL_API;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) Precise /arch:IA32 %(AdditionalOptions) MultiThreadedDebug diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 21655509..165f5b2d 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -35,8 +35,8 @@ #include "client.h" #include "items.h" -#define REGAMEDLL_API_VERSION_MAJOR 4 -#define REGAMEDLL_API_VERSION_MINOR 2 +#define REGAMEDLL_API_VERSION_MAJOR 5 +#define REGAMEDLL_API_VERSION_MINOR 0 // CBasePlayer::Spawn hook typedef IVoidHookChainClass IReGameHook_CBasePlayer_Spawn; @@ -139,8 +139,8 @@ typedef IVoidHookChainClass IReGameHook_CBasePlayer_GiveDefau typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveDefaultItems; // CBasePlayer::GiveNamedItem hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_GiveNamedItem; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveNamedItem; +typedef IHookChainClass IReGameHook_CBasePlayer_GiveNamedItem; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveNamedItem; // CBasePlayer::AddAccount hook typedef IVoidHookChainClass IReGameHook_CBasePlayer_AddAccount; @@ -155,8 +155,8 @@ typedef IVoidHookChainClass IReGameHook_CBase typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel; // CBasePlayer:SetClientUserInfoName hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoName; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoName; +typedef IHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoName; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoName; // CBasePlayer::HasRestrictItem hook typedef IHookChainClass IReGameHook_CBasePlayer_HasRestrictItem; @@ -166,6 +166,38 @@ typedef IHookChainRegistryClass I typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropPlayerItem; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropPlayerItem; +// CBasePlayer::DropShield hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropShield; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropShield; + +// CBasePlayer::OnSpawnEquip hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_OnSpawnEquip; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_OnSpawnEquip; + +// CBasePlayer::Radio hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Radio; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Radio; + +// CBasePlayer::Disappear hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Disappear; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Disappear; + +// CBasePlayer::MakeVIP hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_MakeVIP; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_MakeVIP; + +// CBasePlayer::MakeBomber hook +typedef IHookChainClass IReGameHook_CBasePlayer_MakeBomber; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_MakeBomber; + +// CBasePlayer::StartObserver hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_StartObserver; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_StartObserver; + +// CBasePlayer::GetIntoGame hook +typedef IHookChainClass IReGameHook_CBasePlayer_GetIntoGame; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GetIntoGame; + // CBaseAnimating::ResetSequenceInfo hook typedef IVoidHookChainClass IReGameHook_CBaseAnimating_ResetSequenceInfo; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo; @@ -218,6 +250,18 @@ typedef IVoidHookChainRegistry IReG typedef IVoidHookChain IReGameHook_ShowVGUIMenu; typedef IVoidHookChainRegistry IReGameHookRegistry_ShowVGUIMenu; +// BuyGunAmmo hook +typedef IHookChain IReGameHook_BuyGunAmmo; +typedef IHookChainRegistry IReGameHookRegistry_BuyGunAmmo; + +// BuyWeaponByWeaponID hook +typedef IHookChain IReGameHook_BuyWeaponByWeaponID; +typedef IHookChainRegistry IReGameHookRegistry_BuyWeaponByWeaponID; + +// InternalCommand hook +typedef IHookChain IReGameHook_InternalCommand; +typedef IHookChainRegistry IReGameHookRegistry_InternalCommand; + // CHalfLifeMultiplay::FShouldSwitchWeapon hook typedef IHookChain IReGameHook_CSGameRules_FShouldSwitchWeapon; typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon; @@ -306,9 +350,14 @@ typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GoToIntermissio typedef IVoidHookChain<> IReGameHook_CSGameRules_BalanceTeams; typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams; +// CHalfLifeMultiplay::OnRoundFreezeEnd hook +typedef IVoidHookChain<> IReGameHook_CSGameRules_OnRoundFreezeEnd; +typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} + // CBasePlayer virtual virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn() = 0; virtual IReGameHookRegistry_CBasePlayer_Precache* CBasePlayer_Precache() = 0; @@ -343,6 +392,15 @@ public: virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName() = 0; virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem* CBasePlayer_HasRestrictItem() = 0; virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0; + virtual IReGameHookRegistry_CBasePlayer_DropShield* CBasePlayer_DropShield() = 0; + virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip* CBasePlayer_OnSpawnEquip() = 0; + virtual IReGameHookRegistry_CBasePlayer_Radio* CBasePlayer_Radio() = 0; + virtual IReGameHookRegistry_CBasePlayer_Disappear* CBasePlayer_Disappear() = 0; + virtual IReGameHookRegistry_CBasePlayer_MakeVIP* CBasePlayer_MakeVIP() = 0; + virtual IReGameHookRegistry_CBasePlayer_MakeBomber* CBasePlayer_MakeBomber() = 0; + virtual IReGameHookRegistry_CBasePlayer_StartObserver* CBasePlayer_StartObserver() = 0; + virtual IReGameHookRegistry_CBasePlayer_GetIntoGame* CBasePlayer_GetIntoGame() = 0; + virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0; virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0; @@ -357,6 +415,9 @@ public: virtual IReGameHookRegistry_HandleMenu_ChooseTeam* HandleMenu_ChooseTeam() = 0; virtual IReGameHookRegistry_ShowMenu* ShowMenu() = 0; virtual IReGameHookRegistry_ShowVGUIMenu* ShowVGUIMenu() = 0; + virtual IReGameHookRegistry_BuyGunAmmo* BuyGunAmmo() = 0; + virtual IReGameHookRegistry_BuyWeaponByWeaponID* BuyWeaponByWeaponID() = 0; + virtual IReGameHookRegistry_InternalCommand* InternalCommand() = 0; virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon* CSGameRules_FShouldSwitchWeapon() = 0; virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon* CSGameRules_GetNextBestWeapon() = 0; @@ -380,10 +441,10 @@ public: virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel() = 0; virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0; virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0; + virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd* CSGameRules_OnRoundFreezeEnd() = 0; }; struct ReGameFuncs_t { - class CBasePlayer *(*UTIL_PlayerByIndex)(int playerIndex); struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass); void (*ChangeString)(char *&dest, const char *source); void (*RadiusDamage)(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType); @@ -393,6 +454,8 @@ struct ReGameFuncs_t { class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue); void (*AddEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType); void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType); + int (*Cmd_Argc)(); + const char *(*Cmd_Argv)(int i); }; class IReGameApi { diff --git a/regamedll/public/regamedll/regamedll_common.h b/regamedll/public/regamedll/regamedll_common.h index 638d5dcb..826b6ded 100644 --- a/regamedll/public/regamedll/regamedll_common.h +++ b/regamedll/public/regamedll/regamedll_common.h @@ -85,6 +85,7 @@ #define Q_pow pow #define Q_fmod fmod #define Q_fopen fopen +#define Q_fwrite fwrite #define Q_fprintf fprintf #define Q_fclose fclose diff --git a/regamedll/public/regamedll/regamedll_interfaces.h b/regamedll/public/regamedll/regamedll_interfaces.h index 84a749fd..38486f63 100644 --- a/regamedll/public/regamedll/regamedll_interfaces.h +++ b/regamedll/public/regamedll/regamedll_interfaces.h @@ -59,8 +59,8 @@ public: virtual bool IsConnected() const; virtual void SetAnimation(PLAYER_ANIM playerAnim); virtual void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true); - virtual void GiveNamedItem(const char *pszName); - virtual void GiveNamedItemEx(const char *pszName); + virtual CBaseEntity *GiveNamedItem(const char *pszName); + virtual CBaseEntity *GiveNamedItemEx(const char *pszName); virtual void GiveDefaultItems(); virtual void GiveShield(bool bDeploy = true); virtual void DropShield(bool bDeploy = true); @@ -90,6 +90,11 @@ public: virtual void DropPrimary(); virtual bool HasPlayerItem(CBasePlayerItem *pCheckItem); virtual bool HasNamedPlayerItem(const char *pszItemName); + virtual CBasePlayerItem *GetItemById(WeaponIdType weaponID); + virtual CBasePlayerItem *GetItemByName(const char *itemName); + virtual void Disappear(); + virtual void MakeVIP(); + virtual bool MakeBomber(); CBasePlayer *BasePlayer() const; public: diff --git a/regamedll/regamedll/dlls.h b/regamedll/regamedll/dlls.h index f6f4bd50..e9b1950e 100644 --- a/regamedll/regamedll/dlls.h +++ b/regamedll/regamedll/dlls.h @@ -119,8 +119,8 @@ typedef float& FloatRef; #include "game_shared/shared_util.h" #include "game_shared/bot/bot_profile.h" -#include "game_shared/bot/improv.h" #include "game_shared/bot/nav.h" +#include "game_shared/bot/improv.h" #include "game_shared/bot/nav_node.h" #include "game_shared/bot/nav_area.h" #include "game_shared/bot/nav_file.h" diff --git a/regamedll/regamedll/regamedll_api_impl.cpp b/regamedll/regamedll/regamedll_api_impl.cpp index 9180fed8..00034aa0 100644 --- a/regamedll/regamedll/regamedll_api_impl.cpp +++ b/regamedll/regamedll/regamedll_api_impl.cpp @@ -29,8 +29,15 @@ CReGameHookchains g_ReGameHookchains; +int EXT_FUNC Cmd_Argc_api() { + return CMD_ARGC_(); +} + +const char *EXT_FUNC Cmd_Argv_api(int i) { + return CMD_ARGV_(i); +} + ReGameFuncs_t g_ReGameApiFuncs = { - &UTIL_PlayerByIndex, &CREATE_NAMED_ENTITY, &Regamedll_ChangeString_api, @@ -43,80 +50,95 @@ ReGameFuncs_t g_ReGameApiFuncs = { &UTIL_FindEntityByString, &AddEntityHashValue, - &RemoveEntityHashValue + &RemoveEntityHashValue, + Cmd_Argc_api, + Cmd_Argv_api }; -IReGameHookRegistry_CBasePlayer_Spawn* CReGameHookchains::CBasePlayer_Spawn() { return &m_CBasePlayer_Spawn; } -IReGameHookRegistry_CBasePlayer_Precache* CReGameHookchains::CBasePlayer_Precache() { return &m_CBasePlayer_Precache; } -IReGameHookRegistry_CBasePlayer_ObjectCaps* CReGameHookchains::CBasePlayer_ObjectCaps() { return &m_CBasePlayer_ObjectCaps; } -IReGameHookRegistry_CBasePlayer_Classify* CReGameHookchains::CBasePlayer_Classify() { return &m_CBasePlayer_Classify; } -IReGameHookRegistry_CBasePlayer_TraceAttack* CReGameHookchains::CBasePlayer_TraceAttack() { return &m_CBasePlayer_TraceAttack; } -IReGameHookRegistry_CBasePlayer_TakeDamage* CReGameHookchains::CBasePlayer_TakeDamage() { return &m_CBasePlayer_TakeDamage; } -IReGameHookRegistry_CBasePlayer_TakeHealth* CReGameHookchains::CBasePlayer_TakeHealth() { return &m_CBasePlayer_TakeHealth; } -IReGameHookRegistry_CBasePlayer_Killed* CReGameHookchains::CBasePlayer_Killed() { return &m_CBasePlayer_Killed; } -IReGameHookRegistry_CBasePlayer_AddPoints* CReGameHookchains::CBasePlayer_AddPoints() { return &m_CBasePlayer_AddPoints; } -IReGameHookRegistry_CBasePlayer_AddPointsToTeam* CReGameHookchains::CBasePlayer_AddPointsToTeam() { return &m_CBasePlayer_AddPointsToTeam; } -IReGameHookRegistry_CBasePlayer_AddPlayerItem* CReGameHookchains::CBasePlayer_AddPlayerItem() { return &m_CBasePlayer_AddPlayerItem; } -IReGameHookRegistry_CBasePlayer_RemovePlayerItem* CReGameHookchains::CBasePlayer_RemovePlayerItem() { return &m_CBasePlayer_RemovePlayerItem; } -IReGameHookRegistry_CBasePlayer_GiveAmmo* CReGameHookchains::CBasePlayer_GiveAmmo() { return &m_CBasePlayer_GiveAmmo; } -IReGameHookRegistry_CBasePlayer_ResetMaxSpeed* CReGameHookchains::CBasePlayer_ResetMaxSpeed() { return &m_CBasePlayer_ResetMaxSpeed; } -IReGameHookRegistry_CBasePlayer_Jump* CReGameHookchains::CBasePlayer_Jump() { return &m_CBasePlayer_Jump; } -IReGameHookRegistry_CBasePlayer_Duck* CReGameHookchains::CBasePlayer_Duck() { return &m_CBasePlayer_Duck; } -IReGameHookRegistry_CBasePlayer_PreThink* CReGameHookchains::CBasePlayer_PreThink() { return &m_CBasePlayer_PreThink; } -IReGameHookRegistry_CBasePlayer_PostThink* CReGameHookchains::CBasePlayer_PostThink() { return &m_CBasePlayer_PostThink; } -IReGameHookRegistry_CBasePlayer_UpdateClientData* CReGameHookchains::CBasePlayer_UpdateClientData() { return &m_CBasePlayer_UpdateClientData; } -IReGameHookRegistry_CBasePlayer_ImpulseCommands* CReGameHookchains::CBasePlayer_ImpulseCommands() { return &m_CBasePlayer_ImpulseCommands; } -IReGameHookRegistry_CBasePlayer_RoundRespawn* CReGameHookchains::CBasePlayer_RoundRespawn() { return &m_CBasePlayer_RoundRespawn; } -IReGameHookRegistry_CBasePlayer_Blind* CReGameHookchains::CBasePlayer_Blind() { return &m_CBasePlayer_Blind; } +GAMEHOOK_REGISTRY(CBasePlayer_Spawn); +GAMEHOOK_REGISTRY(CBasePlayer_Precache); +GAMEHOOK_REGISTRY(CBasePlayer_ObjectCaps); +GAMEHOOK_REGISTRY(CBasePlayer_Classify); +GAMEHOOK_REGISTRY(CBasePlayer_TraceAttack); +GAMEHOOK_REGISTRY(CBasePlayer_TakeDamage); +GAMEHOOK_REGISTRY(CBasePlayer_TakeHealth); +GAMEHOOK_REGISTRY(CBasePlayer_Killed); +GAMEHOOK_REGISTRY(CBasePlayer_AddPoints); +GAMEHOOK_REGISTRY(CBasePlayer_AddPointsToTeam); +GAMEHOOK_REGISTRY(CBasePlayer_AddPlayerItem); +GAMEHOOK_REGISTRY(CBasePlayer_RemovePlayerItem); +GAMEHOOK_REGISTRY(CBasePlayer_GiveAmmo); +GAMEHOOK_REGISTRY(CBasePlayer_ResetMaxSpeed); +GAMEHOOK_REGISTRY(CBasePlayer_Jump); +GAMEHOOK_REGISTRY(CBasePlayer_Duck); +GAMEHOOK_REGISTRY(CBasePlayer_PreThink); +GAMEHOOK_REGISTRY(CBasePlayer_PostThink); +GAMEHOOK_REGISTRY(CBasePlayer_UpdateClientData); +GAMEHOOK_REGISTRY(CBasePlayer_ImpulseCommands); +GAMEHOOK_REGISTRY(CBasePlayer_RoundRespawn); +GAMEHOOK_REGISTRY(CBasePlayer_Blind); -IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget* CReGameHookchains::CBasePlayer_Observer_IsValidTarget() { return &m_CBasePlayer_Observer_IsValidTarget; } -IReGameHookRegistry_CBasePlayer_SetAnimation* CReGameHookchains::CBasePlayer_SetAnimation() { return &m_CBasePlayer_SetAnimation; } -IReGameHookRegistry_CBasePlayer_GiveDefaultItems* CReGameHookchains::CBasePlayer_GiveDefaultItems() { return &m_CBasePlayer_GiveDefaultItems; } -IReGameHookRegistry_CBasePlayer_GiveNamedItem* CReGameHookchains::CBasePlayer_GiveNamedItem() { return &m_CBasePlayer_GiveNamedItem; } -IReGameHookRegistry_CBasePlayer_AddAccount* CReGameHookchains::CBasePlayer_AddAccount() { return &m_CBasePlayer_AddAccount; } -IReGameHookRegistry_CBasePlayer_GiveShield* CReGameHookchains::CBasePlayer_GiveShield() { return &m_CBasePlayer_GiveShield; } -IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel* CReGameHookchains::CBasePlayer_SetClientUserInfoModel() { return &m_CBasePlayer_SetClientUserInfoModel; } -IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CReGameHookchains::CBasePlayer_SetClientUserInfoName() { return &m_CBasePlayer_SetClientUserInfoName; } -IReGameHookRegistry_CBasePlayer_HasRestrictItem* CReGameHookchains::CBasePlayer_HasRestrictItem() { return &m_CBasePlayer_HasRestrictItem; } -IReGameHookRegistry_CBasePlayer_DropPlayerItem* CReGameHookchains::CBasePlayer_DropPlayerItem() { return &m_CBasePlayer_DropPlayerItem; } -IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CReGameHookchains::CBaseAnimating_ResetSequenceInfo() { return &m_CBaseAnimating_ResetSequenceInfo; } +GAMEHOOK_REGISTRY(CBasePlayer_Observer_IsValidTarget); +GAMEHOOK_REGISTRY(CBasePlayer_SetAnimation); +GAMEHOOK_REGISTRY(CBasePlayer_GiveDefaultItems); +GAMEHOOK_REGISTRY(CBasePlayer_GiveNamedItem); +GAMEHOOK_REGISTRY(CBasePlayer_AddAccount); +GAMEHOOK_REGISTRY(CBasePlayer_GiveShield); +GAMEHOOK_REGISTRY(CBasePlayer_SetClientUserInfoModel); +GAMEHOOK_REGISTRY(CBasePlayer_SetClientUserInfoName); +GAMEHOOK_REGISTRY(CBasePlayer_HasRestrictItem); +GAMEHOOK_REGISTRY(CBasePlayer_DropPlayerItem); +GAMEHOOK_REGISTRY(CBasePlayer_DropShield); +GAMEHOOK_REGISTRY(CBasePlayer_OnSpawnEquip); +GAMEHOOK_REGISTRY(CBasePlayer_Radio); +GAMEHOOK_REGISTRY(CBasePlayer_Disappear); +GAMEHOOK_REGISTRY(CBasePlayer_MakeVIP); +GAMEHOOK_REGISTRY(CBasePlayer_MakeBomber); +GAMEHOOK_REGISTRY(CBasePlayer_StartObserver); +GAMEHOOK_REGISTRY(CBasePlayer_GetIntoGame); -IReGameHookRegistry_GetForceCamera* CReGameHookchains::GetForceCamera() { return &m_GetForceCamera; } -IReGameHookRegistry_PlayerBlind* CReGameHookchains::PlayerBlind() { return &m_PlayerBlind; } -IReGameHookRegistry_RadiusFlash_TraceLine* CReGameHookchains::RadiusFlash_TraceLine() { return &m_RadiusFlash_TraceLine; } -IReGameHookRegistry_RoundEnd* CReGameHookchains::RoundEnd() { return &m_RoundEnd; } -IReGameHookRegistry_InstallGameRules* CReGameHookchains::InstallGameRules() { return &m_InstallGameRules; } -IReGameHookRegistry_PM_Init* CReGameHookchains::PM_Init() { return &m_PM_Init; } -IReGameHookRegistry_PM_Move* CReGameHookchains::PM_Move() { return &m_PM_Move; } -IReGameHookRegistry_PM_AirMove* CReGameHookchains::PM_AirMove() { return &m_PM_AirMove; } -IReGameHookRegistry_HandleMenu_ChooseAppearance* CReGameHookchains::HandleMenu_ChooseAppearance() { return &m_HandleMenu_ChooseAppearance; } -IReGameHookRegistry_HandleMenu_ChooseTeam* CReGameHookchains::HandleMenu_ChooseTeam() { return &m_HandleMenu_ChooseTeam; } -IReGameHookRegistry_ShowMenu* CReGameHookchains::ShowMenu() { return &m_ShowMenu; } -IReGameHookRegistry_ShowVGUIMenu* CReGameHookchains::ShowVGUIMenu() { return &m_ShowVGUIMenu; } +GAMEHOOK_REGISTRY(CBaseAnimating_ResetSequenceInfo); -IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon* CReGameHookchains::CSGameRules_FShouldSwitchWeapon() { return &m_CSGameRules_FShouldSwitchWeapon; } -IReGameHookRegistry_CSGameRules_GetNextBestWeapon* CReGameHookchains::CSGameRules_GetNextBestWeapon() { return &m_CSGameRules_GetNextBestWeapon; } -IReGameHookRegistry_CSGameRules_FlPlayerFallDamage* CReGameHookchains::CSGameRules_FlPlayerFallDamage() { return &m_CSGameRules_FlPlayerFallDamage; } -IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage* CReGameHookchains::CSGameRules_FPlayerCanTakeDamage() { return &m_CSGameRules_FPlayerCanTakeDamage; } -IReGameHookRegistry_CSGameRules_PlayerSpawn* CReGameHookchains::CSGameRules_PlayerSpawn() { return &m_CSGameRules_PlayerSpawn; } -IReGameHookRegistry_CSGameRules_FPlayerCanRespawn* CReGameHookchains::CSGameRules_FPlayerCanRespawn() { return &m_CSGameRules_FPlayerCanRespawn; } -IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot* CReGameHookchains::CSGameRules_GetPlayerSpawnSpot() { return &m_CSGameRules_GetPlayerSpawnSpot; } -IReGameHookRegistry_CSGameRules_ClientUserInfoChanged* CReGameHookchains::CSGameRules_ClientUserInfoChanged() { return &m_CSGameRules_ClientUserInfoChanged; } -IReGameHookRegistry_CSGameRules_PlayerKilled* CReGameHookchains::CSGameRules_PlayerKilled() { return &m_CSGameRules_PlayerKilled; } -IReGameHookRegistry_CSGameRules_DeathNotice* CReGameHookchains::CSGameRules_DeathNotice() { return &m_CSGameRules_DeathNotice; } -IReGameHookRegistry_CSGameRules_CanHavePlayerItem* CReGameHookchains::CSGameRules_CanHavePlayerItem() { return &m_CSGameRules_CanHavePlayerItem; } -IReGameHookRegistry_CSGameRules_DeadPlayerWeapons* CReGameHookchains::CSGameRules_DeadPlayerWeapons() { return &m_CSGameRules_DeadPlayerWeapons; } -IReGameHookRegistry_CSGameRules_ServerDeactivate* CReGameHookchains::CSGameRules_ServerDeactivate() { return &m_CSGameRules_ServerDeactivate; } -IReGameHookRegistry_CSGameRules_CheckMapConditions* CReGameHookchains::CSGameRules_CheckMapConditions() { return &m_CSGameRules_CheckMapConditions; } -IReGameHookRegistry_CSGameRules_CleanUpMap* CReGameHookchains::CSGameRules_CleanUpMap() { return &m_CSGameRules_CleanUpMap; } -IReGameHookRegistry_CSGameRules_RestartRound* CReGameHookchains::CSGameRules_RestartRound() { return &m_CSGameRules_RestartRound; } -IReGameHookRegistry_CSGameRules_CheckWinConditions* CReGameHookchains::CSGameRules_CheckWinConditions() { return &m_CSGameRules_CheckWinConditions; } -IReGameHookRegistry_CSGameRules_RemoveGuns* CReGameHookchains::CSGameRules_RemoveGuns() { return &m_CSGameRules_RemoveGuns; } -IReGameHookRegistry_CSGameRules_GiveC4* CReGameHookchains::CSGameRules_GiveC4() { return &m_CSGameRules_GiveC4; } -IReGameHookRegistry_CSGameRules_ChangeLevel* CReGameHookchains::CSGameRules_ChangeLevel() { return &m_CSGameRules_ChangeLevel; } -IReGameHookRegistry_CSGameRules_GoToIntermission* CReGameHookchains::CSGameRules_GoToIntermission() { return &m_CSGameRules_GoToIntermission; } -IReGameHookRegistry_CSGameRules_BalanceTeams* CReGameHookchains::CSGameRules_BalanceTeams() { return &m_CSGameRules_BalanceTeams; } +GAMEHOOK_REGISTRY(GetForceCamera); +GAMEHOOK_REGISTRY(PlayerBlind); +GAMEHOOK_REGISTRY(RadiusFlash_TraceLine); +GAMEHOOK_REGISTRY(RoundEnd); +GAMEHOOK_REGISTRY(InstallGameRules); +GAMEHOOK_REGISTRY(PM_Init); +GAMEHOOK_REGISTRY(PM_Move); +GAMEHOOK_REGISTRY(PM_AirMove); +GAMEHOOK_REGISTRY(HandleMenu_ChooseAppearance); +GAMEHOOK_REGISTRY(HandleMenu_ChooseTeam); +GAMEHOOK_REGISTRY(ShowMenu); +GAMEHOOK_REGISTRY(ShowVGUIMenu); +GAMEHOOK_REGISTRY(BuyGunAmmo); +GAMEHOOK_REGISTRY(BuyWeaponByWeaponID); +GAMEHOOK_REGISTRY(InternalCommand); + +GAMEHOOK_REGISTRY(CSGameRules_FShouldSwitchWeapon); +GAMEHOOK_REGISTRY(CSGameRules_GetNextBestWeapon); +GAMEHOOK_REGISTRY(CSGameRules_FlPlayerFallDamage); +GAMEHOOK_REGISTRY(CSGameRules_FPlayerCanTakeDamage); +GAMEHOOK_REGISTRY(CSGameRules_PlayerSpawn); +GAMEHOOK_REGISTRY(CSGameRules_FPlayerCanRespawn); +GAMEHOOK_REGISTRY(CSGameRules_GetPlayerSpawnSpot); +GAMEHOOK_REGISTRY(CSGameRules_ClientUserInfoChanged); +GAMEHOOK_REGISTRY(CSGameRules_PlayerKilled); +GAMEHOOK_REGISTRY(CSGameRules_DeathNotice); +GAMEHOOK_REGISTRY(CSGameRules_CanHavePlayerItem); +GAMEHOOK_REGISTRY(CSGameRules_DeadPlayerWeapons); +GAMEHOOK_REGISTRY(CSGameRules_ServerDeactivate); +GAMEHOOK_REGISTRY(CSGameRules_CheckMapConditions); +GAMEHOOK_REGISTRY(CSGameRules_CleanUpMap); +GAMEHOOK_REGISTRY(CSGameRules_RestartRound); +GAMEHOOK_REGISTRY(CSGameRules_CheckWinConditions); +GAMEHOOK_REGISTRY(CSGameRules_RemoveGuns); +GAMEHOOK_REGISTRY(CSGameRules_GiveC4); +GAMEHOOK_REGISTRY(CSGameRules_ChangeLevel); +GAMEHOOK_REGISTRY(CSGameRules_GoToIntermission); +GAMEHOOK_REGISTRY(CSGameRules_BalanceTeams); +GAMEHOOK_REGISTRY(CSGameRules_OnRoundFreezeEnd); int EXT_FUNC CReGameApi::GetMajorVersion() { return REGAMEDLL_API_VERSION_MAJOR; diff --git a/regamedll/regamedll/regamedll_api_impl.h b/regamedll/regamedll/regamedll_api_impl.h index 7a06ec81..1c37eccb 100644 --- a/regamedll/regamedll/regamedll_api_impl.h +++ b/regamedll/regamedll/regamedll_api_impl.h @@ -31,6 +31,9 @@ #include "regamedll_api.h" #include "regamedll_interfaces_impl.h" +#define GAMEHOOK_REGISTRY(func)\ + IReGameHookRegistry_##func* CReGameHookchains::##func() { return &m_##func; } + // CBasePlayer::Spawn hook typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_Spawn; typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Spawn; @@ -132,8 +135,8 @@ typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_GiveDefault typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_GiveDefaultItems; // CBasePlayer::GiveNamedItem hook -typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_GiveNamedItem; -typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_GiveNamedItem; +typedef IHookChainClassImpl CReGameHook_CBasePlayer_GiveNamedItem; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_GiveNamedItem; // CBasePlayer::AddAccount hook typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_AddAccount; @@ -148,8 +151,8 @@ typedef IVoidHookChainClassImpl CReGameHook_CBasePl typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_SetClientUserInfoModel; // CBasePlayer:SetClientUserInfoName hook -typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_SetClientUserInfoName; -typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_SetClientUserInfoName; +typedef IHookChainClassImpl CReGameHook_CBasePlayer_SetClientUserInfoName; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_SetClientUserInfoName; // CBasePlayer::HasRestrictItem hook typedef IHookChainClassImpl CReGameHook_CBasePlayer_HasRestrictItem; @@ -159,6 +162,38 @@ typedef IHookChainRegistryClassImpl CRe typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_DropPlayerItem; typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropPlayerItem; +// CBasePlayer::DropShield hook +typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_DropShield; +typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropShield; + +// CBasePlayer::OnSpawnEquip hook +typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_OnSpawnEquip; +typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_OnSpawnEquip; + +// CBasePlayer::Radio hook +typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_Radio; +typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Radio; + +// CBasePlayer::Disappear hook +typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_Disappear; +typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_Disappear; + +// CBasePlayer::MakeVIP hook +typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_MakeVIP; +typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_MakeVIP; + +// CBasePlayer::MakeBomber hook +typedef IHookChainClassImpl CReGameHook_CBasePlayer_MakeBomber; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_MakeBomber; + +// CBasePlayer::StartObserver hook +typedef IVoidHookChainClassImpl CReGameHook_CBasePlayer_StartObserver; +typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_StartObserver; + +// CBasePlayer::GetIntoGame hook +typedef IHookChainClassImpl CReGameHook_CBasePlayer_GetIntoGame; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_GetIntoGame; + // CBaseAnimating::ResetSequenceInfo hook typedef IVoidHookChainClassImpl CReGameHook_CBaseAnimating_ResetSequenceInfo; typedef IVoidHookChainRegistryClassImpl CReGameHookRegistry_CBaseAnimating_ResetSequenceInfo; @@ -211,6 +246,18 @@ typedef IVoidHookChainRegistryImpl CReGam typedef IVoidHookChainImpl CReGameHook_ShowVGUIMenu; typedef IVoidHookChainRegistryImpl CReGameHookRegistry_ShowVGUIMenu; +// BuyGunAmmo hook +typedef IHookChainImpl CReGameHook_BuyGunAmmo; +typedef IHookChainRegistryImpl CReGameHookRegistry_BuyGunAmmo; + +// BuyWeaponByWeaponID hook +typedef IHookChainImpl CReGameHook_BuyWeaponByWeaponID; +typedef IHookChainRegistryImpl CReGameHookRegistry_BuyWeaponByWeaponID; + +// InternalCommand hook +typedef IHookChainImpl CReGameHook_InternalCommand; +typedef IHookChainRegistryImpl CReGameHookRegistry_InternalCommand; + // CHalfLifeMultiplay::FShouldSwitchWeapon hook typedef IHookChainClassImpl CReGameHook_CSGameRules_FShouldSwitchWeapon; typedef IHookChainRegistryClassEmptyImpl CReGameHookRegistry_CSGameRules_FShouldSwitchWeapon; @@ -241,7 +288,7 @@ typedef IHookChainRegistryClassEmptyImpl CReGameHook_CSGameRules_ClientUserInfoChanged; -typedef IVoidHookChainRegistryClassEmptyImpl< class CHalfLifeMultiplay, CBasePlayer *, char *> CReGameHookRegistry_CSGameRules_ClientUserInfoChanged; +typedef IVoidHookChainRegistryClassEmptyImpl CReGameHookRegistry_CSGameRules_ClientUserInfoChanged; // CHalfLifeMultiplay::PlayerKilled hook typedef IVoidHookChainClassImpl CReGameHook_CSGameRules_PlayerKilled; @@ -299,6 +346,10 @@ typedef IVoidHookChainRegistryClassEmptyImpl CReGameHo typedef IVoidHookChainClassImpl CReGameHook_CSGameRules_BalanceTeams; typedef IVoidHookChainRegistryClassEmptyImpl CReGameHookRegistry_CSGameRules_BalanceTeams; +// CHalfLifeMultiplay::OnRoundFreezeEnd hook +typedef IVoidHookChainClassImpl CReGameHook_CSGameRules_OnRoundFreezeEnd; +typedef IVoidHookChainRegistryClassEmptyImpl CReGameHookRegistry_CSGameRules_OnRoundFreezeEnd; + class CReGameHookchains: public IReGameHookchains { public: // CBasePlayer virtual @@ -335,6 +386,15 @@ public: CReGameHookRegistry_CBasePlayer_SetClientUserInfoName m_CBasePlayer_SetClientUserInfoName; CReGameHookRegistry_CBasePlayer_HasRestrictItem m_CBasePlayer_HasRestrictItem; CReGameHookRegistry_CBasePlayer_DropPlayerItem m_CBasePlayer_DropPlayerItem; + CReGameHookRegistry_CBasePlayer_DropShield m_CBasePlayer_DropShield; + CReGameHookRegistry_CBasePlayer_OnSpawnEquip m_CBasePlayer_OnSpawnEquip; + CReGameHookRegistry_CBasePlayer_Radio m_CBasePlayer_Radio; + CReGameHookRegistry_CBasePlayer_Disappear m_CBasePlayer_Disappear; + CReGameHookRegistry_CBasePlayer_MakeVIP m_CBasePlayer_MakeVIP; + CReGameHookRegistry_CBasePlayer_MakeBomber m_CBasePlayer_MakeBomber; + CReGameHookRegistry_CBasePlayer_StartObserver m_CBasePlayer_StartObserver; + CReGameHookRegistry_CBasePlayer_GetIntoGame m_CBasePlayer_GetIntoGame; + CReGameHookRegistry_CBaseAnimating_ResetSequenceInfo m_CBaseAnimating_ResetSequenceInfo; CReGameHookRegistry_GetForceCamera m_GetForceCamera; @@ -349,6 +409,9 @@ public: CReGameHookRegistry_HandleMenu_ChooseTeam m_HandleMenu_ChooseTeam; CReGameHookRegistry_ShowMenu m_ShowMenu; CReGameHookRegistry_ShowVGUIMenu m_ShowVGUIMenu; + CReGameHookRegistry_BuyGunAmmo m_BuyGunAmmo; + CReGameHookRegistry_BuyWeaponByWeaponID m_BuyWeaponByWeaponID; + CReGameHookRegistry_InternalCommand m_InternalCommand; CReGameHookRegistry_CSGameRules_FShouldSwitchWeapon m_CSGameRules_FShouldSwitchWeapon; CReGameHookRegistry_CSGameRules_GetNextBestWeapon m_CSGameRules_GetNextBestWeapon; @@ -372,6 +435,7 @@ public: CReGameHookRegistry_CSGameRules_ChangeLevel m_CSGameRules_ChangeLevel; CReGameHookRegistry_CSGameRules_GoToIntermission m_CSGameRules_GoToIntermission; CReGameHookRegistry_CSGameRules_BalanceTeams m_CSGameRules_BalanceTeams; + CReGameHookRegistry_CSGameRules_OnRoundFreezeEnd m_CSGameRules_OnRoundFreezeEnd; public: virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn(); @@ -407,6 +471,15 @@ public: virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName(); virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem* CBasePlayer_HasRestrictItem(); virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem(); + virtual IReGameHookRegistry_CBasePlayer_DropShield* CBasePlayer_DropShield(); + virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip* CBasePlayer_OnSpawnEquip(); + virtual IReGameHookRegistry_CBasePlayer_Radio* CBasePlayer_Radio(); + virtual IReGameHookRegistry_CBasePlayer_Disappear* CBasePlayer_Disappear(); + virtual IReGameHookRegistry_CBasePlayer_MakeVIP* CBasePlayer_MakeVIP(); + virtual IReGameHookRegistry_CBasePlayer_MakeBomber* CBasePlayer_MakeBomber(); + virtual IReGameHookRegistry_CBasePlayer_StartObserver* CBasePlayer_StartObserver(); + virtual IReGameHookRegistry_CBasePlayer_GetIntoGame* CBasePlayer_GetIntoGame(); + virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo(); virtual IReGameHookRegistry_GetForceCamera* GetForceCamera(); @@ -421,6 +494,9 @@ public: virtual IReGameHookRegistry_HandleMenu_ChooseTeam* HandleMenu_ChooseTeam(); virtual IReGameHookRegistry_ShowMenu* ShowMenu(); virtual IReGameHookRegistry_ShowVGUIMenu* ShowVGUIMenu(); + virtual IReGameHookRegistry_BuyGunAmmo* BuyGunAmmo(); + virtual IReGameHookRegistry_BuyWeaponByWeaponID* BuyWeaponByWeaponID(); + virtual IReGameHookRegistry_InternalCommand* InternalCommand(); virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon* CSGameRules_FShouldSwitchWeapon(); virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon* CSGameRules_GetNextBestWeapon(); @@ -444,6 +520,7 @@ public: virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel(); virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission(); virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams(); + virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd* CSGameRules_OnRoundFreezeEnd(); }; extern CReGameHookchains g_ReGameHookchains; diff --git a/regamedll/regamedll/regamedll_interfaces_impl.cpp b/regamedll/regamedll/regamedll_interfaces_impl.cpp index 85f4325c..42e8a2e3 100644 --- a/regamedll/regamedll/regamedll_interfaces_impl.cpp +++ b/regamedll/regamedll/regamedll_interfaces_impl.cpp @@ -73,7 +73,7 @@ bool EXT_FUNC CCSPlayer::JoinTeam(TeamName team) case CT: case TERRORIST: { - if (pPlayer->m_iTeam == SPECTATOR || pPlayer->m_iTeam == UNASSIGNED) + if (pPlayer->m_iTeam == SPECTATOR) { // If they're switching into spectator, setup spectator properties.. pPlayer->m_bNotKilled = true; @@ -81,7 +81,7 @@ bool EXT_FUNC CCSPlayer::JoinTeam(TeamName team) pPlayer->m_iTeamKills = 0; if (pPlayer->m_iAccount < int(startmoney.value)) { - pPlayer->m_iAccount = int(startmoney.value); + pPlayer->AddAccount(startmoney.value, RT_PLAYER_JOIN); } pPlayer->pev->solid = SOLID_NOT; @@ -207,7 +207,6 @@ bool EXT_FUNC CCSPlayer::RemovePlayerItem(const char* pszItemName) pPlayer->RemoveShield(); CBasePlayerWeapon *pWeapon = static_cast(pPlayer->m_pActiveItem); - if (pWeapon) { if (!pWeapon->CanHolster()) @@ -237,44 +236,34 @@ bool EXT_FUNC CCSPlayer::RemovePlayerItem(const char* pszItemName) return true; } - bool bIsC4 = !!FStrEq(pszItemName, "weapon_c4"); - for (auto pItem : pPlayer->m_rgpPlayerItems) { - while (pItem != nullptr) - { - if (FClassnameIs(pItem->pev, pszItemName)) - { - if (pItem->iItemSlot() == PRIMARY_WEAPON_SLOT) { - pPlayer->m_bHasPrimary = false; - } - else if (bIsC4) - { - pPlayer->m_bHasC4 = false; - pPlayer->pev->body = 0; - pPlayer->SetBombIcon(FALSE); - pPlayer->SetProgressBarTime(0); - } + auto pItem = GetItemByName(pszItemName); + if (pItem) + { + if (pItem->iItemSlot() == PRIMARY_WEAPON_SLOT) { + pPlayer->m_bHasPrimary = false; + } + else if (FClassnameIs(pItem->pev, "weapon_c4")) { + pPlayer->m_bHasC4 = false; + pPlayer->pev->body = 0; + pPlayer->SetBombIcon(FALSE); + pPlayer->SetProgressBarTime(0); + } - if (pItem->IsWeapon() && pItem == pPlayer->m_pActiveItem) { - ((CBasePlayerWeapon *)pItem)->RetireWeapon(); - } + if (pItem->IsWeapon() && pItem == pPlayer->m_pActiveItem) { + ((CBasePlayerWeapon *)pItem)->RetireWeapon(); + } - if (pPlayer->RemovePlayerItem(pItem)) { - pPlayer->pev->weapons &= ~(1 << pItem->m_iId); - pItem->Kill(); - return true; - } - - return false; - } - - pItem = pItem->m_pNext; + if (pPlayer->RemovePlayerItem(pItem)) { + pPlayer->pev->weapons &= ~(1 << pItem->m_iId); + pItem->Kill(); + return true; } } return false; } -void EXT_FUNC CCSPlayer::GiveNamedItemEx(const char *pszName) +CBaseEntity *EXT_FUNC CCSPlayer::GiveNamedItemEx(const char *pszName) { CBasePlayer *pPlayer = BasePlayer(); @@ -288,16 +277,16 @@ void EXT_FUNC CCSPlayer::GiveNamedItemEx(const char *pszName) } else if (FStrEq(pszName, "weapon_shield")) { pPlayer->DropPrimary(); pPlayer->GiveShield(); - return; + return nullptr; } - pPlayer->GiveNamedItemEx(pszName); + return pPlayer->GiveNamedItemEx(pszName); } bool EXT_FUNC CCSPlayer::IsConnected() const { return m_pContainingEntity->has_disconnected == false; } void EXT_FUNC CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim) { BasePlayer()->SetAnimation(playerAnim); } void EXT_FUNC CCSPlayer::AddAccount(int amount, RewardType type, bool bTrackChange) { BasePlayer()->AddAccount(amount, type, bTrackChange); } -void EXT_FUNC CCSPlayer::GiveNamedItem(const char *pszName) { BasePlayer()->GiveNamedItem(pszName); } +CBaseEntity *EXT_FUNC CCSPlayer::GiveNamedItem(const char *pszName) { return BasePlayer()->GiveNamedItem(pszName); } void EXT_FUNC CCSPlayer::GiveDefaultItems() { BasePlayer()->GiveDefaultItems(); } void EXT_FUNC CCSPlayer::GiveShield(bool bDeploy) { BasePlayer()->GiveShield(bDeploy); } void EXT_FUNC CCSPlayer::DropShield(bool bDeploy) { BasePlayer()->DropShield(bDeploy); } @@ -325,3 +314,8 @@ void EXT_FUNC CCSPlayer::DropSecondary() { BasePlayer()->DropSecondary(); } void EXT_FUNC CCSPlayer::DropPrimary() { BasePlayer()->DropPrimary(); } bool EXT_FUNC CCSPlayer::HasPlayerItem(CBasePlayerItem *pCheckItem) { return BasePlayer()->HasPlayerItem(pCheckItem); } bool EXT_FUNC CCSPlayer::HasNamedPlayerItem(const char *pszItemName) { return BasePlayer()->HasNamedPlayerItem(pszItemName); } +CBasePlayerItem *EXT_FUNC CCSPlayer::GetItemById(WeaponIdType weaponID) { return BasePlayer()->GetItemById(weaponID); } +CBasePlayerItem *EXT_FUNC CCSPlayer::GetItemByName(const char *itemName) { return BasePlayer()->GetItemByName(itemName); } +void EXT_FUNC CCSPlayer::Disappear() { BasePlayer()->Disappear(); } +void EXT_FUNC CCSPlayer::MakeVIP() { BasePlayer()->MakeVIP(); } +bool EXT_FUNC CCSPlayer::MakeBomber() { return BasePlayer()->MakeBomber(); }