diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 56297b358..825125cfc 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -673,10 +673,12 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity) CBaseEntity *pTarget = nullptr; pPlayer->m_pIntroCamera = UTIL_FindEntityByClassname(nullptr, "trigger_camera"); +#ifndef REGAMEDLL_FIXES if (g_pGameRules && g_pGameRules->IsMultiplayer()) { CSGameRules()->m_bMapHasCameras = (pPlayer->m_pIntroCamera != nullptr); } +#endif if (pPlayer->m_pIntroCamera) { @@ -694,7 +696,12 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity) pPlayer->pev->angles = CamAngles; pPlayer->pev->v_angle = pPlayer->pev->angles; - pPlayer->m_fIntroCamTime = gpGlobals->time + 6; + pPlayer->m_fIntroCamTime = +#ifdef REGAMEDLL_FIXES + (CSGameRules()->m_bMapHasCameras <= 1) ? 0.0 : // no need to refresh cameras if map has only one +#endif + gpGlobals->time + 6; + pPlayer->pev->view_ofs = g_vecZero; } #ifndef REGAMEDLL_FIXES diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index 1346de2f9..e29aaba88 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -779,7 +779,7 @@ class CHalfLifeMultiplay: public CGameRules bool m_bMapHasEscapeZone; BOOL m_bMapHasVIPSafetyZone; // TRUE = has VIP safety zone, FALSE = does not have VIP safetyzone - BOOL m_bMapHasCameras; + int 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 diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 58116bd9a..4f4899712 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -382,7 +382,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() m_iNumTerrorist = 0; m_iNumSpawnableCT = 0; m_iNumSpawnableTerrorist = 0; - m_bMapHasCameras = FALSE; + m_bMapHasCameras = -1; m_iLoserBonus = m_rgRewardAccountRules[RR_LOSER_BONUS_DEFAULT]; m_iNumConsecutiveCTLoses = 0; @@ -3086,17 +3086,11 @@ void CHalfLifeMultiplay::CheckLevelInitialized() { // Count the number of spawn points for each team // This determines the maximum number of players allowed on each - CBaseEntity *pEnt = nullptr; - - m_iSpawnPointCount_Terrorist = 0; - m_iSpawnPointCount_CT = 0; - - while ((pEnt = UTIL_FindEntityByClassname(pEnt, "info_player_deathmatch"))) - m_iSpawnPointCount_Terrorist++; - - while ((pEnt = UTIL_FindEntityByClassname(pEnt, "info_player_start"))) - m_iSpawnPointCount_CT++; - + m_iSpawnPointCount_Terrorist = UTIL_CountEntities("info_player_deathmatch"); + m_iSpawnPointCount_CT = UTIL_CountEntities("info_player_start"); +#ifdef REGAMEDLL_FIXES + m_bMapHasCameras = UTIL_CountEntities("trigger_camera"); +#endif m_bLevelInitialized = true; } } diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 99bf2b982..8b71d8446 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -3666,7 +3666,11 @@ void EXT_FUNC CBasePlayer::__API_HOOK(JoiningThink)() } } - if (m_pIntroCamera && gpGlobals->time >= m_fIntroCamTime) + if (m_pIntroCamera && gpGlobals->time >= m_fIntroCamTime +#ifdef REGAMEDLL_FIXES + && m_fIntroCamTime > 0.0 // update only if cameras are available +#endif + ) { // find the next another camera m_pIntroCamera = UTIL_FindEntityByClassname(m_pIntroCamera, "trigger_camera"); diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index 6b2fda0c7..714fe79d1 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -1758,6 +1758,17 @@ int UTIL_GetNumPlayers() return nNumPlayers; } +int UTIL_CountEntities(const char *szName) +{ + int count = 0; + CBaseEntity *pEnt = nullptr; + + while ((pEnt = UTIL_FindEntityByClassname(pEnt, szName))) + count++; + + return count; +} + bool UTIL_IsSpawnPointOccupied(CBaseEntity *pSpot) { if (!pSpot) diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index 9ed3f40ee..f96be669b 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -297,6 +297,7 @@ bool UTIL_AreBotsAllowed(); bool UTIL_IsBeta(); bool UTIL_AreHostagesImprov(); int UTIL_GetNumPlayers(); +int UTIL_CountEntities(const char *szName); bool UTIL_IsSpawnPointOccupied(CBaseEntity *pSpot); void MAKE_STRING_CLASS(const char *str, entvars_t *pev); void NORETURN Sys_Error(const char *error, ...);