Beispiel #1
0
        InstanceMap CreateInstance(uint InstanceId, InstanceSave save, Difficulty difficulty, int teamId)
        {
            // make sure we have a valid map id
            MapRecord entry = CliDB.MapStorage.LookupByKey(GetId());

            if (entry == null)
            {
                Log.outError(LogFilter.Maps, "CreateInstance: no record for map {0}", GetId());
                Contract.Assert(false);
            }
            InstanceTemplate iTemplate = Global.ObjectMgr.GetInstanceTemplate(GetId());

            if (iTemplate == null)
            {
                Log.outError(LogFilter.Maps, "CreateInstance: no instance template for map {0}", GetId());
                Contract.Assert(false);
            }

            // some instances only have one difficulty
            Global.DB2Mgr.GetDownscaledMapDifficultyData(GetId(), ref difficulty);

            Log.outDebug(LogFilter.Maps, "MapInstanced.CreateInstance: {0} map instance {1} for {2} created with difficulty {3}", save != null ? "" : "new ", InstanceId, GetId(), difficulty);

            InstanceMap map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);

            Contract.Assert(map.IsDungeon());

            map.LoadRespawnTimes();
            map.LoadCorpseData();

            bool load_data = save != null;

            map.CreateInstanceData(load_data);
            InstanceScenario instanceScenario = Global.ScenarioMgr.CreateInstanceScenario(map, teamId);

            if (instanceScenario != null)
            {
                map.SetInstanceScenario(instanceScenario);
            }

            if (WorldConfig.GetBoolValue(WorldCfg.InstancemapLoadGrids))
            {
                map.LoadAllCells();
            }

            m_InstancedMaps[InstanceId] = map;
            return(map);
        }