Advertisement
Guest User

packet prot - jamey

a guest
Aug 24th, 2013
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #define CHECK_INTERVAL 1000
  3. class Packet_Protection : public WorldScript
  4. {
  5. public:
  6. Packet_Protection() : WorldScript("Packet_Protection") {}
  7.  
  8. void OnStartup()
  9. {
  10. timer = CHECK_INTERVAL;
  11. }
  12.  
  13. void OnUpdate(uint32 diff)
  14. {
  15. if(timer < diff)
  16. {
  17. ResetCounters();
  18. timer = CHECK_INTERVAL;
  19. }
  20. else
  21. timer -= diff;
  22. }
  23.  
  24. void ResetCounters()
  25. {
  26. SessionMap const& sessions = sWorld->GetAllSessions();
  27. for(SessionMap::const_iterator itr = sessions.begin(); itr != sessions.end(); ++itr)
  28. for(int i = 0; i < MAX_PROTECTED_PACKETS; ++i)
  29. itr->second->protectedPacketsCounter[i] = 0;
  30. }
  31.  
  32. private:
  33. uint32 timer;
  34. };
  35.  
  36. void AddSC_Packet_Protection()
  37. {
  38. new Packet_Protection();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement