client.h 3.3 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);
  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. int16 GetOrigVersion(){ return origversion; }
  45. char* GetKey() { return key; }
  46. void SetKey(char* in_key) { strcpy(key,in_key); }
  47. int32 GetIP() { return ip; }
  48. int16 GetPort() { return port; }
  49. int32 GetAccountID() { return account_id; }
  50. char* GetAccountName(){ return (char*)account_name.c_str(); }
  51. void SetAccountName(const char* name){ account_name = string(name); }
  52. void ProcessLogin(char* name, char* pass,int seq=0);
  53. void QueuePacket(EQ2Packet* app);
  54. void FatalError(int8 response);
  55. void WorldResponse(int32 worldid, int8 response, char* ip_address, int32 port, int32 access_key);
  56. bool AwaitingCharCreationRequest(){
  57. if(createRequest)
  58. return true;
  59. else
  60. return false;
  61. }
  62. Timer* updatetimer;
  63. Timer* updatelisttimer;
  64. Timer* disconnectTimer;
  65. //Timer* keepalive;
  66. //Timer* logintimer;
  67. int16 packettotal;
  68. int32 requested_server_id;
  69. int32 request_num;
  70. LinkedList<DelayQue*> delay_que;
  71. void SendPlayFailed(int8 response);
  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. int16 origversion;
  94. char bannedreason[30];
  95. eLoginMode LoginMode;
  96. PacketStruct* createRequest;
  97. Timer* playWaitTimer;
  98. };
  99. class ClientList
  100. {
  101. public:
  102. ClientList() {}
  103. ~ClientList() {}
  104. void Add(Client* client);
  105. Client* Get(int32 ip, int16 port);
  106. Client* FindByLSID(int32 lsaccountid);
  107. void FindByCreateRequest();
  108. void SendPacketToAllClients(EQ2Packet* app);
  109. void Process();
  110. private:
  111. Mutex MClientList;
  112. map<Client*, bool> client_list;
  113. };
  114. class DelayQue {
  115. public:
  116. DelayQue(Timer* in_timer, EQApplicationPacket* in_packet){
  117. timer = in_timer;
  118. packet = in_packet;
  119. };
  120. Timer* timer;
  121. EQApplicationPacket* packet;
  122. };
  123. #endif