Refactoring API

This commit is contained in:
s1lentq 2016-05-31 20:04:51 +06:00
parent 905064d44d
commit 06b0c16145
41 changed files with 740 additions and 6939 deletions

View File

@ -14,19 +14,17 @@ int GetBotFollowCount(CBasePlayer *leader)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBaseEntity *entity = UTIL_PlayerByIndex(i); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (entity == NULL) if (player == NULL)
continue; continue;
if (FNullEnt(entity->pev)) if (FNullEnt(player->pev))
continue; continue;
if (FStrEq(STRING(entity->pev->netname), "")) if (FStrEq(STRING(player->pev->netname), ""))
continue; continue;
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
if (!player->IsBot()) if (!player->IsBot())
continue; continue;
@ -632,23 +630,21 @@ CBasePlayer *CCSBot::GetImportantEnemy(bool checkVisibility) const
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBaseEntity *entity = UTIL_PlayerByIndex(i); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (entity == NULL) if (player == NULL)
continue; continue;
if (FNullEnt(entity->pev)) if (FNullEnt(player->pev))
continue; continue;
if (FStrEq(STRING(entity->pev->netname), "")) if (FStrEq(STRING(player->pev->netname), ""))
continue; continue;
// is it a player? // is it a player?
if (!entity->IsPlayer()) if (!player->IsPlayer())
continue; continue;
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
// is it alive? // is it alive?
if (!player->IsAlive()) if (!player->IsAlive())
continue; continue;

View File

@ -48,7 +48,7 @@ void BotMeme::Transmit(CCSBot *sender) const
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;
@ -1528,7 +1528,7 @@ BotStatement *BotChatterInterface::GetActiveStatement()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;

View File

@ -402,7 +402,7 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd)
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(iIndex)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex);
if (pPlayer == NULL) if (pPlayer == NULL)
continue; continue;
@ -434,7 +434,7 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd)
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(iIndex)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex);
if (pPlayer == NULL) if (pPlayer == NULL)
continue; continue;

View File

@ -1083,7 +1083,7 @@ bool CCSBot::IsFriendInTheWay(const Vector *goalPos) const
// check if any friends are overlapping this linear path // check if any friends are overlapping this linear path
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;

View File

@ -657,20 +657,18 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
{ {
for (i = 1; i <= gpGlobals->maxClients; ++i) for (i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBaseEntity *entity = UTIL_PlayerByIndex(i); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (entity == NULL) if (player == NULL)
continue; continue;
if (FNullEnt(entity->pev)) if (FNullEnt(player->pev))
continue; continue;
// is it a player? // is it a player?
if (!entity->IsPlayer()) if (!player->IsPlayer())
continue; continue;
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
// ignore self // ignore self
if (player->entindex() == entindex()) if (player->entindex() == entindex())
continue; continue;

View File

@ -562,7 +562,7 @@ void CCareerTaskManager::HandleDeath(int team, CBasePlayer *pAttacker)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer && pPlayer->m_iTeam == enemyTeam && pPlayer->IsAlive()) if (pPlayer && pPlayer->m_iTeam == enemyTeam && pPlayer->IsAlive())
++numEnemies; ++numEnemies;

View File

@ -62,7 +62,7 @@ static DLL_FUNCTIONS gFunctionTable =
static NEW_DLL_FUNCTIONS gNewDLLFunctions static NEW_DLL_FUNCTIONS gNewDLLFunctions
{ {
&OnFreeEntPrivateData, &OnFreeEntPrivateData,
&GameDLLShutdown, NULL,
NULL, NULL,
NULL, NULL,
NULL NULL
@ -1082,5 +1082,11 @@ void OnFreeEntPrivateData(edict_t *pEnt)
pEntity->UpdateOnRemove(); pEntity->UpdateOnRemove();
RemoveEntityHashValue(pEntity->pev, STRING(pEntity->pev->classname), CLASSNAME); RemoveEntityHashValue(pEntity->pev, STRING(pEntity->pev->classname), CLASSNAME);
Regamedll_FreeEntities(pEntity);
#ifdef REGAMEDLL_ADD
if (pEntity->m_pEntity != nullptr) {
delete pEntity->m_pEntity;
pEntity->m_pEntity = nullptr;
}
#endif
} }

View File

@ -199,6 +199,7 @@ class CBaseMonster;
class CBasePlayerItem; class CBasePlayerItem;
class CBasePlayerWeapon; class CBasePlayerWeapon;
class CSquadMonster; class CSquadMonster;
class CCSEntity;
class CCineMonster; class CCineMonster;
class CSound; class CSound;
@ -364,8 +365,15 @@ public:
void (CBaseEntity::*m_pfnUse)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); void (CBaseEntity::*m_pfnUse)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
void (CBaseEntity::*m_pfnBlocked)(CBaseEntity *pOther); void (CBaseEntity::*m_pfnBlocked)(CBaseEntity *pOther);
#ifdef REGAMEDLL_ADD
CCSEntity *m_pEntity;
#endif
// We use this variables to store each ammo count. // We use this variables to store each ammo count.
#ifndef REGAMEDLL_ADD
// let's sacrifice this unused member, for its own needs in favor of m_pEntity
int *current_ammo; int *current_ammo;
#endif
float currentammo; float currentammo;
int maxammo_buckshot; int maxammo_buckshot;
int ammo_buckshot; int ammo_buckshot;
@ -659,13 +667,9 @@ public:
}; };
#ifdef REGAMEDLL_SELF
extern class CCSEntity **g_GameEntities;
#endif
// Converts a entvars_t * to a class pointer // Converts a entvars_t * to a class pointer
// It will allocate the class and entity if necessary // It will allocate the class and entity if necessary
template <class TWrap, class T> template <class W, class T>
T *GetClassPtr(T *a) T *GetClassPtr(T *a)
{ {
entvars_t *pev = (entvars_t *)a; entvars_t *pev = (entvars_t *)a;
@ -683,8 +687,9 @@ T *GetClassPtr(T *a)
a = new(pev) T; a = new(pev) T;
a->pev = pev; a->pev = pev;
#ifdef REGAMEDLL_SELF #ifdef REGAMEDLL_ADD
g_GameEntities[a->entindex()] = new TWrap (a); a->m_pEntity = new W();
a->m_pEntity->m_pContainingEntity = a;
#endif #endif
#if defined(HOOK_GAMEDLL) && defined(_WIN32) && !defined(REGAMEDLL_UNIT_TESTS) #if defined(HOOK_GAMEDLL) && defined(_WIN32) && !defined(REGAMEDLL_UNIT_TESTS)
@ -695,9 +700,7 @@ T *GetClassPtr(T *a)
return a; return a;
} }
#ifdef REGAMEDLL_SELF
extern CUtlVector<hash_item_t> stringsHashTable; extern CUtlVector<hash_item_t> stringsHashTable;
#endif
C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion);
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion);

View File

