Core/Commands: Prevent crash upon using .pinfo on characters in unknown areas

Closes #2784
This commit is contained in:
leak
2011-08-30 13:15:38 +02:00
parent 3be7485020
commit d498a5b68f
+15 -5
View File
@@ -408,21 +408,31 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
// Add map, zone, subzone and phase to output // Add map, zone, subzone and phase to output
int locale = GetSessionDbcLocale(); int locale = GetSessionDbcLocale();
std::string areaName = "<unknown>";
std::string zoneName = "";
MapEntry const* map = sMapStore.LookupEntry(mapId); MapEntry const* map = sMapStore.LookupEntry(mapId);
AreaTableEntry const* area = GetAreaEntryByAreaID(areaId); AreaTableEntry const* area = GetAreaEntryByAreaID(areaId);
AreaTableEntry const* zone = NULL; if (area)
{
areaName = area->area_name[locale];
AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone);
if (zone)
zoneName = zone->area_name[locale];
}
if (target) if (target)
{ {
if (AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone)) if (!zoneName.empty())
PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], zone->area_name[locale], area->area_name[locale], phase); PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], zoneName.c_str(), areaName.c_str(), phase);
else else
PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], area->area_name[locale], "--", phase); PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], areaName.c_str(), "<unknown>", phase);
} }
else else
PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], area->area_name[locale]); PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], areaName.c_str());
return true; return true;
} }