Titles.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef TITLES_H_
  17. #define TITLES_H_
  18. #include <string>
  19. #include <map>
  20. #include <vector>
  21. #include "../common/Mutex.h"
  22. #include "../common/types.h"
  23. using namespace std;
  24. class Title {
  25. public:
  26. Title();
  27. Title(Title* title);
  28. ~Title();
  29. void SetID(int32 id) {this->id = id;}
  30. void SetName(const char *name) {strncpy(this->name, name, sizeof(this->name));}
  31. void SetPrefix(int8 prefix) {this->prefix = prefix;}
  32. void SetSaveNeeded(bool save_needed) {this->save_needed = save_needed;}
  33. sint32 GetID() {return id;}
  34. const char* GetName() {return name;}
  35. int8 GetPrefix() {return prefix;}
  36. bool GetSaveNeeded() {return save_needed;}
  37. private:
  38. sint32 id;
  39. int8 prefix;
  40. char name[256];
  41. bool save_needed;
  42. };
  43. class MasterTitlesList {
  44. public:
  45. MasterTitlesList();
  46. ~MasterTitlesList();
  47. void Clear();
  48. int32 Size();
  49. void AddTitle(Title* title);
  50. Title* GetTitle(sint32 id);
  51. Title* GetTitleByName(const char* title_name);
  52. private:
  53. map<sint32,Title*> titles_list;
  54. Mutex MMasterTitleMutex;
  55. };
  56. class PlayerTitlesList {
  57. public:
  58. PlayerTitlesList();
  59. ~PlayerTitlesList();
  60. Title* GetTitle(sint32 index);
  61. Title* GetTitleByName(const char* title_name);
  62. vector<Title*>* GetAllTitles();
  63. void Add(Title* title);
  64. int32 Size();
  65. void ReleaseReadLock() { MPlayerTitleMutex.releasereadlock(); }
  66. private:
  67. vector<Title*> player_titles_list;
  68. Mutex MPlayerTitleMutex;
  69. };
  70. #endif