Advertisement
EmuDevs

CharHandler

Sep 4th, 2013
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.99 KB | None | 0 0
  1.  
  2. void WorldSession::HandleCharEnumOpcode(WorldPacket & /*recvData*/)
  3. {
  4.         if(++protectedPacketsCounter[PACKET_CMSG_CHAR_ENUM] >= 3)
  5.         {
  6.                 std::ostringstream ss;
  7.                         if(protectedPacketsCounter[PACKET_CMSG_CHAR_ENUM] < 5 || protectedPacketsCounter[PACKET_CMSG_CHAR_ENUM] % 25 == 0)
  8.                         {
  9.                                 ss << "[Overflood Protection] : Session with ";
  10.                                 ss << "IP address ";
  11.                                 ss << GetRemoteAddress();
  12.                                 ss << " triggered OverFlood Protection for packet CMSG_CHAR_ENUM. info : ";
  13.                                 ss << "Account ID : ";
  14.                                 ss << GetAccountId();
  15.                                 ss << " Account Name : ";
  16.                                 std::string accountName;
  17.                                 sAccountMgr->GetName(GetAccountId(), accountName);
  18.                                 ss << accountName;
  19.                                 ss << " Player Name : ";
  20.                             if(GetPlayer() && GetPlayer()->IsInWorld())
  21.                                     ss << GetPlayer()->GetName();
  22.                             else
  23.                                     ss << " No Name ( not logged in )";
  24.                                 ss << " current packet count : ";
  25.                                 ss << (uint32)protectedPacketsCounter[PACKET_CMSG_CHAR_ENUM];
  26.                                 ss << ", ignoring.";
  27.                                 sLog->outError(LOG_FILTER_GENERAL, ss.str().c_str());
  28.                         }
  29.                 return;
  30.         }
  31.     // remove expired bans
  32.     PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXPIRED_BANS);
  33.     CharacterDatabase.Execute(stmt);
  34.  
  35.     /// get all the data necessary for loading all characters (along with their pets) on the account
  36.  
  37.     if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
  38.         stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ENUM_DECLINED_NAME);
  39.     else
  40.         stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ENUM);
  41.  
  42.     stmt->setUInt8(0, PET_SAVE_AS_CURRENT);
  43.     stmt->setUInt32(1, GetAccountId());
  44.  
  45.     _charEnumCallback = CharacterDatabase.AsyncQuery(stmt);
  46.  
  47.   {
  48.     AntiDOS.AllowOpcode(CMSG_CHAR_ENUM, false);
  49.  
  50.     // remove expired bans
  51.     PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXPIRED_BANS);
  52.     CharacterDatabase.Execute(stmt);
  53.  
  54.     /// get all the data necessary for loading all characters (along with their pets) on the account
  55.  
  56.     if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
  57.         stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ENUM_DECLINED_NAME);
  58.     else
  59.         stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ENUM);
  60.  
  61.     stmt->setUInt8(0, PET_SAVE_AS_CURRENT);
  62.     stmt->setUInt32(1, GetAccountId());
  63.  
  64.     _charEnumCallback = CharacterDatabase.AsyncQuery(stmt);
  65.   }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement