· 8 years ago · Apr 24, 2018, 05:04 PM
1diff --git a/sql/characters.sql b/sql/characters.sql
2index aed3b1d..946fb3b 100644
3--- a/sql/characters.sql
4+++ b/sql/characters.sql
5@@ -1170,6 +1170,7 @@ UNLOCK TABLES;
6 DROP TABLE IF EXISTS `instance_reset`;
7 CREATE TABLE `instance_reset` (
8 `mapid` int(11) unsigned NOT NULL default '0',
9+ `difficulty` tinyint(1) unsigned NOT NULL default '0',
10 `resettime` bigint(40) NOT NULL default '0',
11 PRIMARY KEY (`mapid`)
12 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13diff --git a/sql/updates/9999_01_characters_instance_reset.sql b/sql/updates/9999_01_characters_instance_reset.sql
14new file mode 100644
15index 0000000..e3c380c
16--- /dev/null
17+++ b/sql/updates/9999_01_characters_instance_reset.sql
18@@ -0,0 +1,2 @@
19+ALTER TABLE instance_reset
20+ ADD COLUMN difficulty tinyint(1) unsigned NOT NULL default '0' AFTER mapid;
21diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp
22index 8963de3..1cc40b5 100644
23--- a/src/game/InstanceSaveMgr.cpp
24+++ b/src/game/InstanceSaveMgr.cpp
25@@ -101,12 +101,12 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance
26 // initialize reset time
27 // for normal instances if no creatures are killed the instance will reset in two hours
28 if(entry->map_type == MAP_RAID || difficulty == DUNGEON_DIFFICULTY_HEROIC)
29- resetTime = GetResetTimeFor(mapId);
30+ resetTime = GetResetTimeFor(mapId,difficulty);
31 else
32 {
33 resetTime = time(NULL) + 2 * HOUR;
34 // normally this will be removed soon after in InstanceMap::Add, prevent error
35- ScheduleReset(true, resetTime, InstResetEvent(0, mapId, instanceId));
36+ ScheduleReset(true, resetTime, InstResetEvent(0, mapId, difficulty, instanceId));
37 }
38 }
39
40@@ -378,18 +378,24 @@ void InstanceSaveManager::LoadResetTimes()
41 // get the current reset times for normal instances (these may need to be updated)
42 // these are only kept in memory for InstanceSaves that are loaded later
43 // resettime = 0 in the DB for raid/heroic instances so those are skipped
44- typedef std::map<uint32, std::pair<uint32, time_t> > ResetTimeMapType;
45- ResetTimeMapType InstResetTime;
46- QueryResult *result = CharacterDatabase.Query("SELECT id, map, resettime FROM instance WHERE resettime > 0");
47+ typedef std::map<uint32, std::pair<uint32 /*PAIR32(map,difficulty)*/, time_t> > ResetTimeMapDiffType;
48+ ResetTimeMapDiffType InstResetTime;
49+
50+ typedef std::multimap<uint32 /*PAIR32(map,difficulty)*/, uint32 /*instanceid*/ > ResetTimeMapDiffInstances;
51+ ResetTimeMapDiffInstances MapDiffResetInstances;
52+
53+ QueryResult *result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance WHERE resettime > 0");
54 if( result )
55 {
56 do
57 {
58- if(time_t resettime = time_t((*result)[2].GetUInt64()))
59+ if(time_t resettime = time_t((*result)[3].GetUInt64()))
60 {
61 uint32 id = (*result)[0].GetUInt32();
62 uint32 mapid = (*result)[1].GetUInt32();
63- InstResetTime[id] = std::pair<uint32, uint64>(mapid, resettime);
64+ uint32 difficulty = (*result)[2].GetUInt32();
65+ InstResetTime[id] = std::pair<uint32, uint64>(MAKE_PAIR32(mapid,difficulty), resettime);
66+ MapDiffResetInstances.insert(ResetTimeMapDiffInstances::value_type(MAKE_PAIR32(mapid,difficulty),id));
67 }
68 }
69 while (result->NextRow());
70@@ -404,7 +410,7 @@ void InstanceSaveManager::LoadResetTimes()
71 Field *fields = result->Fetch();
72 uint32 instance = fields[1].GetUInt32();
73 time_t resettime = time_t(fields[0].GetUInt64() + 2 * HOUR);
74- ResetTimeMapType::iterator itr = InstResetTime.find(instance);
75+ ResetTimeMapDiffType::iterator itr = InstResetTime.find(instance);
76 if(itr != InstResetTime.end() && itr->second.second != resettime)
77 {
78 CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", uint64(resettime), instance);
79@@ -416,35 +422,37 @@ void InstanceSaveManager::LoadResetTimes()
80 }
81
82 // schedule the reset times
83- for(ResetTimeMapType::iterator itr = InstResetTime.begin(); itr != InstResetTime.end(); ++itr)
84+ for(ResetTimeMapDiffType::iterator itr = InstResetTime.begin(); itr != InstResetTime.end(); ++itr)
85 if(itr->second.second > now)
86- ScheduleReset(true, itr->second.second, InstResetEvent(0, itr->second.first, itr->first));
87+ ScheduleReset(true, itr->second.second, InstResetEvent(0, PAIR32_LOPART(itr->second.first),Difficulty(PAIR32_HIPART(itr->second.first)),itr->first));
88 }
89
90 // load the global respawn times for raid/heroic instances
91 uint32 diff = sWorld.getConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;
92- m_resetTimeByMapId.resize(sMapStore.GetNumRows()+1);
93- result = CharacterDatabase.Query("SELECT mapid, resettime FROM instance_reset");
94+ result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset");
95 if(result)
96 {
97 do
98 {
99 Field *fields = result->Fetch();
100 uint32 mapid = fields[0].GetUInt32();
101- if(!ObjectMgr::GetInstanceTemplate(mapid))
102+ Difficulty difficulty = Difficulty(fields[1].GetUInt32());
103+ uint64 oldresettime = fields[1].GetUInt64();
104+
105+ MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty);
106+ if(!mapDiff)
107 {
108- sLog.outError("InstanceSaveManager::LoadResetTimes: invalid mapid %u in instance_reset!", mapid);
109- CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u'", mapid);
110+ sLog.outError("InstanceSaveManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, difficulty);
111+ CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid,difficulty);
112 continue;
113 }
114
115 // update the reset time if the hour in the configs changes
116- uint64 oldresettime = fields[1].GetUInt64();
117 uint64 newresettime = (oldresettime / DAY) * DAY + diff;
118 if(oldresettime != newresettime)
119- CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u'", newresettime, mapid);
120+ CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", newresettime, mapid, difficulty);
121
122- m_resetTimeByMapId[mapid] = newresettime;
123+ SetResetTimeFor(mapid,difficulty,newresettime);
124 } while(result->NextRow());
125 delete result;
126 }
127@@ -455,39 +463,47 @@ void InstanceSaveManager::LoadResetTimes()
128
129 // calculate new global reset times for expired instances and those that have never been reset yet
130 // add the global reset times to the priority queue
131- for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++)
132+ for(uint32 mapid = 0; mapid < sInstanceTemplate.MaxEntry; ++mapid)
133 {
134- InstanceTemplate const* temp = ObjectMgr::GetInstanceTemplate(i);
135- if(!temp || temp->reset_delay == 0)
136- continue;
137-
138- uint32 period = temp->reset_delay * DAY;
139- assert(period != 0);
140- time_t t = m_resetTimeByMapId[temp->map];
141- if(!t)
142+ for(int d = 0; d < MAX_DIFFICULTY; ++d)
143 {
144- // initialize the reset time
145- t = today + period + diff;
146- CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','"UI64FMTD"')", i, (uint64)t);
147- }
148+ MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,Difficulty(d));
149
150- if(t < now)
151- {
152- // assume that expired instances have already been cleaned
153- // calculate the next reset time
154- t = (t / DAY) * DAY;
155- t += ((today - t) / period + 1) * period + diff;
156- CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u'", (uint64)t, i);
157- }
158+ // the reset_delay must be at least one day
159+ uint32 period = mapDiff ? (mapDiff->resetTime / DAY * sWorld.getRate(RATE_INSTANCE_RESET_TIME)) * DAY : 0;
160+
161+ time_t t = GetResetTimeFor(mapid,Difficulty(d));
162+ if(!t)
163+ {
164+ // initialize the reset time
165+ t = today + period + diff;
166+ CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','%u','"UI64FMTD"')", mapid, d, (uint64)t);
167+ }
168+
169+ if(t < now)
170+ {
171+ // assume that expired instances have already been cleaned
172+ // calculate the next reset time
173+ t = (t / DAY) * DAY;
174+ t += ((today - t) / period + 1) * period + diff;
175+ CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty= '%u'", (uint64)t, mapid, d);
176+ }
177
178- m_resetTimeByMapId[temp->map] = t;
179+ SetResetTimeFor(mapid,Difficulty(d),t);
180
181- // schedule the global reset/warning
182- uint8 type = 1;
183- static int tim[4] = {3600, 900, 300, 60};
184- for(; type < 4; type++)
185- if(t - tim[type-1] > now) break;
186- ScheduleReset(true, t - tim[type-1], InstResetEvent(type, i));
187+ // schedule the global reset/warning
188+ uint8 type = 1;
189+ static int tim[4] = {3600, 900, 300, 60};
190+ for(; type < 4; type++)
191+ if(t - tim[type-1] > now)
192+ break;
193+
194+ for(ResetTimeMapDiffInstances::const_iterator in_itr = MapDiffResetInstances.lower_bound(MAKE_PAIR32(mapid,d));
195+ in_itr != MapDiffResetInstances.upper_bound(MAKE_PAIR32(mapid,d)); ++in_itr)
196+ {
197+ ScheduleReset(true, t - tim[type-1], InstResetEvent(type, mapid, Difficulty(d), in_itr->second));
198+ }
199+ }
200 }
201 }
202
203@@ -528,8 +544,8 @@ void InstanceSaveManager::Update()
204 else
205 {
206 // global reset/warning for a certain map
207- time_t resetTime = GetResetTimeFor(event.mapid);
208- _ResetOrWarnAll(event.mapid, event.type != 4, resetTime - now);
209+ time_t resetTime = GetResetTimeFor(event.mapid,event.difficulty);
210+ _ResetOrWarnAll(event.mapid, event.difficulty, event.type != 4, resetTime - now);
211 if(event.type != 4)
212 {
213 // schedule the next warning/reset
214@@ -580,29 +596,28 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
215 else sObjectMgr.DeleteRespawnTimeForInstance(instanceId); // even if map is not loaded
216 }
217
218-void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLeft)
219+void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeLeft)
220 {
221 // global reset for all instances of the given map
222 // note: this isn't fast but it's meant to be executed very rarely
223- Map const *map = sMapMgr.CreateBaseMap(mapid);
224+ Map const *map = sMapMgr.CreateBaseMap(mapid); // _not_ include difficulty
225 if(!map->Instanceable())
226 return;
227 uint64 now = (uint64)time(NULL);
228
229 if(!warn)
230 {
231- // this is called one minute before the reset time
232- InstanceTemplate const* temp = ObjectMgr::GetInstanceTemplate(mapid);
233- if(!temp || !temp->reset_delay)
234+ MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty);
235+ if(!mapDiff || !mapDiff->resetTime)
236 {
237- sLog.outError("InstanceSaveManager::ResetOrWarnAll: no instance template or reset delay for map %d", mapid);
238+ sLog.outError("InstanceSaveManager::ResetOrWarnAll: not valid difficulty or no reset delay for map %d", mapid);
239 return;
240 }
241
242 // remove all binds to instances of the given map
243 for(InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end();)
244 {
245- if(itr->second->GetMapId() == mapid)
246+ if (itr->second->GetMapId() == mapid && itr->second->GetDifficulty() == difficulty)
247 _ResetSave(itr);
248 else
249 ++itr;
250@@ -617,7 +632,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLe
251
252 // calculate the next reset time
253 uint32 diff = sWorld.getConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;
254- uint32 period = temp->reset_delay * DAY;
255+ uint32 period = mapDiff->resetTime * DAY;
256 uint64 next_reset = ((now + timeLeft + MINUTE) / DAY * DAY) + period + diff;
257 // update it in the DB
258 CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d'", next_reset, mapid);
259diff --git a/src/game/InstanceSaveMgr.h b/src/game/InstanceSaveMgr.h
260index c080fd5..f457fe3 100644
261--- a/src/game/InstanceSaveMgr.h
262+++ b/src/game/InstanceSaveMgr.h
263@@ -118,28 +118,39 @@ class MANGOS_DLL_DECL InstanceSaveManager : public MaNGOS::Singleton<InstanceSav
264 InstanceSaveManager();
265 ~InstanceSaveManager();
266
267- typedef std::map<uint32 /*InstanceId*/, InstanceSave*> InstanceSaveMap;
268 typedef UNORDERED_MAP<uint32 /*InstanceId*/, InstanceSave*> InstanceSaveHashMap;
269- typedef std::map<uint32 /*mapId*/, InstanceSaveMap> InstanceSaveMapMap;
270+ typedef UNORDERED_MAP<uint32 /*mapId*/, InstanceSaveHashMap> InstanceSaveMapMap;
271
272 /* resetTime is a global propery of each (raid/heroic) map
273 all instances of that map reset at the same time */
274 struct InstResetEvent
275 {
276 uint8 type;
277+ Difficulty difficulty:8;
278 uint16 mapid;
279 uint16 instanceId;
280- InstResetEvent(uint8 t = 0, uint16 m = 0, uint16 i = 0) : type(t), mapid(m), instanceId(i) {}
281+
282+ InstResetEvent() : type(0), difficulty(DUNGEON_DIFFICULTY_NORMAL), mapid(0), instanceId(0) {}
283+ InstResetEvent(uint8 t, uint32 _mapid, Difficulty d, uint16 _instanceid)
284+ : type(t), difficulty(d), mapid(_mapid), instanceId(_instanceid) {}
285 bool operator == (const InstResetEvent& e) { return e.instanceId == instanceId; }
286 };
287 typedef std::multimap<time_t /*resetTime*/, InstResetEvent> ResetTimeQueue;
288- typedef std::vector<time_t /*resetTime*/> ResetTimeVector;
289+ typedef UNORDERED_MAP<uint32 /*PAIR32(map,difficulty)*/,time_t /*resetTime*/> ResetTimeByMapDifficultyMap;
290
291 void CleanupInstances();
292 void PackInstances();
293
294 void LoadResetTimes();
295- time_t GetResetTimeFor(uint32 mapid) { return m_resetTimeByMapId[mapid]; }
296+ time_t GetResetTimeFor(uint32 mapid, Difficulty d) const
297+ {
298+ ResetTimeByMapDifficultyMap::const_iterator itr = m_resetTimeByMapDifficulty.find(MAKE_PAIR32(mapid,d));
299+ return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0;
300+ }
301+ void SetResetTimeFor(uint32 mapid, Difficulty d, time_t t)
302+ {
303+ m_resetTimeByMapDifficulty[MAKE_PAIR32(mapid,d)] = t;
304+ }
305 void ScheduleReset(bool add, time_t time, InstResetEvent event);
306
307 void Update();
308@@ -156,7 +167,7 @@ class MANGOS_DLL_DECL InstanceSaveManager : public MaNGOS::Singleton<InstanceSav
309 uint32 GetNumBoundGroupsTotal();
310
311 private:
312- void _ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeleft);
313+ void _ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeleft);
314 void _ResetInstance(uint32 mapid, uint32 instanceId);
315 void _ResetSave(InstanceSaveHashMap::iterator &itr);
316 void _DelHelper(DatabaseType &db, const char *fields, const char *table, const char *queryTail,...);
317@@ -164,8 +175,8 @@ class MANGOS_DLL_DECL InstanceSaveManager : public MaNGOS::Singleton<InstanceSav
318 bool lock_instLists;
319 // fast lookup by instance id
320 InstanceSaveHashMap m_instanceSaveById;
321- // fast lookup for reset times
322- ResetTimeVector m_resetTimeByMapId;
323+ // fast lookup for reset times (always use existed functions for access/set)
324+ ResetTimeByMapDifficultyMap m_resetTimeByMapDifficulty;
325 ResetTimeQueue m_resetTimeQueue;
326 };
327
328diff --git a/src/game/Map.cpp b/src/game/Map.cpp
329index aa38ed3..8e9d087 100644
330--- a/src/game/Map.cpp
331+++ b/src/game/Map.cpp
332@@ -2614,18 +2614,28 @@ void InstanceMap::SetResetSchedule(bool on)
333 {
334 InstanceSave *save = sInstanceSaveMgr.GetInstanceSave(GetInstanceId());
335 if(!save) sLog.outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, no save available for instance %d of %d", on ? "on" : "off", GetInstanceId(), GetId());
336- else sInstanceSaveMgr.ScheduleReset(on, save->GetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), GetInstanceId()));
337+ else sInstanceSaveMgr.ScheduleReset(on, save->GetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), Difficulty(GetSpawnMode()), GetInstanceId()));
338 }
339 }
340
341+MapDifficulty const* InstanceMap::GetMapDifficulty() const
342+{
343+ return GetMapDifficultyData(GetId(),GetDifficulty());
344+}
345+
346 uint32 InstanceMap::GetMaxPlayers() const
347 {
348- InstanceTemplate const* iTemplate = ObjectMgr::GetInstanceTemplate(GetId());
349- if(!iTemplate)
350- return 0;
351- return IsHeroic() ? iTemplate->maxPlayersHeroic : iTemplate->maxPlayers;
352+ MapDifficulty const* mapDiff = GetMapDifficulty();
353+ return mapDiff ? mapDiff->maxPlayers : 0;
354 }
355
356+uint32 InstanceMap::GetMaxResetDelay() const
357+{
358+ MapDifficulty const* mapDiff = GetMapDifficulty();
359+ return mapDiff ? mapDiff->resetTime : 0;
360+}
361+
362+
363 /* ******* Battleground Instance Maps ******* */
364
365 BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId, Map* _parent, uint8 spawnMode)
366@@ -3560,4 +3570,3 @@ uint32 Map::GenerateLocalLowGuid(HighGuid guidhigh)
367 ASSERT(0);
368 return 0;
369 }
370-
371diff --git a/src/game/Map.h b/src/game/Map.h
372index 849efcb..02c3332 100644
373--- a/src/game/Map.h
374+++ b/src/game/Map.h
375@@ -227,9 +227,6 @@ struct InstanceTemplate
376 uint32 parent;
377 uint32 levelMin;
378 uint32 levelMax;
379- uint32 maxPlayers;
380- uint32 maxPlayersHeroic;
381- uint32 reset_delay; // FIX ME: now exist normal/heroic raids with possible different time of reset.
382 float startLocX;
383 float startLocY;
384 float startLocZ;
385@@ -599,7 +596,12 @@ class MANGOS_DLL_SPEC InstanceMap : public Map
386 bool CanEnter(Player* player);
387 void SendResetWarnings(uint32 timeLeft) const;
388 void SetResetSchedule(bool on);
389+
390+ // have meaning only for instanced map (that have set real difficulty)
391+ Difficulty GetDifficulty() const { return Difficulty(GetSpawnMode()); }
392 uint32 GetMaxPlayers() const;
393+ uint32 GetMaxResetDelay() const;
394+ MapDifficulty const* GetMapDifficulty() const;
395
396 virtual void InitVisibilityDistance();
397 private:
398diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
399index 7f7ef94..74ff8d1 100644
400--- a/src/game/MovementHandler.cpp
401+++ b/src/game/MovementHandler.cpp
402@@ -144,17 +144,12 @@ void WorldSession::HandleMoveWorldportAckOpcode()
403
404 if (mInstance)
405 {
406- if(mEntry->IsRaid())
407+ if(mEntry->IsDungeon())
408 {
409- uint32 timeleft = sInstanceSaveMgr.GetResetTimeFor(GetPlayer()->GetMapId()) - time(NULL);
410- GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), GetPlayer()->GetRaidDifficulty(), timeleft);
411- }
412- else if(mEntry->IsNonRaidDungeon() && GetPlayer()->GetDungeonDifficulty() > DUNGEON_DIFFICULTY_NORMAL)
413- {
414- if(MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID,GetPlayer()->GetDungeonDifficulty()))
415+ if(uint32 timeReset = sInstanceSaveMgr.GetResetTimeFor(GetPlayer()->GetMapId(),Difficulty(GetPlayer()->GetMap()->GetSpawnMode())))
416 {
417- uint32 timeleft = sInstanceSaveMgr.GetResetTimeFor(GetPlayer()->GetMapId()) - time(NULL);
418- GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), GetPlayer()->GetDungeonDifficulty(), timeleft);
419+ uint32 timeleft = timeReset - time(NULL);
420+ GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), GetPlayer()->GetRaidDifficulty(), timeleft);
421 }
422 }
423 }
424diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
425index 11b577f..b466f12 100644
426--- a/src/game/ObjectMgr.cpp
427+++ b/src/game/ObjectMgr.cpp
428@@ -4593,42 +4593,14 @@ void ObjectMgr::LoadInstanceTemplate()
429 if(!temp)
430 continue;
431
432- const MapEntry* entry = sMapStore.LookupEntry(temp->map);
433- if(!entry)
434- {
435+ if(!MapManager::IsValidMAP(temp->map))
436 sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad mapid %d for template!", temp->map);
437- continue;
438- }
439
440- //FIXME: now exist heroic instance, normal/heroic raid instances
441- // entry->resetTimeHeroic store reset time for both heroic mode instance (raid and non-raid)
442- // entry->resetTimeRaid store reset time for normal raid only
443- // for current state entry->resetTimeRaid == entry->resetTimeHeroic in case raid instances with heroic mode.
444- // but at some point wee need implement reset time dependent from raid instance mode
445- if(temp->reset_delay == 0)
446+ if(!MapManager::IsValidMapCoord(temp->parent,temp->startLocX,temp->startLocY,temp->startLocZ,temp->startLocO))
447 {
448- MapDifficulty const* mapDiffNorm = GetMapDifficultyData(temp->map,DUNGEON_DIFFICULTY_NORMAL);
449- MapDifficulty const* mapDiffHeroic = GetMapDifficultyData(temp->map,DUNGEON_DIFFICULTY_HEROIC);
450-
451- // no reset time
452- if ((!mapDiffNorm || mapDiffNorm->resetTime == 0) &&
453- (!mapDiffHeroic || mapDiffHeroic->resetTime == 0))
454- continue;
455-
456- // use defaults from the DBC
457- if(mapDiffHeroic && mapDiffHeroic->resetTime) // for both raid and non raids, read above
458- {
459- temp->reset_delay = mapDiffHeroic->resetTime / DAY;
460- }
461- else if (mapDiffNorm && mapDiffNorm->resetTime && entry->map_type == MAP_RAID)
462- // for normal raid only
463- {
464- temp->reset_delay = mapDiffNorm->resetTime / DAY;
465- }
466+ sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad parent entrance coordinates for map id %d template!", temp->map);
467+ temp->parent = 0; // will have wrong continent 0 parent, at least existed
468 }
469-
470- // the reset_delay must be at least one day
471- temp->reset_delay = std::max((uint32)1, (uint32)(temp->reset_delay * sWorld.getRate(RATE_INSTANCE_RESET_TIME)));
472 }
473
474 sLog.outString( ">> Loaded %u Instance Template definitions", sInstanceTemplate.RecordCount );
475diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp
476index e48f45c..0a16e71 100644
477--- a/src/shared/Database/SQLStorage.cpp
478+++ b/src/shared/Database/SQLStorage.cpp
479@@ -36,8 +36,8 @@ const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii";
480 const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiii";
481 const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiii";
482 const char PageTextfmt[]="isi";
483-const char InstanceTemplatesrcfmt[]="iiiiiiiffffs";
484-const char InstanceTemplatedstfmt[]="iiiiiiiffffi";
485+const char InstanceTemplatesrcfmt[]="iiiiffffs";
486+const char InstanceTemplatedstfmt[]="iiiiffffi";
487
488 SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template");
489 SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon");