client.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. 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. 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. private:
  72. string pending_play_char_name;
  73. int32 pending_play_char_id;
  74. int8 update_position;
  75. int16 num_updates;
  76. vector<PacketStruct*>* update_packets;
  77. LoginAccount* login_account;
  78. EQStream* eqnc;
  79. int32 ip;
  80. int16 port;
  81. int32 account_id;
  82. string account_name;
  83. char key[10];
  84. int8 lsadmin;
  85. sint16 worldadmin;
  86. int lsstatus;
  87. bool kicked;
  88. bool verified;
  89. bool start;
  90. bool needs_world_list;
  91. int16 version;
  92. char bannedreason[30];
  93. eLoginMode LoginMode;
  94. PacketStruct* createRequest;
  95. Timer* playWaitTimer;
  96. };
  97. class ClientList
  98. {
  99. public:
  100. ClientList() {}
  101. ~ClientList() {}
  102. void Add(Client* client);
  103. Client* Get(int32 ip, int16 port);
  104. Client* FindByLSID(int32 lsaccountid);
  105. void FindByCreateRequest();
  106. void SendPacketToAllClients(EQ2Packet* app);
  107. void Process();
  108. private:
  109. Mutex MClientList;
  110. map<Client*, bool> client_list;
  111. };
  112. class DelayQue {
  113. public:
  114. DelayQue(Timer* in_timer, EQApplicationPacket* in_packet){
  115. timer = in_timer;
  116. packet = in_packet;
  117. };
  118. Timer* timer;
  119. EQApplicationPacket* packet;
  120. };
  121. #endif