Created
October 7, 2013 19:03
-
-
Save rsa/6873149 to your computer and use it in GitHub Desktop.
make class MOTransport for split regular transport (GAMEOBJECT_TYPE_T… …RANSPORT) and MOTransport (GAMEOBJECT_TYPE_MO_TRANSPORT) functionality. independent from other Transport related commits, need test (no real changes in game mechanic must be). testing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/game/BattleGround/BattleGroundIC.cpp b/src/game/BattleGround/BattleGroundIC.cpp | |
index 0734064..b31315b 100644 | |
--- a/src/game/BattleGround/BattleGroundIC.cpp | |
+++ b/src/game/BattleGround/BattleGroundIC.cpp | |
@@ -213,7 +213,7 @@ void BattleGroundIC::Update(uint32 diff) | |
// gunship starting | |
if (node == BG_IC_NODE_HANGAR) | |
- (teamIndex == TEAM_INDEX_ALLIANCE ? gunshipAlliance : gunshipHorde)->BuildStartMovePacket(GetBgMap()); | |
+ (teamIndex == TEAM_INDEX_ALLIANCE ? gunshipAlliance : gunshipHorde)->Start(); | |
} | |
} | |
} | |
@@ -593,7 +593,7 @@ void BattleGroundIC::EventPlayerClickedOnFlag(Player *source, GameObject* target | |
sound = (teamIndex == TEAM_INDEX_ALLIANCE) ? BG_IC_SOUND_NODE_ASSAULTED_ALLIANCE : BG_IC_SOUND_NODE_ASSAULTED_HORDE; | |
if (node == BG_IC_NODE_HANGAR) | |
- (teamIndex == TEAM_INDEX_ALLIANCE ? gunshipHorde : gunshipAlliance)->BuildStopMovePacket(GetBgMap()); | |
+ (teamIndex == TEAM_INDEX_ALLIANCE ? gunshipHorde : gunshipAlliance)->Stop(); | |
} | |
PlaySoundToAll(sound); | |
} | |
@@ -784,7 +784,8 @@ WorldSafeLocsEntry const* BattleGroundIC::GetClosestGraveYard(Player* player) | |
Transport* BattleGroundIC::CreateTransport(uint32 goEntry, uint32 period) | |
{ | |
- Transport* t = new Transport; | |
+ // FIXME - remove this method always... | |
+ MOTransport* t = new MOTransport; | |
const GameObjectInfo* goinfo = sObjectMgr.GetGameObjectInfo(goEntry); | |
@@ -796,7 +797,7 @@ Transport* BattleGroundIC::CreateTransport(uint32 goEntry, uint32 period) | |
} | |
std::set<uint32> mapsUsed; | |
- t->m_period = period; | |
+ t->SetDBPeriod(period); | |
if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed)) | |
// skip transports with empty waypoints list | |
@@ -806,7 +807,7 @@ Transport* BattleGroundIC::CreateTransport(uint32 goEntry, uint32 period) | |
return NULL; | |
} | |
- WorldLocation const& loc = t->m_WayPoints[0].loc; | |
+ WorldLocation const& loc = t->GetWayPoint(0).loc; | |
// creates the Gameobject | |
if (!t->Create(goEntry, loc.GetMapId(), loc.x, loc.y, loc.z, loc.o, GO_ANIMPROGRESS_DEFAULT, 0)) | |
diff --git a/src/game/Creature.h b/src/game/Creature.h | |
index 474251a..0768853 100644 | |
--- a/src/game/Creature.h | |
+++ b/src/game/Creature.h | |
@@ -505,7 +505,7 @@ class MANGOS_DLL_SPEC Creature : public Unit | |
char const* GetSubName() const { return m_creatureInfo->SubName; } | |
- void Update(uint32 update_diff, uint32 time) override; // overwrite Unit::Update | |
+ virtual void Update(uint32 update_diff, uint32 time) override; // overwrite Unit::Update | |
virtual void RegenerateAll(uint32 update_diff); | |
diff --git a/src/game/GameObject.h b/src/game/GameObject.h | |
index ac4b563..fd0ca04 100644 | |
--- a/src/game/GameObject.h | |
+++ b/src/game/GameObject.h | |
@@ -629,7 +629,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject | |
virtual bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, | |
QuaternionData rotation = QuaternionData(), uint8 animprogress = GO_ANIMPROGRESS_DEFAULT, GOState go_state = GO_STATE_READY); | |
- void Update(uint32 update_diff, uint32 p_time) override; | |
+ virtual void Update(uint32 update_diff, uint32 p_time) override; | |
GameObjectInfo const* GetGOInfo() const; | |
virtual bool IsTransport() const override; | |
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp | |
index 35a3089..6b2e439 100644 | |
--- a/src/game/Level3.cpp | |
+++ b/src/game/Level3.cpp | |
@@ -7481,9 +7481,9 @@ bool ChatHandler::HandleTransportCurrentCommand(char* args) | |
if (!transport) | |
{ | |
PSendSysMessage("Player not on same map with binded transport!"); | |
- uint32 currentMap = Transport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
+ uint32 currentMap = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
if (currentMap == UINT32_MAX || currentMap == player->GetMapId()) | |
- currentMap = Transport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
+ currentMap = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
if (currentMap != UINT32_MAX) | |
map = sMapMgr.CreateMap(currentMap, player); | |
@@ -7549,7 +7549,7 @@ bool ChatHandler::HandleTransportPathCommand(char* args) | |
return true; | |
} | |
- uint32 currentMap = Transport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
+ uint32 currentMap = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
Map* map = NULL; | |
if (currentMap != UINT32_MAX) | |
@@ -7562,7 +7562,7 @@ bool ChatHandler::HandleTransportPathCommand(char* args) | |
if (!transport) | |
{ | |
- uint32 currentMap2 = Transport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
+ uint32 currentMap2 = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
if (currentMap2 != UINT32_MAX) | |
map = sMapMgr.CreateMap(currentMap2, player); | |
@@ -7575,30 +7575,42 @@ bool ChatHandler::HandleTransportPathCommand(char* args) | |
return true; | |
} | |
} | |
- PSendSysMessage("Transport: %s on map %u (%s), %s, passengers "SIZEFMTD", current time %u (map %u xyz %f %f %f)", | |
+ if (transport->IsMOTransport()) | |
+ { | |
+ PSendSysMessage("Transport: %s on map %u (%s), %s, passengers "SIZEFMTD", current time %u (map %u xyz %f %f %f)", | |
transport->GetObjectGuid().GetString().c_str(), | |
map->GetId(), | |
- transport->GetName(), | |
+ ((MOTransport*)transport)->GetName(), | |
transport->isActiveObject() ? "active" : "passive", | |
transport->GetTransportKit()->GetPassengers().size(), | |
- transport->GetCurrent()->first, | |
- transport->GetCurrent()->second.loc.GetMapId(), | |
- transport->GetCurrent()->second.loc.getX(), | |
- transport->GetCurrent()->second.loc.getY(), | |
- transport->GetCurrent()->second.loc.getZ() | |
+ ((MOTransport*)transport)->GetCurrent()->first, | |
+ ((MOTransport*)transport)->GetCurrent()->second.loc.GetMapId(), | |
+ ((MOTransport*)transport)->GetCurrent()->second.loc.getX(), | |
+ ((MOTransport*)transport)->GetCurrent()->second.loc.getY(), | |
+ ((MOTransport*)transport)->GetCurrent()->second.loc.getZ() | |
); | |
- PSendSysMessage("Transport: %s on map %u (%s), %s, passengers "SIZEFMTD", next time %u (map %u xyz %f %f %f)", | |
+ PSendSysMessage("Transport: %s on map %u (%s), %s, passengers "SIZEFMTD", next time %u (map %u xyz %f %f %f)", | |
transport->GetObjectGuid().GetString().c_str(), | |
map->GetId(), | |
- transport->GetName(), | |
+ ((MOTransport*)transport)->GetName(), | |
transport->isActiveObject() ? "active" : "passive", | |
transport->GetTransportKit()->GetPassengers().size(), | |
- transport->GetNext()->first, | |
- transport->GetNext()->second.loc.GetMapId(), | |
- transport->GetNext()->second.loc.getX(), | |
- transport->GetNext()->second.loc.getY(), | |
- transport->GetNext()->second.loc.getZ() | |
+ ((MOTransport*)transport)->GetNext()->first, | |
+ ((MOTransport*)transport)->GetNext()->second.loc.GetMapId(), | |
+ ((MOTransport*)transport)->GetNext()->second.loc.getX(), | |
+ ((MOTransport*)transport)->GetNext()->second.loc.getY(), | |
+ ((MOTransport*)transport)->GetNext()->second.loc.getZ() | |
); | |
+ } | |
+ else | |
+ { | |
+ PSendSysMessage("Transport: %s on map %u, %s, passengers "SIZEFMTD"", | |
+ transport->GetObjectGuid().GetString().c_str(), | |
+ map->GetId(), | |
+ transport->isActiveObject() ? "active" : "passive", | |
+ transport->GetTransportKit()->GetPassengers().size() | |
+ ); | |
+ } | |
return true; | |
} | |
@@ -7615,7 +7627,7 @@ bool ChatHandler::HandleTransportCommand(char* args) | |
Player* player = m_session->GetPlayer(); | |
ObjectGuid guid = ObjectGuid(HIGHGUID_MO_TRANSPORT, transportEntry); | |
- uint32 currentMap = Transport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
+ uint32 currentMap = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
Map* map = NULL; | |
if (currentMap != UINT32_MAX) | |
@@ -7628,7 +7640,7 @@ bool ChatHandler::HandleTransportCommand(char* args) | |
if (!transport) | |
{ | |
- uint32 currentMap2 = Transport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
+ uint32 currentMap2 = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
if (currentMap2 != UINT32_MAX) | |
map = sMapMgr.CreateMap(currentMap2, player); | |
@@ -7668,7 +7680,7 @@ bool ChatHandler::HandleTransportGoCommand(char* args) | |
Player* player = m_session->GetPlayer(); | |
ObjectGuid guid = ObjectGuid(HIGHGUID_MO_TRANSPORT, transportEntry); | |
- uint32 currentMap = Transport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
+ uint32 currentMap = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
Map* map = NULL; | |
if (currentMap != UINT32_MAX) | |
@@ -7681,7 +7693,7 @@ bool ChatHandler::HandleTransportGoCommand(char* args) | |
if (!transport) | |
{ | |
- uint32 currentMap2 = Transport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
+ uint32 currentMap2 = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
if (currentMap2 != UINT32_MAX) | |
map = sMapMgr.CreateMap(currentMap2, player); | |
@@ -7713,7 +7725,7 @@ bool ChatHandler::HandleTransportStartCommand(char* args) | |
Player* player = m_session->GetPlayer(); | |
ObjectGuid guid = ObjectGuid(HIGHGUID_MO_TRANSPORT, transportEntry); | |
- uint32 currentMap = Transport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
+ uint32 currentMap = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
Map* map = NULL; | |
if (currentMap != UINT32_MAX) | |
@@ -7726,7 +7738,7 @@ bool ChatHandler::HandleTransportStartCommand(char* args) | |
if (!transport) | |
{ | |
- uint32 currentMap2 = Transport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
+ uint32 currentMap2 = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
if (currentMap2 != UINT32_MAX) | |
map = sMapMgr.CreateMap(currentMap2, player); | |
@@ -7755,7 +7767,7 @@ bool ChatHandler::HandleTransportStopCommand(char* args) | |
Player* player = m_session->GetPlayer(); | |
ObjectGuid guid = ObjectGuid(HIGHGUID_MO_TRANSPORT, transportEntry); | |
- uint32 currentMap = Transport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
+ uint32 currentMap = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), true); | |
Map* map = NULL; | |
if (currentMap != UINT32_MAX) | |
@@ -7768,7 +7780,7 @@ bool ChatHandler::HandleTransportStopCommand(char* args) | |
if (!transport) | |
{ | |
- uint32 currentMap2 = Transport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
+ uint32 currentMap2 = MOTransport::GetPossibleMapByEntry(guid.GetCounter(), false); | |
if (currentMap2 != UINT32_MAX) | |
map = sMapMgr.CreateMap(currentMap2, player); | |
diff --git a/src/game/Object.h b/src/game/Object.h | |
index e5c8963..35764fc 100644 | |
--- a/src/game/Object.h | |
+++ b/src/game/Object.h | |
@@ -473,6 +473,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object | |
void SetTransportInfo(TransportInfo* transportInfo) { m_transportInfo = transportInfo; } | |
virtual bool IsTransport() const { return false; }; | |
+ virtual bool IsMOTransport() const { return false; }; | |
TransportBase* GetTransportBase(); | |
void Relocate(WorldLocation const& location); | |
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp | |
index 5cd14ac..3b24931 100644 | |
--- a/src/game/ObjectMgr.cpp | |
+++ b/src/game/ObjectMgr.cpp | |
@@ -10101,15 +10101,15 @@ void ObjectMgr::LoadTransports() | |
{ | |
bar.step(); | |
- Transport* t = new Transport; | |
+ MOTransport* t = new MOTransport; | |
- Field *fields = result->Fetch(); | |
+ Field* fields = result->Fetch(); | |
uint32 entry = fields[0].GetUInt32(); | |
std::string name = fields[1].GetCppString(); | |
- t->m_period = fields[2].GetUInt32(); | |
+ t->SetDBPeriod(fields[2].GetUInt32()); | |
- const GameObjectInfo *goinfo = ObjectMgr::GetGameObjectInfo(entry); | |
+ GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(entry); | |
if(!goinfo) | |
{ | |
@@ -10137,10 +10137,10 @@ void ObjectMgr::LoadTransports() | |
continue; | |
} | |
- WorldLocation loc = t->m_WayPoints[0].loc; | |
+ WorldLocation loc = t->GetWayPoint(0).loc; | |
//current code does not support transports in dungeon! | |
- const MapEntry* pMapInfo = sMapStore.LookupEntry(loc.GetMapId()); | |
+ MapEntry const* pMapInfo = sMapStore.LookupEntry(loc.GetMapId()); | |
if(!pMapInfo || pMapInfo->Instanceable()) | |
{ | |
delete t; | |
@@ -10189,11 +10189,11 @@ void ObjectMgr::LoadTransports() | |
} | |
} | |
-Transport const* ObjectMgr::GetTransportByGOMapId(uint32 mapid) const | |
+MOTransport const* ObjectMgr::GetTransportByGOMapId(uint32 mapid) const | |
{ | |
for (TransportSet::const_iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter) | |
{ | |
- Transport const* transport = *iter; | |
+ MOTransport const* transport = *iter; | |
if (!transport) | |
continue; | |
@@ -10204,11 +10204,11 @@ Transport const* ObjectMgr::GetTransportByGOMapId(uint32 mapid) const | |
return NULL; | |
} | |
-Transport* ObjectMgr::GetTransportByGuid(ObjectGuid const& guid) | |
+MOTransport* ObjectMgr::GetTransportByGuid(ObjectGuid const& guid) | |
{ | |
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter) | |
{ | |
- Transport* transport = *iter; | |
+ MOTransport* transport = *iter; | |
if (!transport) | |
continue; | |
@@ -10232,12 +10232,12 @@ void ObjectMgr::LoadTransports(Map* map) | |
uint32 count = 0; | |
do | |
{ | |
- Field *fields = result->Fetch(); | |
+ Field* fields = result->Fetch(); | |
uint32 entry = fields[0].GetUInt32(); | |
std::string name = fields[1].GetCppString(); | |
uint32 period = fields[2].GetUInt32(); | |
- if (Transport::GetPossibleMapByEntry(entry, true) != map->GetId() || !Transport::IsSpawnedAtDifficulty(entry, map->GetDifficulty())) | |
+ if (MOTransport::GetPossibleMapByEntry(entry, true) != map->GetId() || !MOTransport::IsSpawnedAtDifficulty(entry, map->GetDifficulty())) | |
continue; | |
++count; | |
@@ -10259,7 +10259,7 @@ void ObjectMgr::LoadTransports(Map* map) | |
transport->GetPositionZ()); | |
} | |
*/ | |
- } while(result->NextRow()); | |
+ } while (result->NextRow()); | |
delete result; | |
diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h | |
index 5870882..ff8db7e 100644 | |
--- a/src/game/ObjectMgr.h | |
+++ b/src/game/ObjectMgr.h | |
@@ -47,6 +47,7 @@ class Group; | |
class ArenaTeam; | |
class Item; | |
class SQLStorage; | |
+class MOTransport; | |
struct GameTele | |
{ | |
@@ -856,11 +857,11 @@ class ObjectMgr | |
void LoadTransports(Map* map); | |
void LoadTransports(); | |
- typedef UNORDERED_SET<Transport*> TransportSet; | |
+ typedef UNORDERED_SET<MOTransport*> TransportSet; | |
TransportSet const& GetTransports() { return m_Transports; }; | |
- Transport* GetTransportByGuid(ObjectGuid const& guid); | |
- Transport const* GetTransportByGOMapId(uint32 mapid) const; | |
+ MOTransport* GetTransportByGuid(ObjectGuid const& guid); | |
+ MOTransport const* GetTransportByGOMapId(uint32 mapid) const; | |
std::string GeneratePetName(uint32 entry); | |
uint32 GetBaseXP(uint32 level) const; | |
diff --git a/src/game/Pet.h b/src/game/Pet.h | |
index 3f6d3bb..c8b4454 100644 | |
--- a/src/game/Pet.h | |
+++ b/src/game/Pet.h | |
@@ -171,7 +171,7 @@ class MANGOS_DLL_SPEC Pet : public Creature | |
static void DeleteFromDB(uint32 guidlow, bool separate_transaction = true); | |
void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState | |
- void Update(uint32 update_diff, uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update | |
+ virtual void Update(uint32 update_diff, uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update | |
uint8 GetPetAutoSpellSize() const { return m_autospells.size(); } | |
uint32 GetPetAutoSpellOnPos(uint8 pos) const | |
diff --git a/src/game/Player.h b/src/game/Player.h | |
index 35625c0..d4f9bba 100644 | |
--- a/src/game/Player.h | |
+++ b/src/game/Player.h | |
@@ -1068,7 +1068,7 @@ class MANGOS_DLL_SPEC Player : public Unit | |
bool Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ); | |
- void Update(uint32 update_diff, uint32 time) override; | |
+ virtual void Update(uint32 update_diff, uint32 time) override; | |
static bool BuildEnumData( QueryResult * result, WorldPacket * p_data ); | |
diff --git a/src/game/TemporarySummon.h b/src/game/TemporarySummon.h | |
index 6bf6f2f..4d7f3a2 100644 | |
--- a/src/game/TemporarySummon.h | |
+++ b/src/game/TemporarySummon.h | |
@@ -39,7 +39,7 @@ class TemporarySummon : public Creature | |
explicit TemporarySummon(ObjectGuid summoner = ObjectGuid()); | |
virtual ~TemporarySummon(){}; | |
- void Update(uint32 update_diff, uint32 time) override; | |
+ virtual void Update(uint32 update_diff, uint32 time) override; | |
void Summon(TempSummonType type, uint32 lifetime); | |
void MANGOS_DLL_SPEC UnSummon(uint32 delay = 0); | |
void SaveToDB(); | |
diff --git a/src/game/Totem.h b/src/game/Totem.h | |
index 1b38a77..7bd35b3 100644 | |
--- a/src/game/Totem.h | |
+++ b/src/game/Totem.h | |
@@ -36,7 +36,7 @@ class Totem : public Creature | |
explicit Totem(); | |
virtual ~Totem(){}; | |
bool Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, Unit* owner); | |
- void Update(uint32 update_diff, uint32 time) override; | |
+ virtual void Update(uint32 update_diff, uint32 time) override; | |
void Summon(Unit* owner); | |
void UnSummon(); | |
uint32 GetSpell(uint32 idx = 0) const { return ((Creature*)this)->GetSpell(idx); } | |
diff --git a/src/game/TransportSystem.cpp b/src/game/TransportSystem.cpp | |
index a666d60..cbdc267 100644 | |
--- a/src/game/TransportSystem.cpp | |
+++ b/src/game/TransportSystem.cpp | |
@@ -252,7 +252,7 @@ void NotifyMapChangeBegin::operator() (WorldObject* obj) const | |
if (plr->GetSession() && m_oldloc.GetMapId() != m_loc.GetMapId()) | |
{ | |
WorldPacket data(SMSG_NEW_WORLD, 4); | |
- data << uint32(plr->IsOnTransport() ? plr->GetTransport()->GetTransportMapId() : m_loc.GetMapId()); | |
+ data << uint32(m_loc.GetMapId()); | |
plr->GetSession()->SendPacket(&data); | |
} | |
plr->TeleportTo(m_loc, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NODELAY); | |
diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp | |
index b85ca84..ef8983b 100644 | |
--- a/src/game/Transports.cpp | |
+++ b/src/game/Transports.cpp | |
@@ -30,6 +30,7 @@ | |
#include "movement/MoveSplineInit.h" | |
#include "movement/MoveSpline.h" | |
+// Transport - base class for regular Transport && MOTransport class | |
Transport::Transport() : GameObject(), m_transportKit(NULL) | |
{ | |
m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_ROTATION); | |
@@ -37,17 +38,61 @@ Transport::Transport() : GameObject(), m_transportKit(NULL) | |
Transport::~Transport() | |
{ | |
- if (IsInWorld()) | |
+ if (m_transportKit) | |
+ delete m_transportKit; | |
+} | |
+ | |
+bool Transport::AddPassenger(WorldObject* passenger, Position const& transportPos) | |
+{ | |
+ GetTransportKit()->AddPassenger(passenger, transportPos); | |
+ if (passenger->isType(TYPEMASK_UNIT)) | |
{ | |
- if (GetMap()) | |
- GetMap()->Remove((GameObject*)this, true); | |
+ GuidSet const& groupPets = ((Unit*)passenger)->GetPets(); | |
+ if (!groupPets.empty()) | |
+ { | |
+ for (GuidSet::const_iterator itr = groupPets.begin(); itr != groupPets.end(); ++itr) | |
+ if (Pet* pPet = GetMap()->GetPet(*itr)) | |
+ if (pPet && pPet->IsInWorld()) | |
+ GetTransportKit()->AddPassenger(pPet, transportPos); | |
+ } | |
} | |
+ return true; | |
+} | |
- if (m_transportKit) | |
- delete m_transportKit; | |
+bool Transport::RemovePassenger(WorldObject* passenger) | |
+{ | |
+ GetTransportKit()->RemovePassenger(passenger); | |
+ if (passenger->isType(TYPEMASK_UNIT)) | |
+ { | |
+ GuidSet groupPetsCopy = ((Unit*)passenger)->GetPets(); | |
+ if (!groupPetsCopy.empty()) | |
+ { | |
+ for (GuidSet::const_iterator itr = groupPetsCopy.begin(); itr != groupPetsCopy.end(); ++itr) | |
+ if (Pet* pPet = GetMap()->GetPet(*itr)) | |
+ if (pPet && pPet->IsInWorld()) | |
+ GetTransportKit()->RemovePassenger(pPet); | |
+ } | |
+ } | |
+ return true; | |
} | |
-bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicLowValue) | |
+void Transport::Update(uint32 update_diff, uint32 p_time) | |
+{ | |
+ GameObject::Update(update_diff, p_time); | |
+} | |
+ | |
+// MOTransport - work class for MO_TRANSPORT GO type | |
+MOTransport::MOTransport() : Transport() | |
+{ | |
+} | |
+ | |
+MOTransport::~MOTransport() | |
+{ | |
+ if (GetMap()) | |
+ GetMap()->Remove((GameObject*)this, true); | |
+} | |
+ | |
+bool MOTransport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicLowValue) | |
{ | |
Relocate(WorldLocation(mapid, x, y, z, ang)); | |
// FIXME - instance id and phaseMask isn't set to values different from std. | |
@@ -76,7 +121,7 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, | |
SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); | |
//SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); | |
SetUInt32Value(GAMEOBJECT_FLAGS, (GO_FLAG_TRANSPORT | GO_FLAG_NODESPAWN)); | |
- SetUInt32Value(GAMEOBJECT_LEVEL, m_period); | |
+ SetUInt32Value(GAMEOBJECT_LEVEL, GetPeriod(true)); | |
SetEntry(goinfo->id); | |
SetDisplayId(goinfo->displayId); | |
@@ -114,7 +159,7 @@ struct keyFrame | |
float tFrom, tTo; | |
}; | |
-bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids) | |
+bool MOTransport::GenerateWaypoints(uint32 pathid, std::set<uint32>& mapids) | |
{ | |
if (pathid >= sTaxiPathNodesByPath.size()) | |
return false; | |
@@ -334,7 +379,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids) | |
return true; | |
} | |
-void Transport::MoveToNextWayPoint() | |
+void MOTransport::MoveToNextWayPoint() | |
{ | |
m_curr = m_next; | |
@@ -342,41 +387,9 @@ void Transport::MoveToNextWayPoint() | |
if (m_next == m_WayPoints.end()) | |
m_next = m_WayPoints.begin(); | |
} | |
-bool Transport::AddPassenger(WorldObject* passenger, Position const& transportPos) | |
-{ | |
- GetTransportKit()->AddPassenger(passenger, transportPos); | |
- if (passenger->isType(TYPEMASK_UNIT)) | |
- { | |
- GuidSet const& groupPets = ((Unit*)passenger)->GetPets(); | |
- if (!groupPets.empty()) | |
- { | |
- for (GuidSet::const_iterator itr = groupPets.begin(); itr != groupPets.end(); ++itr) | |
- if (Pet* pPet = GetMap()->GetPet(*itr)) | |
- if (pPet && pPet->IsInWorld()) | |
- GetTransportKit()->AddPassenger(pPet, transportPos); | |
- } | |
- } | |
- return true; | |
-} | |
-bool Transport::RemovePassenger(WorldObject* passenger) | |
-{ | |
- GetTransportKit()->RemovePassenger(passenger); | |
- if (passenger->isType(TYPEMASK_UNIT)) | |
- { | |
- GuidSet groupPetsCopy = ((Unit*)passenger)->GetPets(); | |
- if (!groupPetsCopy.empty()) | |
- { | |
- for (GuidSet::const_iterator itr = groupPetsCopy.begin(); itr != groupPetsCopy.end(); ++itr) | |
- if (Pet* pPet = GetMap()->GetPet(*itr)) | |
- if (pPet && pPet->IsInWorld()) | |
- GetTransportKit()->RemovePassenger(pPet); | |
- } | |
- } | |
- return true; | |
-} | |
-void Transport::Update(uint32 update_diff, uint32 p_time) | |
+void MOTransport::Update(uint32 update_diff, uint32 p_time) | |
{ | |
UpdateSplineMovement(p_time); | |
@@ -404,7 +417,7 @@ void Transport::Update(uint32 update_diff, uint32 p_time) | |
} | |
} | |
- m_timer = WorldTimer::getMSTime() % m_period; | |
+ m_timer = WorldTimer::getMSTime() % GetPeriod(true); | |
while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime)) | |
{ | |
@@ -449,7 +462,7 @@ void Transport::Update(uint32 update_diff, uint32 p_time) | |
} | |
} | |
-void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure) | |
+void MOTransport::DoEventIfAny(WayPointMap::value_type const& node, bool departure) | |
{ | |
if (uint32 eventid = departure ? node.second.departureEventID : node.second.arrivalEventID) | |
{ | |
@@ -460,19 +473,7 @@ void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure | |
} | |
} | |
-void Transport::BuildStartMovePacket(Map const* targetMap) | |
-{ | |
- SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); | |
- SetGoState(GO_STATE_ACTIVE); | |
-} | |
- | |
-void Transport::BuildStopMovePacket(Map const* targetMap) | |
-{ | |
- RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); | |
- SetGoState(GO_STATE_READY); | |
-} | |
- | |
-uint32 Transport::GetPossibleMapByEntry(uint32 entry, bool start) | |
+uint32 MOTransport::GetPossibleMapByEntry(uint32 entry, bool start) | |
{ | |
GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(entry); | |
if (!goinfo || goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT) | |
@@ -496,7 +497,7 @@ uint32 Transport::GetPossibleMapByEntry(uint32 entry, bool start) | |
return path[0].mapid; | |
} | |
-bool Transport::IsSpawnedAtDifficulty(uint32 entry, Difficulty difficulty) | |
+bool MOTransport::IsSpawnedAtDifficulty(uint32 entry, Difficulty difficulty) | |
{ | |
GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(entry); | |
if (!goinfo || goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT) | |
@@ -506,7 +507,7 @@ bool Transport::IsSpawnedAtDifficulty(uint32 entry, Difficulty difficulty) | |
return goinfo->moTransport.difficultyMask & uint32( 1 << difficulty); | |
} | |
-void Transport::Start() | |
+void MOTransport::Start() | |
{ | |
DETAIL_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, "Transport::StartMovement %s (%s) start moves, period %u/%u", | |
GetObjectGuid().GetString().c_str(), | |
@@ -515,10 +516,12 @@ void Transport::Start() | |
GetPeriod() | |
); | |
SetActiveObjectState(true); | |
- BuildStartMovePacket(GetMap()); | |
+ SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); | |
+ SetGoState(GO_STATE_ACTIVE); | |
+ SetLootState(GO_ACTIVATED); | |
} | |
-void Transport::Stop() | |
+void MOTransport::Stop() | |
{ | |
DETAIL_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, "Transport::StartMovement %s (%s) stop moves, period %u/%u", | |
GetObjectGuid().GetString().c_str(), | |
@@ -527,11 +530,13 @@ void Transport::Stop() | |
GetPeriod() | |
); | |
SetActiveObjectState(false); | |
- BuildStopMovePacket(GetMap()); | |
+ RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); | |
+ SetGoState(GO_STATE_READY); | |
+ SetLootState(GO_JUST_DEACTIVATED); | |
} | |
// Return true, only if transport has correct position! | |
-bool Transport::SetPosition(WorldLocation const& loc, bool teleport) | |
+bool MOTransport::SetPosition(WorldLocation const& loc, bool teleport) | |
{ | |
// prevent crash when a bad coord is sent by the client | |
if (!MaNGOS::IsValidMapCoord(loc.x, loc.y, loc.z, loc.orientation)) | |
diff --git a/src/game/Transports.h b/src/game/Transports.h | |
index 5e6b07a..14143c8 100644 | |
--- a/src/game/Transports.h | |
+++ b/src/game/Transports.h | |
@@ -35,30 +35,53 @@ class MANGOS_DLL_SPEC Transport : public GameObject | |
explicit Transport(); | |
virtual ~Transport(); | |
- static uint32 GetPossibleMapByEntry(uint32 entry, bool start = true); | |
- static bool IsSpawnedAtDifficulty(uint32 entry, Difficulty difficulty); | |
- | |
- bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicHighValue); | |
- bool GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids); | |
- void Update(uint32 update_diff, uint32 p_time) override; | |
- | |
- bool SetPosition(WorldLocation const& loc, bool teleport); | |
+ virtual void Update(uint32 update_diff, uint32 p_time) override; | |
bool AddPassenger(WorldObject* passenger, Position const& transportPos); | |
bool RemovePassenger(WorldObject* passenger); | |
- void Start(); | |
- void Stop(); | |
+ virtual void Start() {}; | |
+ virtual void Stop() {}; | |
TransportKit* GetTransportKit() { return m_transportKit; }; | |
- void BuildStartMovePacket(Map const *targetMap); | |
- void BuildStopMovePacket(Map const *targetMap); | |
+ virtual bool IsTransport() const override { return bool(m_transportKit); }; | |
+ TransportBase* GetTransportBase() { return (TransportBase*)m_transportKit; }; | |
+ | |
+ uint32 GetPeriod(bool isDB = false) const { return isDB ? m_period : GetUInt32Value(GAMEOBJECT_LEVEL);} | |
+ | |
+ void SetDBPeriod(uint32 _period) { m_period = _period; }; | |
+ void SetPeriod(uint32 time) { SetUInt32Value(GAMEOBJECT_LEVEL, time);} | |
+ | |
+ private: | |
+ uint32 m_period; | |
+ | |
+ protected: | |
+ bool m_isInitialized; | |
+ TransportKit* m_transportKit; | |
+}; | |
+ | |
+class MANGOS_DLL_SPEC MOTransport : public Transport | |
+{ | |
+ public: | |
+ explicit MOTransport(); | |
+ virtual ~MOTransport(); | |
+ | |
+ static uint32 GetPossibleMapByEntry(uint32 entry, bool start = true); | |
+ static bool IsSpawnedAtDifficulty(uint32 entry, Difficulty difficulty); | |
+ | |
+ bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicHighValue); | |
+ bool GenerateWaypoints(uint32 pathid, std::set<uint32>& mapids); | |
+ | |
+ virtual void Update(uint32 update_diff, uint32 p_time) override; | |
+ bool SetPosition(WorldLocation const& loc, bool teleport); | |
uint32 GetTransportMapId() const { return GetGOInfo() ? GetGOInfo()->moTransport.mapID : 0; }; | |
- virtual bool IsTransport() const override { return bool(m_transportKit); }; | |
- TransportBase* GetTransportBase() { return (TransportBase*)m_transportKit; }; | |
+ virtual void Start() override; | |
+ virtual void Stop() override; | |
+ | |
+ virtual bool IsMOTransport() const override { return bool(m_transportKit); }; | |
private: | |
struct WayPoint | |
@@ -75,31 +98,26 @@ class MANGOS_DLL_SPEC Transport : public GameObject | |
uint32 departureEventID; | |
}; | |
- typedef std::map<uint32, WayPoint> WayPointMap; | |
- | |
- WayPointMap::const_iterator m_curr; | |
- WayPointMap::const_iterator m_next; | |
- uint32 m_pathTime; | |
- uint32 m_timer; | |
- | |
public: | |
- WayPointMap m_WayPoints; | |
- uint32 m_nextNodeTime; | |
- uint32 m_period; | |
- | |
- WayPointMap::const_iterator GetCurrent() { return m_curr; } | |
- WayPointMap::const_iterator GetNext() { return m_next; } | |
+ typedef std::map<uint32, WayPoint> WayPointMap; | |
private: | |
void DoEventIfAny(WayPointMap::value_type const& node, bool departure); | |
void MoveToNextWayPoint(); // move m_next/m_cur to next points | |
- void SetPeriod(uint32 time) { SetUInt32Value(GAMEOBJECT_LEVEL, time);} | |
- uint32 GetPeriod() const { return GetUInt32Value(GAMEOBJECT_LEVEL);} | |
- | |
- TransportKit* m_transportKit; | |
+ WayPointMap m_WayPoints; | |
+ uint32 m_timer; | |
+ uint32 m_pathTime; | |
+ uint32 m_nextNodeTime; | |
IntervalTimer m_anchorageTimer; | |
+ WayPointMap::const_iterator m_curr; | |
+ WayPointMap::const_iterator m_next; | |
+ | |
+ public: | |
+ WayPointMap::const_iterator GetCurrent() { return m_curr; } | |
+ WayPointMap::const_iterator GetNext() { return m_next; } | |
+ WayPoint const& GetWayPoint(uint32 index) { return index < m_WayPoints.size() ? m_WayPoints[index] : m_WayPoints[0]; } | |
}; | |
class MANGOS_DLL_SPEC TransportKit : public TransportBase | |
@@ -123,7 +141,6 @@ class MANGOS_DLL_SPEC TransportKit : public TransportBase | |
private: | |
// Internal use to calculate the boarding position | |
virtual Position CalculateBoardingPositionOf(Position const& pos) const override; | |
- | |
bool m_isInitialized; | |
}; | |
diff --git a/src/game/Unit.h b/src/game/Unit.h | |
index 35ad187..c91db45 100644 | |
--- a/src/game/Unit.h | |
+++ b/src/game/Unit.h | |
@@ -1326,7 +1326,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject | |
void ApplyDiminishingAura(DiminishingGroup group, bool apply); | |
void ClearDiminishings() { m_Diminishing.clear(); } | |
- void Update(uint32 update_diff, uint32 time) override; | |
+ virtual void Update(uint32 update_diff, uint32 time) override; | |
void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; } | |
void resetAttackTimer(WeaponAttackType type = BASE_ATTACK); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment