1587 | | char* cId = extractKeyFromLink((char*)args,"Htele"); // string or [name] Shift-click form |color|Htele:name|h[name]|h|r |
1588 | | if(!cId) |
1589 | | return false; |
1590 | | |
1591 | | std::string name = cId; |
1592 | | WorldDatabase.escape_string(name); |
1593 | | |
1594 | | QueryResult *result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM game_tele WHERE name = '%s'",name.c_str()); |
1595 | | if (!result) |
| 1586 | // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r |
| 1587 | GameTele const* tele = extractGameTeleFromLink((char*)args); |
| 1588 | |
| 1589 | if (!tele) |
1598 | | SetSentErrorMessage(true); |
1599 | | return false; |
1600 | | } |
1601 | | Field *fields = result->Fetch(); |
1602 | | float x = fields[0].GetFloat(); |
1603 | | float y = fields[1].GetFloat(); |
1604 | | float z = fields[2].GetFloat(); |
1605 | | float ort = fields[3].GetFloat(); |
1606 | | int mapid = fields[4].GetUInt16(); |
1607 | | delete result; |
1608 | | |
1609 | | if(!MapManager::IsValidMapCoord(mapid,x,y,x,ort)) |
1610 | | { |
1611 | | PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); |
1705 | | WorldDatabase.escape_string(namepart); |
1706 | | QueryResult *result = WorldDatabase.PQuery("SELECT name FROM game_tele WHERE name "_LIKE_" '""%%%s%%""'",namepart.c_str()); |
1707 | | if (!result) |
1708 | | { |
1709 | | SendSysMessage(LANG_COMMAND_TELE_NOREQUEST); |
1710 | | SetSentErrorMessage(true); |
1711 | | return false; |
1712 | | } |
1713 | | std::string reply; |
1714 | | for (uint64 i=0; i < result->GetRowCount(); i++) |
1715 | | { |
1716 | | Field *fields = result->Fetch(); |
1717 | | reply += " |cffffffff|Htele:"; |
1718 | | reply += fields[0].GetCppString(); |
1719 | | reply += "|h["; |
1720 | | reply += fields[0].GetCppString(); |
1721 | | reply += "]|h|r\n"; |
1722 | | result->NextRow(); |
1723 | | } |
1724 | | delete result; |
1725 | | |
1726 | | if(reply.empty()) |
| 1685 | std::wstring wnamepart; |
| 1686 | |
| 1687 | if(!Utf8toWStr(namepart,wnamepart)) |
| 1688 | return false; |
| 1689 | |
| 1690 | // converting string that we try to find to lower case |
| 1691 | wstrToLower( wnamepart ); |
| 1692 | |
| 1693 | GameTeleMap const & teleMap = objmgr.GetGameTeleMap(); |
| 1694 | |
| 1695 | std::ostringstream reply; |
| 1696 | for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr) |
| 1697 | { |
| 1698 | GameTele const* tele = &itr->second; |
| 1699 | |
| 1700 | if(tele->wnameLow.find(wnamepart) == std::wstring::npos) |
| 1701 | continue; |
| 1702 | |
| 1703 | reply << " |cffffffff|Htele:"; |
| 1704 | reply << itr->first; |
| 1705 | reply << "|h["; |
| 1706 | reply << tele->name; |
| 1707 | reply << "]|h|r\n"; |
| 1708 | } |
| 1709 | |
| 1710 | if(reply.str().empty()) |
1868 | | char* cId = extractKeyFromLink((char*)tail,"Htele"); // string or [name] Shift-click form |color|Htele:name|h[name]|h|r |
1869 | | if(!cId) |
1870 | | return false; |
1871 | | |
1872 | | std::string location = cId; |
1873 | | |
1874 | | std::string name = pName; |
1875 | | |
1876 | | if(!normalizePlayerName(name)) |
1877 | | { |
1878 | | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
1879 | | SetSentErrorMessage(true); |
1880 | | return false; |
1881 | | } |
1882 | | |
1883 | | WorldDatabase.escape_string(location); |
1884 | | QueryResult *result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM game_tele WHERE name = '%s'",location.c_str()); |
1885 | | if (!result) |
| 1859 | // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r |
| 1860 | GameTele const* tele = extractGameTeleFromLink(tail); |
| 1861 | if(!tele) |
1888 | | SetSentErrorMessage(true); |
1889 | | return false; |
1890 | | } |
1891 | | |
1892 | | Field *fields = result->Fetch(); |
1893 | | float x = fields[0].GetFloat(); |
1894 | | float y = fields[1].GetFloat(); |
1895 | | float z = fields[2].GetFloat(); |
1896 | | float ort = fields[3].GetFloat(); |
1897 | | int mapid = fields[4].GetUInt16(); |
1898 | | delete result; |
1899 | | |
1900 | | if(!MapManager::IsValidMapCoord(mapid,x,y,x,ort)) |
1901 | | { |
1902 | | PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); |
1937 | | PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetMangosString(LANG_OFFLINE), location.c_str()); |
1938 | | Player::SavePositionInDB(mapid,x,y,z,ort,MapManager::Instance().GetZoneId(mapid,x,y),guid); |
| 1898 | PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str()); |
| 1899 | 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); |
1960 | | char* cId = extractKeyFromLink((char*)args,"Htele"); // string or [name] Shift-click form |color|Htele:name|h[name]|h|r |
1961 | | if(!cId) |
1962 | | return false; |
1963 | | |
1964 | | std::string location = cId; |
1965 | | |
1966 | | WorldDatabase.escape_string(location); |
1967 | | QueryResult *result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM game_tele WHERE name = '%s'",location.c_str()); |
1968 | | if (!result) |
| 1921 | // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r |
| 1922 | GameTele const* tele = extractGameTeleFromLink((char*)args); |
| 1923 | if(!tele) |
1974 | | Field *fields = result->Fetch(); |
1975 | | float x = fields[0].GetFloat(); |
1976 | | float y = fields[1].GetFloat(); |
1977 | | float z = fields[2].GetFloat(); |
1978 | | float ort = fields[3].GetFloat(); |
1979 | | int mapid = fields[4].GetUInt16(); |
1980 | | delete result; |
1981 | | |
1982 | | if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) |
1983 | | { |
1984 | | PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); |
1985 | | SetSentErrorMessage(true); |
1986 | | return false; |
1987 | | } |