Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[11158] Fixed respawn times loading for instances.

Now MapPersistentState will created for instances at repawn time load if any not expired timers
still exist.
  • Loading branch information...
commit 437792635e924d4b60fd9a8f00366181a9a18633 1 parent dd0f7b2
VladimirMangos authored
40 src/game/MapPersistentStateMgr.cpp
@@ -821,8 +821,7 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
821 821
822 822 uint32 count = 0;
823 823
824   - QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, instance FROM creature_respawn");
825   -
  824 + QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime FROM creature_respawn LEFT JOIN instance ON instance = id");
826 825 if(!result)
827 826 {
828 827 barGoLink bar(1);
@@ -843,21 +842,27 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
843 842
844 843 uint32 loguid = fields[0].GetUInt32();
845 844 uint64 respawn_time = fields[1].GetUInt64();
846   - uint32 instanceId = fields[2].GetUInt32();
  845 + uint32 mapId = fields[2].GetUInt32();
  846 + uint32 instanceId = fields[3].GetUInt32();
  847 + uint8 difficulty = fields[4].GetUInt8();
  848 +
  849 + time_t resetTime = (time_t)fields[5].GetUInt64();
847 850
848 851 CreatureData const* data = sObjectMgr.GetCreatureData(loguid);
849 852 if (!data)
850 853 continue;
851 854
852   - MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
  855 + if (mapId != data->mapid)
  856 + continue;
  857 +
  858 + MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
853 859 if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0)))
854 860 continue;
855 861
856   - // instances loaded early and respawn data must exist only for existed instances (state loaded) or non-instanced maps
857   - MapPersistentState* state = instanceId
858   - ? GetPersistentState(data->mapid, instanceId)
859   - : AddPersistentState(mapEntry, 0, REGULAR_DIFFICULTY, 0, false, true);
  862 + if(difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
  863 + continue;
860 864
  865 + MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true);
861 866 if (!state)
862 867 continue;
863 868
@@ -880,7 +885,7 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
880 885
881 886 uint32 count = 0;
882 887
883   - QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, instance FROM gameobject_respawn");
  888 + QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime FROM gameobject_respawn LEFT JOIN instance ON instance = id");
884 889
885 890 if(!result)
886 891 {
@@ -902,22 +907,27 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
902 907
903 908 uint32 loguid = fields[0].GetUInt32();
904 909 uint64 respawn_time = fields[1].GetUInt64();
905   - uint32 instanceId = fields[2].GetUInt32();
  910 + uint32 mapId = fields[2].GetUInt32();
  911 + uint32 instanceId = fields[3].GetUInt32();
  912 + uint8 difficulty = fields[4].GetUInt8();
906 913
  914 + time_t resetTime = (time_t)fields[5].GetUInt64();
907 915
908 916 GameObjectData const* data = sObjectMgr.GetGOData(loguid);
909 917 if (!data)
910 918 continue;
911 919
912   - MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
  920 + if (mapId != data->mapid)
  921 + continue;
  922 +
  923 + MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
913 924 if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0)))
914 925 continue;
915 926
916   - // instances loaded early and respawn data must exist only for existed instances (state loaded) or non-instanced maps
917   - MapPersistentState* state = instanceId
918   - ? GetPersistentState(data->mapid, instanceId)
919   - : AddPersistentState(mapEntry, 0, REGULAR_DIFFICULTY, 0, false, true);
  927 + if(difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
  928 + continue;
920 929
  930 + MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true);
921 931 if (!state)
922 932 continue;
923 933
2  src/shared/revision_nr.h
... ... @@ -1,4 +1,4 @@
1 1 #ifndef __REVISION_NR_H__
2 2 #define __REVISION_NR_H__
3   - #define REVISION_NR "11157"
  3 + #define REVISION_NR "11158"
4 4 #endif // __REVISION_NR_H__

0 comments on commit 4377926

Please sign in to comment.
Something went wrong with that request. Please try again.