@ -3023,7 +3023,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pObserver = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pObserver = UTIL_PlayerByIndex(i);
if (pObserver && pObserver->IsObservingPlayer(player)) if (pObserver && pObserver->IsObservingPlayer(player))
{ {
@ -3049,7 +3049,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pObserver = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pObserver = UTIL_PlayerByIndex(i);
if (pObserver && pObserver->IsObservingPlayer(player)) if (pObserver && pObserver->IsObservingPlayer(player))
{ {

View File

@ -904,7 +904,7 @@ void EXT_FUNC PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pObserver = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pObserver = UTIL_PlayerByIndex(i);
if (!pObserver || !pObserver->IsObservingPlayer(pPlayer)) if (!pObserver || !pObserver->IsObservingPlayer(pPlayer))
continue; continue;

View File

@ -239,8 +239,3 @@ void EXT_FUNC GameDLLInit()
Tutor_RegisterCVars(); Tutor_RegisterCVars();
Hostage_RegisterCVars(); Hostage_RegisterCVars();
} }
void EXT_FUNC GameDLLShutdown()
{
Regamedll_FreeEntities();
}

View File

@ -142,6 +142,5 @@ extern cvar_t roundrespawn_time;
#endif #endif
void GameDLLInit(); void GameDLLInit();
void GameDLLShutdown();
#endif // GAME_H #endif // GAME_H

View File

@ -327,7 +327,7 @@ bool CHostageImprov::__MAKE_VHOOK(IsFriendInTheWay)(const Vector &goalPos) const
// check if any CT are overlapping this linear path // check if any CT are overlapping this linear path
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;
@ -526,7 +526,7 @@ CBasePlayer *CHostageImprov::__MAKE_VHOOK(IsAnyPlayerLookingAtMe)(int team, floa
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!IsEntityValid(player)) if (!IsEntityValid(player))
continue; continue;
@ -553,7 +553,7 @@ CBasePlayer *CHostageImprov::__MAKE_VHOOK(GetClosestPlayerByTravelDistance)(int
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!IsEntityValid(player)) if (!IsEntityValid(player))
continue; continue;
@ -644,7 +644,7 @@ void CHostageImprov::UpdateVision()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;

View File

@ -360,14 +360,13 @@ void CGamePlayerZone::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pC
if (!CanFireForActivator(pActivator)) if (!CanFireForActivator(pActivator))
return; return;
CBaseEntity *pPlayer = NULL;
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBaseEntity *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer == nullptr)
continue;
if (pPlayer)
{
TraceResult trace; TraceResult trace;
int hullNumber; int hullNumber;
@ -396,7 +395,6 @@ void CGamePlayerZone::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pC
} }
} }
} }
}
if (!FStringNull(m_iszInCount)) if (!FStringNull(m_iszInCount))
{ {

View File

@ -17,7 +17,7 @@ bool IsBotSpeaking()
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer == NULL || !pPlayer->IsBot()) if (pPlayer == NULL || !pPlayer->IsBot())
continue; continue;
@ -44,7 +44,7 @@ void SV_Continue_f()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer && !pPlayer->IsBot()) if (pPlayer && !pPlayer->IsBot())
{ {
@ -85,7 +85,7 @@ void SV_Career_EndRound_f()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!player || FNullEnt(player->pev)) if (!player || FNullEnt(player->pev))
continue; continue;
@ -768,7 +768,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GiveC4)()
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!player || FNullEnt(player->edict())) if (!player || FNullEnt(player->edict()))
continue; continue;
@ -850,7 +850,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GiveC4)()
player->m_bHasC4 = true; player->m_bHasC4 = true;
player->GiveNamedItem("weapon_c4"); player->GiveNamedItem("weapon_c4");
player->SetBombIcon(FALSE); player->SetBombIcon();
player->pev->body = 1; player->pev->body = 1;
player->m_flDisplayHistory |= DHF_BOMB_RETRIEVED; player->m_flDisplayHistory |= DHF_BOMB_RETRIEVED;
@ -1132,7 +1132,7 @@ bool CHalfLifeMultiplay::NeededPlayersCheck()
{ {
if (IsCareer()) if (IsCareer())
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(gpGlobals->maxClients)); CBasePlayer *player = UTIL_PlayerByIndex(gpGlobals->maxClients);
if (!player || !player->IsBot()) if (!player || !player->IsBot())
{ {
@ -1825,7 +1825,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)()
// Reset the player stats // Reset the player stats
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *plr = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *plr = UTIL_PlayerByIndex(i);
if (plr && !FNullEnt(plr->pev)) if (plr && !FNullEnt(plr->pev))
plr->Reset(); plr->Reset();
@ -2528,7 +2528,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer != NULL && !pPlayer->IsBot()) if (pPlayer != NULL && !pPlayer->IsBot())
{ {
@ -2777,7 +2777,7 @@ void CHalfLifeMultiplay::CheckFreezePeriodExpired()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *plr = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *plr = UTIL_PlayerByIndex(i);
if (!plr || plr->pev->flags == FL_DORMANT) if (!plr || plr->pev->flags == FL_DORMANT)
{ {
@ -3044,7 +3044,7 @@ void CHalfLifeMultiplay::MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!player || FNullEnt(player->pev)) if (!player || FNullEnt(player->pev))
continue; continue;
@ -3082,7 +3082,7 @@ void CHalfLifeMultiplay::CareerRestart()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!player || FNullEnt(player->pev)) if (!player || FNullEnt(player->pev))
continue; continue;
@ -3255,7 +3255,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
for (i = 1; i <= gpGlobals->maxClients; ++i) for (i = 1; i <= gpGlobals->maxClients; ++i)
{ {
// FIXME: Probably don't need to cast this just to read m_iDeaths // FIXME: Probably don't need to cast this just to read m_iDeaths
CBasePlayer *plr = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *plr = UTIL_PlayerByIndex(i);
if (plr != NULL) if (plr != NULL)
{ {
@ -3297,7 +3297,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
for (i = 1; i <= gpGlobals->maxClients; ++i) for (i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *plr = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *plr = UTIL_PlayerByIndex(i);
if (plr != NULL) if (plr != NULL)
{ {
@ -4384,9 +4384,8 @@ int CountPlayers()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBaseEntity *pEnt = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer != NULL)
if (pEnt != NULL)
{ {
num = num + 1; num = num + 1;
} }

View File

@ -19,14 +19,14 @@ int __API_HOOK(GetForceCamera)(CBasePlayer *pObserver)
return retVal; return retVal;
} }
LINK_HOOK_CLASS_CHAIN(CBaseEntity *, CBasePlayer, Observer_IsValidTarget, (int iPlayerIndex, bool bSameTeam), iPlayerIndex, bSameTeam); LINK_HOOK_CLASS_CHAIN(CBasePlayer *, CBasePlayer, Observer_IsValidTarget, (int iPlayerIndex, bool bSameTeam), iPlayerIndex, bSameTeam);
CBaseEntity *CBasePlayer::__API_HOOK(Observer_IsValidTarget)(int iPlayerIndex, bool bSameTeam) CBasePlayer *CBasePlayer::__API_HOOK(Observer_IsValidTarget)(int iPlayerIndex, bool bSameTeam)
{ {
if (iPlayerIndex > gpGlobals->maxClients || iPlayerIndex < 1) if (iPlayerIndex > gpGlobals->maxClients || iPlayerIndex < 1)
return NULL; return NULL;
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(iPlayerIndex)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(iPlayerIndex);
// Don't spec observers or players who haven't picked a class yet // Don't spec observers or players who haven't picked a class yet
if (!pPlayer || pPlayer == this || pPlayer->has_disconnected || pPlayer->IsObserver() || (pPlayer->pev->effects & EF_NODRAW) || pPlayer->m_iTeam == UNASSIGNED || (bSameTeam && pPlayer->m_iTeam != m_iTeam)) if (!pPlayer || pPlayer == this || pPlayer->has_disconnected || pPlayer->IsObserver() || (pPlayer->pev->effects & EF_NODRAW) || pPlayer->m_iTeam == UNASSIGNED || (bSameTeam && pPlayer->m_iTeam != m_iTeam))
@ -50,7 +50,7 @@ void UpdateClientEffects(CBasePlayer *pObserver, int oldMode)
if (pObserver->m_hObserverTarget->IsPlayer()) if (pObserver->m_hObserverTarget->IsPlayer())
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(pObserver->m_hObserverTarget->entindex())); CBasePlayer *pPlayer = UTIL_PlayerByIndex(pObserver->m_hObserverTarget->entindex());
if (pPlayer) if (pPlayer)
{ {
@ -132,7 +132,6 @@ void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name)
int iCurrent; int iCurrent;
int iDir; int iDir;
bool bForceSameTeam; bool bForceSameTeam;
CBasePlayer *pPlayer;
if (m_flNextFollowTime && m_flNextFollowTime > gpGlobals->time) if (m_flNextFollowTime && m_flNextFollowTime > gpGlobals->time)
return; return;
@ -166,8 +165,7 @@ void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name)
if (!name) if (!name)
break; break;
pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(m_hObserverTarget->entindex())); CBasePlayer *pPlayer = UTIL_PlayerByIndex(m_hObserverTarget->entindex());
if (!Q_strcmp(name, STRING(pPlayer->pev->netname))) if (!Q_strcmp(name, STRING(pPlayer->pev->netname)))
break; break;
} }
@ -269,7 +267,7 @@ void CBasePlayer::Observer_CheckTarget()
if (m_hObserverTarget) if (m_hObserverTarget)
{ {
int iPlayerIndex = ENTINDEX(m_hObserverTarget->edict()); int iPlayerIndex = ENTINDEX(m_hObserverTarget->edict());
CBasePlayer *target = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(iPlayerIndex)); CBasePlayer *target = UTIL_PlayerByIndex(iPlayerIndex);
// check taget // check taget
if (!target || target->pev->deadflag == DEAD_RESPAWNABLE || (target->pev->effects & EF_NODRAW)) if (!target || target->pev->deadflag == DEAD_RESPAWNABLE || (target->pev->effects & EF_NODRAW))
@ -305,7 +303,7 @@ void CBasePlayer::Observer_CheckProperties()
// try to find a traget if we have no current one // 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 != NULL)
{ {
CBasePlayer *target = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(m_hObserverTarget->entindex())); CBasePlayer *target = UTIL_PlayerByIndex(m_hObserverTarget->entindex());
if (!target) if (!target)
return; return;

View File

@ -363,9 +363,9 @@ void CBasePlayer::SetPlayerModel(BOOL HasC4)
char *model; char *model;
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
CCSPlayer *pPlayer = CSPlayer(this); auto& modelEx = CSPlayer()->m_szModel;
if (*pPlayer->m_szModel != '\0') { if (*modelEx != '\0') {
model = pPlayer->m_szModel; model = modelEx;
} else } else
#endif #endif
if (m_iTeam == CT) if (m_iTeam == CT)
@ -1052,7 +1052,7 @@ int CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pev
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer) if (!pPlayer)
continue; continue;
@ -1095,7 +1095,7 @@ int CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pev
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer || pPlayer->m_hObserverTarget != this) if (!pPlayer || pPlayer->m_hObserverTarget != this)
continue; continue;
@ -1289,7 +1289,7 @@ int CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pev
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer) if (!pPlayer)
continue; continue;
@ -1332,7 +1332,7 @@ int CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pev
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer) if (!pPlayer)
continue; continue;
@ -1947,7 +1947,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer) if (!pPlayer)
continue; continue;
@ -1978,7 +1978,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pObserver = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pObserver = UTIL_PlayerByIndex(i);
if (!pObserver) if (!pObserver)
continue; continue;
@ -3325,7 +3325,6 @@ void CBasePlayer::JoiningThink()
if (g_pGameRules->FPlayerCanRespawn(this)) if (g_pGameRules->FPlayerCanRespawn(this))
{ {
Spawn(); Spawn();
CSGameRules()->CheckWinConditions(); CSGameRules()->CheckWinConditions();
if (!CSGameRules()->m_fTeamCount && CSGameRules()->m_bMapHasBombTarget && !CSGameRules()->IsThereABomber() && !CSGameRules()->IsThereABomb()) if (!CSGameRules()->m_fTeamCount && CSGameRules()->m_bMapHasBombTarget && !CSGameRules()->IsThereABomber() && !CSGameRules()->IsThereABomb())
@ -4051,7 +4050,7 @@ void CBasePlayer::__API_VHOOK(AddPointsToTeam)(int score, BOOL bAllowNegativeSco
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer != NULL && i != index) if (pPlayer != NULL && i != index)
{ {
@ -5308,7 +5307,7 @@ void CBasePlayer::__API_VHOOK(Spawn)()
for (i = 1; i <= gpGlobals->maxClients; ++i) for (i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pObserver = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pObserver = UTIL_PlayerByIndex(i);
if (pObserver && pObserver->IsObservingPlayer(this)) if (pObserver && pObserver->IsObservingPlayer(this))
{ {
@ -5448,7 +5447,7 @@ void CBasePlayer::SetScoreboardAttributes(CBasePlayer *destination)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player != NULL && !FNullEnt(player->edict())) if (player != NULL && !FNullEnt(player->edict()))
SetScoreboardAttributes(player); SetScoreboardAttributes(player);
@ -7362,7 +7361,6 @@ void CBasePlayer::DropPlayerItem(const char *pszItemName)
if (pWeapon->iFlags() & ITEM_FLAG_EXHAUSTIBLE) if (pWeapon->iFlags() & ITEM_FLAG_EXHAUSTIBLE)
{ {
int iAmmoIndex = GetAmmoIndex(pWeapon->pszAmmo1()); int iAmmoIndex = GetAmmoIndex(pWeapon->pszAmmo1());
if (iAmmoIndex != -1) if (iAmmoIndex != -1)
{ {
pWeaponBox->PackAmmo(MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[iAmmoIndex] > 0); pWeaponBox->PackAmmo(MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[iAmmoIndex] > 0);
@ -7371,7 +7369,6 @@ void CBasePlayer::DropPlayerItem(const char *pszItemName)
} }
const char *modelname = GetCSModelName(pWeapon->m_iId); const char *modelname = GetCSModelName(pWeapon->m_iId);
if (modelname != NULL) if (modelname != NULL)
{ {
SET_MODEL(ENT(pWeaponBox->pev), modelname); SET_MODEL(ENT(pWeaponBox->pev), modelname);
@ -9181,7 +9178,7 @@ void CBasePlayer::UpdateLocation(bool forceUpdate)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!player) if (!player)
continue; continue;

View File

@ -157,8 +157,7 @@ enum RewardType
RT_VIP_KILLED, RT_VIP_KILLED,
RT_VIP_RESCUED_MYSELF RT_VIP_RESCUED_MYSELF
}; };
enum PLAYER_ANIM
typedef enum
{ {
PLAYER_IDLE, PLAYER_IDLE,
PLAYER_WALK, PLAYER_WALK,
@ -171,10 +170,9 @@ typedef enum
PLAYER_LARGE_FLINCH, PLAYER_LARGE_FLINCH,
PLAYER_RELOAD, PLAYER_RELOAD,
PLAYER_HOLDBOMB PLAYER_HOLDBOMB
};
} PLAYER_ANIM; enum _Menu
typedef enum
{ {
Menu_OFF, Menu_OFF,
Menu_ChooseTeam, Menu_ChooseTeam,
@ -191,19 +189,18 @@ typedef enum
Menu_Radio2, Menu_Radio2,
Menu_Radio3, Menu_Radio3,
Menu_ClientBuy Menu_ClientBuy
};
} _Menu; enum TeamName
typedef enum
{ {
UNASSIGNED, UNASSIGNED,
TERRORIST, TERRORIST,
CT, CT,
SPECTATOR, SPECTATOR,
} TeamName; };
typedef enum enum ModelName
{ {
MODEL_UNASSIGNED, MODEL_UNASSIGNED,
MODEL_URBAN, MODEL_URBAN,
@ -216,11 +213,11 @@ typedef enum
MODEL_GUERILLA, MODEL_GUERILLA,
MODEL_VIP, MODEL_VIP,
MODEL_MILITIA, MODEL_MILITIA,
MODEL_SPETSNAZ MODEL_SPETSNAZ,
MODEL_AUTO
};
} ModelName; enum JoinState
typedef enum
{ {
JOINED, JOINED,
SHOWLTEXT, SHOWLTEXT,
@ -229,9 +226,9 @@ typedef enum
PICKINGTEAM, PICKINGTEAM,
GETINTOGAME GETINTOGAME
} JoinState; };
typedef enum enum TrackCommands
{ {
CMD_SAY = 0, CMD_SAY = 0,
CMD_SAYTEAM, CMD_SAYTEAM,
@ -243,9 +240,9 @@ typedef enum
CMD_NIGHTVISION, CMD_NIGHTVISION,
COMMANDS_TO_TRACK, COMMANDS_TO_TRACK,
} TrackCommands; };
typedef struct struct RebuyStruct
{ {
int m_primaryWeapon; int m_primaryWeapon;
int m_primaryAmmo; int m_primaryAmmo;
@ -257,10 +254,9 @@ typedef struct
int m_defuser; int m_defuser;
int m_nightVision; int m_nightVision;
int m_armor; int m_armor;
};
} RebuyStruct; enum ThrowDirection
typedef enum
{ {
THROW_NONE, THROW_NONE,
THROW_FORWARD, THROW_FORWARD,
@ -269,8 +265,7 @@ typedef enum
THROW_BOMB, THROW_BOMB,
THROW_GRENADE, THROW_GRENADE,
THROW_HITVEL_MINUS_AIRVEL THROW_HITVEL_MINUS_AIRVEL
};
} ThrowDirection;
enum sbar_data enum sbar_data
{ {
@ -282,6 +277,8 @@ enum sbar_data
enum MusicState { SILENT, CALM, INTENSE }; enum MusicState { SILENT, CALM, INTENSE };
class CCSPlayer;
class CStripWeapons: public CPointEntity { class CStripWeapons: public CPointEntity {
public: public:
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
@ -428,8 +425,8 @@ public:
public: public:
void SpawnClientSideCorpse(); void SpawnClientSideCorpse();
void Observer_FindNextPlayer(bool bReverse, const char *name = NULL); void Observer_FindNextPlayer(bool bReverse, const char *name = NULL);
CBaseEntity *Observer_IsValidTarget(int iPlayerIndex, bool bSameTeam); CBasePlayer *Observer_IsValidTarget(int iPlayerIndex, bool bSameTeam);
CBaseEntity *Observer_IsValidTarget_(int iPlayerIndex, bool bSameTeam); CBasePlayer *Observer_IsValidTarget_(int iPlayerIndex, bool bSameTeam);
void Observer_HandleButtons(); void Observer_HandleButtons();
void Observer_SetMode(int iMode); void Observer_SetMode(int iMode);
@ -555,15 +552,7 @@ public:
void GiveShield_(bool bDeploy = true); void GiveShield_(bool bDeploy = true);
bool IsHittingShield(Vector &vecDirection, TraceResult *ptr); bool IsHittingShield(Vector &vecDirection, TraceResult *ptr);
bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot); bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot);
bool IsReloading() bool IsReloading() const;
{
CBasePlayerWeapon *weapon = static_cast<CBasePlayerWeapon *>(m_pActiveItem);
if (weapon != NULL && weapon->m_fInReload)
return true;
return false;
}
bool IsBlind() const { return (m_blindUntilTime > gpGlobals->time); } bool IsBlind() const { return (m_blindUntilTime > gpGlobals->time); }
bool IsAutoFollowAllowed() const { return (gpGlobals->time > m_allowAutoFollowTime); } bool IsAutoFollowAllowed() const { return (gpGlobals->time > m_allowAutoFollowTime); }
void InhibitAutoFollow(float duration) { m_allowAutoFollowTime = gpGlobals->time + duration; } void InhibitAutoFollow(float duration) { m_allowAutoFollowTime = gpGlobals->time + duration; }
@ -603,6 +592,10 @@ public:
//m_musicState = INTENSE; //m_musicState = INTENSE;
//m_intenseTimestamp = gpGlobals->time; //m_intenseTimestamp = gpGlobals->time;
} }
#ifdef REGAMEDLL_ADD
CCSPlayer *CSPlayer() const;
#endif
public: public:
enum { MaxLocationLen = 32 }; enum { MaxLocationLen = 32 };
@ -826,6 +819,22 @@ public:
float m_flTimeToIgnoreTouches; float m_flTimeToIgnoreTouches;
}; };
inline bool CBasePlayer::IsReloading() const
{
CBasePlayerWeapon *weapon = static_cast<CBasePlayerWeapon *>(m_pActiveItem);
if (weapon != NULL && weapon->m_fInReload)
return true;
return false;
}
#ifdef REGAMEDLL_ADD
inline CCSPlayer *CBasePlayer::CSPlayer() const {
return reinterpret_cast<CCSPlayer *>(this->m_pEntity);
}
#endif
extern int gEvilImpulse101; extern int gEvilImpulse101;
extern char g_szMapBriefingText[512]; extern char g_szMapBriefingText[512];
extern entvars_t *g_pevLastInflictor; extern entvars_t *g_pevLastInflictor;

View File

@ -43,7 +43,7 @@ void CHalfLifeTraining::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
void CHalfLifeTraining::HostageDied() void CHalfLifeTraining::HostageDied()
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(1)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(1);
if (pPlayer != NULL) if (pPlayer != NULL)
{ {

View File

@ -1728,7 +1728,7 @@ void CEscapeZone::EscapeTouch(CBaseEntity *pOther)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer == NULL || FNullEnt(pPlayer->pev)) if (pPlayer == NULL || FNullEnt(pPlayer->pev))
continue; continue;

View File

@ -80,7 +80,7 @@ void MonitorTutorStatus()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer != NULL && !pPlayer->IsBot()) if (pPlayer != NULL && !pPlayer->IsBot())
++numHumans; ++numHumans;

View File

@ -2188,7 +2188,7 @@ void CCSTutor::GetNumPlayersAliveOnTeams(int &numT, int &numCT)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL || !player->IsAlive()) if (player == NULL || !player->IsAlive())
continue; continue;
@ -2289,7 +2289,7 @@ void CCSTutor::CheckForBombViewable()
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player != NULL && player->m_bHasC4) if (player != NULL && player->m_bHasC4)
{ {
@ -3016,7 +3016,7 @@ void CCSTutor::ConstructRecentDeathsList(TeamName team, char *buf, int buflen, T
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer == NULL) if (pPlayer == NULL)
continue; continue;

View File

@ -522,14 +522,14 @@ CBaseEntity *UTIL_FindEntityGeneric(const char *szWhatever, const Vector &vecSrc
return pEntity; return pEntity;
} }
CBaseEntity *EXT_FUNC UTIL_PlayerByIndex(int playerIndex) CBasePlayer *EXT_FUNC UTIL_PlayerByIndex(int playerIndex)
{ {
CBaseEntity *pPlayer = NULL; CBasePlayer *pPlayer = NULL;
if (playerIndex > 0 && playerIndex <= gpGlobals->maxClients) if (playerIndex > 0 && playerIndex <= gpGlobals->maxClients)
{ {
edict_t *pPlayerEdict = INDEXENT(playerIndex); edict_t *pPlayerEdict = INDEXENT(playerIndex);
if (pPlayerEdict != NULL && !pPlayerEdict->free) if (pPlayerEdict != NULL && !pPlayerEdict->free)
pPlayer = CBaseEntity::Instance(pPlayerEdict); pPlayer = (CBasePlayer *)CBaseEntity::Instance(pPlayerEdict);
} }
return pPlayer; return pPlayer;
@ -2283,7 +2283,7 @@ char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd)
NOXREF int GetPlayerTeam(int index) NOXREF int GetPlayerTeam(int index)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(index)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(index);
if (pPlayer != NULL) if (pPlayer != NULL)
{ {
return pPlayer->m_iTeam; return pPlayer->m_iTeam;
@ -2308,7 +2308,7 @@ bool UTIL_IsGame(const char *gameName)
float_precision UTIL_GetPlayerGaitYaw(int playerIndex) float_precision UTIL_GetPlayerGaitYaw(int playerIndex)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(playerIndex)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(playerIndex);
if (pPlayer != NULL) if (pPlayer != NULL)
{ {
return pPlayer->m_flGaityaw; return pPlayer->m_flGaityaw;

View File

@ -158,12 +158,10 @@ extern globalvars_t *gpGlobals;
#endif #endif
#define REGAMEDLL_ALLOC_FUNC
#define LINK_ENTITY_TO_CLASS(mapClassName, DLLClassName, DLLClassWrapName)\ #define LINK_ENTITY_TO_CLASS(mapClassName, DLLClassName, DLLClassWrapName)\
C_DLLEXPORT void EXT_FUNC mapClassName(entvars_t *pev);\ C_DLLEXPORT void EXT_FUNC mapClassName(entvars_t *pev);\
void mapClassName(entvars_t *pev)\ void mapClassName(entvars_t *pev)\
{\ {\
REGAMEDLL_ALLOC_FUNC\
GetClassPtr<DLLClassWrapName>((DLLClassName *)pev);\ GetClassPtr<DLLClassWrapName>((DLLClassName *)pev);\
} }
@ -249,7 +247,7 @@ CBaseEntity *UTIL_FindEntityByString(CBaseEntity *pStartEntity, const char *szKe
CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName); CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName);
CBaseEntity *UTIL_FindEntityByTargetname(CBaseEntity *pStartEntity, const char *szName); CBaseEntity *UTIL_FindEntityByTargetname(CBaseEntity *pStartEntity, const char *szName);
CBaseEntity *UTIL_FindEntityGeneric(const char *szWhatever, const Vector &vecSrc, float flRadius); CBaseEntity *UTIL_FindEntityGeneric(const char *szWhatever, const Vector &vecSrc, float flRadius);
CBaseEntity *UTIL_PlayerByIndex(int playerIndex); CBasePlayer *UTIL_PlayerByIndex(int playerIndex);
void UTIL_MakeVectors(const Vector &vecAngles); void UTIL_MakeVectors(const Vector &vecAngles);
void UTIL_MakeAimVectors(const Vector &vecAngles); void UTIL_MakeAimVectors(const Vector &vecAngles);
void UTIL_MakeInvVectors(const Vector &vec, globalvars_t *pgv); void UTIL_MakeInvVectors(const Vector &vec, globalvars_t *pgv);

View File

@ -410,13 +410,8 @@ void EXT_FUNC ResetGlobalState()
gInitHUD = TRUE; gInitHUD = TRUE;
} }
#pragma push_macro("REGAMEDLL_ALLOC_FUNC")
#define REGAMEDLL_ALLOC_FUNC Regamedll_AllocEntities(gpGlobals->maxEntities);
LINK_ENTITY_TO_CLASS(worldspawn, CWorld, CCSWorld); LINK_ENTITY_TO_CLASS(worldspawn, CWorld, CCSWorld);
#pragma pop_macro("REGAMEDLL_ALLOC_FUNC")
void CWorld::__MAKE_VHOOK(Spawn)() void CWorld::__MAKE_VHOOK(Spawn)()
{ {
EmptyEntityHashTable(); EmptyEntityHashTable();

View File

@ -307,7 +307,7 @@ void CC4::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T
return; return;
} }
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(1)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(1);
if (pPlayer != NULL) if (pPlayer != NULL)
{ {

View File

@ -37,6 +37,7 @@ class CBaseEntity;
class CBaseMonster; class CBaseMonster;
class CBasePlayerItem; class CBasePlayerItem;
class CSquadMonster; class CSquadMonster;
class CCSEntity;
class CBaseEntity { class CBaseEntity {
public: public:
@ -135,8 +136,9 @@ public:
EOFFSET eoffset() { return OFFSET(pev); } EOFFSET eoffset() { return OFFSET(pev); }
int entindex() { return ENTINDEX(edict()); } int entindex() { return ENTINDEX(edict()); }
public: public:
CCSEntity *m_pEntity;
// We use this variables to store each ammo count. // We use this variables to store each ammo count.
int *current_ammo;
float currentammo; float currentammo;
int maxammo_buckshot; int maxammo_buckshot;
int ammo_buckshot; int ammo_buckshot;

View File

@ -27,8 +27,6 @@
*/ */
#pragma once #pragma once
//#include "weapons.h"
#include "pm_materials.h" #include "pm_materials.h"
#include "hintmessage.h" #include "hintmessage.h"
#include "unisignals.h" #include "unisignals.h"
@ -150,7 +148,7 @@ enum RewardType
RT_VIP_RESCUED_MYSELF RT_VIP_RESCUED_MYSELF
}; };
typedef enum enum PLAYER_ANIM
{ {
PLAYER_IDLE, PLAYER_IDLE,
PLAYER_WALK, PLAYER_WALK,
@ -164,9 +162,9 @@ typedef enum
PLAYER_RELOAD, PLAYER_RELOAD,
PLAYER_HOLDBOMB PLAYER_HOLDBOMB
} PLAYER_ANIM; };
typedef enum enum _Menu
{ {
Menu_OFF, Menu_OFF,
Menu_ChooseTeam, Menu_ChooseTeam,
@ -184,18 +182,18 @@ typedef enum
Menu_Radio3, Menu_Radio3,
Menu_ClientBuy Menu_ClientBuy
} _Menu; };
typedef enum enum TeamName
{ {
UNASSIGNED, UNASSIGNED,
TERRORIST, TERRORIST,
CT, CT,
SPECTATOR, SPECTATOR,
} TeamName; };
typedef enum enum ModelName
{ {
MODEL_UNASSIGNED, MODEL_UNASSIGNED,
MODEL_URBAN, MODEL_URBAN,
@ -208,11 +206,12 @@ typedef enum
MODEL_GUERILLA, MODEL_GUERILLA,
MODEL_VIP, MODEL_VIP,
MODEL_MILITIA, MODEL_MILITIA,
MODEL_SPETSNAZ MODEL_SPETSNAZ,
MODEL_AUTO
} ModelName; };
typedef enum enum JoinState
{ {
JOINED, JOINED,
SHOWLTEXT, SHOWLTEXT,
@ -221,9 +220,9 @@ typedef enum
PICKINGTEAM, PICKINGTEAM,
GETINTOGAME GETINTOGAME
} JoinState; };
typedef enum enum TrackCommands
{ {
CMD_SAY = 0, CMD_SAY = 0,
CMD_SAYTEAM, CMD_SAYTEAM,
@ -235,9 +234,9 @@ typedef enum
CMD_NIGHTVISION, CMD_NIGHTVISION,
COMMANDS_TO_TRACK, COMMANDS_TO_TRACK,
} TrackCommands; };
typedef struct struct RebuyStruct
{ {
int m_primaryWeapon; int m_primaryWeapon;
int m_primaryAmmo; int m_primaryAmmo;
@ -250,9 +249,9 @@ typedef struct
int m_nightVision; int m_nightVision;
int m_armor; int m_armor;
} RebuyStruct; };
typedef enum enum ThrowDirection
{ {
THROW_NONE, THROW_NONE,
THROW_FORWARD, THROW_FORWARD,
@ -262,7 +261,7 @@ typedef enum
THROW_GRENADE, THROW_GRENADE,
THROW_HITVEL_MINUS_AIRVEL THROW_HITVEL_MINUS_AIRVEL
} ThrowDirection; };
enum sbar_data enum sbar_data
{ {
@ -272,13 +271,9 @@ enum sbar_data
SBAR_END SBAR_END
}; };
typedef enum enum MusicState { SILENT, CALM, INTENSE };
{
SILENT,
CALM,
INTENSE
} MusicState; class CCSPlayer;
class CStripWeapons: public CPointEntity { class CStripWeapons: public CPointEntity {
public: public:
@ -356,21 +351,14 @@ public:
int IsObserver() { return pev->iuser1; } int IsObserver() { return pev->iuser1; }
void SetWeaponAnimType(const char *szExtention) { strcpy(m_szAnimExtention, szExtention); } void SetWeaponAnimType(const char *szExtention) { strcpy(m_szAnimExtention, szExtention); }
bool IsProtectedByShield() { return m_bOwnsShield && m_bShieldDrawn; } bool IsProtectedByShield() { return m_bOwnsShield && m_bShieldDrawn; }
bool IsReloading() bool IsReloading() const;
{
CBasePlayerWeapon *weapon = static_cast<CBasePlayerWeapon *>(m_pActiveItem);
if (weapon != NULL && weapon->m_fInReload)
return true;
return false;
}
bool IsBlind() const { return (m_blindUntilTime > gpGlobals->time); } bool IsBlind() const { return (m_blindUntilTime > gpGlobals->time); }
bool IsAutoFollowAllowed() const { return (gpGlobals->time > m_allowAutoFollowTime); } bool IsAutoFollowAllowed() const { return (gpGlobals->time > m_allowAutoFollowTime); }
void InhibitAutoFollow(float duration) { m_allowAutoFollowTime = gpGlobals->time + duration; } void InhibitAutoFollow(float duration) { m_allowAutoFollowTime = gpGlobals->time + duration; }
void AllowAutoFollow() { m_allowAutoFollowTime = 0; } void AllowAutoFollow() { m_allowAutoFollowTime = 0; }
void SetObserverAutoDirector(bool val) { m_bObserverAutoDirector = val; } void SetObserverAutoDirector(bool val) { m_bObserverAutoDirector = val; }
bool CanSwitchObserverModes() const { return m_canSwitchObserverModes; } bool CanSwitchObserverModes() const { return m_canSwitchObserverModes; }
CCSPlayer *CSPlayer() const;
public: public:
enum { MaxLocationLen = 32 }; enum { MaxLocationLen = 32 };
@ -574,3 +562,17 @@ public:
EHANDLE m_hEntToIgnoreTouchesFrom; EHANDLE m_hEntToIgnoreTouchesFrom;
float m_flTimeToIgnoreTouches; float m_flTimeToIgnoreTouches;
}; };
inline bool CBasePlayer::IsReloading() const
{
CBasePlayerWeapon *weapon = static_cast<CBasePlayerWeapon *>(m_pActiveItem);
if (weapon != NULL && weapon->m_fInReload)
return true;
return false;
}
inline CCSPlayer *CBasePlayer::CSPlayer() const {
return reinterpret_cast<CCSPlayer *>(this->m_pEntity);
}

View File

@ -31,7 +31,7 @@
#include "hookchains.h" #include "hookchains.h"
#include "interface.h" #include "interface.h"
#define REGAMEDLL_API_VERSION_MAJOR 1 #define REGAMEDLL_API_VERSION_MAJOR 2
#define REGAMEDLL_API_VERSION_MINOR 1 #define REGAMEDLL_API_VERSION_MINOR 1
// CBasePlayer::Spawn hook // CBasePlayer::Spawn hook
@ -124,8 +124,8 @@ typedef IVoidHookChainRegistryClass<class CBasePlayer, float, float, float, int>
// CBasePlayer::Observer_IsValidTarget hook // CBasePlayer::Observer_IsValidTarget hook
typedef IHookChain<class CBaseEntity *, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget; typedef IHookChain<class CBasePlayer *, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget;
typedef IHookChainRegistryClass<class CBaseEntity *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; typedef IHookChainRegistryClass<class CBasePlayer *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
// CBasePlayer::SetAnimation hook // CBasePlayer::SetAnimation hook
typedef IVoidHookChain<PLAYER_ANIM> IReGameHook_CBasePlayer_SetAnimation; typedef IVoidHookChain<PLAYER_ANIM> IReGameHook_CBasePlayer_SetAnimation;
@ -376,11 +376,7 @@ public:
}; };
struct ReGameFuncs_t { struct ReGameFuncs_t {
class CBaseEntity *(*UTIL_PlayerByIndex)(int playerIndex); class CBasePlayer *(*UTIL_PlayerByIndex)(int playerIndex);
class ICSPlayer *(*CBASE_TO_CSPLAYER)(class CBaseEntity *pEntity);
class ICSEntity *(*CBASE_TO_CSENTITY)(class CBaseEntity *pEntity);
class ICSPlayer *(*INDEX_TO_CSPLAYER)(int iPlayerIndex);
class ICSEntity *(*INDEX_TO_CSENTITY)(int iEntityIndex);
struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass); struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass);
void (*ChangeString)(char *&dest, const char *source); void (*ChangeString)(char *&dest, const char *source);

File diff suppressed because it is too large Load Diff

View File

@ -193,7 +193,7 @@ void CBotManager::__MAKE_VHOOK(StartFrame)()
// Process each active bot // Process each active bot
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer) if (!pPlayer)
continue; continue;
@ -222,7 +222,7 @@ void CBotManager::__MAKE_VHOOK(OnEvent)(GameEventType event, CBaseEntity *entity
// propogate event to all bots // propogate event to all bots
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;

View File

@ -75,19 +75,17 @@ int UTIL_ActivePlayersInGame()
int iCount = 0; int iCount = 0;
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex)
{ {
CBaseEntity *entity = UTIL_PlayerByIndex(iIndex); CBasePlayer *player = UTIL_PlayerByIndex(iIndex);
if (entity == NULL) if (player == NULL)
continue; continue;
if (FNullEnt(entity->pev)) if (FNullEnt(player->pev))
continue; continue;
if (FStrEq(STRING(entity->pev->netname), "")) if (FStrEq(STRING(player->pev->netname), ""))
continue; continue;
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
// ignore spectators // ignore spectators
if (player->m_iTeam != TERRORIST && player->m_iTeam != CT) if (player->m_iTeam != TERRORIST && player->m_iTeam != CT)
continue; continue;
@ -107,19 +105,17 @@ int UTIL_HumansInGame(bool ignoreSpectators)
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex)
{ {
CBaseEntity *entity = UTIL_PlayerByIndex(iIndex); CBasePlayer *player = UTIL_PlayerByIndex(iIndex);
if (entity == NULL) if (player == NULL)
continue; continue;
if (FNullEnt(entity->pev)) if (FNullEnt(player->pev))
continue; continue;
if (FStrEq(STRING(entity->pev->netname), "")) if (FStrEq(STRING(player->pev->netname), ""))
continue; continue;
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
if (player->IsBot()) if (player->IsBot())
continue; continue;
@ -140,19 +136,17 @@ int UTIL_HumansOnTeam(int teamID, bool isAlive)
int iCount = 0; int iCount = 0;
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex)
{ {
CBaseEntity *entity = UTIL_PlayerByIndex(iIndex); CBasePlayer *player = UTIL_PlayerByIndex(iIndex);
if (entity == NULL) if (player == NULL)
continue; continue;
if (FNullEnt(entity->pev)) if (FNullEnt(player->pev))
continue; continue;
if (FStrEq(STRING(entity->pev->netname), "")) if (FStrEq(STRING(player->pev->netname), ""))
continue; continue;
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
if (player->IsBot()) if (player->IsBot())
continue; continue;
@ -174,7 +168,7 @@ int UTIL_BotsInGame()
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(iIndex)); CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex);
if (pPlayer == NULL) if (pPlayer == NULL)
continue; continue;
@ -201,7 +195,7 @@ bool UTIL_KickBotFromTeam(TeamName kickTeam)
// try to kick a dead bot first // try to kick a dead bot first
for (i = 1; i <= gpGlobals->maxClients; ++i) for (i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;
@ -227,7 +221,7 @@ bool UTIL_KickBotFromTeam(TeamName kickTeam)
// no dead bots, kick any bot on the given team // no dead bots, kick any bot on the given team
for (i = 1; i <= gpGlobals->maxClients; ++i) for (i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;
@ -258,7 +252,7 @@ bool UTIL_IsTeamAllBots(int team)
int botCount = 0; int botCount = 0;
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;
@ -290,7 +284,7 @@ extern CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, float *distance)
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!IsEntityValid(player)) if (!IsEntityValid(player))
continue; continue;
@ -321,7 +315,7 @@ extern CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, int team, float *di
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!IsEntityValid(player)) if (!IsEntityValid(player))
continue; continue;
@ -373,7 +367,7 @@ bool UTIL_IsVisibleToTeam(const Vector &spot, int team, float maxRange)
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == NULL) if (player == NULL)
continue; continue;
@ -406,7 +400,7 @@ bool UTIL_IsVisibleToTeam(const Vector &spot, int team, float maxRange)
CBasePlayer *UTIL_GetLocalPlayer() CBasePlayer *UTIL_GetLocalPlayer()
{ {
if (!IS_DEDICATED_SERVER()) if (!IS_DEDICATED_SERVER())
return static_cast<CBasePlayer *>(UTIL_PlayerByIndex(1)); return UTIL_PlayerByIndex(1);
return NULL; return NULL;
} }

View File

@ -154,7 +154,7 @@ bool ForEachPlayer(Functor &func)
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (!IsEntityValid((CBaseEntity *)player)) if (!IsEntityValid((CBaseEntity *)player))
continue; continue;

View File

@ -3277,7 +3277,7 @@ bool IsCrossingLineOfFire(const Vector &start, const Vector &finish, CBaseEntity
{ {
for (int p = 1; p <= gpGlobals->maxClients; ++p) for (int p = 1; p <= gpGlobals->maxClients; ++p)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(p)); CBasePlayer *player = UTIL_PlayerByIndex(p);
if (!IsEntityValid(player)) if (!IsEntityValid(player))
continue; continue;
@ -3424,7 +3424,7 @@ int CNavArea::GetPlayerCount(int teamID, CBasePlayer *ignore) const
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); CBasePlayer *player = UTIL_PlayerByIndex(i);
if (player == ignore) if (player == ignore)
continue; continue;

View File

@ -124,8 +124,8 @@ typedef IVoidHookChainRegistryClass<class CBasePlayer, float, float, float, int>
// CBasePlayer::Observer_IsValidTarget hook // CBasePlayer::Observer_IsValidTarget hook
typedef IHookChain<class CBaseEntity *, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget; typedef IHookChain<class CBasePlayer *, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget;
typedef IHookChainRegistryClass<class CBaseEntity *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; typedef IHookChainRegistryClass<class CBasePlayer *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
// CBasePlayer::SetAnimation hook // CBasePlayer::SetAnimation hook
typedef IVoidHookChain<PLAYER_ANIM> IReGameHook_CBasePlayer_SetAnimation; typedef IVoidHookChain<PLAYER_ANIM> IReGameHook_CBasePlayer_SetAnimation;
@ -376,11 +376,7 @@ public:
}; };
struct ReGameFuncs_t { struct ReGameFuncs_t {
class CBaseEntity *(*UTIL_PlayerByIndex)(int playerIndex); class CBasePlayer *(*UTIL_PlayerByIndex)(int playerIndex);
class ICSPlayer *(*CBASE_TO_CSPLAYER)(class CBaseEntity *pEntity);
class ICSEntity *(*CBASE_TO_CSENTITY)(class CBaseEntity *pEntity);
class ICSPlayer *(*INDEX_TO_CSPLAYER)(int iPlayerIndex);
class ICSEntity *(*INDEX_TO_CSENTITY)(int iEntityIndex);
struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass); struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass);
void (*ChangeString)(char *&dest, const char *source); void (*ChangeString)(char *&dest, const char *source);

File diff suppressed because it is too large Load Diff

View File

@ -5,5 +5,4 @@ void Regamedll_Game_Init()
g_bIsCzeroGame = UTIL_IsGame("czero"); g_bIsCzeroGame = UTIL_IsGame("czero");
g_bAllowedCSBot = UTIL_AreBotsAllowed(); // determine whether bots can be used or not g_bAllowedCSBot = UTIL_AreBotsAllowed(); // determine whether bots can be used or not
g_bHostageImprov = UTIL_AreHostagesImprov(); // determine whether hostage improv can be used or not g_bHostageImprov = UTIL_AreHostagesImprov(); // determine whether hostage improv can be used or not
} }

View File

@ -31,10 +31,6 @@ CReGameHookchains g_ReGameHookchains;
ReGameFuncs_t g_ReGameApiFuncs = { ReGameFuncs_t g_ReGameApiFuncs = {
&UTIL_PlayerByIndex, &UTIL_PlayerByIndex,
&CBASE_TO_CSPLAYER,
&CBASE_TO_CSENTITY,
&INDEX_TO_CSPLAYER,
&INDEX_TO_CSENTITY,
&CREATE_NAMED_ENTITY, &CREATE_NAMED_ENTITY,
&Regamedll_ChangeString_api, &Regamedll_ChangeString_api,

View File

@ -121,8 +121,8 @@ typedef IVoidHookChainRegistryClassImpl<CBasePlayer, float, float, float, int> C
// CBasePlayer::Observer_IsValidTarget hook // CBasePlayer::Observer_IsValidTarget hook
typedef IHookChainClassImpl<CBaseEntity *, CBasePlayer, int, bool> CReGameHook_CBasePlayer_Observer_IsValidTarget; typedef IHookChainClassImpl<CBasePlayer *, CBasePlayer, int, bool> CReGameHook_CBasePlayer_Observer_IsValidTarget;
typedef IHookChainRegistryClassImpl<CBaseEntity *, CBasePlayer, int, bool> CReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; typedef IHookChainRegistryClassImpl<CBasePlayer *, CBasePlayer, int, bool> CReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
// CBasePlayer::SetAnimation hook // CBasePlayer::SetAnimation hook
typedef IVoidHookChainClassImpl<CBasePlayer, PLAYER_ANIM> CReGameHook_CBasePlayer_SetAnimation; typedef IVoidHookChainClassImpl<CBasePlayer, PLAYER_ANIM> CReGameHook_CBasePlayer_SetAnimation;

View File

@ -28,109 +28,25 @@
#include "precompiled.h" #include "precompiled.h"
CCSEntity **g_GameEntities = NULL; void CCSEntity::FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) {
bool g_bInitialized = false; m_pContainingEntity->FireBullets(iShots, vecSrc, vecDirShooting, vecSpread, flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker);
};
ICSEntity::~ICSEntity() {} Vector CCSEntity::FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand) {
return m_pContainingEntity->FireBullets3(vecSrc, vecDirShooting, vecSpread, flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand);
};
void Regamedll_AllocEntities(int maxEdicts) bool CCSPlayer::IsConnected() const { return m_pContainingEntity->has_disconnected == false; }
{ void CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim) { BasePlayer()->SetAnimation(playerAnim); }
if (g_bInitialized) void CCSPlayer::AddAccount(int amount, RewardType type, bool bTrackChange) { BasePlayer()->AddAccount(amount, type, bTrackChange); }
return; void CCSPlayer::GiveNamedItem(const char *pszName) { BasePlayer()->GiveNamedItem(pszName); }
void CCSPlayer::GiveNamedItemEx(const char *pszName) { BasePlayer()->GiveNamedItemEx(pszName); }
g_bInitialized = true; void CCSPlayer::GiveDefaultItems() { BasePlayer()->GiveDefaultItems(); }
g_GameEntities = (CCSEntity **)Q_malloc(sizeof(CCSEntity *) * maxEdicts); void CCSPlayer::GiveShield(bool bDeploy) { BasePlayer()->GiveShield(bDeploy); }
Q_memset(g_GameEntities, 0, sizeof(CCSEntity *) * maxEdicts); void CCSPlayer::DropShield(bool bDeploy) { BasePlayer()->DropShield(bDeploy); }
void CCSPlayer::DropPlayerItem(const char *pszItemName) { BasePlayer()->DropPlayerItem(pszItemName); }
#ifdef _DEBUG void CCSPlayer::RemoveShield() { BasePlayer()->RemoveShield(); }
//CONSOLE_ECHO(__FUNCTION__":: alloc entities!\n"); void CCSPlayer::RemoveAllItems(bool bRemoveSuit) { BasePlayer()->RemoveAllItems(bRemoveSuit ? TRUE : FALSE); }
void CCSPlayer::SetPlayerModel(bool bHasC4) { BasePlayer()->SetPlayerModel(bHasC4 ? TRUE : FALSE); }
ADD_SERVER_COMMAND("check_ent", [](){ void CCSPlayer::SetPlayerModelEx(const char *modelName) { strncpy(m_szModel, modelName, sizeof(m_szModel) - 1); m_szModel[sizeof(m_szModel) - 1] = '\0'; };
Regamedll_MonitorEntities(); void CCSPlayer::SetNewPlayerModel(const char *modelName) { BasePlayer()->SetNewPlayerModel(modelName); }
});
#endif
}
void Regamedll_FreeEntities(CBaseEntity *pEntity)
{
if (pEntity == NULL)
{
for (int i = 0; i < gpGlobals->maxEntities; ++i)
{
delete g_GameEntities[i];
g_GameEntities[i] = NULL;
}
Q_free(g_GameEntities);
g_GameEntities = NULL;
g_bInitialized = false;
return;
}
int index = pEntity->entindex();
if (index < 0 || index > gpGlobals->maxEntities)
return;
delete g_GameEntities[index];
g_GameEntities[index] = NULL;
#ifdef _DEBUG
//CONSOLE_ECHO(__FUNCTION__ ":: Free on (#%d. %s)\n", index, STRING(pEntity->edict()->v.classname));
#endif
}
void Regamedll_MonitorEntities()
{
int nCount = 0;
for (int i = 0; i < gpGlobals->maxEntities; ++i)
{
if (g_GameEntities[i] == NULL)
continue;
++nCount;
}
CONSOLE_ECHO(__FUNCTION__":: nCount: (%d) (%d)\n", nCount, gpGlobals->maxEntities);
}
ICSPlayer *EXT_FUNC CBASE_TO_CSPLAYER(CBaseEntity *pEntity)
{
if (pEntity == NULL)
return NULL;
int index = pEntity->entindex();
if (index < 1 || index > gpGlobals->maxClients)
{
return NULL;
//regamedll_syserror(__FUNCTION__": Invalid player index %d", index);
}
return reinterpret_cast<ICSPlayer *>(g_GameEntities[index]);
}
ICSPlayer *EXT_FUNC INDEX_TO_CSPLAYER(int iPlayerIndex)
{
CBaseEntity *pEntity = UTIL_PlayerByIndex(iPlayerIndex);
return CBASE_TO_CSPLAYER(pEntity);
}
ICSEntity *EXT_FUNC CBASE_TO_CSENTITY(CBaseEntity *pEntity)
{
if (pEntity == NULL)
return NULL;
int index = pEntity->entindex();
if (index < 0 || index > gpGlobals->maxEntities)
{
return NULL;
//regamedll_syserror(__FUNCTION__": Invalid entity index %d", index);
}
return g_GameEntities[index];
}
ICSEntity *EXT_FUNC INDEX_TO_CSENTITY(int iEntityIndex)
{
CBaseEntity *pEntity = CBaseEntity::Instance(INDEXENT(iEntityIndex));
return CBASE_TO_CSENTITY(pEntity);
}

File diff suppressed because it is too large Load Diff