[9422] Return success result for Zone<->map coordinates convertions.

This will prevent #INF-inity values in gps for zones where
zone coordinates calculation impossible with current code.

Also fix small typo in debug output format for honor
This commit is contained in:
VladimirMangos 2010-02-20 17:15:16 +03:00
parent a916e31316
commit b2019913d4
5 changed files with 25 additions and 12 deletions

View file

@ -772,30 +772,34 @@ bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredT
return (itemEntry->categoryMask & reqEntry->categoryMask)==reqEntry->categoryMask;
}
void Zone2MapCoordinates(float& x,float& y,uint32 zone)
bool Zone2MapCoordinates(float& x,float& y,uint32 zone)
{
WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone);
// if not listed then map coordinates (instance)
if(!maEntry)
return;
if (!maEntry || maEntry->x2 == maEntry->x1 || maEntry->y2 == maEntry->y1)
return false;
std::swap(x,y); // at client map coords swapped
x = x*((maEntry->x2-maEntry->x1)/100)+maEntry->x1;
y = y*((maEntry->y2-maEntry->y1)/100)+maEntry->y1; // client y coord from top to down
return true;
}
void Map2ZoneCoordinates(float& x,float& y,uint32 zone)
bool Map2ZoneCoordinates(float& x,float& y,uint32 zone)
{
WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone);
// if not listed then map coordinates (instance)
if(!maEntry)
return;
if (!maEntry || maEntry->x2 == maEntry->x1 || maEntry->y2 == maEntry->y1)
return false;
x = (x-maEntry->x1)/((maEntry->x2-maEntry->x1)/100);
y = (y-maEntry->y1)/((maEntry->y2-maEntry->y1)/100); // client y coord from top to down
std::swap(x,y); // client have map coords swapped
return true;
}
MapDifficulty const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty)

View file

@ -55,8 +55,8 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id);
bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId);
void Zone2MapCoordinates(float& x,float& y,uint32 zone);
void Map2ZoneCoordinates(float& x,float& y,uint32 zone);
bool Zone2MapCoordinates(float& x,float& y,uint32 zone);
bool Map2ZoneCoordinates(float& x,float& y,uint32 zone);
typedef std::map<uint32/*pair32(map,diff)*/,MapDifficulty> MapDifficultyMap;
MapDifficulty const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty);

View file

@ -294,7 +294,11 @@ bool ChatHandler::HandleGPSCommand(const char* args)
float zone_x = obj->GetPositionX();
float zone_y = obj->GetPositionY();
Map2ZoneCoordinates(zone_x,zone_y,zone_id);
if (Map2ZoneCoordinates(zone_x,zone_y,zone_id))
{
zone_x = 0;
zone_y = 0;
}
Map const *map = obj->GetMap();
float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
@ -2409,7 +2413,12 @@ bool ChatHandler::HandleGoZoneXYCommand(const char* args)
return false;
}
Zone2MapCoordinates(x,y,zoneEntry->ID);
if (!Zone2MapCoordinates(x,y,zoneEntry->ID))
{
PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[GetSessionDbcLocale()],map->GetId(),map->GetMapName());
SetSentErrorMessage(true);
return false;
}
if(!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y))
{

View file

@ -4179,7 +4179,7 @@ void Spell::EffectAddHonor(SpellEffectIndex /*eff_idx*/)
{
float honor_reward = MaNGOS::Honor::hk_honor_at_level(unitTarget->getLevel(), damage);
((Player*)unitTarget)->RewardHonor(NULL, 1, honor_reward);
sLog.outDebug("SpellEffect::AddHonor (spell_id %u) rewards %u honor points (scale) to player: %u", m_spellInfo->Id, honor_reward, ((Player*)unitTarget)->GetGUIDLow());
sLog.outDebug("SpellEffect::AddHonor (spell_id %u) rewards %f honor points (scale) to player: %u", m_spellInfo->Id, honor_reward, ((Player*)unitTarget)->GetGUIDLow());
}
else
{

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9421"
#define REVISION_NR "9422"
#endif // __REVISION_NR_H__