RaceTypes.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #include "RaceTypes.h"
  17. #include <string.h>
  18. MasterRaceTypeList::MasterRaceTypeList() {
  19. }
  20. MasterRaceTypeList::~MasterRaceTypeList() {
  21. }
  22. bool MasterRaceTypeList::AddRaceType(int16 model_id, int16 race_type_id, const char* category, const char* subcategory, const char* modelname, bool allow_override) {
  23. if (m_raceList.count(model_id) == 0 || allow_override) {
  24. RaceTypeStructure rts;
  25. m_raceList[model_id].race_type_id = race_type_id;
  26. if(category != NULL) {
  27. strncpy(m_raceList[model_id].category, category, 64);
  28. } else {
  29. strcpy(m_raceList[model_id].category,"");
  30. }
  31. if(subcategory != NULL) {
  32. strncpy(m_raceList[model_id].subcategory, subcategory, 64);
  33. } else {
  34. strcpy(m_raceList[model_id].subcategory,"");
  35. }
  36. if(modelname != NULL) {
  37. strncpy(m_raceList[model_id].modelname, modelname, 64);
  38. } else {
  39. strcpy(m_raceList[model_id].modelname,"");
  40. }
  41. return true;
  42. }
  43. return false;
  44. }
  45. int16 MasterRaceTypeList::GetRaceType(int16 model_id) {
  46. int16 ret = 0;
  47. if (m_raceList.count(model_id) > 0)
  48. ret = m_raceList[model_id].race_type_id;
  49. return ret;
  50. }
  51. char* MasterRaceTypeList::GetRaceTypeCategory(int16 model_id) {
  52. if(m_raceList.count(model_id) > 0 && strlen(m_raceList[model_id].category) > 0)
  53. return m_raceList[model_id].category;
  54. return "";
  55. }
  56. char* MasterRaceTypeList::GetRaceTypeSubCategory(int16 model_id) {
  57. if(m_raceList.count(model_id) > 0 && strlen(m_raceList[model_id].subcategory) > 0)
  58. return m_raceList[model_id].subcategory;
  59. return "";
  60. }
  61. char* MasterRaceTypeList::GetRaceTypeModelName(int16 model_id) {
  62. if(m_raceList.count(model_id) > 0 && strlen(m_raceList[model_id].modelname) > 0)
  63. return m_raceList[model_id].modelname;
  64. return "";
  65. }
  66. int16 MasterRaceTypeList::GetRaceBaseType(int16 model_id) {
  67. int16 ret = 0;
  68. if (m_raceList.count(model_id) == 0)
  69. return ret;
  70. int16 race = m_raceList[model_id].race_type_id;
  71. if (race >= DRAGONKIND && race < FAY)
  72. ret = DRAGONKIND;
  73. else if (race >= FAY && race < MAGICAL)
  74. ret = FAY;
  75. else if (race >= MAGICAL && race < MECHANIMAGICAL)
  76. ret = MAGICAL;
  77. else if (race >= MECHANIMAGICAL && race < NATURAL)
  78. ret = MECHANIMAGICAL;
  79. else if (race >= NATURAL && race < PLANAR)
  80. ret = NATURAL;
  81. else if (race >= PLANAR && race < PLANT)
  82. ret = PLANAR;
  83. else if (race >= PLANT && race < SENTIENT)
  84. ret = PLANT;
  85. else if (race >= SENTIENT && race < UNDEAD)
  86. ret = SENTIENT;
  87. else if (race >= UNDEAD && race < WERE)
  88. ret = UNDEAD;
  89. else if (race >= WERE)
  90. ret = WERE;
  91. return ret;
  92. }