LoginAccount.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. */
  6. #include "LoginAccount.h"
  7. LoginAccount::LoginAccount(){
  8. }
  9. LoginAccount::~LoginAccount(){
  10. vector<CharSelectProfile*>::iterator iter;
  11. for(iter = charlist.begin(); iter != charlist.end(); iter++){
  12. safe_delete(*iter);
  13. }
  14. }
  15. void LoginAccount::flushCharacters ( )
  16. {
  17. vector<CharSelectProfile*>::iterator iter;
  18. for(iter = charlist.begin(); iter != charlist.end(); iter++){
  19. safe_delete(*iter);
  20. }
  21. charlist.clear ( );
  22. }
  23. CharSelectProfile* LoginAccount::getCharacter(char* name){
  24. vector<CharSelectProfile*>::iterator char_iterator;
  25. CharSelectProfile* profile = 0;
  26. EQ2_16BitString temp;
  27. for(char_iterator = charlist.begin(); char_iterator != charlist.end(); char_iterator++){
  28. profile = *char_iterator;
  29. temp = profile->packet->getType_EQ2_16BitString_ByName("name");
  30. if(strcmp(temp.data.c_str(), name)==0)
  31. return profile;
  32. }
  33. return 0;
  34. }
  35. void LoginAccount::removeCharacter(char* name, int16 version){
  36. vector<CharSelectProfile*>::iterator iter;
  37. CharSelectProfile* profile = 0;
  38. EQ2_16BitString temp;
  39. for(iter = charlist.begin(); iter != charlist.end(); iter++){
  40. profile = *iter;
  41. temp = profile->packet->getType_EQ2_16BitString_ByName("name");
  42. if(strcmp(temp.data.c_str(), name)==0){
  43. if(version <= 561) {
  44. profile->deleted = true; // workaround for char select crash on old clients
  45. }
  46. else {
  47. safe_delete(*iter);
  48. charlist.erase(iter);
  49. }
  50. return;
  51. }
  52. }
  53. }