aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-04-23 15:47:50 +0200
committerShauren <shauren.trinity@gmail.com>2015-04-23 15:47:50 +0200
commit149ff8da879a8286a01081d4ffb1f200a67ddefd (patch)
treec1921981e061348522410e7448ad73b0d89a8bb1 /src
parent915828bb1ff3d8c8c43c253a4b645abbf5efa4f0 (diff)
Core/GameObjects: Removed the possibility to spawn transports wih gm commands (such objects did not have any transport mechanics but could still cause crashes)
Closes #14542
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp21
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h2
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp6
-rw-r--r--src/server/game/Entities/Transport/Transport.h2
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp4
5 files changed, 19 insertions, 16 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 5466a848701..b8bd9c35f35 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -193,6 +193,12 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
return false;
}
+ if (goinfo->type == GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT)
+ {
+ TC_LOG_ERROR("sql.sql", "Gameobject (GUID: " UI64FMTD " Entry: %u) not created: gameobject type GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT cannot be manually created.", guidlow, name_id);
+ return false;
+ }
+
if (goinfo->type == GAMEOBJECT_TYPE_TRANSPORT)
m_updateFlag |= UPDATEFLAG_TRANSPORT;
@@ -2140,8 +2146,7 @@ uint32 GameObject::GetTransportPeriod() const
if (m_goValue.Transport.AnimationInfo)
return m_goValue.Transport.AnimationInfo->TotalTime;
- // return something that will nicely divide for GAMEOBJECT_DYNAMIC value calculation
- return m_goValue.Transport.PathProgress;
+ return 0;
}
void GameObject::SetTransportState(GOState state, uint32 stopFrame /*= 0*/)
@@ -2310,15 +2315,13 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
dynFlags |= GO_DYNFLAG_LO_SPARKLE;
break;
case GAMEOBJECT_TYPE_TRANSPORT:
- {
- float timer = float(m_goValue.Transport.PathProgress % GetTransportPeriod());
- pathProgress = int16(timer / float(GetTransportPeriod()) * 65535.0f);
- break;
- }
case GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT:
{
- float timer = float(m_goValue.Transport.PathProgress % GetUInt32Value(GAMEOBJECT_LEVEL));
- pathProgress = int16(timer / float(GetUInt32Value(GAMEOBJECT_LEVEL)) * 65535.0f);
+ if (uint32 transportPeriod = GetTransportPeriod())
+ {
+ float timer = float(m_goValue.Transport.PathProgress % transportPeriod);
+ pathProgress = int16(timer / float(transportPeriod) * 65535.0f);
+ }
break;
}
default:
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 50bd1ebd9f5..f254936608f 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -953,7 +953,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
void SetGoType(GameobjectTypes type) { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); }
GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
void SetGoState(GOState state);
- uint32 GetTransportPeriod() const;
+ virtual uint32 GetTransportPeriod() const;
void SetTransportState(GOState state, uint32 stopFrame = 0);
uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
void SetGoArtKit(uint8 artkit);
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index 6ad2bd52130..454a9317c8e 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -129,7 +129,7 @@ void Transport::Update(uint32 diff)
if (IsMoving() || !_pendingStop)
m_goValue.Transport.PathProgress += diff;
- uint32 timer = m_goValue.Transport.PathProgress % GetPeriod();
+ uint32 timer = m_goValue.Transport.PathProgress % GetTransportPeriod();
// Set current waypoint
// Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime
@@ -151,8 +151,8 @@ void Transport::Update(uint32 diff)
if (_pendingStop && GetGoState() != GO_STATE_READY)
{
SetGoState(GO_STATE_READY);
- m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetPeriod());
- m_goValue.Transport.PathProgress *= GetPeriod();
+ m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetTransportPeriod());
+ m_goValue.Transport.PathProgress *= GetTransportPeriod();
m_goValue.Transport.PathProgress += _currentFrame->ArriveTime;
}
break; // its a stop frame and we are waiting
diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h
index a24c8179ead..193e32300c0 100644
--- a/src/server/game/Entities/Transport/Transport.h
+++ b/src/server/game/Entities/Transport/Transport.h
@@ -79,7 +79,7 @@ class Transport : public GameObject, public TransportBase
TransportBase::CalculatePassengerOffset(x, y, z, o, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
}
- uint32 GetPeriod() const { return GetUInt32Value(GAMEOBJECT_LEVEL); }
+ uint32 GetTransportPeriod() const override { return GetUInt32Value(GAMEOBJECT_LEVEL); }
void SetPeriod(uint32 period) { SetUInt32Value(GAMEOBJECT_LEVEL, period); }
uint32 GetTimer() const { return GetGOValue()->Transport.PathProgress; }
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index eafcf16383c..390962b1a0e 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -6583,7 +6583,7 @@ void ObjectMgr::LoadGameObjectTemplate()
{
if (got.moTransport.taxiPathID >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[got.moTransport.taxiPathID].empty())
TC_LOG_ERROR("sql.sql", "GameObject (Entry: %u GoType: %u) have data0=%u but TaxiPath (Id: %u) not exist.",
- entry, got.type, got.moTransport.taxiPathID, got.moTransport.taxiPathID);
+ entry, got.type, got.moTransport.taxiPathID, got.moTransport.taxiPathID);
}
if (uint32 transportMap = got.moTransport.mapID)
_transportMaps.insert(transportMap);
@@ -9175,7 +9175,7 @@ void ObjectMgr::LoadCharacterTemplates()
uint8 factionGroup = fields[0].GetUInt8();
uint8 classID = fields[1].GetUInt8();
- if (!((factionGroup & (FACTION_MASK_PLAYER | FACTION_MASK_ALLIANCE)) == (FACTION_MASK_PLAYER | FACTION_MASK_ALLIANCE)) &&
+ if (!((factionGroup & (FACTION_MASK_PLAYER | FACTION_MASK_ALLIANCE)) == (FACTION_MASK_PLAYER | FACTION_MASK_ALLIANCE)) &&
!((factionGroup & (FACTION_MASK_PLAYER | FACTION_MASK_HORDE)) == (FACTION_MASK_PLAYER | FACTION_MASK_HORDE)))
{
TC_LOG_ERROR("sql.sql", "Faction group %u defined for character template %u in `character_template_class` is invalid. Skipped.", factionGroup, templateSetId);