Core/VMap: Add outdoor state to Map::GetFullTerrainStatusForPosition. Add WorldObject::IsOutdoors, basic member access.

Ref #21479.
This commit is contained in:
Treeston
2018-02-26 17:40:40 +01:00
parent 71b5ed6832
commit e79c595b69
7 changed files with 25 additions and 28 deletions

View File

@@ -1123,6 +1123,7 @@ void WorldObject::ProcessPositionDataChanged(PositionFullTerrainStatus const& da
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(m_areaId))
if (area->zone)
m_zoneId = area->zone;
m_outdoors = data.outdoors;
m_staticFloorZ = data.floorZ;
}

View File

@@ -297,6 +297,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
uint32 GetZoneId() const { return m_zoneId; }
uint32 GetAreaId() const { return m_areaId; }
void GetZoneAndAreaId(uint32& zoneid, uint32& areaid) const { zoneid = m_zoneId, areaid = m_areaId; }
bool IsOutdoors() const { return m_outdoors; }
InstanceScript* GetInstanceScript() const;
@@ -403,10 +404,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
void DestroyForNearbyPlayers();
virtual void UpdateObjectVisibility(bool forced = true);
virtual void UpdateObjectVisibilityOnCreate()
{
UpdateObjectVisibility(true);
}
virtual void UpdateObjectVisibilityOnCreate() { UpdateObjectVisibility(true); }
void UpdatePositionData();
void BuildUpdate(UpdateDataMapType&) override;
@@ -469,6 +467,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
uint32 m_zoneId;
uint32 m_areaId;
float m_staticFloorZ;
bool m_outdoors;
//these functions are used mostly for Relocate() and Corpse/Player specific stuff...
//use them ONLY in LoadFromDB()/Create() funcs and nowhere else!

View File

