[7005] Request Area/Zone Ids using 3D coordinates.

.map files not have 3D specifci area infor. So use hack way for update areaflag for some cases (areas 4281, 4342)
where exist area dependent auras.
This commit is contained in:
VladimirMangos 2009-01-02 19:07:34 +03:00
parent d2d5cb4643
commit bd4fc1b0ae
8 changed files with 42 additions and 21 deletions

View file

@ -2125,7 +2125,8 @@ bool ChatHandler::HandleNameTeleCommand(const char * args)
return false; return false;
PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str()); 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 else
PSendSysMessage(LANG_NO_PLAYER, name.c_str()); PSendSysMessage(LANG_NO_PLAYER, name.c_str());

View file

@ -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 //local x,y coords
float lx,ly; float lx,ly;
@ -1094,11 +1094,30 @@ uint16 Map::GetAreaFlag(float x, float y ) const
// ensure GridMap is loaded // ensure GridMap is loaded
const_cast<Map*>(this)->EnsureGridCreated(GridPair(63-gx,63-gy)); const_cast<Map*>(this)->EnsureGridCreated(GridPair(63-gx,63-gy));
uint16 areaflag;
if(GridMaps[gx][gy]) 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) // this used while not all *.map files generated (instances)
else 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 uint8 Map::GetTerrainType(float x, float y ) const

View file

@ -182,7 +182,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
float GetHeight(float x, float y, float z, bool pCheckVMap=true) const; 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 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; uint8 GetTerrainType(float x, float y ) const;
float GetWaterLevel(float x, float y ) const; float GetWaterLevel(float x, float y ) const;
bool IsUnderWater(float x, float y, float z) const; bool IsUnderWater(float x, float y, float z) const;
@ -190,14 +190,14 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
static uint32 GetAreaId(uint16 areaflag,uint32 map_id); static uint32 GetAreaId(uint16 areaflag,uint32 map_id);
static uint32 GetZoneId(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(); virtual void MoveAllCreaturesInMoveList();

View file

@ -45,13 +45,13 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
Map const* GetBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_GetBaseMap(id); } Map const* GetBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_GetBaseMap(id); }
void DeleteInstance(uint32 mapid, uint32 instanceId); 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); 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 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) { return Map::GetZoneId(GetAreaFlag(mapid, x, y),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 Initialize(void);
void Update(time_t); void Update(time_t);

View file

@ -1044,12 +1044,12 @@ void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid )
uint32 WorldObject::GetZoneId() const 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 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() InstanceData* WorldObject::GetInstanceData()

View file

@ -4858,7 +4858,7 @@ void ObjectMgr::LoadGraveyardZones()
WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team) WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team)
{ {
// search for zone associated closest graveyard // 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: // Simulate std. algorithm:
// found some graveyard associated to (ghost_zone,ghost_map) // found some graveyard associated to (ghost_zone,ghost_map)

View file

@ -1368,7 +1368,7 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
*p_data << uint8(getLevel()); // player level *p_data << uint8(getLevel()); // player level
// do not use GetMap! it will spawn a new instance since the bound instances are not loaded // 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); 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(zoneId);
*p_data << uint32(GetMapId()); *p_data << uint32(GetMapId());
@ -5328,7 +5328,7 @@ void Player::CheckExploreSystem()
if (isInFlight()) if (isInFlight())
return; return;
uint16 areaFlag=MapManager::Instance().GetBaseMap(GetMapId())->GetAreaFlag(GetPositionX(),GetPositionY()); uint16 areaFlag=MapManager::Instance().GetBaseMap(GetMapId())->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ());
if(areaFlag==0xffff) if(areaFlag==0xffff)
return; return;
int offset = areaFlag / 32; int offset = areaFlag / 32;
@ -6170,16 +6170,17 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
if (!zone) if (!zone)
{ {
// stored zone is zero, use generic and slow zone detection // 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 ) if( !result )
return 0; return 0;
fields = result->Fetch(); fields = result->Fetch();
uint32 map = fields[0].GetUInt32(); uint32 map = fields[0].GetUInt32();
float posx = fields[1].GetFloat(); float posx = fields[1].GetFloat();
float posy = fields[2].GetFloat(); float posy = fields[2].GetFloat();
float posz = fields[3].GetFloat();
delete result; 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); CharacterDatabase.PExecute("UPDATE characters SET zone='%u' WHERE guid='%u'", zone, guidLow);
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7004" #define REVISION_NR "7005"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__