当前位置: 首页>>代码示例>>C++>>正文


C++ IServerUnknown::GetBaseEntity方法代码示例

本文整理汇总了C++中IServerUnknown::GetBaseEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ IServerUnknown::GetBaseEntity方法的具体用法?C++ IServerUnknown::GetBaseEntity怎么用?C++ IServerUnknown::GetBaseEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServerUnknown的用法示例。


在下文中一共展示了IServerUnknown::GetBaseEntity方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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; 

}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:35,代码来源:entitylist.cpp

示例2: if

/* 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();
}
开发者ID:Anime4000,项目名称:Left4Downtown2,代码行数:30,代码来源:util.cpp

示例3: OnClientPutInServer

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);
}
开发者ID:KyleSanderson,项目名称:SourceMod,代码行数:28,代码来源:hooks.cpp

示例4: LookupEntity

CBaseEntity *GetBaseEntity(int index)
{
	IServerUnknown *pUnknown = LookupEntity(index);
	if(pUnknown == NULL)
		return NULL;

	return pUnknown->GetBaseEntity();
}
开发者ID:MerlinStarfinder,项目名称:gmodmodules,代码行数:8,代码来源:gm_pimpmyride.cpp

示例5:

	CBaseEntity *EdictToBaseEntity( edict_t *pEdict )
	{
		if (pEdict)
		{
			IServerUnknown *pUnk = pEdict->GetUnknown();
			if (pUnk)
			{
				return pUnk->GetBaseEntity();
			}
		}
		return nullptr;
	}
开发者ID:SizzlingStats,项目名称:sizzlingplugins,代码行数:12,代码来源:SC_helpers.cpp

示例6: 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;
}
开发者ID:dsezen,项目名称:Source.Python,代码行数:15,代码来源:baseentity_from.cpp

示例7: 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;
}
开发者ID:imyzcn,项目名称:mani-admin-plugin,代码行数:50,代码来源:mani_reservedslot.cpp

示例8: GetLifeState

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;
	}
}
开发者ID:Nephyrin,项目名称:-furry-octo-nemesis,代码行数:41,代码来源:PlayerManager.cpp

示例9: 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;
}
开发者ID:404UserNotFound,项目名称:sourcemod,代码行数:40,代码来源:HalfLife2.cpp

示例10: 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);
}
开发者ID:404UserNotFound,项目名称:sourcemod,代码行数:22,代码来源:HalfLife2.cpp

示例11:

IServerEntity *CServerTools::GetIServerEntity( IClientEntity *pClientEntity )
{
	if ( pClientEntity == NULL )
		return NULL;

	CBaseHandle ehandle = pClientEntity->GetRefEHandle();
	if ( ehandle.GetEntryIndex() >= MAX_EDICTS )
		return NULL; // the first MAX_EDICTS entities are networked, the rest are client or server only

#if 0
	// this fails, since the server entities have extra bits in their serial numbers,
	// since 20 bits are reserved for serial numbers, except for networked entities, which are restricted to 10

	// Brian believes that everything should just restrict itself to 10 to make things simpler,
	// so if/when he changes NUM_SERIAL_NUM_BITS to 10, we can switch back to this simpler code

	IServerNetworkable *pNet = gEntList.GetServerNetworkable( ehandle );
	if ( pNet == NULL )
		return NULL;

	CBaseEntity *pServerEnt = pNet->GetBaseEntity();
	return pServerEnt;
#else
	IHandleEntity *pEnt = gEntList.LookupEntityByNetworkIndex( ehandle.GetEntryIndex() );
	if ( pEnt == NULL )
		return NULL;

	CBaseHandle h = gEntList.GetNetworkableHandle( ehandle.GetEntryIndex() );
	const int mask = ( 1 << NUM_NETWORKED_EHANDLE_SERIAL_NUMBER_BITS ) - 1;
	if ( !h.IsValid() || ( ( h.GetSerialNumber() & mask ) != ( ehandle.GetSerialNumber() & mask ) ) )
		return NULL;

	IServerUnknown *pUnk = static_cast< IServerUnknown* >( pEnt );
	return pUnk->GetBaseEntity();
#endif
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:36,代码来源:entity_tools_server.cpp

示例12: DecodeValveParam


//.........这里部分代码省略.........
					pContext->ThrowNativeError("Client %d is not in game", param);
					return Data_Fail;
				}
				pEdict = player->GetEdict();
			} else if (param == -1) {
				if (data->decflags & VDECODE_FLAG_ALLOWNULL)
				{
					pEdict = NULL;
				} else {
					pContext->ThrowNativeError("NULL not allowed");
					return Data_Fail;
				}
			} else if (param == 0) {
				if (data->decflags & VDECODE_FLAG_ALLOWWORLD)
				{
					pEdict = engine->PEntityOfEntIndex(0);
				} else {
					pContext->ThrowNativeError("World not allowed");
					return Data_Fail;
				}
			} else {
				pContext->ThrowNativeError("Entity index %d is not a valid client", param);
				return Data_Fail;
			}
			CBaseEntity *pEntity = NULL;
			if (pEdict)
			{
				IServerUnknown *pUnknown = pEdict->GetUnknown();
				if (!pUnknown)
				{
					pContext->ThrowNativeError("Entity %d is a not an IServerUnknown", param);
					return Data_Fail;
				}
				pEntity = pUnknown->GetBaseEntity();
				if (!pEntity)
				{
					pContext->ThrowNativeError("Entity %d is not a CBaseEntity", param);
					return Data_Fail;
				}
			}

			CBaseEntity **ebuf = (CBaseEntity **)buffer;
			*ebuf = pEntity;

			return Data_Okay;
		}
	case Valve_CBaseEntity:
		{
			edict_t *pEdict;
			if (data->decflags & VDECODE_FLAG_BYREF)
			{
				cell_t *addr;
				pContext->LocalToPhysAddr(param, &addr);
				param = *addr;
			}
			if (param >= 1 && param <= playerhelpers->GetMaxClients())
			{
				IGamePlayer *player = playerhelpers->GetGamePlayer(param);
				if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
					&& !player->IsConnected())
				{
					pContext->ThrowNativeError("Client %d is not connected", param);
					return Data_Fail;
				} else if (!player->IsInGame()) {
					pContext->ThrowNativeError("Client %d is not in game", param);
					return Data_Fail;
开发者ID:Nephyrin,项目名称:-furry-octo-nemesis,代码行数:67,代码来源:vdecoder.cpp


注:本文中的IServerUnknown::GetBaseEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。