mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-28 15:45:41 +03:00
Refactoring API
This commit is contained in:
parent
905064d44d
commit
06b0c16145
@ -14,19 +14,17 @@ int GetBotFollowCount(CBasePlayer *leader)
|
||||
|
||||
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;
|
||||
|
||||
if (FNullEnt(entity->pev))
|
||||
if (FNullEnt(player->pev))
|
||||
continue;
|
||||
|
||||
if (FStrEq(STRING(entity->pev->netname), ""))
|
||||
if (FStrEq(STRING(player->pev->netname), ""))
|
||||
continue;
|
||||
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
|
||||
|
||||
if (!player->IsBot())
|
||||
continue;
|
||||
|
||||
@ -632,23 +630,21 @@ CBasePlayer *CCSBot::GetImportantEnemy(bool checkVisibility) const
|
||||
|
||||
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;
|
||||
|
||||
if (FNullEnt(entity->pev))
|
||||
if (FNullEnt(player->pev))
|
||||
continue;
|
||||
|
||||
if (FStrEq(STRING(entity->pev->netname), ""))
|
||||
if (FStrEq(STRING(player->pev->netname), ""))
|
||||
continue;
|
||||
|
||||
// is it a player?
|
||||
if (!entity->IsPlayer())
|
||||
if (!player->IsPlayer())
|
||||
continue;
|
||||
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
|
||||
|
||||
// is it alive?
|
||||
if (!player->IsAlive())
|
||||
continue;
|
||||
|
@ -48,7 +48,7 @@ void BotMeme::Transmit(CCSBot *sender) const
|
||||
{
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
@ -1528,7 +1528,7 @@ BotStatement *BotChatterInterface::GetActiveStatement()
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
|
@ -402,7 +402,7 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd)
|
||||
|
||||
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(iIndex));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex);
|
||||
|
||||
if (pPlayer == NULL)
|
||||
continue;
|
||||
@ -434,7 +434,7 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd)
|
||||
|
||||
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(iIndex));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex);
|
||||
|
||||
if (pPlayer == NULL)
|
||||
continue;
|
||||
|
@ -1083,7 +1083,7 @@ bool CCSBot::IsFriendInTheWay(const Vector *goalPos) const
|
||||
// check if any friends are overlapping this linear path
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
|
@ -657,20 +657,18 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
|
||||
{
|
||||
for (i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBaseEntity *entity = UTIL_PlayerByIndex(i);
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (entity == NULL)
|
||||
if (player == NULL)
|
||||
continue;
|
||||
|
||||
if (FNullEnt(entity->pev))
|
||||
if (FNullEnt(player->pev))
|
||||
continue;
|
||||
|
||||
// is it a player?
|
||||
if (!entity->IsPlayer())
|
||||
if (!player->IsPlayer())
|
||||
continue;
|
||||
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
|
||||
|
||||
// ignore self
|
||||
if (player->entindex() == entindex())
|
||||
continue;
|
||||
|
@ -562,7 +562,7 @@ void CCareerTaskManager::HandleDeath(int team, CBasePlayer *pAttacker)
|
||||
|
||||
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())
|
||||
++numEnemies;
|
||||
|
@ -62,7 +62,7 @@ static DLL_FUNCTIONS gFunctionTable =
|
||||
static NEW_DLL_FUNCTIONS gNewDLLFunctions
|
||||
{
|
||||
&OnFreeEntPrivateData,
|
||||
&GameDLLShutdown,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
@ -1082,5 +1082,11 @@ void OnFreeEntPrivateData(edict_t *pEnt)
|
||||
|
||||
pEntity->UpdateOnRemove();
|
||||
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
|
||||
}
|
||||
|
@ -199,6 +199,7 @@ class CBaseMonster;
|
||||
class CBasePlayerItem;
|
||||
class CBasePlayerWeapon;
|
||||
class CSquadMonster;
|
||||
class CCSEntity;
|
||||
|
||||
class CCineMonster;
|
||||
class CSound;
|
||||
@ -364,8 +365,15 @@ public:
|
||||
void (CBaseEntity::*m_pfnUse)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
void (CBaseEntity::*m_pfnBlocked)(CBaseEntity *pOther);
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
CCSEntity *m_pEntity;
|
||||
#endif
|
||||
|
||||
// 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;
|
||||
#endif
|
||||
float currentammo;
|
||||
int maxammo_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
|
||||
// It will allocate the class and entity if necessary
|
||||
template <class TWrap, class T>
|
||||
template <class W, class T>
|
||||
T *GetClassPtr(T *a)
|
||||
{
|
||||
entvars_t *pev = (entvars_t *)a;
|
||||
@ -683,8 +687,9 @@ T *GetClassPtr(T *a)
|
||||
a = new(pev) T;
|
||||
a->pev = pev;
|
||||
|
||||
#ifdef REGAMEDLL_SELF
|
||||
g_GameEntities[a->entindex()] = new TWrap (a);
|
||||
#ifdef REGAMEDLL_ADD
|
||||
a->m_pEntity = new W();
|
||||
a->m_pEntity->m_pContainingEntity = a;
|
||||
#endif
|
||||
|
||||
#if defined(HOOK_GAMEDLL) && defined(_WIN32) && !defined(REGAMEDLL_UNIT_TESTS)
|
||||
@ -695,9 +700,7 @@ T *GetClassPtr(T *a)
|
||||
return a;
|
||||
}
|
||||
|
||||
#ifdef REGAMEDLL_SELF
|
||||
extern CUtlVector<hash_item_t> stringsHashTable;
|
||||
#endif
|
||||
|
||||
C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion);
|
||||
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion);
|
||||
|
@ -3023,7 +3023,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity)
|
||||
|
||||
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))
|
||||
{
|
||||
@ -3049,7 +3049,7 @@ void EXT_FUNC ClientCommand(edict_t *pEntity)
|
||||
|
||||
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))
|
||||
{
|
||||
|
@ -904,7 +904,7 @@ void EXT_FUNC PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars
|
||||
|
||||
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))
|
||||
continue;
|
||||
|
@ -239,8 +239,3 @@ void EXT_FUNC GameDLLInit()
|
||||
Tutor_RegisterCVars();
|
||||
Hostage_RegisterCVars();
|
||||
}
|
||||
|
||||
void EXT_FUNC GameDLLShutdown()
|
||||
{
|
||||
Regamedll_FreeEntities();
|
||||
}
|
||||
|
@ -142,6 +142,5 @@ extern cvar_t roundrespawn_time;
|
||||
#endif
|
||||
|
||||
void GameDLLInit();
|
||||
void GameDLLShutdown();
|
||||
|
||||
#endif // GAME_H
|
||||
|
@ -327,7 +327,7 @@ bool CHostageImprov::__MAKE_VHOOK(IsFriendInTheWay)(const Vector &goalPos) const
|
||||
// check if any CT are overlapping this linear path
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
@ -526,7 +526,7 @@ CBasePlayer *CHostageImprov::__MAKE_VHOOK(IsAnyPlayerLookingAtMe)(int team, floa
|
||||
{
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!IsEntityValid(player))
|
||||
continue;
|
||||
@ -553,7 +553,7 @@ CBasePlayer *CHostageImprov::__MAKE_VHOOK(GetClosestPlayerByTravelDistance)(int
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!IsEntityValid(player))
|
||||
continue;
|
||||
@ -644,7 +644,7 @@ void CHostageImprov::UpdateVision()
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
|
@ -360,40 +360,38 @@ void CGamePlayerZone::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pC
|
||||
if (!CanFireForActivator(pActivator))
|
||||
return;
|
||||
|
||||
CBaseEntity *pPlayer = NULL;
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBaseEntity *pPlayer = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (pPlayer)
|
||||
if (pPlayer == nullptr)
|
||||
continue;
|
||||
|
||||
TraceResult trace;
|
||||
int hullNumber;
|
||||
|
||||
hullNumber = human_hull;
|
||||
if (pPlayer->pev->flags & FL_DUCKING)
|
||||
{
|
||||
TraceResult trace;
|
||||
int hullNumber;
|
||||
hullNumber = head_hull;
|
||||
}
|
||||
|
||||
hullNumber = human_hull;
|
||||
if (pPlayer->pev->flags & FL_DUCKING)
|
||||
UTIL_TraceModel(pPlayer->pev->origin, pPlayer->pev->origin, hullNumber, edict(), &trace);
|
||||
|
||||
if (trace.fStartSolid)
|
||||
{
|
||||
++playersInCount;
|
||||
if (!FStringNull(m_iszInTarget))
|
||||
{
|
||||
hullNumber = head_hull;
|
||||
FireTargets(STRING(m_iszInTarget), pPlayer, pActivator, useType, value);
|
||||
}
|
||||
|
||||
UTIL_TraceModel(pPlayer->pev->origin, pPlayer->pev->origin, hullNumber, edict(), &trace);
|
||||
|
||||
if (trace.fStartSolid)
|
||||
}
|
||||
else
|
||||
{
|
||||
++playersOutCount;
|
||||
if (!FStringNull(m_iszOutTarget))
|
||||
{
|
||||
++playersInCount;
|
||||
if (!FStringNull(m_iszInTarget))
|
||||
{
|
||||
FireTargets(STRING(m_iszInTarget), pPlayer, pActivator, useType, value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++playersOutCount;
|
||||
if (!FStringNull(m_iszOutTarget))
|
||||
{
|
||||
FireTargets(STRING(m_iszOutTarget), pPlayer, pActivator, useType, value);
|
||||
}
|
||||
FireTargets(STRING(m_iszOutTarget), pPlayer, pActivator, useType, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ bool IsBotSpeaking()
|
||||
{
|
||||
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())
|
||||
continue;
|
||||
@ -44,7 +44,7 @@ void SV_Continue_f()
|
||||
|
||||
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())
|
||||
{
|
||||
@ -85,7 +85,7 @@ void SV_Career_EndRound_f()
|
||||
|
||||
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))
|
||||
continue;
|
||||
@ -768,7 +768,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GiveC4)()
|
||||
{
|
||||
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()))
|
||||
continue;
|
||||
@ -850,7 +850,7 @@ void CHalfLifeMultiplay::__API_VHOOK(GiveC4)()
|
||||
|
||||
player->m_bHasC4 = true;
|
||||
player->GiveNamedItem("weapon_c4");
|
||||
player->SetBombIcon(FALSE);
|
||||
player->SetBombIcon();
|
||||
player->pev->body = 1;
|
||||
|
||||
player->m_flDisplayHistory |= DHF_BOMB_RETRIEVED;
|
||||
@ -1132,7 +1132,7 @@ bool CHalfLifeMultiplay::NeededPlayersCheck()
|
||||
{
|
||||
if (IsCareer())
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(gpGlobals->maxClients));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(gpGlobals->maxClients);
|
||||
|
||||
if (!player || !player->IsBot())
|
||||
{
|
||||
@ -1825,7 +1825,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)()
|
||||
// Reset the player stats
|
||||
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))
|
||||
plr->Reset();
|
||||
@ -2528,7 +2528,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)()
|
||||
|
||||
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())
|
||||
{
|
||||
@ -2777,7 +2777,7 @@ void CHalfLifeMultiplay::CheckFreezePeriodExpired()
|
||||
|
||||
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)
|
||||
{
|
||||
@ -3044,7 +3044,7 @@ void CHalfLifeMultiplay::MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int
|
||||
{
|
||||
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))
|
||||
continue;
|
||||
@ -3082,7 +3082,7 @@ void CHalfLifeMultiplay::CareerRestart()
|
||||
|
||||
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))
|
||||
continue;
|
||||
@ -3255,7 +3255,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
|
||||
for (i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
@ -3297,7 +3297,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
|
||||
|
||||
for (i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *plr = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *plr = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (plr != NULL)
|
||||
{
|
||||
@ -4384,9 +4384,8 @@ int CountPlayers()
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBaseEntity *pEnt = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (pEnt != NULL)
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
|
||||
if (pPlayer != NULL)
|
||||
{
|
||||
num = num + 1;
|
||||
}
|
||||
|
@ -19,14 +19,14 @@ int __API_HOOK(GetForceCamera)(CBasePlayer *pObserver)
|
||||
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)
|
||||
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
|
||||
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())
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(pObserver->m_hObserverTarget->entindex()));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(pObserver->m_hObserverTarget->entindex());
|
||||
|
||||
if (pPlayer)
|
||||
{
|
||||
@ -132,7 +132,6 @@ void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name)
|
||||
int iCurrent;
|
||||
int iDir;
|
||||
bool bForceSameTeam;
|
||||
CBasePlayer *pPlayer;
|
||||
|
||||
if (m_flNextFollowTime && m_flNextFollowTime > gpGlobals->time)
|
||||
return;
|
||||
@ -166,8 +165,7 @@ void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name)
|
||||
if (!name)
|
||||
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)))
|
||||
break;
|
||||
}
|
||||
@ -269,7 +267,7 @@ void CBasePlayer::Observer_CheckTarget()
|
||||
if (m_hObserverTarget)
|
||||
{
|
||||
int iPlayerIndex = ENTINDEX(m_hObserverTarget->edict());
|
||||
CBasePlayer *target = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(iPlayerIndex));
|
||||
CBasePlayer *target = UTIL_PlayerByIndex(iPlayerIndex);
|
||||
|
||||
// check taget
|
||||
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
|
||||
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)
|
||||
return;
|
||||
|
@ -363,9 +363,9 @@ void CBasePlayer::SetPlayerModel(BOOL HasC4)
|
||||
char *model;
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
CCSPlayer *pPlayer = CSPlayer(this);
|
||||
if (*pPlayer->m_szModel != '\0') {
|
||||
model = pPlayer->m_szModel;
|
||||
auto& modelEx = CSPlayer()->m_szModel;
|
||||
if (*modelEx != '\0') {
|
||||
model = modelEx;
|
||||
} else
|
||||
#endif
|
||||
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)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!pPlayer)
|
||||
continue;
|
||||
@ -1095,7 +1095,7 @@ int CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pev
|
||||
|
||||
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)
|
||||
continue;
|
||||
@ -1289,7 +1289,7 @@ int CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pev
|
||||
{
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!pPlayer)
|
||||
continue;
|
||||
@ -1332,7 +1332,7 @@ int CBasePlayer::__API_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pev
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!pPlayer)
|
||||
continue;
|
||||
@ -1947,7 +1947,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib)
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!pPlayer)
|
||||
continue;
|
||||
@ -1978,7 +1978,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib)
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *pObserver = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *pObserver = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!pObserver)
|
||||
continue;
|
||||
@ -3325,7 +3325,6 @@ void CBasePlayer::JoiningThink()
|
||||
if (g_pGameRules->FPlayerCanRespawn(this))
|
||||
{
|
||||
Spawn();
|
||||
|
||||
CSGameRules()->CheckWinConditions();
|
||||
|
||||
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)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (pPlayer != NULL && i != index)
|
||||
{
|
||||
@ -5308,7 +5307,7 @@ void CBasePlayer::__API_VHOOK(Spawn)()
|
||||
|
||||
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))
|
||||
{
|
||||
@ -5448,7 +5447,7 @@ void CBasePlayer::SetScoreboardAttributes(CBasePlayer *destination)
|
||||
|
||||
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()))
|
||||
SetScoreboardAttributes(player);
|
||||
@ -7362,7 +7361,6 @@ void CBasePlayer::DropPlayerItem(const char *pszItemName)
|
||||
if (pWeapon->iFlags() & ITEM_FLAG_EXHAUSTIBLE)
|
||||
{
|
||||
int iAmmoIndex = GetAmmoIndex(pWeapon->pszAmmo1());
|
||||
|
||||
if (iAmmoIndex != -1)
|
||||
{
|
||||
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);
|
||||
|
||||
if (modelname != NULL)
|
||||
{
|
||||
SET_MODEL(ENT(pWeaponBox->pev), modelname);
|
||||
@ -9181,7 +9178,7 @@ void CBasePlayer::UpdateLocation(bool forceUpdate)
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!player)
|
||||
continue;
|
||||
|
@ -157,8 +157,7 @@ enum RewardType
|
||||
RT_VIP_KILLED,
|
||||
RT_VIP_RESCUED_MYSELF
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum PLAYER_ANIM
|
||||
{
|
||||
PLAYER_IDLE,
|
||||
PLAYER_WALK,
|
||||
@ -171,10 +170,9 @@ typedef enum
|
||||
PLAYER_LARGE_FLINCH,
|
||||
PLAYER_RELOAD,
|
||||
PLAYER_HOLDBOMB
|
||||
};
|
||||
|
||||
} PLAYER_ANIM;
|
||||
|
||||
typedef enum
|
||||
enum _Menu
|
||||
{
|
||||
Menu_OFF,
|
||||
Menu_ChooseTeam,
|
||||
@ -191,19 +189,18 @@ typedef enum
|
||||
Menu_Radio2,
|
||||
Menu_Radio3,
|
||||
Menu_ClientBuy
|
||||
};
|
||||
|
||||
} _Menu;
|
||||
|
||||
typedef enum
|
||||
enum TeamName
|
||||
{
|
||||
UNASSIGNED,
|
||||
TERRORIST,
|
||||
CT,
|
||||
SPECTATOR,
|
||||
|
||||
} TeamName;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum ModelName
|
||||
{
|
||||
MODEL_UNASSIGNED,
|
||||
MODEL_URBAN,
|
||||
@ -216,11 +213,11 @@ typedef enum
|
||||
MODEL_GUERILLA,
|
||||
MODEL_VIP,
|
||||
MODEL_MILITIA,
|
||||
MODEL_SPETSNAZ
|
||||
MODEL_SPETSNAZ,
|
||||
MODEL_AUTO
|
||||
};
|
||||
|
||||
} ModelName;
|
||||
|
||||
typedef enum
|
||||
enum JoinState
|
||||
{
|
||||
JOINED,
|
||||
SHOWLTEXT,
|
||||
@ -229,9 +226,9 @@ typedef enum
|
||||
PICKINGTEAM,
|
||||
GETINTOGAME
|
||||
|
||||
} JoinState;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum TrackCommands
|
||||
{
|
||||
CMD_SAY = 0,
|
||||
CMD_SAYTEAM,
|
||||
@ -243,9 +240,9 @@ typedef enum
|
||||
CMD_NIGHTVISION,
|
||||
COMMANDS_TO_TRACK,
|
||||
|
||||
} TrackCommands;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct RebuyStruct
|
||||
{
|
||||
int m_primaryWeapon;
|
||||
int m_primaryAmmo;
|
||||
@ -257,10 +254,9 @@ typedef struct
|
||||
int m_defuser;
|
||||
int m_nightVision;
|
||||
int m_armor;
|
||||
};
|
||||
|
||||
} RebuyStruct;
|
||||
|
||||
typedef enum
|
||||
enum ThrowDirection
|
||||
{
|
||||
THROW_NONE,
|
||||
THROW_FORWARD,
|
||||
@ -269,8 +265,7 @@ typedef enum
|
||||
THROW_BOMB,
|
||||
THROW_GRENADE,
|
||||
THROW_HITVEL_MINUS_AIRVEL
|
||||
|
||||
} ThrowDirection;
|
||||
};
|
||||
|
||||
enum sbar_data
|
||||
{
|
||||
@ -282,6 +277,8 @@ enum sbar_data
|
||||
|
||||
enum MusicState { SILENT, CALM, INTENSE };
|
||||
|
||||
class CCSPlayer;
|
||||
|
||||
class CStripWeapons: public CPointEntity {
|
||||
public:
|
||||
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
@ -428,8 +425,8 @@ public:
|
||||
public:
|
||||
void SpawnClientSideCorpse();
|
||||
void Observer_FindNextPlayer(bool bReverse, const char *name = NULL);
|
||||
CBaseEntity *Observer_IsValidTarget(int iPlayerIndex, bool bSameTeam);
|
||||
CBaseEntity *Observer_IsValidTarget_(int iPlayerIndex, bool bSameTeam);
|
||||
CBasePlayer *Observer_IsValidTarget(int iPlayerIndex, bool bSameTeam);
|
||||
CBasePlayer *Observer_IsValidTarget_(int iPlayerIndex, bool bSameTeam);
|
||||
|
||||
void Observer_HandleButtons();
|
||||
void Observer_SetMode(int iMode);
|
||||
@ -555,15 +552,7 @@ public:
|
||||
void GiveShield_(bool bDeploy = true);
|
||||
bool IsHittingShield(Vector &vecDirection, TraceResult *ptr);
|
||||
bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot);
|
||||
bool IsReloading()
|
||||
{
|
||||
CBasePlayerWeapon *weapon = static_cast<CBasePlayerWeapon *>(m_pActiveItem);
|
||||
|
||||
if (weapon != NULL && weapon->m_fInReload)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
bool IsReloading() const;
|
||||
bool IsBlind() const { return (m_blindUntilTime > gpGlobals->time); }
|
||||
bool IsAutoFollowAllowed() const { return (gpGlobals->time > m_allowAutoFollowTime); }
|
||||
void InhibitAutoFollow(float duration) { m_allowAutoFollowTime = gpGlobals->time + duration; }
|
||||
@ -603,6 +592,10 @@ public:
|
||||
//m_musicState = INTENSE;
|
||||
//m_intenseTimestamp = gpGlobals->time;
|
||||
}
|
||||
#ifdef REGAMEDLL_ADD
|
||||
CCSPlayer *CSPlayer() const;
|
||||
#endif
|
||||
|
||||
public:
|
||||
enum { MaxLocationLen = 32 };
|
||||
|
||||
@ -826,6 +819,22 @@ public:
|
||||
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 char g_szMapBriefingText[512];
|
||||
extern entvars_t *g_pevLastInflictor;
|
||||
|
@ -43,7 +43,7 @@ void CHalfLifeTraining::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
|
||||
|
||||
void CHalfLifeTraining::HostageDied()
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(1));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(1);
|
||||
|
||||
if (pPlayer != NULL)
|
||||
{
|
||||
|
@ -1728,7 +1728,7 @@ void CEscapeZone::EscapeTouch(CBaseEntity *pOther)
|
||||
|
||||
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))
|
||||
continue;
|
||||
|
@ -80,7 +80,7 @@ void MonitorTutorStatus()
|
||||
|
||||
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())
|
||||
++numHumans;
|
||||
|
@ -2188,7 +2188,7 @@ void CCSTutor::GetNumPlayersAliveOnTeams(int &numT, int &numCT)
|
||||
|
||||
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())
|
||||
continue;
|
||||
@ -2289,7 +2289,7 @@ void CCSTutor::CheckForBombViewable()
|
||||
|
||||
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)
|
||||
{
|
||||
@ -3016,7 +3016,7 @@ void CCSTutor::ConstructRecentDeathsList(TeamName team, char *buf, int buflen, T
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (pPlayer == NULL)
|
||||
continue;
|
||||
|
@ -522,14 +522,14 @@ CBaseEntity *UTIL_FindEntityGeneric(const char *szWhatever, const Vector &vecSrc
|
||||
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)
|
||||
{
|
||||
edict_t *pPlayerEdict = INDEXENT(playerIndex);
|
||||
if (pPlayerEdict != NULL && !pPlayerEdict->free)
|
||||
pPlayer = CBaseEntity::Instance(pPlayerEdict);
|
||||
pPlayer = (CBasePlayer *)CBaseEntity::Instance(pPlayerEdict);
|
||||
}
|
||||
|
||||
return pPlayer;
|
||||
@ -2283,7 +2283,7 @@ char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd)
|
||||
|
||||
NOXREF int GetPlayerTeam(int index)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(index));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(index);
|
||||
if (pPlayer != NULL)
|
||||
{
|
||||
return pPlayer->m_iTeam;
|
||||
@ -2308,7 +2308,7 @@ bool UTIL_IsGame(const char *gameName)
|
||||
|
||||
float_precision UTIL_GetPlayerGaitYaw(int playerIndex)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(playerIndex));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(playerIndex);
|
||||
if (pPlayer != NULL)
|
||||
{
|
||||
return pPlayer->m_flGaityaw;
|
||||
|
@ -158,12 +158,10 @@ extern globalvars_t *gpGlobals;
|
||||
|
||||
#endif
|
||||
|
||||
#define REGAMEDLL_ALLOC_FUNC
|
||||
#define LINK_ENTITY_TO_CLASS(mapClassName, DLLClassName, DLLClassWrapName)\
|
||||
C_DLLEXPORT void EXT_FUNC mapClassName(entvars_t *pev);\
|
||||
void mapClassName(entvars_t *pev)\
|
||||
{\
|
||||
REGAMEDLL_ALLOC_FUNC\
|
||||
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_FindEntityByTargetname(CBaseEntity *pStartEntity, const char *szName);
|
||||
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_MakeAimVectors(const Vector &vecAngles);
|
||||
void UTIL_MakeInvVectors(const Vector &vec, globalvars_t *pgv);
|
||||
|
@ -410,13 +410,8 @@ void EXT_FUNC ResetGlobalState()
|
||||
gInitHUD = TRUE;
|
||||
}
|
||||
|
||||
#pragma push_macro("REGAMEDLL_ALLOC_FUNC")
|
||||
#define REGAMEDLL_ALLOC_FUNC Regamedll_AllocEntities(gpGlobals->maxEntities);
|
||||
|
||||
LINK_ENTITY_TO_CLASS(worldspawn, CWorld, CCSWorld);
|
||||
|
||||
#pragma pop_macro("REGAMEDLL_ALLOC_FUNC")
|
||||
|
||||
void CWorld::__MAKE_VHOOK(Spawn)()
|
||||
{
|
||||
EmptyEntityHashTable();
|
||||
|
@ -307,7 +307,7 @@ void CC4::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T
|
||||
return;
|
||||
}
|
||||
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(1));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(1);
|
||||
|
||||
if (pPlayer != NULL)
|
||||
{
|
||||
|
@ -37,6 +37,7 @@ class CBaseEntity;
|
||||
class CBaseMonster;
|
||||
class CBasePlayerItem;
|
||||
class CSquadMonster;
|
||||
class CCSEntity;
|
||||
|
||||
class CBaseEntity {
|
||||
public:
|
||||
@ -135,8 +136,9 @@ public:
|
||||
EOFFSET eoffset() { return OFFSET(pev); }
|
||||
int entindex() { return ENTINDEX(edict()); }
|
||||
public:
|
||||
CCSEntity *m_pEntity;
|
||||
|
||||
// We use this variables to store each ammo count.
|
||||
int *current_ammo;
|
||||
float currentammo;
|
||||
int maxammo_buckshot;
|
||||
int ammo_buckshot;
|
||||
|
@ -27,8 +27,6 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//#include "weapons.h"
|
||||
|
||||
#include "pm_materials.h"
|
||||
#include "hintmessage.h"
|
||||
#include "unisignals.h"
|
||||
@ -150,7 +148,7 @@ enum RewardType
|
||||
RT_VIP_RESCUED_MYSELF
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum PLAYER_ANIM
|
||||
{
|
||||
PLAYER_IDLE,
|
||||
PLAYER_WALK,
|
||||
@ -164,9 +162,9 @@ typedef enum
|
||||
PLAYER_RELOAD,
|
||||
PLAYER_HOLDBOMB
|
||||
|
||||
} PLAYER_ANIM;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum _Menu
|
||||
{
|
||||
Menu_OFF,
|
||||
Menu_ChooseTeam,
|
||||
@ -184,18 +182,18 @@ typedef enum
|
||||
Menu_Radio3,
|
||||
Menu_ClientBuy
|
||||
|
||||
} _Menu;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum TeamName
|
||||
{
|
||||
UNASSIGNED,
|
||||
TERRORIST,
|
||||
CT,
|
||||
SPECTATOR,
|
||||
|
||||
} TeamName;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum ModelName
|
||||
{
|
||||
MODEL_UNASSIGNED,
|
||||
MODEL_URBAN,
|
||||
@ -208,11 +206,12 @@ typedef enum
|
||||
MODEL_GUERILLA,
|
||||
MODEL_VIP,
|
||||
MODEL_MILITIA,
|
||||
MODEL_SPETSNAZ
|
||||
MODEL_SPETSNAZ,
|
||||
MODEL_AUTO
|
||||
|
||||
} ModelName;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum JoinState
|
||||
{
|
||||
JOINED,
|
||||
SHOWLTEXT,
|
||||
@ -221,9 +220,9 @@ typedef enum
|
||||
PICKINGTEAM,
|
||||
GETINTOGAME
|
||||
|
||||
} JoinState;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum TrackCommands
|
||||
{
|
||||
CMD_SAY = 0,
|
||||
CMD_SAYTEAM,
|
||||
@ -235,9 +234,9 @@ typedef enum
|
||||
CMD_NIGHTVISION,
|
||||
COMMANDS_TO_TRACK,
|
||||
|
||||
} TrackCommands;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct RebuyStruct
|
||||
{
|
||||
int m_primaryWeapon;
|
||||
int m_primaryAmmo;
|
||||
@ -250,9 +249,9 @@ typedef struct
|
||||
int m_nightVision;
|
||||
int m_armor;
|
||||
|
||||
} RebuyStruct;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum ThrowDirection
|
||||
{
|
||||
THROW_NONE,
|
||||
THROW_FORWARD,
|
||||
@ -262,7 +261,7 @@ typedef enum
|
||||
THROW_GRENADE,
|
||||
THROW_HITVEL_MINUS_AIRVEL
|
||||
|
||||
} ThrowDirection;
|
||||
};
|
||||
|
||||
enum sbar_data
|
||||
{
|
||||
@ -272,13 +271,9 @@ enum sbar_data
|
||||
SBAR_END
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SILENT,
|
||||
CALM,
|
||||
INTENSE
|
||||
enum MusicState { SILENT, CALM, INTENSE };
|
||||
|
||||
} MusicState;
|
||||
class CCSPlayer;
|
||||
|
||||
class CStripWeapons: public CPointEntity {
|
||||
public:
|
||||
@ -356,21 +351,14 @@ public:
|
||||
int IsObserver() { return pev->iuser1; }
|
||||
void SetWeaponAnimType(const char *szExtention) { strcpy(m_szAnimExtention, szExtention); }
|
||||
bool IsProtectedByShield() { return m_bOwnsShield && m_bShieldDrawn; }
|
||||
bool IsReloading()
|
||||
{
|
||||
CBasePlayerWeapon *weapon = static_cast<CBasePlayerWeapon *>(m_pActiveItem);
|
||||
|
||||
if (weapon != NULL && weapon->m_fInReload)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
bool IsReloading() const;
|
||||
bool IsBlind() const { return (m_blindUntilTime > gpGlobals->time); }
|
||||
bool IsAutoFollowAllowed() const { return (gpGlobals->time > m_allowAutoFollowTime); }
|
||||
void InhibitAutoFollow(float duration) { m_allowAutoFollowTime = gpGlobals->time + duration; }
|
||||
void AllowAutoFollow() { m_allowAutoFollowTime = 0; }
|
||||
void SetObserverAutoDirector(bool val) { m_bObserverAutoDirector = val; }
|
||||
bool CanSwitchObserverModes() const { return m_canSwitchObserverModes; }
|
||||
CCSPlayer *CSPlayer() const;
|
||||
public:
|
||||
enum { MaxLocationLen = 32 };
|
||||
|
||||
@ -574,3 +562,17 @@ public:
|
||||
EHANDLE m_hEntToIgnoreTouchesFrom;
|
||||
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);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "hookchains.h"
|
||||
#include "interface.h"
|
||||
|
||||
#define REGAMEDLL_API_VERSION_MAJOR 1
|
||||
#define REGAMEDLL_API_VERSION_MAJOR 2
|
||||
#define REGAMEDLL_API_VERSION_MINOR 1
|
||||
|
||||
// CBasePlayer::Spawn hook
|
||||
@ -124,8 +124,8 @@ typedef IVoidHookChainRegistryClass<class CBasePlayer, float, float, float, int>
|
||||
|
||||
|
||||
// CBasePlayer::Observer_IsValidTarget hook
|
||||
typedef IHookChain<class CBaseEntity *, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget;
|
||||
typedef IHookChainRegistryClass<class CBaseEntity *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
|
||||
typedef IHookChain<class CBasePlayer *, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget;
|
||||
typedef IHookChainRegistryClass<class CBasePlayer *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
|
||||
|
||||
// CBasePlayer::SetAnimation hook
|
||||
typedef IVoidHookChain<PLAYER_ANIM> IReGameHook_CBasePlayer_SetAnimation;
|
||||
@ -376,11 +376,7 @@ public:
|
||||
};
|
||||
|
||||
struct ReGameFuncs_t {
|
||||
class CBaseEntity *(*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);
|
||||
class CBasePlayer *(*UTIL_PlayerByIndex)(int playerIndex);
|
||||
struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass);
|
||||
|
||||
void (*ChangeString)(char *&dest, const char *source);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -193,7 +193,7 @@ void CBotManager::__MAKE_VHOOK(StartFrame)()
|
||||
// Process each active bot
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!pPlayer)
|
||||
continue;
|
||||
@ -222,7 +222,7 @@ void CBotManager::__MAKE_VHOOK(OnEvent)(GameEventType event, CBaseEntity *entity
|
||||
// propogate event to all bots
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
|
@ -75,19 +75,17 @@ int UTIL_ActivePlayersInGame()
|
||||
int iCount = 0;
|
||||
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;
|
||||
|
||||
if (FNullEnt(entity->pev))
|
||||
if (FNullEnt(player->pev))
|
||||
continue;
|
||||
|
||||
if (FStrEq(STRING(entity->pev->netname), ""))
|
||||
if (FStrEq(STRING(player->pev->netname), ""))
|
||||
continue;
|
||||
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
|
||||
|
||||
// ignore spectators
|
||||
if (player->m_iTeam != TERRORIST && player->m_iTeam != CT)
|
||||
continue;
|
||||
@ -107,19 +105,17 @@ int UTIL_HumansInGame(bool ignoreSpectators)
|
||||
|
||||
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;
|
||||
|
||||
if (FNullEnt(entity->pev))
|
||||
if (FNullEnt(player->pev))
|
||||
continue;
|
||||
|
||||
if (FStrEq(STRING(entity->pev->netname), ""))
|
||||
if (FStrEq(STRING(player->pev->netname), ""))
|
||||
continue;
|
||||
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
|
||||
|
||||
if (player->IsBot())
|
||||
continue;
|
||||
|
||||
@ -140,19 +136,17 @@ int UTIL_HumansOnTeam(int teamID, bool isAlive)
|
||||
int iCount = 0;
|
||||
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;
|
||||
|
||||
if (FNullEnt(entity->pev))
|
||||
if (FNullEnt(player->pev))
|
||||
continue;
|
||||
|
||||
if (FStrEq(STRING(entity->pev->netname), ""))
|
||||
if (FStrEq(STRING(player->pev->netname), ""))
|
||||
continue;
|
||||
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(entity);
|
||||
|
||||
if (player->IsBot())
|
||||
continue;
|
||||
|
||||
@ -174,7 +168,7 @@ int UTIL_BotsInGame()
|
||||
|
||||
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex)
|
||||
{
|
||||
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(iIndex));
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex);
|
||||
|
||||
if (pPlayer == NULL)
|
||||
continue;
|
||||
@ -201,7 +195,7 @@ bool UTIL_KickBotFromTeam(TeamName kickTeam)
|
||||
// try to kick a dead bot first
|
||||
for (i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
@ -227,7 +221,7 @@ bool UTIL_KickBotFromTeam(TeamName kickTeam)
|
||||
// no dead bots, kick any bot on the given team
|
||||
for (i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
@ -258,7 +252,7 @@ bool UTIL_IsTeamAllBots(int team)
|
||||
int botCount = 0;
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
@ -290,7 +284,7 @@ extern CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, float *distance)
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!IsEntityValid(player))
|
||||
continue;
|
||||
@ -321,7 +315,7 @@ extern CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, int team, float *di
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (!IsEntityValid(player))
|
||||
continue;
|
||||
@ -373,7 +367,7 @@ bool UTIL_IsVisibleToTeam(const Vector &spot, int team, float maxRange)
|
||||
{
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
continue;
|
||||
@ -406,7 +400,7 @@ bool UTIL_IsVisibleToTeam(const Vector &spot, int team, float maxRange)
|
||||
CBasePlayer *UTIL_GetLocalPlayer()
|
||||
{
|
||||
if (!IS_DEDICATED_SERVER())
|
||||
return static_cast<CBasePlayer *>(UTIL_PlayerByIndex(1));
|
||||
return UTIL_PlayerByIndex(1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ bool ForEachPlayer(Functor &func)
|
||||
{
|
||||
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))
|
||||
continue;
|
||||
|
||||
|
@ -3277,7 +3277,7 @@ bool IsCrossingLineOfFire(const Vector &start, const Vector &finish, CBaseEntity
|
||||
{
|
||||
for (int p = 1; p <= gpGlobals->maxClients; ++p)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(p));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(p);
|
||||
|
||||
if (!IsEntityValid(player))
|
||||
continue;
|
||||
@ -3424,7 +3424,7 @@ int CNavArea::GetPlayerCount(int teamID, CBasePlayer *ignore) const
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
|
||||
CBasePlayer *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == ignore)
|
||||
continue;
|
||||
|
@ -124,8 +124,8 @@ typedef IVoidHookChainRegistryClass<class CBasePlayer, float, float, float, int>
|
||||
|
||||
|
||||
// CBasePlayer::Observer_IsValidTarget hook
|
||||
typedef IHookChain<class CBaseEntity *, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget;
|
||||
typedef IHookChainRegistryClass<class CBaseEntity *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
|
||||
typedef IHookChain<class CBasePlayer *, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget;
|
||||
typedef IHookChainRegistryClass<class CBasePlayer *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
|
||||
|
||||
// CBasePlayer::SetAnimation hook
|
||||
typedef IVoidHookChain<PLAYER_ANIM> IReGameHook_CBasePlayer_SetAnimation;
|
||||
@ -376,11 +376,7 @@ public:
|
||||
};
|
||||
|
||||
struct ReGameFuncs_t {
|
||||
class CBaseEntity *(*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);
|
||||
class CBasePlayer *(*UTIL_PlayerByIndex)(int playerIndex);
|
||||
struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass);
|
||||
|
||||
void (*ChangeString)(char *&dest, const char *source);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,5 +5,4 @@ void Regamedll_Game_Init()
|
||||
g_bIsCzeroGame = UTIL_IsGame("czero");
|
||||
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
|
||||
|
||||
}
|
||||
|
@ -31,10 +31,6 @@ CReGameHookchains g_ReGameHookchains;
|
||||
|
||||
ReGameFuncs_t g_ReGameApiFuncs = {
|
||||
&UTIL_PlayerByIndex,
|
||||
&CBASE_TO_CSPLAYER,
|
||||
&CBASE_TO_CSENTITY,
|
||||
&INDEX_TO_CSPLAYER,
|
||||
&INDEX_TO_CSENTITY,
|
||||
&CREATE_NAMED_ENTITY,
|
||||
|
||||
&Regamedll_ChangeString_api,
|
||||
|
@ -121,8 +121,8 @@ typedef IVoidHookChainRegistryClassImpl<CBasePlayer, float, float, float, int> C
|
||||
|
||||
|
||||
// CBasePlayer::Observer_IsValidTarget hook
|
||||
typedef IHookChainClassImpl<CBaseEntity *, CBasePlayer, int, bool> CReGameHook_CBasePlayer_Observer_IsValidTarget;
|
||||
typedef IHookChainRegistryClassImpl<CBaseEntity *, CBasePlayer, int, bool> CReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
|
||||
typedef IHookChainClassImpl<CBasePlayer *, CBasePlayer, int, bool> CReGameHook_CBasePlayer_Observer_IsValidTarget;
|
||||
typedef IHookChainRegistryClassImpl<CBasePlayer *, CBasePlayer, int, bool> CReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
|
||||
|
||||
// CBasePlayer::SetAnimation hook
|
||||
typedef IVoidHookChainClassImpl<CBasePlayer, PLAYER_ANIM> CReGameHook_CBasePlayer_SetAnimation;
|
||||
|
@ -28,109 +28,25 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
CCSEntity **g_GameEntities = NULL;
|
||||
bool g_bInitialized = false;
|
||||
void CCSEntity::FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) {
|
||||
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)
|
||||
{
|
||||
if (g_bInitialized)
|
||||
return;
|
||||
|
||||
g_bInitialized = true;
|
||||
g_GameEntities = (CCSEntity **)Q_malloc(sizeof(CCSEntity *) * maxEdicts);
|
||||
Q_memset(g_GameEntities, 0, sizeof(CCSEntity *) * maxEdicts);
|
||||
|
||||
#ifdef _DEBUG
|
||||
//CONSOLE_ECHO(__FUNCTION__":: alloc entities!\n");
|
||||
|
||||
ADD_SERVER_COMMAND("check_ent", [](){
|
||||
Regamedll_MonitorEntities();
|
||||
});
|
||||
#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);
|
||||
}
|
||||
bool CCSPlayer::IsConnected() const { return m_pContainingEntity->has_disconnected == false; }
|
||||
void CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim) { BasePlayer()->SetAnimation(playerAnim); }
|
||||
void CCSPlayer::AddAccount(int amount, RewardType type, bool bTrackChange) { BasePlayer()->AddAccount(amount, type, bTrackChange); }
|
||||
void CCSPlayer::GiveNamedItem(const char *pszName) { BasePlayer()->GiveNamedItem(pszName); }
|
||||
void CCSPlayer::GiveNamedItemEx(const char *pszName) { BasePlayer()->GiveNamedItemEx(pszName); }
|
||||
void CCSPlayer::GiveDefaultItems() { BasePlayer()->GiveDefaultItems(); }
|
||||
void CCSPlayer::GiveShield(bool bDeploy) { BasePlayer()->GiveShield(bDeploy); }
|
||||
void CCSPlayer::DropShield(bool bDeploy) { BasePlayer()->DropShield(bDeploy); }
|
||||
void CCSPlayer::DropPlayerItem(const char *pszItemName) { BasePlayer()->DropPlayerItem(pszItemName); }
|
||||
void CCSPlayer::RemoveShield() { BasePlayer()->RemoveShield(); }
|
||||
void CCSPlayer::RemoveAllItems(bool bRemoveSuit) { BasePlayer()->RemoveAllItems(bRemoveSuit ? TRUE : FALSE); }
|
||||
void CCSPlayer::SetPlayerModel(bool bHasC4) { BasePlayer()->SetPlayerModel(bHasC4 ? TRUE : FALSE); }
|
||||
void CCSPlayer::SetPlayerModelEx(const char *modelName) { strncpy(m_szModel, modelName, sizeof(m_szModel) - 1); m_szModel[sizeof(m_szModel) - 1] = '\0'; };
|
||||
void CCSPlayer::SetNewPlayerModel(const char *modelName) { BasePlayer()->SetNewPlayerModel(modelName); }
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user