@@ -6379,16 +6379,11 @@ void Player::CheckAreaExploreAndOutdoor()
if (IsInFlight())
return;
bool isOutdoor;
uint32 areaId = GetBaseMap()->GetAreaId(GetPositionX(), GetPositionY(), GetPositionZ(), &isOutdoor);
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
if (sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK) && !isOutdoor)
if (sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK) && !IsOutdoors())
RemoveAurasWithAttribute(SPELL_ATTR0_OUTDOORS_ONLY);
if (!areaId)
return;
uint32 const areaId = GetAreaId();
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
if (!areaEntry)
{
TC_LOG_ERROR("entities.player", "Player '%s' (%s) discovered unknown area (x: %f y: %f z: %f map: %u)",

View File

@@ -2457,10 +2457,8 @@ float Map::GetVMapFloor(float x, float y, float z, float maxSearchDist, float co
return VMAP::VMapFactory::createOrGetVMapManager()->getHeight(GetId(), x, y, z + collisionHeight, maxSearchDist);
}
inline bool IsOutdoorWMO(uint32 mogpFlags, int32 /*adtId*/, int32 /*rootId*/, int32 /*groupId*/, WMOAreaTableEntry const* wmoEntry, AreaTableEntry const* atEntry)
inline bool IsOutdoorWMO(uint32 mogpFlags, WMOAreaTableEntry const* wmoEntry, AreaTableEntry const* atEntry)
{
bool outdoor = true;
if (wmoEntry && atEntry)
{
if (atEntry->flags & AREA_FLAG_OUTSIDE)
@@ -2469,16 +2467,15 @@ inline bool IsOutdoorWMO(uint32 mogpFlags, int32 /*adtId*/, int32 /*rootId*/, in
return false;
}
outdoor = (mogpFlags & 0x8) != 0;
if (wmoEntry)
{
if (wmoEntry->Flags & 4)
return true;
if (wmoEntry->Flags & 2)
outdoor = false;
return false;
}
return outdoor;
return (mogpFlags & 0x8);
}
bool Map::IsOutdoors(float x, float y, float z) const
@@ -2491,13 +2488,13 @@ bool Map::IsOutdoors(float x, float y, float z) const
return true;
AreaTableEntry const* atEntry = nullptr;
WMOAreaTableEntry const* wmoEntry= GetWMOAreaTableEntryByTripple(rootId, adtId, groupId);
WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId);
if (wmoEntry)
{
TC_LOG_DEBUG("maps", "Got WMOAreaTableEntry! flag %u, areaid %u", wmoEntry->Flags, wmoEntry->areaId);
atEntry = sAreaTableStore.LookupEntry(wmoEntry->areaId);
}
return IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry);
return IsOutdoorWMO(mogpFlags, wmoEntry, atEntry);
}
bool Map::GetAreaInfo(float x, float y, float z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const
@@ -2551,7 +2548,7 @@ uint32 Map::GetAreaId(float x, float y, float z, bool *isOutdoors) const
if (isOutdoors)
{
if (haveAreaInfo)
*isOutdoors = IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry);
*isOutdoors = IsOutdoorWMO(mogpFlags, wmoEntry, atEntry);
else
*isOutdoors = true;
}
@@ -2684,20 +2681,21 @@ void Map::GetFullTerrainStatusForPosition(float x, float y, float z, PositionFul
// area lookup
AreaTableEntry const* areaEntry = nullptr;
WMOAreaTableEntry const* wmoEntry = nullptr;
if (vmapData.areaInfo && (z <= mapHeight || mapHeight <= vmapData.floorZ))
if (WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(vmapData.areaInfo->rootId, vmapData.areaInfo->adtId, vmapData.areaInfo->groupId))
if ((wmoEntry = GetWMOAreaTableEntryByTripple(vmapData.areaInfo->rootId, vmapData.areaInfo->adtId, vmapData.areaInfo->groupId)))
areaEntry = sAreaTableStore.LookupEntry(wmoEntry->areaId);
data.areaId = 0;
if (areaEntry)
{
data.floorZ = vmapData.floorZ;
data.areaId = areaEntry->ID;
data.floorZ = vmapData.floorZ;
data.outdoors = IsOutdoorWMO(vmapData.areaInfo->mogpFlags, wmoEntry, areaEntry);
}
else
{
data.floorZ = mapHeight;
if (gmap)
data.areaId = gmap->getArea(x, y);
@@ -2706,6 +2704,9 @@ void Map::GetFullTerrainStatusForPosition(float x, float y, float z, PositionFul
if (data.areaId)
areaEntry = sAreaTableStore.LookupEntry(data.areaId);
data.floorZ = mapHeight;
data.outdoors = true; // @todo default true taken from old GetAreaId check, maybe review
}
// liquid processing

View File

@@ -178,6 +178,7 @@ struct PositionFullTerrainStatus
uint32 areaId;
float floorZ;
bool outdoors;
ZLiquidStatus liquidStatus;
Optional<AreaInfo> areaInfo;
Optional<LiquidData> liquidInfo;

View File

@@ -4933,11 +4933,11 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
if (m_caster->GetTypeId() == TYPEID_PLAYER && VMAP::VMapFactory::createOrGetVMapManager()->isLineOfSightCalcEnabled())
{
if (m_spellInfo->HasAttribute(SPELL_ATTR0_OUTDOORS_ONLY) &&
!m_caster->GetMap()->IsOutdoors(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ()))
!m_caster->IsOutdoors())
return SPELL_FAILED_ONLY_OUTDOORS;
if (m_spellInfo->HasAttribute(SPELL_ATTR0_INDOORS_ONLY) &&
m_caster->GetMap()->IsOutdoors(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ()))
m_caster->IsOutdoors())
return SPELL_FAILED_ONLY_INDOORS;
}

View File

@@ -269,7 +269,7 @@ public:
if (haveVMap)
{
if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()))
if (object->IsOutdoors())
handler->PSendSysMessage(LANG_GPS_POSITION_OUTDOORS);
else
handler->PSendSysMessage(LANG_GPS_POSITION_INDOORS);