diff options
author | Vincent_Michael <Vincent_Michael@gmx.de> | 2013-02-25 17:11:36 +0100 |
---|---|---|
committer | Vincent_Michael <Vincent_Michael@gmx.de> | 2013-02-25 17:11:36 +0100 |
commit | 529c4b7592b7e9b2f15436e98566bbe5da463534 (patch) | |
tree | 87d5f56472fbd366a7c06050dd93e9fe435690cd /src/server/game/Globals/ObjectMgr.cpp | |
parent | 1fba352a88472f31b2d0cb36214dc655373e9e84 (diff) | |
parent | c6d6cb7e745f8d320cfc9745dafc2d67fd87ba8c (diff) |
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Conflicts:
src/server/game/Entities/Player/Player.cpp
src/server/game/Handlers/MailHandler.cpp
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 399087d1c0a..265b981639f 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1446,6 +1446,92 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow) return true; } +void ObjectMgr::LoadTempSummons() +{ + uint32 oldMSTime = getMSTime(); + + // 0 1 2 3 4 5 6 7 8 9 + QueryResult result = WorldDatabase.Query("SELECT summonerId, summonerType, groupId, entry, position_x, position_y, position_z, orientation, summonType, summonTime FROM creature_summon_groups"); + + if (!result) + { + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 temp summons. DB table `creature_summon_groups` is empty."); + return; + } + + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint32 summonerId = fields[0].GetUInt32(); + SummonerType summonerType = SummonerType(fields[1].GetUInt8()); + uint8 group = fields[2].GetUInt8(); + + switch (summonerType) + { + case SUMMONER_TYPE_CREATURE: + if (!GetCreatureTemplate(summonerId)) + { + sLog->outError(LOG_FILTER_SQL, "Table `creature_summon_groups` has summoner with non existing entry %u for creature summoner type, skipped.", summonerId); + continue; + } + break; + case SUMMONER_TYPE_GAMEOBJECT: + if (!GetGameObjectTemplate(summonerId)) + { + sLog->outError(LOG_FILTER_SQL, "Table `creature_summon_groups` has summoner with non existing entry %u for gameobject summoner type, skipped.", summonerId); + continue; + } + break; + case SUMMONER_TYPE_MAP: + if (!sMapStore.LookupEntry(summonerId)) + { + sLog->outError(LOG_FILTER_SQL, "Table `creature_summon_groups` has summoner with non existing entry %u for map summoner type, skipped.", summonerId); + continue; + } + break; + default: + sLog->outError(LOG_FILTER_SQL, "Table `creature_summon_groups` has unhandled summoner type %u for summoner %u, skipped.", summonerType, summonerId); + continue; + } + + TempSummonData data; + data.entry = fields[3].GetUInt32(); + + if (!GetCreatureTemplate(data.entry)) + { + sLog->outError(LOG_FILTER_SQL, "Table `creature_summon_groups` has creature in group [Summoner ID: %u, Summoner Type: %u, Group ID: %u] with non existing creature entry %u, skipped.", summonerId, summonerType, group, data.entry); + continue; + } + + float posX = fields[4].GetFloat(); + float posY = fields[5].GetFloat(); + float posZ = fields[6].GetFloat(); + float orientation = fields[7].GetFloat(); + + data.pos.Relocate(posX, posY, posZ, orientation); + + data.type = TempSummonType(fields[8].GetUInt8()); + + if (data.type > TEMPSUMMON_MANUAL_DESPAWN) + { + sLog->outError(LOG_FILTER_SQL, "Table `creature_summon_groups` has unhandled temp summon type %u in group [Summoner ID: %u, Summoner Type: %u, Group ID: %u] for creature entry %u, skipped.", data.type, summonerId, summonerType, group, data.entry); + continue; + } + + data.time = fields[9].GetUInt32(); + + TempSummonGroupKey key(summonerId, summonerType, group); + _tempSummonDataStore[key].push_back(data); + + ++count; + + } while (result->NextRow()); + + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u temp summons in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + void ObjectMgr::LoadCreatures() { uint32 oldMSTime = getMSTime(); |