Changeset 112 for trunk/src/game/Level1.cpp
- Timestamp:
- 11/19/08 13:37:14 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Level1.cpp
r102 r112 1693 1693 bool ChatHandler::HandleLookupAreaCommand(const char* args) 1694 1694 { 1695 if (!*args)1695 if (!*args) 1696 1696 return false; 1697 1697 … … 1699 1699 std::wstring wnamepart; 1700 1700 1701 if (!Utf8toWStr(namepart,wnamepart))1701 if (!Utf8toWStr (namepart,wnamepart)) 1702 1702 return false; 1703 1703 … … 1705 1705 1706 1706 // converting string that we try to find to lower case 1707 wstrToLower ( wnamepart);1707 wstrToLower (wnamepart); 1708 1708 1709 1709 // Search in AreaTable.dbc 1710 for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows (); ++areaflag)1711 { 1712 AreaTableEntry const *areaEntry = sAreaStore.LookupEntry (areaflag);1713 if (areaEntry)1714 { 1715 int loc = m_session ->GetSessionDbcLocale();1710 for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows (); ++areaflag) 1711 { 1712 AreaTableEntry const *areaEntry = sAreaStore.LookupEntry (areaflag); 1713 if (areaEntry) 1714 { 1715 int loc = m_session ? m_session->GetSessionDbcLocale () : sWorld.GetDefaultDbcLocale(); 1716 1716 std::string name = areaEntry->area_name[loc]; 1717 if (name.empty())1717 if (name.empty()) 1718 1718 continue; 1719 1719 1720 if (!Utf8FitTo(name, wnamepart))1720 if (!Utf8FitTo (name, wnamepart)) 1721 1721 { 1722 1722 loc = 0; 1723 1723 for(; loc < MAX_LOCALE; ++loc) 1724 1724 { 1725 if (loc==m_session->GetSessionDbcLocale())1725 if (m_session && loc==m_session->GetSessionDbcLocale ()) 1726 1726 continue; 1727 1727 1728 1728 name = areaEntry->area_name[loc]; 1729 if (name.empty())1729 if (name.empty ()) 1730 1730 continue; 1731 1731 1732 if (Utf8FitTo (name, wnamepart))1732 if (Utf8FitTo (name, wnamepart)) 1733 1733 break; 1734 1734 } 1735 1735 } 1736 1736 1737 if (loc < MAX_LOCALE)1737 if (loc < MAX_LOCALE) 1738 1738 { 1739 1739 // send area in "id - [name]" format 1740 1740 std::ostringstream ss; 1741 ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r"; 1742 1743 SendSysMessage(ss.str().c_str()); 1741 if (m_session) 1742 ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r"; 1743 else 1744 ss << areaEntry->ID << " - " << name << " " << localeNames[loc]; 1745 1746 SendSysMessage (ss.str ().c_str()); 1744 1747 1745 1748 ++counter; … … 1747 1750 } 1748 1751 } 1749 if (counter == 0) 1750 SendSysMessage (LANG_COMMAND_NOAREAFOUND);1752 if (counter == 0) // if counter == 0 then we found nth 1753 SendSysMessage (LANG_COMMAND_NOAREAFOUND); 1751 1754 return true; 1752 1755 } … … 1761 1764 return false; 1762 1765 } 1766 1763 1767 char const* str = strtok((char*)args, " "); 1764 1768 if(!str) … … 1774 1778 wstrToLower( wnamepart ); 1775 1779 1776 GameTeleMap const & teleMap = objmgr.GetGameTeleMap();1777 1778 1780 std::ostringstream reply; 1781 1782 GameTeleMap const & teleMap = objmgr.GetGameTeleMap(); 1779 1783 for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr) 1780 1784 { … … 1784 1788 continue; 1785 1789 1786 reply << " |cffffffff|Htele:"; 1787 reply << itr->first; 1788 reply << "|h["; 1789 reply << tele->name; 1790 reply << "]|h|r\n"; 1790 if (m_session) 1791 reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n"; 1792 else 1793 reply << " " << itr->first << " " << tele->name << "\n"; 1791 1794 } 1792 1795 … … 2073 2076 PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", tele->name.c_str()); 2074 2077 2075 if (m_session->GetPlayer()->IsVisibleGloballyFor(chr)) 2076 ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName()); 2078 if (m_session) 2079 { 2080 if(m_session->GetPlayer()->IsVisibleGloballyFor(chr)) 2081 ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName()); 2082 } 2083 else 2084 ChatHandler(chr).SendSysMessage(LANG_TELEPORTED_TO_BY_CONSOLE); 2077 2085 2078 2086 // stop flight if need