Show
Ignore:
Timestamp:
11/19/08 13:48:57 (17 years ago)
Author:
yumileroy
Message:

[svn] *** Source: MaNGOS ***
* Fixed english spelling in src/game/WorldSocket.h/cpp. Author: Derex
* [240_world.sql] Create new command .senditems and remove from moderator level command .sendmail possibility send items. Author: Vladimir
* Added new command: .sendmoney player "subject" "message" money - Sends a mail with money to a player. Author: fredi
* Correctly apply taken damage debufs/bonuses in cases non-physical melee damage. Author: Frankir
* Fix a crash in add friend/ignore callback. (check if player still logged in). Author: Hunuza
* Better args checking in .sendmoney command. Author: Vladimir

Original author: visagalis
Date: 2008-11-14 17:50:48-06:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Level1.cpp

    r177 r232  
    18641864        return false; 
    18651865 
    1866     // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12] 
     1866    // format: name "subject text" "mail text" 
    18671867 
    18681868    char* pName = strtok((char*)args, " "); 
     
    19111911    std::string text    = msgText; 
    19121912 
    1913     // extract items 
    1914     typedef std::pair<uint32,uint32> ItemPair; 
    1915     typedef std::list< ItemPair > ItemPairs; 
    1916     ItemPairs items; 
    1917  
    1918     // get all tail string 
    1919     char* tail = strtok(NULL, ""); 
    1920  
    1921     // get from tail next item str 
    1922     while(char* itemStr = strtok(tail, " ")) 
    1923     { 
    1924         // and get new tail  
    1925         tail = strtok(NULL, ""); 
    1926  
    1927         // parse item str 
    1928         char* itemIdStr = strtok(itemStr, ":"); 
    1929         char* itemCountStr = strtok(NULL, " "); 
    1930          
    1931         uint32 item_id = atoi(itemIdStr); 
    1932         if(!item_id) 
    1933             return false; 
    1934  
    1935         ItemPrototype const* item_proto = objmgr.GetItemPrototype(item_id); 
    1936         if(!item_proto) 
    1937         { 
    1938             PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); 
    1939             SetSentErrorMessage(true); 
    1940             return false; 
    1941         } 
    1942  
    1943         uint32 item_count = itemCountStr ? atoi(itemCountStr) : 1; 
    1944         if(item_count < 1 || item_proto->MaxCount && item_count > item_proto->MaxCount) 
    1945         { 
    1946             PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id); 
    1947             SetSentErrorMessage(true); 
    1948             return false; 
    1949         } 
    1950  
    1951         while(item_count > item_proto->Stackable) 
    1952         { 
    1953             items.push_back(ItemPair(item_id,item_proto->Stackable)); 
    1954             item_count -= item_proto->Stackable; 
    1955         } 
    1956  
    1957         items.push_back(ItemPair(item_id,item_count)); 
    1958  
    1959         if(items.size() > MAX_MAIL_ITEMS) 
    1960         { 
    1961             PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS); 
    1962             SetSentErrorMessage(true); 
    1963             return false; 
    1964         } 
    1965     } 
    1966  
    19671913    if(!normalizePlayerName(name)) 
    19681914    { 
     
    19811927 
    19821928    uint32 mailId = objmgr.GenerateMailID(); 
    1983     uint32 sender_guidlo = m_session->GetPlayer()->GetGUIDLow(); 
     1929    // from console show not existed sender 
     1930    uint32 sender_guidlo = m_session ? m_session->GetPlayer()->GetGUIDLow() : 0; 
     1931 
    19841932    uint32 messagetype = MAIL_NORMAL; 
    19851933    uint32 stationery = MAIL_STATIONERY_GM; 
    1986     uint32 itemTextId = 0; 
    1987     if (!text.empty()) 
    1988     { 
    1989         itemTextId = objmgr.CreateItemText( text ); 
    1990     } 
     1934    uint32 itemTextId = !text.empty() ? objmgr.CreateItemText( text ) : 0; 
    19911935 
    19921936    Player *receiver = objmgr.GetPlayer(receiver_guid); 
    19931937 
    1994     // fill mail 
    1995     MailItemsInfo mi;                                       // item list preparing 
    1996  
    1997     for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) 
    1998     { 
    1999         if(Item* item = Item::CreateItem(itr->first,itr->second,m_session->GetPlayer())) 
    2000         { 
    2001             item->SaveToDB();                               // save for prevent lost at next mail load, if send fail then item will deleted 
    2002             mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); 
    2003         } 
    2004     } 
    2005  
    2006     WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_NONE); 
     1938    WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE); 
    20071939 
    20081940    PSendSysMessage(LANG_MAIL_SENT, name.c_str());