Core/Players: Fixed fatigue timer appearing in some situations where it shouldn't (in some wmos or on some vehicles)
This commit is contained in:
@@ -3416,9 +3416,13 @@ bool DB2Manager::IsUiMapPhase(uint32 phaseId) const
|
||||
return _uiMapPhases.find(phaseId) != _uiMapPhases.end();
|
||||
}
|
||||
|
||||
WMOAreaTableEntry const* DB2Manager::GetWMOAreaTable(int32 rootId, int32 adtId, int32 groupId) const
|
||||
WMOAreaTableEntry const* DB2Manager::GetWMOAreaTable(int32 rootId, int32 adtId, int32 groupId, bool allowGroupFallback)
|
||||
{
|
||||
return Trinity::Containers::MapGetValuePtr(_wmoAreaTableLookup, WMOAreaTableKey(int16(rootId), int8(adtId), groupId));
|
||||
WMOAreaTableEntry const* wmoAreaTableEntry = Trinity::Containers::MapGetValuePtr(_wmoAreaTableLookup, WMOAreaTableKey(int16(rootId), int8(adtId), groupId));
|
||||
if (!wmoAreaTableEntry && allowGroupFallback)
|
||||
wmoAreaTableEntry = Trinity::Containers::MapGetValuePtr(_wmoAreaTableLookup, WMOAreaTableKey(int16(rootId), int8(adtId), -1));
|
||||
|
||||
return wmoAreaTableEntry;
|
||||
}
|
||||
|
||||
std::unordered_set<uint32> const* DB2Manager::GetPVPStatIDsForMap(uint32 mapId) const
|
||||
|
||||
@@ -556,7 +556,7 @@ public:
|
||||
bool Zone2MapCoordinates(uint32 areaId, float& x, float& y) const;
|
||||
void Map2ZoneCoordinates(uint32 areaId, float& x, float& y) const;
|
||||
bool IsUiMapPhase(uint32 phaseId) const;
|
||||
WMOAreaTableEntry const* GetWMOAreaTable(int32 rootId, int32 adtId, int32 groupId) const;
|
||||
static WMOAreaTableEntry const* GetWMOAreaTable(int32 rootId, int32 adtId, int32 groupId, bool allowGroupFallback);
|
||||
std::unordered_set<uint32> const* GetPVPStatIDsForMap(uint32 mapId) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -5032,6 +5032,7 @@ struct VehicleSeatEntry
|
||||
|
||||
inline bool HasFlag(VehicleSeatFlags flag) const { return !!(Flags & flag); }
|
||||
inline bool HasFlag(VehicleSeatFlagsB flag) const { return !!(FlagsB & flag); }
|
||||
inline bool HasFlag(VehicleSeatFlagsC flag) const { return EnumFlag(static_cast<VehicleSeatFlagsC>(FlagsC)).HasFlag(flag); }
|
||||
|
||||
inline bool CanEnterOrExit() const { return HasFlag(VehicleSeatFlags(VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT | VEHICLE_SEAT_FLAG_CAN_CONTROL | VEHICLE_SEAT_FLAG_SHOULD_USE_VEH_SEAT_EXIT_ANIM_ON_VOLUNTARY_EXIT)); }
|
||||
inline bool CanSwitchFromSeat() const { return HasFlag(VEHICLE_SEAT_FLAG_CAN_SWITCH); }
|
||||
@@ -5099,6 +5100,8 @@ struct WMOAreaTableEntry
|
||||
uint16 UwIntroSound;
|
||||
uint16 AreaTableID;
|
||||
int32 Flags;
|
||||
|
||||
bool HasFlag(WMOAreaTableFlags flag) const { return EnumFlag(static_cast<WMOAreaTableFlags>(Flags)).HasFlag(flag); }
|
||||
};
|
||||
|
||||
struct WorldEffectEntry
|
||||
|
||||
@@ -3108,6 +3108,13 @@ enum VehicleSeatFlagsB
|
||||
VEHICLE_SEAT_FLAG_B_VEHICLE_PLAYERFRAME_UI = 0x80000000 // Lua_UnitHasVehiclePlayerFrameUI - actually checked for flagsb &~ 0x80000000
|
||||
};
|
||||
|
||||
enum class VehicleSeatFlagsC : int32
|
||||
{
|
||||
NoFatigue = 0x00000040
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(VehicleSeatFlagsC);
|
||||
|
||||
enum class VignetteFlags
|
||||
{
|
||||
InfiniteAOI = 0x000001,
|
||||
@@ -3140,6 +3147,20 @@ enum class WarbandSceneFlags : uint8
|
||||
|
||||
DEFINE_ENUM_FLAG(WarbandSceneFlags);
|
||||
|
||||
enum class WMOAreaTableFlags : int32
|
||||
{
|
||||
RenderMinimap = 0x01,
|
||||
ForceIndoors = 0x02,
|
||||
ForceOutdoors = 0x04,
|
||||
GenerateSingleExteriorMap = 0x08,
|
||||
Stormwind = 0x10,
|
||||
ChunkUsesTerrainForMinimap = 0x20,
|
||||
IgnoreForMinimapAndEffects = 0x40,
|
||||
IgnoreFatigue = 0x80
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(WMOAreaTableFlags);
|
||||
|
||||
enum WorldMapTransformsFlags
|
||||
{
|
||||
WORLD_MAP_TRANSFORMS_FLAG_DUNGEON = 0x04
|
||||
|
||||
@@ -26766,11 +26766,20 @@ int32 Player::NextGroupUpdateSequenceNumber(GroupCategory category)
|
||||
return m_groupUpdateSequences[category].UpdateSequenceNumber++;
|
||||
}
|
||||
|
||||
void Player::ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<LiquidData> const& newLiquidData)
|
||||
void Player::ProcessPositionDataChanged(PositionFullTerrainStatus const& data)
|
||||
{
|
||||
// process liquid auras using generic unit code
|
||||
Unit::ProcessTerrainStatusUpdate(oldLiquidStatus, newLiquidData);
|
||||
ZLiquidStatus oldLiquidStatus = GetLiquidStatus();
|
||||
Unit::ProcessPositionDataChanged(data);
|
||||
|
||||
UpdateLiquidMirrorTimerFlagsOnPositionChange(data.liquidInfo);
|
||||
|
||||
// mount capability depends on liquid state change
|
||||
if (oldLiquidStatus != GetLiquidStatus())
|
||||
UpdateMountCapability();
|
||||
}
|
||||
|
||||
void Player::UpdateLiquidMirrorTimerFlagsOnPositionChange(Optional<LiquidData> const& newLiquidData)
|
||||
{
|
||||
m_MirrorTimerFlags &= ~(UNDERWATER_INWATER | UNDERWATER_INLAVA | UNDERWATER_INSLIME | UNDERWATER_INDARKWATER);
|
||||
|
||||
// player specific logic for mirror timers
|
||||
@@ -26783,7 +26792,21 @@ void Player::ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<
|
||||
|
||||
// Fatigue bar state (if not on flight path or transport)
|
||||
if (newLiquidData->type_flags.HasFlag(map_liquidHeaderTypeFlags::DarkWater) && !IsInFlight() && !GetTransport())
|
||||
m_MirrorTimerFlags |= UNDERWATER_INDARKWATER;
|
||||
{
|
||||
bool ignoreFatigue = false;
|
||||
if (WmoLocation const* wmoLocation = GetCurrentWmo())
|
||||
if (WMOAreaTableEntry const* wmoEntry = DB2Manager::GetWMOAreaTable(wmoLocation->RootId, wmoLocation->NameSetId, wmoLocation->GroupId, true))
|
||||
if (wmoEntry->HasFlag(WMOAreaTableFlags::IgnoreFatigue))
|
||||
ignoreFatigue = true;
|
||||
|
||||
if (Vehicle const* vehicle = GetVehicle())
|
||||
if (VehicleSeatEntry const* vehicleSeat = vehicle->GetSeatForPassenger(this))
|
||||
if (vehicleSeat->HasFlag(VehicleSeatFlagsC::NoFatigue))
|
||||
ignoreFatigue = true;
|
||||
|
||||
if (!ignoreFatigue)
|
||||
m_MirrorTimerFlags |= UNDERWATER_INDARKWATER;
|
||||
}
|
||||
|
||||
// Lava state (any contact)
|
||||
if (newLiquidData->type_flags.HasFlag(map_liquidHeaderTypeFlags::Magma))
|
||||
|
||||
@@ -2317,7 +2317,8 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
|
||||
|
||||
bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false) override;
|
||||
bool UpdatePosition(Position const& pos, bool teleport = false) override { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
|
||||
void ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<LiquidData> const& newLiquidData) override;
|
||||
void ProcessPositionDataChanged(PositionFullTerrainStatus const& data) override;
|
||||
void UpdateLiquidMirrorTimerFlagsOnPositionChange(Optional<LiquidData> const& newLiquidData);
|
||||
void AtEnterCombat() override;
|
||||
void AtExitCombat() override;
|
||||
|
||||
|
||||
@@ -3338,13 +3338,12 @@ bool Unit::IsOnOceanFloor() const
|
||||
|
||||
void Unit::ProcessPositionDataChanged(PositionFullTerrainStatus const& data)
|
||||
{
|
||||
ZLiquidStatus oldLiquidStatus = GetLiquidStatus();
|
||||
WorldObject::ProcessPositionDataChanged(data);
|
||||
ProcessTerrainStatusUpdate(oldLiquidStatus, data.liquidInfo);
|
||||
UpdateLiquidStatusOnPositionChange(data.liquidInfo);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::CurrentAreaID), data.areaId);
|
||||
}
|
||||
|
||||
void Unit::ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<LiquidData> const& newLiquidData)
|
||||
void Unit::UpdateLiquidStatusOnPositionChange(Optional<LiquidData> const& newLiquidData)
|
||||
{
|
||||
if (!IsControlledByPlayer())
|
||||
return;
|
||||
@@ -3363,18 +3362,14 @@ void Unit::ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<Li
|
||||
{
|
||||
if (_lastLiquid && _lastLiquid->SpellID)
|
||||
RemoveAurasDueToSpell(_lastLiquid->SpellID);
|
||||
Player* player = GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
|
||||
// Set _lastLiquid before casting liquid spell to avoid infinite loops
|
||||
_lastLiquid = curLiquid;
|
||||
|
||||
Player* player = GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
if (curLiquid && curLiquid->SpellID && (!player || !player->IsGameMaster()))
|
||||
CastSpell(this, curLiquid->SpellID, true);
|
||||
}
|
||||
|
||||
// mount capability depends on liquid state change
|
||||
if (oldLiquidStatus != GetLiquidStatus())
|
||||
UpdateMountCapability();
|
||||
}
|
||||
|
||||
void Unit::DeMorph()
|
||||
|
||||
@@ -1967,7 +1967,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
void DisableSpline();
|
||||
|
||||
void ProcessPositionDataChanged(PositionFullTerrainStatus const& data) override;
|
||||
virtual void ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<LiquidData> const& newLiquidData);
|
||||
void UpdateLiquidStatusOnPositionChange(Optional<LiquidData> const& newLiquidData);
|
||||
|
||||
// notifiers
|
||||
virtual void AtEnterCombat();
|
||||
|
||||
@@ -345,7 +345,10 @@ SeatMap::const_iterator Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
|
||||
|
||||
// Make sure we don't loop indefinetly
|
||||
if (seat->first == seatId)
|
||||
return Seats.end();
|
||||
{
|
||||
seat = Seats.end();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return seat;
|
||||
@@ -685,8 +688,7 @@ VehicleSeatEntry const* Vehicle::GetSeatForPassenger(Unit const* passenger) cons
|
||||
|
||||
SeatMap::iterator Vehicle::GetSeatIteratorForPassenger(Unit* passenger)
|
||||
{
|
||||
SeatMap::iterator itr;
|
||||
for (itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||
for (SeatMap::iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||
if (itr->second.Passenger.Guid == passenger->GetGUID())
|
||||
return itr;
|
||||
|
||||
|
||||
@@ -613,31 +613,27 @@ ZLiquidStatus GridMap::GetLiquidStatus(float x, float y, float z, Optional<map_l
|
||||
int idx=(x_int>>3)*16 + (y_int>>3);
|
||||
map_liquidHeaderTypeFlags type = _liquidFlags ? _liquidFlags[idx] : _liquidGlobalFlags;
|
||||
uint32 entry = _liquidEntry ? _liquidEntry[idx] : _liquidGlobalEntry;
|
||||
if (LiquidTypeEntry const* liquidEntry = sLiquidTypeStore.LookupEntry(entry))
|
||||
if (sLiquidTypeStore.HasRecord(entry))
|
||||
{
|
||||
type &= map_liquidHeaderTypeFlags::DarkWater;
|
||||
uint32 liqTypeIdx = liquidEntry->SoundBank;
|
||||
if (entry < 21)
|
||||
{
|
||||
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(getArea(x, y)))
|
||||
{
|
||||
uint32 overrideLiquid = area->LiquidTypeID[liquidEntry->SoundBank];
|
||||
uint32 overrideLiquid = area->LiquidTypeID[(entry - 1) & 3];
|
||||
if (!overrideLiquid && area->ParentAreaID)
|
||||
{
|
||||
area = sAreaTableStore.LookupEntry(area->ParentAreaID);
|
||||
if (area)
|
||||
overrideLiquid = area->LiquidTypeID[liquidEntry->SoundBank];
|
||||
overrideLiquid = area->LiquidTypeID[(entry - 1) & 3];
|
||||
}
|
||||
|
||||
if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(overrideLiquid))
|
||||
{
|
||||
if (sLiquidTypeStore.HasRecord(overrideLiquid))
|
||||
entry = overrideLiquid;
|
||||
liqTypeIdx = liq->SoundBank;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type |= map_liquidHeaderTypeFlags(1 << liqTypeIdx);
|
||||
type |= map_liquidHeaderTypeFlags(DB2Manager::GetLiquidFlags(entry));
|
||||
}
|
||||
|
||||
if (type == map_liquidHeaderTypeFlags::NoWater)
|
||||
|
||||
@@ -387,19 +387,16 @@ void TerrainInfo::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift,
|
||||
{
|
||||
if (wmoData->areaInfo)
|
||||
{
|
||||
data.wmoLocation.emplace(wmoData->areaInfo->groupId, wmoData->areaInfo->adtId, wmoData->areaInfo->rootId, wmoData->areaInfo->uniqueId);
|
||||
// wmo found
|
||||
WMOAreaTableEntry const* wmoEntry = sDB2Manager.GetWMOAreaTable(wmoData->areaInfo->rootId, wmoData->areaInfo->adtId, wmoData->areaInfo->groupId);
|
||||
if (!wmoEntry)
|
||||
wmoEntry = sDB2Manager.GetWMOAreaTable(wmoData->areaInfo->rootId, wmoData->areaInfo->adtId, -1);
|
||||
|
||||
data.wmoLocation.emplace(wmoData->areaInfo->groupId, wmoData->areaInfo->adtId, wmoData->areaInfo->rootId, wmoData->areaInfo->uniqueId);
|
||||
data.outdoors = (wmoData->areaInfo->mogpFlags & 0x8) != 0;
|
||||
if (wmoEntry)
|
||||
|
||||
if (WMOAreaTableEntry const* wmoEntry = DB2Manager::GetWMOAreaTable(wmoData->areaInfo->rootId, wmoData->areaInfo->adtId, wmoData->areaInfo->groupId, true))
|
||||
{
|
||||
data.areaId = wmoEntry->AreaTableID;
|
||||
if (wmoEntry->Flags & 4)
|
||||
if (wmoEntry->HasFlag(WMOAreaTableFlags::ForceOutdoors))
|
||||
data.outdoors = true;
|
||||
else if (wmoEntry->Flags & 2)
|
||||
else if (wmoEntry->HasFlag(WMOAreaTableFlags::ForceIndoors))
|
||||
data.outdoors = false;
|
||||
}
|
||||
|
||||
@@ -430,32 +427,24 @@ void TerrainInfo::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift,
|
||||
if (GetId() == 530 && liquidType == 2) // gotta love hacks
|
||||
liquidType = 15;
|
||||
|
||||
uint32 liquidFlagType = 0;
|
||||
if (LiquidTypeEntry const* liquidData = sLiquidTypeStore.LookupEntry(liquidType))
|
||||
liquidFlagType = liquidData->SoundBank;
|
||||
|
||||
if (liquidType && liquidType < 21 && areaEntry)
|
||||
{
|
||||
uint32 overrideLiquid = areaEntry->LiquidTypeID[liquidFlagType];
|
||||
uint32 overrideLiquid = areaEntry->LiquidTypeID[(liquidType - 1) & 3];
|
||||
if (!overrideLiquid && areaEntry->ParentAreaID)
|
||||
{
|
||||
AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(areaEntry->ParentAreaID);
|
||||
if (zoneEntry)
|
||||
overrideLiquid = zoneEntry->LiquidTypeID[liquidFlagType];
|
||||
if (AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(areaEntry->ParentAreaID))
|
||||
overrideLiquid = zoneEntry->LiquidTypeID[(liquidType - 1) & 3];
|
||||
}
|
||||
|
||||
if (LiquidTypeEntry const* overrideData = sLiquidTypeStore.LookupEntry(overrideLiquid))
|
||||
{
|
||||
if (sLiquidTypeStore.HasRecord(overrideLiquid))
|
||||
liquidType = overrideLiquid;
|
||||
liquidFlagType = overrideData->SoundBank;
|
||||
}
|
||||
}
|
||||
|
||||
data.liquidInfo.emplace();
|
||||
data.liquidInfo->level = wmoData->liquidInfo->level;
|
||||
data.liquidInfo->depth_level = wmoData->floorZ;
|
||||
data.liquidInfo->entry = liquidType;
|
||||
data.liquidInfo->type_flags = map_liquidHeaderTypeFlags(1 << liquidFlagType);
|
||||
data.liquidInfo->type_flags = map_liquidHeaderTypeFlags(DB2Manager::GetLiquidFlags(liquidType));
|
||||
|
||||
float delta = wmoData->liquidInfo->level - z;
|
||||
uint32 status = LIQUID_MAP_ABOVE_WATER;
|
||||
@@ -508,27 +497,20 @@ ZLiquidStatus TerrainInfo::GetLiquidStatus(PhaseShift const& phaseShift, uint32
|
||||
if (GetId() == 530 && vmapData.liquidInfo->type == 2)
|
||||
vmapData.liquidInfo->type = 15;
|
||||
|
||||
uint32 liquidFlagType = 0;
|
||||
if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(vmapData.liquidInfo->type))
|
||||
liquidFlagType = liq->SoundBank;
|
||||
|
||||
if (vmapData.liquidInfo->type && vmapData.liquidInfo->type < 21)
|
||||
{
|
||||
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(GetAreaId(phaseShift, mapId, x, y, z)))
|
||||
{
|
||||
uint32 overrideLiquid = area->LiquidTypeID[liquidFlagType];
|
||||
uint32 overrideLiquid = area->LiquidTypeID[(vmapData.liquidInfo->type - 1) & 3];
|
||||
if (!overrideLiquid && area->ParentAreaID)
|
||||
{
|
||||
area = sAreaTableStore.LookupEntry(area->ParentAreaID);
|
||||
if (area)
|
||||
overrideLiquid = area->LiquidTypeID[liquidFlagType];
|
||||
overrideLiquid = area->LiquidTypeID[(vmapData.liquidInfo->type - 1) & 3];
|
||||
}
|
||||
|
||||
if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(overrideLiquid))
|
||||
{
|
||||
if (sLiquidTypeStore.HasRecord(overrideLiquid))
|
||||
vmapData.liquidInfo->type = overrideLiquid;
|
||||
liquidFlagType = liq->SoundBank;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,7 +518,7 @@ ZLiquidStatus TerrainInfo::GetLiquidStatus(PhaseShift const& phaseShift, uint32
|
||||
data->depth_level = vmapData.floorZ;
|
||||
|
||||
data->entry = vmapData.liquidInfo->type;
|
||||
data->type_flags = map_liquidHeaderTypeFlags(1 << liquidFlagType);
|
||||
data->type_flags = map_liquidHeaderTypeFlags(DB2Manager::GetLiquidFlags(vmapData.liquidInfo->type));
|
||||
}
|
||||
|
||||
float delta = vmapData.liquidInfo->level - z;
|
||||
@@ -648,7 +630,7 @@ uint32 TerrainInfo::GetAreaId(PhaseShift const& phaseShift, uint32 mapId, float
|
||||
if (hasVmapArea && G3D::fuzzyGe(z, vmapZ - GROUND_HEIGHT_TOLERANCE) && (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapZ > gridMapHeight))
|
||||
{
|
||||
// wmo found
|
||||
if (WMOAreaTableEntry const* wmoEntry = sDB2Manager.GetWMOAreaTable(rootId, adtId, groupId))
|
||||
if (WMOAreaTableEntry const* wmoEntry = DB2Manager::GetWMOAreaTable(rootId, adtId, groupId, false))
|
||||
areaId = wmoEntry->AreaTableID;
|
||||
|
||||
if (!areaId)
|
||||
|
||||
Reference in New Issue
Block a user