diff options
author | Rat <gmstreetrat@gmail.com> | 2015-03-29 19:31:28 +0200 |
---|---|---|
committer | Rat <gmstreetrat@gmail.com> | 2015-03-29 19:31:28 +0200 |
commit | ec99b191999a5da783f070ff3e1ebf05f9871219 (patch) | |
tree | 7d604fc051ff9c79e2b9b7b33e25a14035b5bb38 /src/server/game/Globals/ObjectMgr.cpp | |
parent | 833d57fa27c782c2e9a211ec19c554d057431243 (diff) | |
parent | 17bd724559808b5e327a9a541063b56f21712841 (diff) |
Merge pull request #14389 from streetrat/6.x
Core/Phases: Added new phasing system
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 208 |
1 files changed, 145 insertions, 63 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 2523f316cec..d042fd31e27 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1650,8 +1650,8 @@ void ObjectMgr::LoadCreatures() // 0 1 2 3 4 5 6 7 8 9 10 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, " - // 11 12 13 14 15 16 17 18 19 20 21 22 23 - "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, creature.phaseid, creature.phasegroup " + // 11 12 13 14 15 16 17 18 19 20 21 22 + "currentwaypoint, curhealth, curmana, MovementType, spawnMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, creature.phaseid, creature.phasegroup " "FROM creature " "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid " "LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid"); @@ -1701,14 +1701,13 @@ void ObjectMgr::LoadCreatures() data.curmana = fields[13].GetUInt32(); data.movementType = fields[14].GetUInt8(); data.spawnMask = fields[15].GetUInt32(); - data.phaseMask = fields[16].GetUInt32(); - int16 gameEvent = fields[17].GetInt8(); - uint32 PoolId = fields[18].GetUInt32(); - data.npcflag = fields[19].GetUInt32(); - data.unit_flags = fields[20].GetUInt32(); - data.dynamicflags = fields[21].GetUInt32(); - data.phaseid = fields[22].GetUInt32(); - data.phaseGroup = fields[23].GetUInt32(); + int16 gameEvent = fields[16].GetInt8(); + uint32 PoolId = fields[17].GetUInt32(); + data.npcflag = fields[18].GetUInt32(); + data.unit_flags = fields[19].GetUInt32(); + data.dynamicflags = fields[20].GetUInt32(); + data.phaseid = fields[21].GetUInt32(); + data.phaseGroup = fields[22].GetUInt32(); MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid); if (!mapEntry) @@ -1778,11 +1777,7 @@ void ObjectMgr::LoadCreatures() data.orientation = Position::NormalizeOrientation(data.orientation); } - if (data.phaseMask == 0) - { - TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD " Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id); - data.phaseMask = 1; - } + data.phaseMask = 1; if (data.phaseGroup && data.phaseid) { @@ -1984,8 +1979,8 @@ void ObjectMgr::LoadGameobjects() // 0 1 2 3 4 5 6 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, " - // 7 8 9 10 11 12 13 14 15 16 17 18 19 - "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, eventEntry, pool_entry, phaseid, phasegroup " + // 7 8 9 10 11 12 13 14 15 16 17 18 + "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, eventEntry, pool_entry, phaseid, phasegroup " "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid " "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid"); @@ -2081,11 +2076,10 @@ void ObjectMgr::LoadGameobjects() if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid]) TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) that has wrong spawn mask %u including unsupported difficulty modes for map (Id: %u), skip", guid, data.id, data.spawnMask, data.mapid); - data.phaseMask = fields[15].GetUInt32(); - int16 gameEvent = fields[16].GetInt8(); - uint32 PoolId = fields[17].GetUInt32(); - data.phaseid = fields[18].GetUInt32(); - data.phaseGroup = fields[19].GetUInt32(); + int16 gameEvent = fields[15].GetInt8(); + uint32 PoolId = fields[16].GetUInt32(); + data.phaseid = fields[17].GetUInt32(); + data.phaseGroup = fields[18].GetUInt32(); if (data.phaseGroup && data.phaseid) { @@ -2117,11 +2111,7 @@ void ObjectMgr::LoadGameobjects() continue; } - if (data.phaseMask == 0) - { - TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id); - data.phaseMask = 1; - } + data.phaseMask = 1; if (sWorld->getBoolConfig(CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA)) { @@ -6448,11 +6438,28 @@ uint64 ObjectMgr::GenerateVoidStorageItemId() void ObjectMgr::LoadCorpses() { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, phaseMask, corpseGuid, guid FROM corpse WHERE corpseType <> 0 - uint32 oldMSTime = getMSTime(); + std::unordered_map<uint32, std::list<uint32>> phases; + + // 0 1 + // SELECT Guid, PhaseId FROM corpse_phases + PreparedQueryResult phaseResult = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSE_PHASES)); + if (phaseResult) + { + do + { + Field* fields = phaseResult->Fetch(); + uint32 guid = fields[0].GetUInt32(); + uint32 phaseId = fields[1].GetUInt32(); + + phases[guid].push_back(phaseId); + + } while (phaseResult->NextRow()); + } + + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, corpseGuid, guid FROM corpse WHERE corpseType <> 0 PreparedQueryResult result = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSES)); if (!result) { @@ -6464,11 +6471,11 @@ void ObjectMgr::LoadCorpses() do { Field* fields = result->Fetch(); - ObjectGuid::LowType guid = fields[15].GetUInt64(); + uint32 guid = fields[14].GetUInt32(); CorpseType type = CorpseType(fields[12].GetUInt8()); if (type >= MAX_CORPSE_TYPE) { - TC_LOG_ERROR("misc", "Corpse (guid: " UI64FMTD ") have wrong corpse type (%u), not loading.", guid, type); + TC_LOG_ERROR("misc", "Corpse (guid: %u) have wrong corpse type (%u), not loading.", guid, type); continue; } @@ -6479,6 +6486,9 @@ void ObjectMgr::LoadCorpses() continue; } + for (auto phaseId : phases[guid]) + corpse->SetInPhase(phaseId, false, true); + sObjectAccessor->AddCorpse(corpse); ++count; } @@ -8527,60 +8537,64 @@ void ObjectMgr::LoadFactionChangeTitles() TC_LOG_INFO("server.loading", ">> Loaded %u faction change title pairs in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::LoadPhaseDefinitions() +void ObjectMgr::LoadTerrainSwapDefaults() { - _PhaseDefinitionStore.clear(); + _terrainMapDefaultStore.clear(); uint32 oldMSTime = getMSTime(); - // 0 1 2 3 - QueryResult result = WorldDatabase.Query("SELECT zoneId, entry, phaseId, phaseGroup FROM `phase_definitions` ORDER BY `entry` ASC"); + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT MapId, TerrainSwapMap FROM `terrain_swap_defaults`"); if (!result) { - TC_LOG_INFO("server.loading", ">> Loaded 0 phasing definitions. DB table `phase_definitions` is empty."); + TC_LOG_INFO("server.loading", ">> Loaded 0 terrain swap defaults. DB table `terrain_swap_defaults` is empty."); return; } uint32 count = 0; - do { Field* fields = result->Fetch(); - PhaseDefinition PhaseDefinition; + uint32 mapId = fields[0].GetUInt32(); + + MapEntry const* map = sMapStore.LookupEntry(mapId); + if (!map) + { + TC_LOG_ERROR("sql.sql", "Map %u defined in `terrain_swap_defaults` does not exist, skipped.", mapId); + continue; + } - PhaseDefinition.zoneId = fields[0].GetUInt32(); - PhaseDefinition.entry = fields[1].GetUInt32(); - PhaseDefinition.phaseId = fields[2].GetUInt32(); - PhaseDefinition.phaseGroup = fields[3].GetUInt32(); + uint32 terrainSwap = fields[1].GetUInt32(); - if (PhaseDefinition.phaseGroup && PhaseDefinition.phaseId) + map = sMapStore.LookupEntry(terrainSwap); + if (!map) { - TC_LOG_ERROR("sql.sql", "Phase definition for zone %u (Entry: %u) has phaseGroup and phaseId set, phaseGroup set to 0", PhaseDefinition.zoneId, PhaseDefinition.entry); - PhaseDefinition.phaseGroup = 0; + TC_LOG_ERROR("sql.sql", "TerrainSwapMap %u defined in `terrain_swap_defaults` does not exist, skipped.", terrainSwap); + continue; } - _PhaseDefinitionStore[PhaseDefinition.zoneId].push_back(PhaseDefinition); + + _terrainMapDefaultStore[mapId].push_back(terrainSwap); ++count; - } - while (result->NextRow()); + } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %u phasing definitions in %u ms.", count, GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u terrain swap defaults in %u ms.", count, GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::LoadPhaseInfo() +void ObjectMgr::LoadTerrainPhaseInfo() { - _PhaseInfoStore.clear(); + _terrainPhaseInfoStore.clear(); uint32 oldMSTime = getMSTime(); - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT id, worldmapareaswap, terrainswapmap FROM `phase_info`"); + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT Id, TerrainSwapMap FROM `terrain_phase_info`"); if (!result) { - TC_LOG_INFO("server.loading", ">> Loaded 0 phase infos. DB table `phase_info` is empty."); + TC_LOG_INFO("server.loading", ">> Loaded 0 terrain phase infos. DB table `terrain_phase_info` is empty."); return; } @@ -8589,25 +8603,93 @@ void ObjectMgr::LoadPhaseInfo() { Field* fields = result->Fetch(); - PhaseInfo phaseInfo; - phaseInfo.phaseId = fields[0].GetUInt32(); + uint32 phaseId = fields[0].GetUInt32(); - PhaseEntry const* phase = sPhaseStore.LookupEntry(phaseInfo.phaseId); + PhaseEntry const* phase = sPhaseStore.LookupEntry(phaseId); if (!phase) { - TC_LOG_ERROR("sql.sql", "Phase %u defined in `phase_info` does not exists, skipped.", phaseInfo.phaseId); + TC_LOG_ERROR("sql.sql", "Phase %u defined in `terrain_phase_info` does not exist, skipped.", phaseId); continue; } - phaseInfo.worldMapAreaSwap = fields[1].GetUInt32(); - phaseInfo.terrainSwapMap = fields[2].GetUInt32(); + uint32 terrainSwap = fields[1].GetUInt32(); - _PhaseInfoStore[phaseInfo.phaseId] = phaseInfo; + _terrainPhaseInfoStore[phaseId].push_back(terrainSwap); ++count; } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %u phase infos in %u ms.", count, GetMSTimeDiffToNow(oldMSTime)); + + TC_LOG_INFO("server.loading", ">> Loaded %u terrain phase infos in %u ms.", count, GetMSTimeDiffToNow(oldMSTime)); +} + +void ObjectMgr::LoadTerrainWorldMaps() +{ + _terrainWorldMapStore.clear(); + + uint32 oldMSTime = getMSTime(); + + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT TerrainSwapMap, WorldMapArea FROM `terrain_worldmap`"); + + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 terrain world maps. DB table `terrain_worldmap` is empty."); + return; + } + + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint32 mapId = fields[0].GetUInt32(); + + if (!sMapStore.LookupEntry(mapId)) + { + TC_LOG_ERROR("sql.sql", "TerrainSwapMap %u defined in `terrain_worldmap` does not exist, skipped.", mapId); + continue; + } + + uint32 worldMapArea = fields[1].GetUInt32(); + + _terrainWorldMapStore[mapId].push_back(worldMapArea); + + ++count; + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u terrain world maps in %u ms.", count, GetMSTimeDiffToNow(oldMSTime)); +} + +void ObjectMgr::LoadAreaPhases() +{ + _phases.clear(); + + uint32 oldMSTime = getMSTime(); + + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT AreaId, PhaseId FROM `phase_area`"); + + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 phase areas. DB table `phase_area` is empty."); + return; + } + + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint32 area = fields[0].GetUInt32(); + uint32 phase = fields[1].GetUInt32(); + + _phases[area].push_back(phase); + + ++count; + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u phase areas in %u ms.", count, GetMSTimeDiffToNow(oldMSTime)); } GameObjectTemplate const* ObjectMgr::GetGameObjectTemplate(uint32 entry) |