Skip to content

Commit

Permalink
Vehicles: Fix invalid coordinates (#475)
Browse files Browse the repository at this point in the history
* Vehicles: Fix invalid coordinates

* Vehicles: use itr
  • Loading branch information
insunaa authored Oct 27, 2023
1 parent 6f6ef67 commit 8872fa0
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/game/Entities/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "Entities/Creature.h"
#include "AI/BaseAI/CreatureAI.h"
#include "Globals/ObjectMgr.h"
#include "Models/M2Stores.h"
#include "Server/DBCStores.h"
#include "Server/SQLStorages.h"
#include "Movement/MoveSplineInit.h"
Expand Down Expand Up @@ -303,16 +304,18 @@ void VehicleInfo::Board(Unit* passenger, uint8 seat)
auto* creatureDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(static_cast<Creature*>(m_owner)->GetNativeDisplayId());
float scale = creatureDisplayInfo->scale;
scale *= sCreatureModelDataStore.LookupEntry(creatureDisplayInfo->ModelId)->Scale;
for (auto& attachment : sModelAttachmentStore[creatureDisplayInfo->ModelId])
{
if (attachment.id == attachmentLookup(seatEntry->m_attachmentID))
auto attachmentItr = sModelAttachmentStore.find(creatureDisplayInfo->ModelId);
if (attachmentItr != sModelAttachmentStore.end())
for (auto& attachment : attachmentItr->second)
{
lx = (attachment.position.x + seatEntry->m_attachmentOffsetX) * scale;
ly = (attachment.position.y + seatEntry->m_attachmentOffsetY) * scale;
lz = (attachment.position.z + seatEntry->m_attachmentOffsetZ) * scale;
break;
if (attachment.id == attachmentLookup(seatEntry->m_attachmentID))
{
lx = (attachment.position.x + seatEntry->m_attachmentOffsetX) * scale;
ly = (attachment.position.y + seatEntry->m_attachmentOffsetY) * scale;
lz = (attachment.position.z + seatEntry->m_attachmentOffsetZ) * scale;
break;
}
}
}

BoardPassenger(passenger, lx, ly, lz, lo, seat); // Use TransportBase to store the passenger

Expand Down Expand Up @@ -403,16 +406,18 @@ void VehicleInfo::SwitchSeat(Unit* passenger, uint8 seat)
auto* creatureDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(static_cast<Creature*>(m_owner)->GetNativeDisplayId());
float scale = creatureDisplayInfo->scale;
scale *= sCreatureModelDataStore.LookupEntry(creatureDisplayInfo->ModelId)->Scale;
for (auto& attachment : sModelAttachmentStore[creatureDisplayInfo->ModelId])
{
if (attachment.id == attachmentLookup(seatEntry->m_attachmentID))
auto attachmentItr = sModelAttachmentStore.find(creatureDisplayInfo->ModelId);
if (attachmentItr != sModelAttachmentStore.end())
for (auto& attachment : attachmentItr->second)
{
lx = (attachment.position.x + seatEntry->m_attachmentOffsetX) * scale;
ly = (attachment.position.y + seatEntry->m_attachmentOffsetY) * scale;
lz = (attachment.position.z + seatEntry->m_attachmentOffsetZ) * scale;
break;
if (attachment.id == attachmentLookup(seatEntry->m_attachmentID))
{
lx = (attachment.position.x + seatEntry->m_attachmentOffsetX) * scale;
ly = (attachment.position.y + seatEntry->m_attachmentOffsetY) * scale;
lz = (attachment.position.z + seatEntry->m_attachmentOffsetZ) * scale;
break;
}
}
}

// Set to new seat
itr->second->SetTransportSeat(seat);
Expand Down

0 comments on commit 8872fa0

Please sign in to comment.