本文整理汇总了C++中IServerUnknown类的典型用法代码示例。如果您正苦于以下问题:C++ IServerUnknown类的具体用法?C++ IServerUnknown怎么用?C++ IServerUnknown使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IServerUnknown类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FirstEntInfo
CBaseEntity *CGlobalEntityList::NextEnt( CBaseEntity *pCurrentEnt )
{
if ( !pCurrentEnt )
{
const CEntInfo *pInfo = FirstEntInfo();
if ( !pInfo )
return NULL;
return (CBaseEntity *)pInfo->m_pEntity;
}
// Run through the list until we get a CBaseEntity.
const CEntInfo *pList = GetEntInfoPtr( pCurrentEnt->GetRefEHandle() );
if ( pList )
pList = NextEntInfo(pList);
while ( pList )
{
#if 0
if ( pList->m_pEntity )
{
IServerUnknown *pUnk = static_cast<IServerUnknown*>(const_cast<IHandleEntity*>(pList->m_pEntity));
CBaseEntity *pRet = pUnk->GetBaseEntity();
if ( pRet )
return pRet;
}
#else
return (CBaseEntity *)pList->m_pEntity;
#endif
pList = pList->m_pNext;
}
return NULL;
}
示例2: PEntityOfEntIndex
void CHookManager::OnClientPutInServer(int client)
{
if (!PRCH_enabled)
return;
if (!PRCH_used)
return;
edict_t *pEdict = PEntityOfEntIndex(client);
if (!pEdict)
{
return;
}
IServerUnknown *pUnknown = pEdict->GetUnknown();
if (!pUnknown)
{
return;
}
CBaseEntity *pEntity = pUnknown->GetBaseEntity();
if (!pEntity)
{
return;
}
SH_ADD_MANUALHOOK(PlayerRunCmdHook, pEntity, SH_MEMBER(this, &CHookManager::PlayerRunCmd), false);
}
示例3: PEntityOfEntIndex
/* Taken from Sourcemod Tf2 Extension */
CBaseEntity *UTIL_GetCBaseEntity(int num, bool onlyPlayers)
{
edict_t *pEdict = PEntityOfEntIndex(num);
if (!pEdict || pEdict->IsFree())
{
return NULL;
}
if (num > 0 && num <= playerhelpers->GetMaxClients())
{
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(pEdict);
if (!pPlayer || !pPlayer->IsConnected())
{
return NULL;
}
}
else if (onlyPlayers)
{
return NULL;
}
IServerUnknown *pUnk;
if ((pUnk=pEdict->GetUnknown()) == NULL)
{
return NULL;
}
return pUnk->GetBaseEntity();
}
示例4: LookupEntity
CBaseEntity *GetBaseEntity(int index)
{
IServerUnknown *pUnknown = LookupEntity(index);
if(pUnknown == NULL)
return NULL;
return pUnknown->GetBaseEntity();
}
示例5:
inline edict_t *BaseEntityToEdict(CBaseEntity *pEntity) {
IServerUnknown *pUnk = (IServerUnknown *)pEntity;
IServerNetworkable *pNet = pUnk->GetNetworkable();
if(!pNet)
return NULL;
return pNet->GetEdict();
}
示例6: OnEntityCreated
void CSourcePython::OnEntityCreated( CBaseEntity *pEntity )
{
edict_t *pEdict;
if (EdictFromBaseEntity(pEntity, pEdict)) {
IServerUnknown* pServerUnknown = pEdict->GetUnknown();
if (pServerUnknown)
pEdict->m_pNetworkable = pServerUnknown->GetNetworkable();
}
CALL_LISTENERS(OnEntityCreated, ptr((CBaseEntityWrapper*) pEntity));
}
示例7: IndexFromBaseEntity
void CSourcePython::OnEntityCreated( CBaseEntity *pEntity )
{
int iIndex = IndexFromBaseEntity(pEntity);
edict_t *pEdict = EdictFromIndex(iIndex);
if (pEdict)
{
IServerUnknown* pServerUnknown = pEdict->GetUnknown();
if (pServerUnknown)
pEdict->m_pNetworkable = pServerUnknown->GetNetworkable();
}
CALL_LISTENERS(OnEntityCreated, iIndex, ptr((CBaseEntityWrapper*) pEntity));
}
示例8: BaseEntityFromEdict
//-----------------------------------------------------------------------------
// Returns a BaseEntity instance from the given Edict instance.
//-----------------------------------------------------------------------------
bool BaseEntityFromEdict( edict_t *pEdict, CBaseEntity*& output )
{
if (!pEdict || pEdict->IsFree())
return false;
IServerUnknown *pServerUnknown = pEdict->GetUnknown();
if (!pServerUnknown)
return false;
output = pServerUnknown->GetBaseEntity();
return true;
}
示例9:
CBaseEntity *EdictToBaseEntity( edict_t *pEdict )
{
if (pEdict)
{
IServerUnknown *pUnk = pEdict->GetUnknown();
if (pUnk)
{
return pUnk->GetBaseEntity();
}
}
return nullptr;
}
示例10: GetEntityWrapper
SMJS_Entity* GetEntityWrapper(CBaseEntity *pEntity){
if(pEntity == NULL) return NULL;
auto ref = gamehelpers->EntityToReference(pEntity);
auto it = refs.find(ref);
if(it != refs.end()) return it->second;
IServerUnknown *pUnk = (IServerUnknown *)pEntity;
IServerNetworkable *pNet = pUnk->GetNetworkable();
SMJS_Entity *wrapper = new SMJS_Entity(pEntity);
refs.insert(std::make_pair(ref, wrapper));
return wrapper;
}
示例11: defined
int ManiReservedSlot::FindPlayerToKick ( ) {
// FIRST LOOK FOR BOTS!
for ( int i = 1; i <= max_players; i++ ) {
#if defined ( GAME_CSGO )
edict_t *pEdict = PEntityOfEntIndex(i);
#else
edict_t *pEdict = engine->PEntityOfEntIndex(i);
#endif
IServerUnknown *unknown = pEdict->GetUnknown();
if (!unknown)
continue;
CBaseEntity *base = unknown->GetBaseEntity();
if (!base)
continue;
IPlayerInfo *pi_player = playerinfomanager->GetPlayerInfo( pEdict );
if ( !pi_player )
continue;
if ( FStrEq(pi_player->GetNetworkIDString(), "BOT") )
return i;
}
BuildPlayerKickList();
if ( active_player_list_size == 0 )
return 0;
int KickMethod = mani_reserve_slots_kick_method.GetInt();
//0 = by ping
//1 = by connection time
//2 = by kills per minute
//3 = kill/death ratio
if ( KickMethod == 0 ) {
qsort(active_player_list, active_player_list_size, sizeof(active_player_t), sort_active_players_by_ping);
} else if ( KickMethod == 1 ) {
qsort(active_player_list, active_player_list_size, sizeof(active_player_t), sort_active_players_by_connect_time);
} else if ( KickMethod == 2 ) {
qsort(active_player_list, active_player_list_size, sizeof(active_player_t), sort_active_players_by_kill_rate);
} else if ( KickMethod == 3 ) {
qsort(active_player_list, active_player_list_size, sizeof(active_player_t), sort_active_players_by_kd_ratio);
}
return active_player_list[0].index;
}
示例12: GetPlayerInfo
int CPlayer::GetLifeState()
{
if (lifestate_offset == -1)
{
if (!g_pGameConf->GetOffset("m_lifeState", &lifestate_offset))
{
lifestate_offset = -2;
}
}
if (lifestate_offset < 0)
{
IPlayerInfo *info = GetPlayerInfo();
if (info == NULL)
{
return PLAYER_LIFE_UNKNOWN;
}
return info->IsDead() ? PLAYER_LIFE_DEAD : PLAYER_LIFE_ALIVE;
}
if (m_pEdict == NULL)
{
return PLAYER_LIFE_UNKNOWN;
}
CBaseEntity *pEntity;
IServerUnknown *pUnknown = m_pEdict->GetUnknown();
if (pUnknown == NULL || (pEntity = pUnknown->GetBaseEntity()) == NULL)
{
return PLAYER_LIFE_UNKNOWN;
}
if (*((uint8_t *)pEntity + lifestate_offset) == LIFE_ALIVE)
{
return PLAYER_LIFE_ALIVE;
}
else
{
return PLAYER_LIFE_DEAD;
}
}
示例13: hndl
CBaseEntity *CHalfLife2::ReferenceToEntity(cell_t entRef)
{
if ((unsigned)entRef == INVALID_EHANDLE_INDEX)
{
return NULL;
}
CEntInfo *pInfo = NULL;
if (entRef & (1<<31))
{
/* Proper ent reference */
int hndlValue = entRef & ~(1<<31);
CBaseHandle hndl(hndlValue);
pInfo = LookupEntity(hndl.GetEntryIndex());
if (!pInfo || pInfo->m_SerialNumber != hndl.GetSerialNumber())
{
return NULL;
}
}
else
{
/* Old style index only */
pInfo = LookupEntity(entRef);
}
if (!pInfo)
{
return NULL;
}
IServerUnknown *pUnk = static_cast<IServerUnknown *>(pInfo->m_pEntity);
if (pUnk)
{
return pUnk->GetBaseEntity();
}
return NULL;
}
示例14: GetEntityClassname
const char *CHalfLife2::GetEntityClassname(edict_t * pEdict)
{
if (pEdict == NULL || pEdict->IsFree())
{
return NULL;
}
IServerUnknown *pUnk = pEdict->GetUnknown();
if (pUnk == NULL)
{
return NULL;
}
CBaseEntity * pEntity = pUnk->GetBaseEntity();
if (pEntity == NULL)
{
return NULL;
}
return GetEntityClassname(pEntity);
}
示例15: EntInfoArray
/**
* Retrieves the CEntInfo pointer from g_EntList for a given entity index
*/
CEntInfo *CHalfLife2::LookupEntity(int entIndex)
{
// Make sure that our index is within the bounds of the global ent array
if (entIndex < 0 || entIndex >= NUM_ENT_ENTRIES)
{
return NULL;
}
CEntInfo *entInfos = EntInfoArray();
if (!entInfos)
{
/* Attempt to use engine interface instead */
static CEntInfo tempInfo;
tempInfo.m_pNext = NULL;
tempInfo.m_pPrev = NULL;
edict_t *pEdict = PEntityOfEntIndex(entIndex);
if (!pEdict)
{
return NULL;
}
IServerUnknown *pUnk = pEdict->GetUnknown();
if (!pUnk)
{
return NULL;
}
tempInfo.m_pEntity = pUnk;
tempInfo.m_SerialNumber = pUnk->GetRefEHandle().GetSerialNumber();
return &tempInfo;
}
return &entInfos[entIndex];
}