Languages.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 <assert.h>
  17. #include <string.h>
  18. #include "Languages.h"
  19. Language::Language(){
  20. id = 0;
  21. memset(name, 0, sizeof(name));
  22. save_needed = false;
  23. }
  24. Language::Language(Language* language){
  25. id = language->id;
  26. strncpy(name, language->GetName(), sizeof(name));
  27. save_needed = language->save_needed;
  28. }
  29. MasterLanguagesList::MasterLanguagesList(){
  30. }
  31. MasterLanguagesList::~MasterLanguagesList(){
  32. Clear();
  33. }
  34. void MasterLanguagesList::Clear(){
  35. languages_list.clear();
  36. }
  37. int32 MasterLanguagesList::Size(){
  38. return languages_list.size();
  39. }
  40. void MasterLanguagesList::AddLanguage(Language* language){
  41. assert(language);
  42. languages_list.push_back(language);
  43. }
  44. Language* MasterLanguagesList::GetLanguage(int32 id){
  45. list<Language*>::iterator itr;
  46. Language* language = 0;
  47. Language* ret = 0;
  48. for(itr = languages_list.begin(); itr != languages_list.end(); itr++){
  49. language = *itr;
  50. if(language->GetID() == id){
  51. ret = language;
  52. break;
  53. }
  54. }
  55. return ret;
  56. }
  57. Language* MasterLanguagesList::GetLanguageByName(const char* name){
  58. list<Language*>::iterator itr;
  59. Language* language = 0;
  60. Language* ret = 0;
  61. for(itr = languages_list.begin(); itr != languages_list.end(); itr++){
  62. language = *itr;
  63. if(!language)
  64. continue;
  65. if(!strncmp(language->GetName(), name, strlen(name))){
  66. ret = language;
  67. break;
  68. }
  69. }
  70. return ret;
  71. }
  72. list<Language*>* MasterLanguagesList::GetAllLanguages(){
  73. return &languages_list;
  74. }
  75. PlayerLanguagesList::PlayerLanguagesList(){
  76. }
  77. PlayerLanguagesList::~PlayerLanguagesList(){
  78. }
  79. void PlayerLanguagesList::Add(Language* language){
  80. player_languages_list.push_back(language);
  81. }
  82. Language* PlayerLanguagesList::GetLanguage(int32 id){
  83. list<Language*>::iterator itr;
  84. Language* language = 0;
  85. Language* ret = 0;
  86. for(itr = player_languages_list.begin(); itr != player_languages_list.end(); itr++){
  87. language = *itr;
  88. if(language->GetID() == id){
  89. ret = language;
  90. break;
  91. }
  92. }
  93. return ret;
  94. }
  95. Language* PlayerLanguagesList::GetLanguageByName(const char* name){
  96. list<Language*>::iterator itr;
  97. Language* language = 0;
  98. Language* ret = 0;
  99. for(itr = player_languages_list.begin(); itr != player_languages_list.end(); itr++){
  100. language = *itr;
  101. if(!language)
  102. continue;
  103. if(!strncmp(language->GetName(), name, strlen(name))){
  104. ret = language;
  105. break;
  106. }
  107. }
  108. return ret;
  109. }
  110. list<Language*>* PlayerLanguagesList::GetAllLanguages(){
  111. return &player_languages_list;
  112. }