Core/Phases: Added a new table, terrain_map_info, where you can bind a specific terrain swap to a map, and it will be sent to the player when he enters the map.

ToDo: Add conditions support for this.
ToDo: This data is already in the DBC (parentMapId) but is it complete? This way allows us an extra degree of freedom if / when we need to add extra information to this table.
This commit is contained in:
Subv committed 2014-10-27 21:36:16 -05:00
1 parent 84c3165067
commit f86b8aa573
7 files changed
+85 -13

No files matched your search

+10
View File
@@ -1,9 +1,19 @@
DROP TABLE IF EXISTS `phase_definitions`;
DROP TABLE IF EXISTS `phase_info`;
DROP TABLE IF EXISTS `terrain_phase_info`;
DROP TABLE IF EXISTS `terrain_map_info`;
CREATE TABLE `terrain_phase_info`(
`id` INT(10) NOT NULL,
`terrainswapmap` INT(10) NOT NULL,
`comment` VARCHAR(255),
PRIMARY KEY (`id`, `terrainswapmap`)
);
CREATE TABLE `terrain_map_info`(
`mapid` INT(10) NOT NULL,
`terrainswapmap` INT(10) NOT NULL,
`comment` VARCHAR(255),
PRIMARY KEY (`mapid`, `terrainswapmap`)
);
+21 -11
View File
@@ -2731,17 +2731,7 @@ void WorldObject::SetInPhase(uint32 id, bool update, bool apply)
else
_phases.erase(id);
// Clear all terrain swaps, will be rebuilt below
// Reason for this is, multiple phases can have the same terrain swap, we should not remove the swap if another phase still use it
_terrainSwaps.clear();
// Check all applied phases for terrain swap and add it only once
for (auto phaseId : _phases)
{
std::list<uint32>& swaps = sObjectMgr->GetPhaseTerrainSwaps(phaseId);
for (auto swap : swaps)
_terrainSwaps.insert(swap);
}
RebuildTerrainSwaps();
if (update && IsInWorld())
UpdateObjectVisibility();
@@ -2914,3 +2904,23 @@ ObjectGuid WorldObject::GetTransGUID() const
return GetTransport()->GetGUID();
return ObjectGuid::Empty;
}
void WorldObject::RebuildTerrainSwaps()
{
// Clear all terrain swaps, will be rebuilt below
// Reason for this is, multiple phases can have the same terrain swap, we should not remove the swap if another phase still use it
_terrainSwaps.clear();
// Check all applied phases for terrain swap and add it only once
for (auto phaseId : _phases)
{
std::list<uint32>& swaps = sObjectMgr->GetPhaseTerrainSwaps(phaseId);
for (auto swap : swaps)
_terrainSwaps.insert(swap);
}
// Now insert the map terrain swaps
std::list<uint32>& mapSwaps = sObjectMgr->GetMapTerrainSwaps(GetMapId());
for (auto swap : mapSwaps)
_terrainSwaps.insert(swap);
}
+1
View File
@@ -593,6 +593,7 @@ class WorldObject : public Object, public WorldLocation
virtual void SetPhaseMask(uint32 newPhaseMask, bool update);
virtual void SetInPhase(uint32 id, bool update, bool apply);
void RebuildTerrainSwaps();
uint32 GetPhaseMask() const { return m_phaseMask; }
bool InSamePhase(WorldObject const* obj) const;
bool InSamePhase(uint32 phasemask) const { return (GetPhaseMask() & phasemask) != 0; }
+43 -1
View File
@@ -9226,8 +9226,49 @@ void ObjectMgr::LoadFactionChangeTitles()
TC_LOG_INFO("server.loading", ">> Loaded %u faction change title pairs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadTerrainMapInfo()
{
_terrainMapInfoStore.clear();
uint32 oldMSTime = getMSTime();
// 0 1
QueryResult result = WorldDatabase.Query("SELECT mapid, terrainswapmap FROM `terrain_map_info`");
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 terrain area infos. DB table `terrain_map_info` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 mapId = fields[0].GetUInt32();
MapEntry const* map = sMapStore.LookupEntry(mapId);
if (!map)
{
TC_LOG_ERROR("sql.sql", "Map %u defined in `terrain_map_info` does not exist, skipped.", mapId);
continue;
}
uint32 terrainSwap = fields[1].GetUInt32();
_terrainMapInfoStore[mapId].push_back(terrainSwap);
++count;
} while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u terrain map infos in %u ms.", count, GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadTerrainPhaseInfo()
{
_terrainPhaseInfoStore.clear();
uint32 oldMSTime = getMSTime();
// 0 1
@@ -9249,7 +9290,7 @@ void ObjectMgr::LoadTerrainPhaseInfo()
PhaseEntry const* phase = sPhaseStore.LookupEntry(phaseId);
if (!phase)
{
TC_LOG_ERROR("sql.sql", "Phase %u defined in `terrain_phase_info` does not exists, skipped.", phaseId);
TC_LOG_ERROR("sql.sql", "Phase %u defined in `terrain_phase_info` does not exist, skipped.", phaseId);
continue;
}
@@ -9260,6 +9301,7 @@ void ObjectMgr::LoadTerrainPhaseInfo()
++count;
}
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u terrain phase infos in %u ms.", count, GetMSTimeDiffToNow(oldMSTime));
}
+4 -1
View File
@@ -1029,6 +1029,7 @@ class ObjectMgr
void AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel);
void LoadTerrainPhaseInfo();
void LoadTerrainMapInfo();
std::string GeneratePetName(uint32 entry);
uint32 GetBaseXP(uint8 level);
@@ -1286,6 +1287,7 @@ class ObjectMgr
}
std::list<uint32>& GetPhaseTerrainSwaps(uint32 phaseid) { return _terrainPhaseInfoStore[phaseid]; }
std::list<uint32>& GetMapTerrainSwaps(uint32 mapid) { return _terrainMapInfoStore[mapid]; }
// for wintergrasp only
GraveYardContainer GraveYardStore;
@@ -1403,6 +1405,7 @@ class ObjectMgr
InstanceTemplateContainer _instanceTemplateStore;
TerrainPhaseInfo _terrainPhaseInfoStore;
TerrainPhaseInfo _terrainMapInfoStore;
private:
void LoadScripts(ScriptsType type);
@@ -1418,7 +1421,7 @@ class ObjectMgr
PetLevelInfoContainer _petInfoStore; // [creature_id][level]
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const;
PlayerInfo* _playerInfo[MAX_RACES][MAX_CLASSES];
typedef std::vector<uint32> PlayerXPperLevel; // [level]
+3
View File
@@ -546,6 +546,9 @@ bool Map::AddToMap(T* obj)
if (obj->isActiveObject())
AddToActive(obj);
obj->RebuildTerrainSwaps();
obj->SendUpdatePhasing();
//something, such as vehicle, needs to be update immediately
//also, trigger needs to cast spell, if not update, cannot see visual
obj->UpdateObjectVisibility(true);
+3
View File
@@ -1729,6 +1729,9 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading Terrain Phase definitions...");
sObjectMgr->LoadTerrainPhaseInfo();
TC_LOG_INFO("server.loading", "Loading Terrain Map definitions...");
sObjectMgr->LoadTerrainMapInfo();
TC_LOG_INFO("server.loading", "Loading Conditions...");
sConditionMgr->LoadConditions();