本文整理汇总了C++中Map::GetInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::GetInstance方法的具体用法?C++ Map::GetInstance怎么用?C++ Map::GetInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::GetInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandlePlayerLogin
void ClusterInterface::HandlePlayerLogin(WorldPacket & pck)
{
/* player x logging into instance y */
uint32 guid, instance, mapid;
uint32 accountid, accountflags, sessionid;
string gmpermissions, accountname;
pck >> guid >> mapid >> instance >> accountid >> accountflags >> sessionid >> gmpermissions >> accountname;
/* find the instance */
Map * ma = sWorldCreator.GetMap(mapid);
ASSERT(ma);
MapMgr * mm = ma->GetInstance(instance);
ASSERT(mm);
/* create the session */
WorldSession * s = sWorld.FindSession(accountid);
ASSERT(!s);
/* create the socket */
WorldSocket * so = new WorldSocket(sessionid);
s = new WorldSession(accountid, accountname, so);
_sessions[sessionid] = s;
sWorld.AddSession(s);
bool login_result = s->PlayerLogin(guid, mapid, instance);
if(login_result)
{
/* login was ok. send a message to the realm server telling him to distribute our info to all other realm server */
WorldPacket data(ICMSG_PLAYER_LOGIN_RESULT, 5);
data << guid << sessionid << uint8(1);
SendPacket(&data);
}
else
{
/* for some reason the login failed */
WorldPacket data(ICMSG_PLAYER_LOGIN_RESULT, 5);
data << guid << sessionid << uint8(0);
SendPacket(&data);
/* tell the client his login failed before deleting the session */
data.Initialize(SMSG_CHARACTER_LOGIN_FAILED);
data << uint8(62);
so->SendPacket(&data);
/* destroy the session */
DestroySession(sessionid);
}
}
示例2: GetInstance
MapMgr* WorldCreator::GetInstance(uint32 mapid, Object* obj)
{
// check inactive instances.
if(obj->GetInstanceID() > 2)
{
InactiveInstance * ia = sInstanceSavingManager.GetInactiveInstance(obj->GetInstanceID());
if(ia != 0)
{
//create that inactive instance.
//extra, it now checks if the instance should expire.
MapInfo *pMapInfo = WorldMapInfoStorage.LookupEntry(ia->MapId);
if(pMapInfo)
{
if((uint32)time(NULL) > (ia->Creation) + (pMapInfo ? pMapInfo->cooldown : 604800))
{
sInstanceSavingManager.RemoveSavedInstance(ia->MapId,ia->InstanceId,true);
sInstanceSavingManager.RemoveSavedInstance(ia->InstanceId);
}
else
{
MapMgr * dm = 0;
CreateInstance(NULL, NULL, ia->MapId, ia->InstanceId, ia->Creation, &dm, ia->difficulty);
obj->SetMapId(ia->MapId);
delete ia;
return dm;
}
}
else
{
MapMgr * dm = 0;
CreateInstance(NULL, NULL, ia->MapId, ia->InstanceId, ia->Creation, &dm, ia->difficulty);
obj->SetMapId(ia->MapId);
delete ia;
return dm;
}
}
}
Map* mp = GetMap(mapid);
if(!mp) return NULL;
return mp->GetInstance(obj);
}