| 186 | // Enables or disables hiding of the staff badge |
| 187 | bool ChatHandler::HandleGMChatCommand(const char* args) |
| 188 | { |
| 189 | if(!*args) |
| 190 | { |
| 191 | if(m_session->GetPlayer()->isGMChat()) |
| 192 | m_session->SendNotification(LANG_GM_CHAT_ON); |
| 193 | else |
| 194 | m_session->SendNotification(LANG_GM_CHAT_OFF); |
| 195 | return true; |
| 196 | } |
| 197 | |
| 198 | std::string argstr = (char*)args; |
| 199 | |
| 200 | if (argstr == "on") |
| 201 | { |
| 202 | m_session->GetPlayer()->SetGMChat(true); |
| 203 | m_session->SendNotification(LANG_GM_CHAT_ON); |
| 204 | return true; |
| 205 | } |
| 206 | |
| 207 | if (argstr == "off") |
| 208 | { |
| 209 | m_session->GetPlayer()->SetGMChat(false); |
| 210 | m_session->SendNotification(LANG_GM_CHAT_OFF); |
| 211 | return true; |
| 212 | } |
| 213 | |
| 214 | SendSysMessage(LANG_USE_BOL); |
| 215 | SetSentErrorMessage(true); |
| 216 | return false; |
| 217 | } |
| 218 | |
| 219 | |
1827 | | char* msgSubject = strtok(NULL, " "); |
1828 | | char* msgText = strtok(NULL, ""); |
| 1865 | if(!pName) |
| 1866 | return false; |
| 1867 | |
| 1868 | char* tail1 = strtok(NULL, ""); |
| 1869 | if(!tail1) |
| 1870 | return false; |
| 1871 | |
| 1872 | char* msgSubject; |
| 1873 | if(*tail1=='"') |
| 1874 | msgSubject = strtok(tail1+1, "\""); |
| 1875 | else |
| 1876 | { |
| 1877 | char* space = strtok(tail1, "\""); |
| 1878 | if(!space) |
| 1879 | return false; |
| 1880 | msgSubject = strtok(NULL, "\""); |
| 1881 | } |
| 1882 | |
| 1883 | if (!msgSubject) |
| 1884 | return false; |
| 1885 | |
| 1886 | char* tail2 = strtok(NULL, ""); |
| 1887 | if(!tail2) |
| 1888 | return false; |
| 1889 | |
| 1890 | char* msgText; |
| 1891 | if(*tail2=='"') |
| 1892 | msgText = strtok(tail2+1, "\""); |
| 1893 | else |
| 1894 | { |
| 1895 | char* space = strtok(tail2, "\""); |
| 1896 | if(!space) |
| 1897 | return false; |
| 1898 | msgText = strtok(NULL, "\""); |
| 1899 | } |
| 1909 | // extract items |
| 1910 | typedef std::pair<uint32,uint32> ItemPair; |
| 1911 | typedef std::list< ItemPair > ItemPairs; |
| 1912 | ItemPairs items; |
| 1913 | |
| 1914 | // get all tail string |
| 1915 | char* tail = strtok(NULL, ""); |
| 1916 | |
| 1917 | // get from tail next item str |
| 1918 | while(char* itemStr = strtok(tail, " ")) |
| 1919 | { |
| 1920 | // and get new tail |
| 1921 | tail = strtok(NULL, ""); |
| 1922 | |
| 1923 | // parse item str |
| 1924 | char* itemIdStr = strtok(itemStr, ":"); |
| 1925 | char* itemCountStr = strtok(NULL, " "); |
| 1926 | |
| 1927 | uint32 item_id = atoi(itemIdStr); |
| 1928 | if(!item_id) |
| 1929 | return false; |
| 1930 | |
| 1931 | ItemPrototype const* item_proto = objmgr.GetItemPrototype(item_id); |
| 1932 | if(!item_proto) |
| 1933 | { |
| 1934 | PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); |
| 1935 | SetSentErrorMessage(true); |
| 1936 | return false; |
| 1937 | } |
| 1938 | |
| 1939 | uint32 item_count = itemCountStr ? atoi(itemCountStr) : 1; |
| 1940 | if(item_count < 1 || item_proto->MaxCount && item_count > item_proto->MaxCount) |
| 1941 | { |
| 1942 | PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id); |
| 1943 | SetSentErrorMessage(true); |
| 1944 | return false; |
| 1945 | } |
| 1946 | |
| 1947 | while(item_count > item_proto->Stackable) |
| 1948 | { |
| 1949 | items.push_back(ItemPair(item_id,item_proto->Stackable)); |
| 1950 | item_count -= item_proto->Stackable; |
| 1951 | } |
| 1952 | |
| 1953 | items.push_back(ItemPair(item_id,item_count)); |
| 1954 | |
| 1955 | if(items.size() > MAX_MAIL_ITEMS) |
| 1956 | { |
| 1957 | PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS); |
| 1958 | SetSentErrorMessage(true); |
| 1959 | return false; |
| 1960 | } |
| 1961 | } |
| 1962 | |
1863 | | WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE); |
| 1990 | // fill mail |
| 1991 | MailItemsInfo mi; // item list preparing |
| 1992 | |
| 1993 | for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) |
| 1994 | { |
| 1995 | if(Item* item = Item::CreateItem(itr->first,itr->second,m_session->GetPlayer())) |
| 1996 | { |
| 1997 | item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted |
| 1998 | mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); |
| 1999 | } |
| 2000 | } |
| 2001 | |
| 2002 | WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_NONE); |