Advertisement
EmuDevs

EmuDevs: TrinityCore - Vote Point System (HEADER FILE)

Sep 1st, 2013
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. /*
  2.  *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
  3.  *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
  4.  *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
  5.  *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
  6.  *            http://emudevs.com
  7. */
  8. class VotePointSystem
  9. {
  10. public:
  11.     VotePointSystem();
  12.     ~VotePointSystem();
  13.  
  14.     bool GetPlayerAccount(uint32 acctId) const { return acctId == accountId; }
  15.     bool LoadFromDB(Field* fields);
  16.     void SaveToDB(SQLTransaction& trans) const;
  17.        
  18.     uint32 Points() const { return votePoints; }
  19.     uint32 GetAccountId() const { return accountId; }
  20. private:
  21.     uint32 accountId;
  22.     uint32 votePoints;
  23. };
  24.  
  25. class VotePointSystemMgr
  26. {
  27.     friend class ACE_Singleton<VotePointSystemMgr, ACE_Null_Mutex>;
  28.  
  29. private:
  30.     VotePointSystemMgr();
  31.     ~VotePointSystemMgr();
  32.    
  33. public:
  34.     void LoadVoteSystem();
  35.  
  36.     typedef std::map<uint32, VotePointSystem*> VotePointList;
  37.  
  38.     VotePointSystem* GetPointsByAccountId(uint32 id)
  39.     {
  40.         for(VotePointList::const_iterator itr = _voteList.begin(); itr != _voteList.end(); ++itr)
  41.             if(itr->second && itr->second->GetPlayerAccount(id))
  42.                 return itr->second;
  43.         return NULL;
  44.     }
  45.  
  46.     void SaveToList(VotePointSystem* voteSystem);
  47. protected:
  48.     VotePointList _voteList;
  49. };
  50. #define sVoteSystemMgr ACE_Singleton<VotePointSystemMgr, ACE_Null_Mutex>::instance()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement