- Timestamp:
- 11/19/08 13:48:57 (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Chat.cpp
r229 r232 545 545 { "lockaccount", SEC_PLAYER, false, &ChatHandler::HandleLockAccountCommand, "", NULL }, 546 546 { "respawn", SEC_ADMINISTRATOR, false, &ChatHandler::HandleRespawnCommand, "", NULL }, 547 { "sendmail", SEC_MODERATOR, false, &ChatHandler::HandleSendMailCommand, "", NULL }, 547 { "senditems", SEC_ADMINISTRATOR, true, &ChatHandler::HandleSendItemsCommand, "", NULL }, 548 { "sendmail", SEC_MODERATOR, true, &ChatHandler::HandleSendMailCommand, "", NULL }, 549 { "sendmoney", SEC_ADMINISTRATOR, true, &ChatHandler::HandleSendMoneyCommand, "", NULL }, 548 550 { "rename", SEC_GAMEMASTER, true, &ChatHandler::HandleRenameCommand, "", NULL }, 549 551 { "loadscripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleLoadScriptsCommand, "", NULL }, -
trunk/src/game/Chat.h
r209 r232 118 118 bool HandleTaxiCheatCommand(const char* args); 119 119 bool HandleWhispersCommand(const char* args); 120 bool HandleSendMailCommand(const char* args);121 120 bool HandleNameTeleCommand(const char* args); 122 121 bool HandleGroupTeleCommand(const char* args); 123 122 bool HandleDrunkCommand(const char* args); 123 bool HandleSendItemsCommand(const char* args); 124 bool HandleSendMailCommand(const char* args); 125 bool HandleSendMoneyCommand(const char* args); 124 126 125 127 bool HandleEventActiveListCommand(const char* args); -
trunk/src/game/Level1.cpp
r177 r232 1864 1864 return false; 1865 1865 1866 // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]1866 // format: name "subject text" "mail text" 1867 1867 1868 1868 char* pName = strtok((char*)args, " "); … … 1911 1911 std::string text = msgText; 1912 1912 1913 // extract items1914 typedef std::pair<uint32,uint32> ItemPair;1915 typedef std::list< ItemPair > ItemPairs;1916 ItemPairs items;1917 1918 // get all tail string1919 char* tail = strtok(NULL, "");1920 1921 // get from tail next item str1922 while(char* itemStr = strtok(tail, " "))1923 {1924 // and get new tail1925 tail = strtok(NULL, "");1926 1927 // parse item str1928 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 1967 1913 if(!normalizePlayerName(name)) 1968 1914 { … … 1981 1927 1982 1928 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 1984 1932 uint32 messagetype = MAIL_NORMAL; 1985 1933 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; 1991 1935 1992 1936 Player *receiver = objmgr.GetPlayer(receiver_guid); 1993 1937 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); 2007 1939 2008 1940 PSendSysMessage(LANG_MAIL_SENT, name.c_str()); -
trunk/src/game/Level3.cpp
r230 r232 6202 6202 } 6203 6203 6204 //Send items by mail 6205 bool ChatHandler::HandleSendItemsCommand(const char* args) 6206 { 6207 if(!*args) 6208 return false; 6209 6210 // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12] 6211 6212 char* pName = strtok((char*)args, " "); 6213 if(!pName) 6214 return false; 6215 6216 char* tail1 = strtok(NULL, ""); 6217 if(!tail1) 6218 return false; 6219 6220 char* msgSubject; 6221 if(*tail1=='"') 6222 msgSubject = strtok(tail1+1, "\""); 6223 else 6224 { 6225 char* space = strtok(tail1, "\""); 6226 if(!space) 6227 return false; 6228 msgSubject = strtok(NULL, "\""); 6229 } 6230 6231 if (!msgSubject) 6232 return false; 6233 6234 char* tail2 = strtok(NULL, ""); 6235 if(!tail2) 6236 return false; 6237 6238 char* msgText; 6239 if(*tail2=='"') 6240 msgText = strtok(tail2+1, "\""); 6241 else 6242 { 6243 char* space = strtok(tail2, "\""); 6244 if(!space) 6245 return false; 6246 msgText = strtok(NULL, "\""); 6247 } 6248 6249 if (!msgText) 6250 return false; 6251 6252 // pName, msgSubject, msgText isn't NUL after prev. check 6253 std::string name = pName; 6254 std::string subject = msgSubject; 6255 std::string text = msgText; 6256 6257 // extract items 6258 typedef std::pair<uint32,uint32> ItemPair; 6259 typedef std::list< ItemPair > ItemPairs; 6260 ItemPairs items; 6261 6262 // get all tail string 6263 char* tail = strtok(NULL, ""); 6264 6265 // get from tail next item str 6266 while(char* itemStr = strtok(tail, " ")) 6267 { 6268 // and get new tail 6269 tail = strtok(NULL, ""); 6270 6271 // parse item str 6272 char* itemIdStr = strtok(itemStr, ":"); 6273 char* itemCountStr = strtok(NULL, " "); 6274 6275 uint32 item_id = atoi(itemIdStr); 6276 if(!item_id) 6277 return false; 6278 6279 ItemPrototype const* item_proto = objmgr.GetItemPrototype(item_id); 6280 if(!item_proto) 6281 { 6282 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); 6283 SetSentErrorMessage(true); 6284 return false; 6285 } 6286 6287 uint32 item_count = itemCountStr ? atoi(itemCountStr) : 1; 6288 if(item_count < 1 || item_proto->MaxCount && item_count > item_proto->MaxCount) 6289 { 6290 PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id); 6291 SetSentErrorMessage(true); 6292 return false; 6293 } 6294 6295 while(item_count > item_proto->Stackable) 6296 { 6297 items.push_back(ItemPair(item_id,item_proto->Stackable)); 6298 item_count -= item_proto->Stackable; 6299 } 6300 6301 items.push_back(ItemPair(item_id,item_count)); 6302 6303 if(items.size() > MAX_MAIL_ITEMS) 6304 { 6305 PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS); 6306 SetSentErrorMessage(true); 6307 return false; 6308 } 6309 } 6310 6311 if(!normalizePlayerName(name)) 6312 { 6313 SendSysMessage(LANG_PLAYER_NOT_FOUND); 6314 SetSentErrorMessage(true); 6315 return false; 6316 } 6317 6318 uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name); 6319 if(!receiver_guid) 6320 { 6321 SendSysMessage(LANG_PLAYER_NOT_FOUND); 6322 SetSentErrorMessage(true); 6323 return false; 6324 } 6325 6326 // from console show not existed sender 6327 uint32 sender_guidlo = m_session ? m_session->GetPlayer()->GetGUIDLow() : 0; 6328 6329 uint32 messagetype = MAIL_NORMAL; 6330 uint32 stationery = MAIL_STATIONERY_GM; 6331 uint32 itemTextId = !text.empty() ? objmgr.CreateItemText( text ) : 0; 6332 6333 Player *receiver = objmgr.GetPlayer(receiver_guid); 6334 6335 // fill mail 6336 MailItemsInfo mi; // item list preparing 6337 6338 for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) 6339 { 6340 if(Item* item = Item::CreateItem(itr->first,itr->second,m_session ? m_session->GetPlayer() : 0)) 6341 { 6342 item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted 6343 mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); 6344 } 6345 } 6346 6347 WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_NONE); 6348 6349 PSendSysMessage(LANG_MAIL_SENT, name.c_str()); 6350 return true; 6351 } 6352 6353 ///Send money by mail 6354 bool ChatHandler::HandleSendMoneyCommand(const char* args) 6355 { 6356 if (!*args) 6357 return false; 6358 6359 /// format: name "subject text" "mail text" money 6360 6361 char* pName = strtok((char*)args, " "); 6362 if (!pName) 6363 return false; 6364 6365 char* tail1 = strtok(NULL, ""); 6366 if (!tail1) 6367 return false; 6368 6369 char* msgSubject; 6370 if (*tail1=='"') 6371 msgSubject = strtok(tail1+1, "\""); 6372 else 6373 { 6374 char* space = strtok(tail1, "\""); 6375 if (!space) 6376 return false; 6377 msgSubject = strtok(NULL, "\""); 6378 } 6379 6380 if (!msgSubject) 6381 return false; 6382 6383 char* tail2 = strtok(NULL, ""); 6384 if (!tail2) 6385 return false; 6386 6387 char* msgText; 6388 if (*tail2=='"') 6389 msgText = strtok(tail2+1, "\""); 6390 else 6391 { 6392 char* space = strtok(tail2, "\""); 6393 if (!space) 6394 return false; 6395 msgText = strtok(NULL, "\""); 6396 } 6397 6398 if (!msgText) 6399 return false; 6400 6401 char* money_str = strtok(NULL, ""); 6402 int32 money = money_str ? atoi(money_str) : 0; 6403 if (money <= 0) 6404 return false; 6405 6406 // pName, msgSubject, msgText isn't NUL after prev. check 6407 std::string name = pName; 6408 std::string subject = msgSubject; 6409 std::string text = msgText; 6410 6411 if (!normalizePlayerName(name)) 6412 { 6413 SendSysMessage(LANG_PLAYER_NOT_FOUND); 6414 SetSentErrorMessage(true); 6415 return false; 6416 } 6417 6418 uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name); 6419 if (!receiver_guid) 6420 { 6421 SendSysMessage(LANG_PLAYER_NOT_FOUND); 6422 SetSentErrorMessage(true); 6423 return false; 6424 } 6425 6426 uint32 mailId = objmgr.GenerateMailID(); 6427 6428 // from console show not existed sender 6429 uint32 sender_guidlo = m_session ? m_session->GetPlayer()->GetGUIDLow() : 0; 6430 6431 uint32 messagetype = MAIL_NORMAL; 6432 uint32 stationery = MAIL_STATIONERY_GM; 6433 uint32 itemTextId = !text.empty() ? objmgr.CreateItemText( text ) : 0; 6434 6435 Player *receiver = objmgr.GetPlayer(receiver_guid); 6436 6437 WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, money, 0, MAIL_CHECK_MASK_NONE); 6438 6439 PSendSysMessage(LANG_MAIL_SENT, name.c_str()); 6440 return true; 6441 } 6442 6204 6443 /// Send a message to a player in game 6205 6444 bool ChatHandler::HandleSendMessageCommand(const char* args) -
trunk/src/game/MiscHandler.cpp
r230 r232 500 500 501 501 WorldSession * session = sWorld.FindSession(accountId); 502 if(!session )502 if(!session || !session->GetPlayer()) 503 503 return; 504 504 … … 583 583 584 584 WorldSession * session = sWorld.FindSession(accountId); 585 if(!session )585 if(!session || !session->GetPlayer()) 586 586 return; 587 587 -
trunk/src/game/Unit.cpp
r231 r232 7333 7333 AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); 7334 7334 for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) 7335 if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto))7335 if((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto)) 7336 7336 TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; 7337 7337 … … 8233 8233 AuraList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN); 8234 8234 for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) 8235 if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)8235 if((*i)->GetModifier()->m_miscvalue & GetMeleeDamageSchoolMask()) 8236 8236 TakenFlatBenefit += (*i)->GetModifier()->m_amount; 8237 8237 … … 8257 8257 AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); 8258 8258 for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) 8259 if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)8259 if((*i)->GetModifier()->m_miscvalue & GetMeleeDamageSchoolMask()) 8260 8260 TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; 8261 8261 -
trunk/src/game/WorldSocket.cpp
r229 r232 463 463 if (m_Header.space () > 0) 464 464 { 465 //need to rec ieve the header465 //need to receive the header 466 466 const size_t to_header = (message_block.length () > m_Header.space () ? m_Header.space () : message_block.length ()); 467 467 m_Header.copy (message_block.rd_ptr (), to_header); … … 470 470 if (m_Header.space () > 0) 471 471 { 472 // couldn't recieve the whole header this time472 // Couldn't receive the whole header this time 473 473 ACE_ASSERT (message_block.length () == 0); 474 474 errno = EWOULDBLOCK; … … 476 476 } 477 477 478 // we just recieved nice new header478 // We just received nice new header 479 479 if (handle_input_header () == -1) 480 480 { … … 485 485 486 486 // Its possible on some error situations that this happens 487 // for example on closing when epoll rec ieves more chunked data and stuff487 // for example on closing when epoll receives more chunked data and stuff 488 488 // hope this is not hack ,as proper m_RecvWPct is asserted around 489 489 if (!m_RecvWPct) 490 490 { 491 sLog.outError ("For sing close on input m_RecvWPct = NULL");491 sLog.outError ("Forcing close on input m_RecvWPct = NULL"); 492 492 errno = EINVAL; 493 493 return -1; 494 494 } 495 495 496 // We have full read edheader, now check the data payload496 // We have full read header, now check the data payload 497 497 if (m_RecvPct.space () > 0) 498 498 { … … 504 504 if (m_RecvPct.space () > 0) 505 505 { 506 //couldn't rec ieve the whole data this time506 //couldn't receive the whole data this time 507 507 ACE_ASSERT (message_block.length () == 0); 508 508 errno = EWOULDBLOCK; … … 511 511 } 512 512 513 //just rec ieved fresh new payload513 //just received fresh new payload 514 514 if (handle_input_payload () == -1) 515 515 { … … 573 573 return -1; 574 574 575 // dump recieved packet575 // Dump received packet 576 576 if (sWorldLog.LogWorld ()) 577 577 { … … 638 638 int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) 639 639 { 640 // NOTE: ATM the socket is singlethread ed, have this in mind ...640 // NOTE: ATM the socket is singlethread, have this in mind ... 641 641 uint8 digest[20]; 642 642 uint32 clientSeed; … … 930 930 { 931 931 sLog.outError ("WorldSocket::HandlePing: Player kicked for " 932 "over speeded pings adress = %s",932 "over-speed pings address = %s", 933 933 GetRemoteAddress ().c_str ()); 934 934 … … 951 951 sLog.outError ("WorldSocket::HandlePing: peer sent CMSG_PING, " 952 952 "but is not authenticated or got recently kicked," 953 " ad ress = %s",953 " address = %s", 954 954 GetRemoteAddress ().c_str ()); 955 955 return -1; -
trunk/src/game/WorldSocket.h
r181 r232 56 56 * WorldSocket. 57 57 * 58 * This class is responsible for the com unication with58 * This class is responsible for the communication with 59 59 * remote clients. 60 60 * Most methods return -1 on failure. 61 * The class uses ref ferece counting.61 * The class uses reference counting. 62 62 * 63 63 * For output the class uses one buffer (64K usually) and 64 64 * a queue where it stores packet if there is no place on 65 65 * the queue. The reason this is done, is because the server 66 * does real y a lot of small-size writes to it, and it doesn't66 * does really a lot of small-size writes to it, and it doesn't 67 67 * scale well to allocate memory for every. When something is 68 * writ en to the output buffer the socket is not immideately68 * written to the output buffer the socket is not immediately 69 69 * activated for output (again for the same reason), there 70 70 * is 10ms celling (thats why there is Update() method). 71 * This concept is sim milar to TCP_CORK, but TCP_CORK72 * us ses 200ms celling. As result overhead generated by71 * This concept is similar to TCP_CORK, but TCP_CORK 72 * uses 200ms celling. As result overhead generated by 73 73 * sending packets from "producer" threads is minimal, 74 * and doing a lot of writes with small size is tol lerated.75 * 76 * The calls to Up ate () method are managed by WorldSocketMgr74 * and doing a lot of writes with small size is tolerated. 75 * 76 * The calls to Update () method are managed by WorldSocketMgr 77 77 * and ReactorRunnable. 78 78 * 79 79 * For input ,the class uses one 1024 bytes buffer on stack 80 * to which it does recv() calls. And then rec ieved data is81 * distributed where its needed. 1024 matches pr itey well the80 * to which it does recv() calls. And then received data is 81 * distributed where its needed. 1024 matches pretty well the 82 82 * traffic generated by client for now. 83 83 * 84 84 * The input/output do speculative reads/writes (AKA it tryes 85 * to read all data avai ble in the kernel buffer or tryes to86 * write everything avai ble in userspace buffer),87 * which is ok for using with Level and Edge Trig ered IO85 * to read all data available in the kernel buffer or tryes to 86 * write everything available in userspace buffer), 87 * which is ok for using with Level and Edge Triggered IO 88 88 * notification. 89 89 * … … 100 100 typedef ACE_Acceptor< WorldSocket, ACE_SOCK_ACCEPTOR > Acceptor; 101 101 102 /// Mutex type used for various sync ronizations.102 /// Mutex type used for various synchronizations. 103 103 typedef ACE_Thread_Mutex LockType; 104 104 typedef ACE_Guard<LockType> GuardType; … … 121 121 int SendPacket (const WorldPacket& pct); 122 122 123 /// Add ref ference to this object.123 /// Add reference to this object. 124 124 long AddReference (void); 125 125 126 /// Remove ref ference to this object.126 /// Remove reference to this object. 127 127 long RemoveReference (void); 128 128 … … 186 186 ACE_Time_Value m_LastPingTime; 187 187 188 /// Keep track of over speed pings ,to prevent ping flood.188 /// Keep track of over-speed pings ,to prevent ping flood. 189 189 uint32 m_OverSpeedPings; 190 190 … … 198 198 LockType m_SessionLock; 199 199 200 /// Session to which rec ieved packets are routed200 /// Session to which received packets are routed 201 201 WorldSession* m_Session; 202 202 203 /// here are stored the fragmen s of the recieved data203 /// here are stored the fragments of the received data 204 204 WorldPacket* m_RecvWPct; 205 205 206 206 /// This block actually refers to m_RecvWPct contents, 207 /// which al ows easy and safe writing to it.207 /// which allows easy and safe writing to it. 208 208 /// It wont free memory when its deleted. m_RecvWPct takes care of freeing. 209 209 ACE_Message_Block m_RecvPct; 210 210 211 /// Fragment of the rec ieved header.211 /// Fragment of the received header. 212 212 ACE_Message_Block m_Header; 213 213 214 /// Mutex for protecting o tuput related data.214 /// Mutex for protecting output related data. 215 215 LockType m_OutBufferLock; 216 216 … … 222 222 223 223 /// Here are stored packets for which there was no space on m_OutBuffer, 224 /// this al ows not-to kick player if its buffer is overflowed.224 /// this allows not-to kick player if its buffer is overflowed. 225 225 PacketQueueT m_PacketQueue; 226 226