Core/Transports: Store information about continent transports
This commit is contained in:
1 parent
6e9ec1a4bf
commit
43c1876970
8 files changed
+153
-107
No files matched your search
@@ -598,6 +598,12 @@ enum TaxiNodeFlags
|
||||
TAXI_NODE_FLAG_UNK = 0x4
|
||||
};
|
||||
|
||||
enum TaxiPathNodeFlags
|
||||
{
|
||||
TAXI_PATH_NODE_FLAG_TELEPORT = 0x1,
|
||||
TAXI_PATH_NODE_FLAG_STOP = 0x2
|
||||
};
|
||||
|
||||
enum TotemCategoryType
|
||||
{
|
||||
TOTEM_CATEGORY_TYPE_KNIFE = 1,
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
|
||||
#include "TransportMgr.h"
|
||||
#include "Containers.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DBCStores.h"
|
||||
#include "GameObjectData.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "Log.h"
|
||||
@@ -28,13 +30,16 @@
|
||||
#include "Spline.h"
|
||||
#include "Transport.h"
|
||||
|
||||
TransportTemplate::~TransportTemplate()
|
||||
bool KeyFrame::IsStopFrame() const
|
||||
{
|
||||
return (Node->Flags & TAXI_PATH_NODE_FLAG_TELEPORT) != 0;
|
||||
}
|
||||
|
||||
TransportMgr::TransportMgr() { }
|
||||
TransportTemplate::~TransportTemplate() = default;
|
||||
|
||||
TransportMgr::~TransportMgr() { }
|
||||
TransportMgr::TransportMgr() = default;
|
||||
|
||||
TransportMgr::~TransportMgr() = default;
|
||||
|
||||
TransportMgr* TransportMgr::instance()
|
||||
{
|
||||
@@ -102,6 +107,83 @@ void TransportMgr::LoadTransportAnimationAndRotation()
|
||||
AddPathRotationToTransport(rot->GameObjectsID, rot->TimeIndex, rot);
|
||||
}
|
||||
|
||||
void TransportMgr::LoadTransportSpawns()
|
||||
{
|
||||
if (_transportTemplates.empty())
|
||||
return;
|
||||
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT guid, entry, phaseUseFlags, phaseid, phasegroup FROM transports");
|
||||
|
||||
uint32 count = 0;
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt64();
|
||||
uint32 entry = fields[1].GetUInt32();
|
||||
uint8 phaseUseFlags = fields[2].GetUInt8();
|
||||
uint32 phaseId = fields[3].GetUInt32();
|
||||
uint32 phaseGroupId = fields[4].GetUInt32();
|
||||
|
||||
if (!GetTransportTemplate(entry))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: " UI64FMTD " Entry: %u) with unknown gameobject `entry` set, skipped.", guid, entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (phaseUseFlags & ~PHASE_USE_FLAGS_ALL)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: " UI64FMTD " Entry: %u) with unknown `phaseUseFlags` set, removed unknown value.", guid, entry);
|
||||
phaseUseFlags &= PHASE_USE_FLAGS_ALL;
|
||||
}
|
||||
|
||||
if (phaseUseFlags & PHASE_USE_FLAGS_ALWAYS_VISIBLE && phaseUseFlags & PHASE_USE_FLAGS_INVERSE)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: " UI64FMTD " Entry: %u) has both `phaseUseFlags` PHASE_USE_FLAGS_ALWAYS_VISIBLE and PHASE_USE_FLAGS_INVERSE,"
|
||||
" removing PHASE_USE_FLAGS_INVERSE.", guid, entry);
|
||||
phaseUseFlags &= ~PHASE_USE_FLAGS_INVERSE;
|
||||
}
|
||||
|
||||
if (phaseGroupId && phaseId)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: " UI64FMTD " Entry: %u) with both `phaseid` and `phasegroup` set, `phasegroup` set to 0", guid, entry);
|
||||
phaseGroupId = 0;
|
||||
}
|
||||
|
||||
if (phaseId)
|
||||
{
|
||||
if (!sPhaseStore.LookupEntry(phaseId))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: " UI64FMTD " Entry: %u) with `phaseid` %u does not exist, set to 0", guid, entry, phaseId);
|
||||
phaseId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (phaseGroupId)
|
||||
{
|
||||
if (!sDBCManager.GetPhasesForGroup(phaseGroupId))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: " UI64FMTD " Entry: %u) with `phaseGroup` %u does not exist, set to 0", guid, entry, phaseGroupId);
|
||||
phaseGroupId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
TransportSpawn& spawn = _transportSpawns[guid];
|
||||
spawn.SpawnId = guid;
|
||||
spawn.TransportGameObjectId = entry;
|
||||
spawn.PhaseUseFlags = phaseUseFlags;
|
||||
spawn.PhaseId = phaseId;
|
||||
spawn.PhaseGroup = phaseGroupId;
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Spawned %u continent transports in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
class SplineRawInitializer
|
||||
{
|
||||
public:
|
||||
@@ -429,84 +511,44 @@ Transport* TransportMgr::CreateTransport(uint32 entry, ObjectGuid::LowType guid
|
||||
|
||||
void TransportMgr::SpawnContinentTransports()
|
||||
{
|
||||
if (_transportTemplates.empty())
|
||||
return;
|
||||
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT guid, entry, phaseUseFlags, phaseid, phasegroup FROM transports");
|
||||
|
||||
uint32 count = 0;
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
uint32 entry = fields[1].GetUInt32();
|
||||
uint8 phaseUseFlags = fields[2].GetUInt8();
|
||||
uint32 phaseId = fields[3].GetUInt32();
|
||||
uint32 phaseGroupId = fields[4].GetUInt32();
|
||||
|
||||
if (phaseUseFlags & ~PHASE_USE_FLAGS_ALL)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: %u Entry: %u) with unknown `phaseUseFlags` set, removed unknown value.", guid, entry);
|
||||
phaseUseFlags &= PHASE_USE_FLAGS_ALL;
|
||||
}
|
||||
|
||||
if (phaseUseFlags & PHASE_USE_FLAGS_ALWAYS_VISIBLE && phaseUseFlags & PHASE_USE_FLAGS_INVERSE)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: %u Entry: %u) has both `phaseUseFlags` PHASE_USE_FLAGS_ALWAYS_VISIBLE and PHASE_USE_FLAGS_INVERSE,"
|
||||
" removing PHASE_USE_FLAGS_INVERSE.", guid, entry);
|
||||
phaseUseFlags &= ~PHASE_USE_FLAGS_INVERSE;
|
||||
}
|
||||
|
||||
if (phaseGroupId && phaseId)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: %u Entry: %u) with both `phaseid` and `phasegroup` set, `phasegroup` set to 0", guid, entry);
|
||||
phaseGroupId = 0;
|
||||
}
|
||||
|
||||
if (phaseId)
|
||||
{
|
||||
if (!sPhaseStore.LookupEntry(phaseId))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: %u Entry: %u) with `phaseid` %u does not exist, set to 0", guid, entry, phaseId);
|
||||
phaseId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (phaseGroupId)
|
||||
{
|
||||
if (!sDBCManager.GetPhasesForGroup(phaseGroupId))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `transports` have transport (GUID: %u Entry: %u) with `phaseGroup` %u does not exist, set to 0", guid, entry, phaseGroupId);
|
||||
phaseGroupId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (TransportTemplate const* tInfo = GetTransportTemplate(entry))
|
||||
if (!tInfo->inInstance)
|
||||
if (CreateTransport(entry, guid, nullptr, phaseUseFlags, phaseId, phaseGroupId))
|
||||
++count;
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
for (auto itr = _transportSpawns.begin(); itr != _transportSpawns.end(); ++itr)
|
||||
if (!ASSERT_NOTNULL(GetTransportTemplate(itr->second.TransportGameObjectId))->inInstance)
|
||||
if (CreateTransport(itr->second.TransportGameObjectId, itr->second.SpawnId, nullptr, itr->second.PhaseUseFlags, itr->second.PhaseId, itr->second.PhaseGroup))
|
||||
++count;
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Spawned %u continent transports in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void TransportMgr::CreateInstanceTransports(Map* map)
|
||||
{
|
||||
TransportInstanceMap::const_iterator mapTransports = _instanceTransports.find(map->GetId());
|
||||
auto mapTransports = _instanceTransports.find(map->GetId());
|
||||
|
||||
// no transports here
|
||||
if (mapTransports == _instanceTransports.end() || mapTransports->second.empty())
|
||||
if (mapTransports == _instanceTransports.end())
|
||||
return;
|
||||
|
||||
// create transports
|
||||
for (std::set<uint32>::const_iterator itr = mapTransports->second.begin(); itr != mapTransports->second.end(); ++itr)
|
||||
CreateTransport(*itr, 0, map);
|
||||
for (uint32 transportGameObjectId : mapTransports->second)
|
||||
CreateTransport(transportGameObjectId, UI64LIT(0), map);
|
||||
}
|
||||
|
||||
TransportTemplate const* TransportMgr::GetTransportTemplate(uint32 entry) const
|
||||
{
|
||||
return Trinity::Containers::MapGetValuePtr(_transportTemplates, entry);
|
||||
}
|
||||
|
||||
TransportAnimation const* TransportMgr::GetTransportAnimInfo(uint32 entry) const
|
||||
{
|
||||
return Trinity::Containers::MapGetValuePtr(_transportAnimations, entry);
|
||||
}
|
||||
|
||||
TransportSpawn const* TransportMgr::GetTransportSpawn(ObjectGuid::LowType spawnId) const
|
||||
{
|
||||
return Trinity::Containers::MapGetValuePtr(_transportSpawns, spawnId);
|
||||
}
|
||||
|
||||
TransportAnimationEntry const* TransportAnimation::GetAnimNode(uint32 time) const
|
||||
|
||||
@@ -18,12 +18,16 @@
|
||||
#ifndef TRANSPORTMGR_H
|
||||
#define TRANSPORTMGR_H
|
||||
|
||||
#include "DBCStores.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
struct KeyFrame;
|
||||
struct GameObjectTemplate;
|
||||
struct TaxiPathNodeEntry;
|
||||
struct TransportAnimationEntry;
|
||||
struct TransportRotationEntry;
|
||||
struct TransportTemplate;
|
||||
class Transport;
|
||||
class Map;
|
||||
@@ -33,12 +37,8 @@ namespace Movement
|
||||
template <typename length_type> class Spline;
|
||||
}
|
||||
|
||||
typedef Movement::Spline<double> TransportSpline;
|
||||
typedef std::vector<KeyFrame> KeyFrameVec;
|
||||
typedef std::unordered_map<uint32, TransportTemplate> TransportTemplates;
|
||||
typedef std::set<Transport*> TransportSet;
|
||||
typedef std::unordered_map<uint32, TransportSet> TransportMap;
|
||||
typedef std::unordered_map<uint32, std::set<uint32> > TransportInstanceMap;
|
||||
using TransportSpline = Movement::Spline<double>;
|
||||
using KeyFrameVec = std::vector<KeyFrame>;
|
||||
|
||||
struct KeyFrame
|
||||
{
|
||||
@@ -65,14 +65,8 @@ struct KeyFrame
|
||||
float NextDistFromPrev;
|
||||
uint32 NextArriveTime;
|
||||
|
||||
bool IsTeleportFrame() const
|
||||
{
|
||||
return Teleport;
|
||||
}
|
||||
bool IsStopFrame() const
|
||||
{
|
||||
return Node->Flags == 2;
|
||||
}
|
||||
bool IsTeleportFrame() const{ return Teleport; }
|
||||
bool IsStopFrame() const;
|
||||
};
|
||||
|
||||
struct TransportTemplate
|
||||
@@ -91,24 +85,27 @@ struct TransportTemplate
|
||||
uint32 entry;
|
||||
};
|
||||
|
||||
typedef std::map<uint32, TransportAnimationEntry const*> TransportPathContainer;
|
||||
typedef std::map<uint32, TransportRotationEntry const*> TransportPathRotationContainer;
|
||||
|
||||
struct TC_GAME_API TransportAnimation
|
||||
{
|
||||
TransportAnimation() : TotalTime(0)
|
||||
{
|
||||
}
|
||||
TransportAnimation() : TotalTime(0) { }
|
||||
|
||||
TransportPathContainer Path;
|
||||
TransportPathRotationContainer Rotations;
|
||||
std::map<uint32, TransportAnimationEntry const*> Path;
|
||||
std::map<uint32, TransportRotationEntry const*> Rotations;
|
||||
uint32 TotalTime;
|
||||
|
||||
TransportAnimationEntry const* GetAnimNode(uint32 time) const;
|
||||
TransportRotationEntry const* GetAnimRotation(uint32 time) const;
|
||||
};
|
||||
|
||||
typedef std::map<uint32, TransportAnimation> TransportAnimationContainer;
|
||||
|
||||
struct TransportSpawn
|
||||
{
|
||||
ObjectGuid::LowType SpawnId = UI64LIT(0);
|
||||
uint32 TransportGameObjectId = 0; // entry in respective _template table
|
||||
uint8 PhaseUseFlags = 0;
|
||||
uint32 PhaseId = 0;
|
||||
uint32 PhaseGroup = 0;
|
||||
};
|
||||
|
||||
class TC_GAME_API TransportMgr
|
||||
{
|
||||
@@ -121,6 +118,8 @@ public:
|
||||
|
||||
void LoadTransportAnimationAndRotation();
|
||||
|
||||
void LoadTransportSpawns();
|
||||
|
||||
// Creates a transport using given GameObject template entry
|
||||
Transport* CreateTransport(uint32 entry, ObjectGuid::LowType guid = 0, Map* map = nullptr, uint8 phaseUseFlags = 0, uint32 phaseId = 0, uint32 phaseGroupId = 0);
|
||||
|
||||
@@ -130,22 +129,11 @@ public:
|
||||
// creates all transports for instance
|
||||
void CreateInstanceTransports(Map* map);
|
||||
|
||||
TransportTemplate const* GetTransportTemplate(uint32 entry) const
|
||||
{
|
||||
TransportTemplates::const_iterator itr = _transportTemplates.find(entry);
|
||||
if (itr != _transportTemplates.end())
|
||||
return &itr->second;
|
||||
return nullptr;
|
||||
}
|
||||
TransportTemplate const* GetTransportTemplate(uint32 entry) const;
|
||||
|
||||
TransportAnimation const* GetTransportAnimInfo(uint32 entry) const
|
||||
{
|
||||
TransportAnimationContainer::const_iterator itr = _transportAnimations.find(entry);
|
||||
if (itr != _transportAnimations.end())
|
||||
return &itr->second;
|
||||
TransportAnimation const* GetTransportAnimInfo(uint32 entry) const;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
TransportSpawn const* GetTransportSpawn(ObjectGuid::LowType spawnId) const;
|
||||
|
||||
private:
|
||||
TransportMgr();
|
||||
@@ -164,12 +152,14 @@ private:
|
||||
}
|
||||
|
||||
// Container storing transport templates
|
||||
TransportTemplates _transportTemplates;
|
||||
std::unordered_map<uint32, TransportTemplate> _transportTemplates;
|
||||
|
||||
// Container storing transport entries to create for instanced maps
|
||||
TransportInstanceMap _instanceTransports;
|
||||
std::unordered_map<uint32, std::set<uint32>> _instanceTransports;
|
||||
|
||||
TransportAnimationContainer _transportAnimations;
|
||||
std::map<uint32, TransportAnimation> _transportAnimations;
|
||||
|
||||
std::unordered_map<ObjectGuid::LowType, TransportSpawn> _transportSpawns;
|
||||
};
|
||||
|
||||
#define sTransportMgr TransportMgr::instance()
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "CreatureGroups.h"
|
||||
#include "CreatureTextMgr.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DBCStores.h"
|
||||
#include "DB2Stores.h"
|
||||
#include "DBCStores.h"
|
||||
#include "DisableMgr.h"
|
||||
@@ -1794,6 +1795,9 @@ void World::SetInitialWorldSettings()
|
||||
TC_LOG_INFO("server.loading", "Loading Transport animations and rotations...");
|
||||
sTransportMgr->LoadTransportAnimationAndRotation();
|
||||
|
||||
TC_LOG_INFO("server.loading", "Loading Transport spawns...");
|
||||
sTransportMgr->LoadTransportSpawns();
|
||||
|
||||
TC_LOG_INFO("server.loading", "Loading Spell Rank Data...");
|
||||
sSpellMgr->LoadSpellRanks();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ EndScriptData */
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "CellImpl.h"
|
||||
#include "Chat.h"
|
||||
#include "DBCStores.h"
|
||||
#include "GossipDef.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "InstanceScript.h"
|
||||
|
||||
@@ -25,6 +25,7 @@ EndScriptData */
|
||||
#include "ScriptMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DBCStores.h"
|
||||
#include "Language.h"
|
||||
#include "MapManager.h"
|
||||
#include "MotionMaster.h"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ChaseMovementGenerator.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DBCStores.h"
|
||||
#include "DB2Stores.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "FollowMovementGenerator.h"
|
||||
|
||||
@@ -27,6 +27,7 @@ EndScriptData */
|
||||
#include "CreatureAI.h"
|
||||
#include "CreatureGroups.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DBCStores.h"
|
||||
#include "FollowMovementGenerator.h"
|
||||
#include "GameTime.h"
|
||||
#include "Language.h"
|
||||
|
||||
Reference in new issue
Block a user