9
3

client.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. #ifndef CLIENT_H
  7. #define CLIENT_H
  8. #include "../common/linked_list.h"
  9. #include "../common/timer.h"
  10. #include "../common/TCPConnection.h"
  11. #include "login_structs.h"
  12. #include "LoginAccount.h"
  13. #include "../common/PacketStruct.h"
  14. #include <string>
  15. #include <vector>
  16. enum eLoginMode { None, Normal, Registration };
  17. class DelayQue;
  18. class Client
  19. {
  20. public:
  21. Client(EQStream* ieqnc);
  22. ~Client();
  23. void SendLoginDenied();
  24. void SendLoginDeniedBadVersion();
  25. void SendLoginAccepted();
  26. void SendWorldList();
  27. void SendCharList();
  28. int16 AddWorldToList2(uchar* buffer, char* name, int32 id, int16* flags);
  29. void GenerateChecksum(EQApplicationPacket* outapp);
  30. int8 LoginKey[10];
  31. int8 ClientSession[25];
  32. bool Process();
  33. void SaveErrorsToDB(EQApplicationPacket* app, char* type, int32 version);
  34. void CharacterApproved(int32 server_id,int32 char_id);
  35. void CharacterRejected(int8 reason_number);
  36. EQStream* getConnection() { return eqnc; }
  37. LoginAccount* GetLoginAccount() { return login_account; }
  38. void SetLoginAccount(LoginAccount* in_account) {
  39. login_account = in_account;
  40. if(in_account)
  41. account_id = in_account->getLoginAccountID();
  42. }
  43. int16 GetVersion(){ return version; }
  44. char* GetKey() { return key; }
  45. void SetKey(char* in_key) { strcpy(key,in_key); }
  46. int32 GetIP() { return ip; }
  47. int16 GetPort() { return port; }
  48. int32 GetAccountID() { return account_id; }
  49. const char* GetAccountName(){ return (char*)account_name.c_str(); }
  50. void SetAccountName(const char* name){ account_name = string(name); }
  51. void ProcessLogin(char* name, char* pass,int seq=0);
  52. void QueuePacket(EQ2Packet* app);
  53. void FatalError(int8 response);
  54. void WorldResponse(int32 worldid, int8 response, char* ip_address, int32 port, int32 access_key);
  55. bool AwaitingCharCreationRequest(){
  56. if(createRequest)
  57. return true;
  58. else
  59. return false;
  60. }
  61. Timer* updatetimer;
  62. Timer* updatelisttimer;
  63. Timer* disconnectTimer;
  64. //Timer* keepalive;
  65. //Timer* logintimer;
  66. int16 packettotal;
  67. int32 requested_server_id;
  68. int32 request_num;
  69. LinkedList<DelayQue*> delay_que;
  70. void SendPlayFailed(int8 response);
  71. void StartDisconnectTimer();
  72. private:
  73. string pending_play_char_name;
  74. int32 pending_play_char_id;
  75. int8 update_position;
  76. int16 num_updates;
  77. vector<PacketStruct*>* update_packets;
  78. LoginAccount* login_account;
  79. EQStream* eqnc;
  80. int32 ip;
  81. int16 port;
  82. int32 account_id;
  83. string account_name;
  84. char key[10];
  85. int8 lsadmin;
  86. sint16 worldadmin;
  87. int lsstatus;
  88. bool kicked;
  89. bool verified;
  90. bool start;
  91. bool needs_world_list;
  92. int16 version;
  93. char bannedreason[30];
  94. eLoginMode LoginMode;
  95. PacketStruct* createRequest;
  96. Timer* playWaitTimer;
  97. };
  98. class ClientList
  99. {
  100. public:
  101. ClientList() {}
  102. ~ClientList() {}
  103. void Add(Client* client);
  104. Client* Get(int32 ip, int16 port);
  105. Client* FindByLSID(int32 lsaccountid);
  106. void FindByCreateRequest();
  107. void SendPacketToAllClients(EQ2Packet* app);
  108. void Process();
  109. private:
  110. Mutex MClientList;
  111. map<Client*, bool> client_list;
  112. };
  113. class DelayQue {
  114. public:
  115. DelayQue(Timer* in_timer, EQApplicationPacket* in_packet){
  116. timer = in_timer;
  117. packet = in_packet;
  118. };
  119. Timer* timer;
  120. EQApplicationPacket* packet;
  121. };
  122. #endif