コード例 #1
0
/*-------------------------------------------------------------------------
 * DestroyAllSessions()
 *-------------------------------------------------------------------------
 * Purpose:
 *    Kill all active (and hosed) sessions
 *
 */
/* static*/void  CAdminSession::DestroyAllSessions()
{
	int cSessions;
	while (cSessions = GetSessionCount()) // Intentional assignment
	{
		// Keep a reference while disconnecting object
		CAdminSession* pSession = GetLastSession();
		IUnknownPtr spUnk(pSession);

		// Disconnect all external references
		if (NULL != spUnk)
			::CoDisconnectObject(spUnk, 0);

		// Release the IUnknown
		spUnk = NULL;

		// That /should/ have forced a deletion. If not, remove from list
		XLockStatic lock(&s_cs);
		if (GetSessionCount() == cSessions)
		{
			XSessionsIt it = std::find(s_vecSessions.begin(), s_vecSessions.end(), pSession);
			assert(it != s_vecSessions.end());
			s_vecSessions.erase(it);
		}
	}
}
コード例 #2
0
ファイル: World.cpp プロジェクト: DeaDSandro/shadowfade
void World::UnregisterObject(uint32 Id, PlayerSession *Reg)
{
	stdext::hash_map<uint32, WorldObject*>::iterator itr = Registrated_Objects.find(Id);

	if(itr != Registrated_Objects.end())
	{
		delete itr->second;
		Registrated_Objects.erase(itr);
	}
	
	if(GetSessionCount() > 1)
	{
		Reg->GetPlayer()->UpdateInRangePlayers();

		if(Reg->GetPlayer()->m_inRangePlayers.size())
		{
			for(set<Player*>::iterator itr = Reg->GetPlayer()->m_inRangePlayers.begin(); itr != Reg->GetPlayer()->m_inRangePlayers.end(); ++itr)
			{
				WorldPacket wp(SMSG_OBJECT_UNREGISTER,4);
				wp << Id;
				(*itr)->GetSession()->SendPacket(&wp);
			}
		}
	}
}
コード例 #3
0
/*-------------------------------------------------------------------------
 * ~CAdminSession()
 *-------------------------------------------------------------------------
 */
CAdminSession::~CAdminSession()
{
	XLockStatic lock(&s_cs);
	if (this == s_pWhoStartedServer)
		s_pWhoStartedServer = NULL;

	// Remove ourself from the static collection
	XSessionsIt it = std::find(s_vecSessions.begin(), s_vecSessions.end(), this);
	if (it != s_vecSessions.end())
		s_vecSessions.erase(it);
	lock.Unlock();

#if defined(ALLSRV_STANDALONE)
	// Possibly shutdown the standalone server if no more sessions
	if (0 == GetSessionCount())
	{
		// Get the Server property
		IAdminServerPtr spServer;
		if (SUCCEEDED(get_Server(&spServer)))
		{
			IAdminGamesPtr spGames;
			if (SUCCEEDED(spServer->get_Games(&spGames)))
			{
				// Shutdown the server if no games exist
				long cGames = 0;
				spGames->get_Count(&cGames);
				// KGJV #114 - if lobbied then dont shutdown if create game allowed on this server
				bool bSupposedToConnectToLobby = !(FEDSRV_GUID != g.fm.GetHostApplicationGuid());
				if ((0 == cGames) && (bSupposedToConnectToLobby ? (g.cStaticCoreInfo == 0) : true))
					PostThreadMessage(g.idReceiveThread, WM_QUIT, 0, 0);
			}
		}
	}
#endif // defined(ALLSRV_STANDALONE)
}
コード例 #4
0
ファイル: World.cpp プロジェクト: DeaDSandro/shadowfade
void World::RegisterProjectile(Projectile *proj, PlayerSession *Owner)
{
	if(proj == NULL)
		return;

	Projectiles.push_back(proj);
	
	if(GetSessionCount() > 1)
	{
		Owner->GetPlayer()->UpdateInRangePlayers();

		if(Owner->GetPlayer()->m_inRangePlayers.size())
		{
			for(set<Player*>::iterator itr = Owner->GetPlayer()->m_inRangePlayers.begin(); itr != Owner->GetPlayer()->m_inRangePlayers.end(); ++itr)
			{
				WorldPacket wp(SMSG_NEW_PROJECTILE,12+12+4);
				wp << proj->GetInitPos();
				wp << proj->GetVelocity();
				wp << (float)proj->GetLifeTime();
				(*itr)->GetSession()->SendPacket(&wp);
			}
		}
	}
}
コード例 #5
0
ファイル: World.cpp プロジェクト: DeaDSandro/shadowfade
void World::RegisterObject(WorldObject *obj, PlayerSession *Reg)
{
	if(obj == NULL)
		return;
	
	Registrated_Objects[obj->MeshId] = obj;

	if(GetSessionCount() > 1)
	{
		Reg->GetPlayer()->UpdateInRangePlayers();

		if(Reg->GetPlayer()->m_inRangePlayers.size())
		{
			for(set<Player*>::iterator itr = Reg->GetPlayer()->m_inRangePlayers.begin(); itr != Reg->GetPlayer()->m_inRangePlayers.end(); ++itr)
			{
				WorldPacket wp(CMSG_OBJECT_REGISTER,1+4+12);
				wp << (uint32)obj->GetObjType();
				wp << (uint32)obj->MeshId;
				wp << obj->GetPosition();
				(*itr)->GetSession()->SendPacket(&wp);
			}
		}
	}
}