Exemple #1
0
uint32 WorldCreator::CreateInstance(Group *pGroup, Player *pPlayer, uint32 mapid, uint32 instanceid, uint32 creation, MapMgr ** destptr, uint32 difficulty)
{
	if(pGroup == NULL && pPlayer == NULL && instanceid == 0)
	{
		return INSTANCE_ABORT_ERROR;
	}

	Map* instance_map = GetMap(mapid);
	ASSERT(instance_map != NULL);

	MapMgr * pInstance = instance_map->CreateMapMgrInstance(instanceid);
	ASSERT(pInstance);
	if(creation)
	{
		pInstance->SetNewExpireTime(creation);
	}
	if(pGroup)
	{
		pInstance->SetGroupSignature(pGroup->GetID());
        pInstance->iInstanceMode = pGroup->GetLeader()->iInstanceType;
	}
	if(pPlayer)
	{
		pInstance->SetCreator(pPlayer);
        pInstance->iInstanceMode = pPlayer->iInstanceType;
	}
    if(difficulty)
    {
       pInstance->iInstanceMode = difficulty;
    }
    //Capt: We do not realy need to store this one if we are not doing something with it.
	sInstanceSavingManager.SaveInstance(pInstance); //first time instance saving holder
	if(destptr)
		*destptr = pInstance;

	return pInstance->GetInstanceID();
}