mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Vehicles: Added field to set a default pitch (#30878)
(cherry picked from commit 47440e9dd2)
# Conflicts:
# sql/old/4.4.x/world/25021_2025_05_11/2025_05_11_03_world.sql
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `vehicle_template`
|
||||
ADD `Pitch` FLOAT DEFAULT NULL AFTER `despawnDelayMs`;
|
||||
@@ -632,6 +632,8 @@ void Vehicle::InitMovementInfoForBase()
|
||||
_me->AddExtraUnitMovementFlag(MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING);
|
||||
if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDPITCHING)
|
||||
_me->AddExtraUnitMovementFlag(MOVEMENTFLAG2_FULL_SPEED_PITCHING);
|
||||
|
||||
_me->m_movementInfo.pitch = GetPitch();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -966,6 +968,15 @@ Milliseconds Vehicle::GetDespawnDelay()
|
||||
return 1ms;
|
||||
}
|
||||
|
||||
float Vehicle::GetPitch()
|
||||
{
|
||||
if (VehicleTemplate const* vehicleTemplate = sObjectMgr->GetVehicleTemplate(this))
|
||||
if (vehicleTemplate->Pitch)
|
||||
return *vehicleTemplate->Pitch;
|
||||
|
||||
return std::clamp(0.0f, _vehicleInfo->PitchMin, _vehicleInfo->PitchMax);
|
||||
}
|
||||
|
||||
std::string Vehicle::GetDebugInfo() const
|
||||
{
|
||||
std::stringstream sstr;
|
||||
|
||||
@@ -71,6 +71,7 @@ class TC_GAME_API Vehicle final : public TransportBase
|
||||
void RemovePendingEventsForPassenger(Unit* passenger);
|
||||
|
||||
Milliseconds GetDespawnDelay();
|
||||
float GetPitch();
|
||||
|
||||
std::string GetDebugInfo() const;
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ struct VehicleAccessory
|
||||
struct VehicleTemplate
|
||||
{
|
||||
Milliseconds DespawnDelay = Milliseconds::zero();
|
||||
Optional<float> Pitch;
|
||||
};
|
||||
|
||||
typedef std::vector<VehicleAccessory> VehicleAccessoryList;
|
||||
|
||||
@@ -3266,8 +3266,8 @@ void ObjectMgr::LoadVehicleTemplate()
|
||||
|
||||
_vehicleTemplateStore.clear();
|
||||
|
||||
// 0 1
|
||||
QueryResult result = WorldDatabase.Query("SELECT creatureId, despawnDelayMs FROM vehicle_template");
|
||||
// 0 1 2
|
||||
QueryResult result = WorldDatabase.Query("SELECT creatureId, despawnDelayMs, Pitch FROM vehicle_template");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -3281,15 +3281,38 @@ void ObjectMgr::LoadVehicleTemplate()
|
||||
|
||||
uint32 creatureId = fields[0].GetUInt32();
|
||||
|
||||
if (!GetCreatureTemplate(creatureId))
|
||||
CreatureTemplate const* creatureInfo = GetCreatureTemplate(creatureId);
|
||||
if (!creatureInfo)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `vehicle_template`: Vehicle {} does not exist.", creatureId);
|
||||
TC_LOG_ERROR("sql.sql", "Table `vehicle_template`: Creature (Entry: {}) does not exist.", creatureId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!creatureInfo->VehicleId)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `vehicle_template`: Creature (Entry: {}) is not a vehicle.", creatureId);
|
||||
continue;
|
||||
}
|
||||
|
||||
VehicleTemplate& vehicleTemplate = _vehicleTemplateStore[creatureId];
|
||||
vehicleTemplate.DespawnDelay = Milliseconds(fields[1].GetInt32());
|
||||
|
||||
if (!fields[2].IsNull())
|
||||
{
|
||||
VehicleEntry const* vehicle = sVehicleStore.LookupEntry(creatureInfo->VehicleId);
|
||||
if (!vehicle)
|
||||
continue;
|
||||
|
||||
float pitch = fields[2].GetFloat();
|
||||
if (pitch < vehicle->PitchMin || pitch > vehicle->PitchMax)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `vehicle_template`: Creature (Entry: {}) has invalid Pitch ({}).`. Ignoring",
|
||||
creatureId, pitch);
|
||||
continue;
|
||||
}
|
||||
|
||||
vehicleTemplate.Pitch = pitch;
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} Vehicle Template entries in {} ms", _vehicleTemplateStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
|
||||
Reference in New Issue
Block a user