diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index d42141d0d..fb27666b6 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -2125,7 +2125,8 @@ bool ChatHandler::HandleNameTeleCommand(const char * args) return false; PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str()); - Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y),guid); + Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation, + MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),guid); } else PSendSysMessage(LANG_NO_PLAYER, name.c_str()); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index d2f8c06a9..4d05e5e2e 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1076,7 +1076,7 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const } } -uint16 Map::GetAreaFlag(float x, float y ) const +uint16 Map::GetAreaFlag(float x, float y, float z) const { //local x,y coords float lx,ly; @@ -1094,11 +1094,30 @@ uint16 Map::GetAreaFlag(float x, float y ) const // ensure GridMap is loaded const_cast(this)->EnsureGridCreated(GridPair(63-gx,63-gy)); + uint16 areaflag; if(GridMaps[gx][gy]) - return GridMaps[gx][gy]->area_flag[(int)(lx)][(int)(ly)]; + areaflag = GridMaps[gx][gy]->area_flag[(int)(lx)][(int)(ly)]; // this used while not all *.map files generated (instances) else - return GetAreaFlagByMapId(i_id); + areaflag = GetAreaFlagByMapId(i_id); + + //FIXME: some hacks for areas above or underground for ground area + // required for area specific spells/etc, until map/vmap data + // not provided correct areaflag with this hacks + switch(areaflag) + { + // Acherus: The Ebon Hold (Plaguelands: The Scarlet Enclave) + case 1984: // Plaguelands: The Scarlet Enclave + case 2076: // Death's Breach (Plaguelands: The Scarlet Enclave) + case 2745: // The Noxious Pass (Plaguelands: The Scarlet Enclave) + if(z > 350.0f) areaflag = 2048; break; + // Acherus: The Ebon Hold (Eastern Plaguelands) + case 856: // The Noxious Glade (Eastern Plaguelands) + case 2456: // Death's Breach (Eastern Plaguelands) + if(z > 350.0f) areaflag = 1950; break; + } + + return areaflag; } uint8 Map::GetTerrainType(float x, float y ) const diff --git a/src/game/Map.h b/src/game/Map.h index 70137a614..21e2d7d01 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -182,7 +182,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj float GetHeight(float x, float y, float z, bool pCheckVMap=true) const; bool IsInWater(float x, float y, float z) const; // does not use z pos. This is for future use - uint16 GetAreaFlag(float x, float y ) const; + uint16 GetAreaFlag(float x, float y, float z) const; uint8 GetTerrainType(float x, float y ) const; float GetWaterLevel(float x, float y ) const; bool IsUnderWater(float x, float y, float z) const; @@ -190,14 +190,14 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj static uint32 GetAreaId(uint16 areaflag,uint32 map_id); static uint32 GetZoneId(uint16 areaflag,uint32 map_id); - uint32 GetAreaId(float x, float y) const + uint32 GetAreaId(float x, float y, float z) const { - return GetAreaId(GetAreaFlag(x,y),i_id); + return GetAreaId(GetAreaFlag(x,y,z),i_id); } - uint32 GetZoneId(float x, float y) const + uint32 GetZoneId(float x, float y, float z) const { - return GetZoneId(GetAreaFlag(x,y),i_id); + return GetZoneId(GetAreaFlag(x,y,z),i_id); } virtual void MoveAllCreaturesInMoveList(); diff --git a/src/game/MapManager.h b/src/game/MapManager.h index 43ba884a9..74312d602 100644 --- a/src/game/MapManager.h +++ b/src/game/MapManager.h @@ -45,13 +45,13 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton(this)->_GetBaseMap(id); } void DeleteInstance(uint32 mapid, uint32 instanceId); - inline uint16 GetAreaFlag(uint32 mapid, float x, float y) const + inline uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const { Map const* m = GetBaseMap(mapid); - return m->GetAreaFlag(x, y); + return m->GetAreaFlag(x, y, z); } - inline uint32 GetAreaId(uint32 mapid, float x, float y) { return Map::GetAreaId(GetAreaFlag(mapid, x, y),mapid); } - inline uint32 GetZoneId(uint32 mapid, float x, float y) { return Map::GetZoneId(GetAreaFlag(mapid, x, y),mapid); } + inline uint32 GetAreaId(uint32 mapid, float x, float y, float z) { return Map::GetAreaId(GetAreaFlag(mapid, x, y, z),mapid); } + inline uint32 GetZoneId(uint32 mapid, float x, float y, float z) { return Map::GetZoneId(GetAreaFlag(mapid, x, y, z),mapid); } void Initialize(void); void Update(time_t); diff --git a/src/game/Object.cpp b/src/game/Object.cpp index ebd2279b7..b2c9e16d5 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1044,12 +1044,12 @@ void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid ) uint32 WorldObject::GetZoneId() const { - return MapManager::Instance().GetBaseMap(m_mapId)->GetZoneId(m_positionX,m_positionY); + return MapManager::Instance().GetBaseMap(m_mapId)->GetZoneId(m_positionX,m_positionY,m_positionZ); } uint32 WorldObject::GetAreaId() const { - return MapManager::Instance().GetBaseMap(m_mapId)->GetAreaId(m_positionX,m_positionY); + return MapManager::Instance().GetBaseMap(m_mapId)->GetAreaId(m_positionX,m_positionY,m_positionZ); } InstanceData* WorldObject::GetInstanceData() diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index f492192e1..e33152c86 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4858,7 +4858,7 @@ void ObjectMgr::LoadGraveyardZones() WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team) { // search for zone associated closest graveyard - uint32 zoneId = MapManager::Instance().GetZoneId(MapId,x,y); + uint32 zoneId = MapManager::Instance().GetZoneId(MapId,x,y,z); // Simulate std. algorithm: // found some graveyard associated to (ghost_zone,ghost_map) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 347c24305..7124023e0 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1368,7 +1368,7 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) *p_data << uint8(getLevel()); // player level // do not use GetMap! it will spawn a new instance since the bound instances are not loaded - uint32 zoneId = MapManager::Instance().GetZoneId(GetMapId(), GetPositionX(),GetPositionY()); + uint32 zoneId = MapManager::Instance().GetZoneId(GetMapId(), GetPositionX(),GetPositionY(),GetPositionZ()); sLog.outDebug("Player::BuildEnumData: m:%u, x:%f, y:%f, z:%f zone:%u", GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), zoneId); *p_data << uint32(zoneId); *p_data << uint32(GetMapId()); @@ -5328,7 +5328,7 @@ void Player::CheckExploreSystem() if (isInFlight()) return; - uint16 areaFlag=MapManager::Instance().GetBaseMap(GetMapId())->GetAreaFlag(GetPositionX(),GetPositionY()); + uint16 areaFlag=MapManager::Instance().GetBaseMap(GetMapId())->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ()); if(areaFlag==0xffff) return; int offset = areaFlag / 32; @@ -6170,16 +6170,17 @@ uint32 Player::GetZoneIdFromDB(uint64 guid) if (!zone) { // stored zone is zero, use generic and slow zone detection - result = CharacterDatabase.PQuery("SELECT map,position_x,position_y FROM characters WHERE guid='%u'", guidLow); + result = CharacterDatabase.PQuery("SELECT map,position_x,position_y,position_z FROM characters WHERE guid='%u'", guidLow); if( !result ) return 0; fields = result->Fetch(); uint32 map = fields[0].GetUInt32(); float posx = fields[1].GetFloat(); float posy = fields[2].GetFloat(); + float posz = fields[3].GetFloat(); delete result; - zone = MapManager::Instance().GetZoneId(map,posx,posy); + zone = MapManager::Instance().GetZoneId(map,posx,posy,posz); CharacterDatabase.PExecute("UPDATE characters SET zone='%u' WHERE guid='%u'", zone, guidLow); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c60dc916b..262124edd 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7004" + #define REVISION_NR "7005" #endif // __REVISION_NR_H__