mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
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
(cherry picked from commit 149ff8da87)
Conflicts:
src/server/game/Entities/GameObject/GameObject.cpp
src/server/game/Entities/GameObject/GameObject.h
src/server/game/Globals/ObjectMgr.cpp
This commit is contained in:
@@ -190,6 +190,12 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
|
||||
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 = (m_updateFlag | UPDATEFLAG_TRANSPORT) & ~UPDATEFLAG_POSITION;
|
||||
|
||||
@@ -2068,6 +2074,15 @@ void GameObject::SetGoState(GOState state)
|
||||
}
|
||||
}
|
||||
|
||||
uint32 GameObject::GetTransportPeriod() const
|
||||
{
|
||||
ASSERT(GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT);
|
||||
if (m_goValue.Transport.AnimationInfo)
|
||||
return m_goValue.Transport.AnimationInfo->TotalTime;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GameObject::SetDisplayId(uint32 displayid)
|
||||
{
|
||||
SetUInt32Value(GAMEOBJECT_DISPLAYID, displayid);
|
||||
@@ -2206,9 +2221,16 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
|
||||
if (ActivateToQuest(target))
|
||||
dynFlags |= GO_DYNFLAG_LO_SPARKLE;
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_TRANSPORT:
|
||||
case GAMEOBJECT_TYPE_MO_TRANSPORT:
|
||||
pathProgress = int16(float(m_goValue.Transport.PathProgress) / 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:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -717,6 +717,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);
|
||||
virtual uint32 GetTransportPeriod() const;
|
||||
uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
|
||||
void SetGoArtKit(uint8 artkit);
|
||||
uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
|
||||
|
||||
@@ -125,7 +125,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
|
||||
@@ -147,8 +147,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
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -6674,7 +6674,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);
|
||||
|
||||
Reference in New Issue
Block a user