Client.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef CLIENT_H
  2. #define CLIENT_H
  3. #include "QWClient.h"
  4. #include <QString>
  5. #include <QStringList>
  6. #include <QList>
  7. #include <QTime>
  8. #include "ServerQuery.h"
  9. class App;
  10. class QTime;
  11. class QTimer;
  12. class ActiveClient;
  13. class Client : public QWClient
  14. {
  15. public:
  16. Client(App* app, ActiveClient* ac);
  17. ~Client();
  18. void connect(const char *host, quint16 port);
  19. void run();
  20. void disconnect();
  21. void say(const QString& msg);
  22. void sayTeam(const QString& msg);
  23. void setTeam(const QString& msg);
  24. void setSocket(class QTcpSocket* socket);
  25. void retryConnection(); //unused
  26. bool isOnServer() const;
  27. bool isQWMuted() const;
  28. bool isSpamMuted() const;
  29. void setPlayerList(PlayerList &playerList);
  30. void setMaxClients(int maxClients);
  31. protected:
  32. void onLevelChanged(int playerNum, const char *levelName, float gravity, float stopSpeed, float maxSpeed, float spectatorMaxSpeed, float accelerate, float airAccelerate, float waterAccelerate, float friction, float waterFriction, float entGravity);
  33. void onDisconnect();
  34. void onPrint(int level, const char *msg);
  35. void onChallenge();
  36. void onConnection();
  37. void onConnected();
  38. void onDownloadStarted(const char *fileName);
  39. void onDownloadFinished();
  40. void onDownloadProgress(int percent);
  41. void onStuffedCmd(const char *cmd);
  42. void onError(const char *description);
  43. void onOOBPrint(const char *msg);
  44. private:
  45. ActiveClient* myActiveClient;
  46. App* myApp;
  47. QTime myEndFloodTime;
  48. bool myFloodMsgPrinted;
  49. int myConnectionRetries;
  50. static const int ConnectionRetries = 10;
  51. QString myPrintLine;
  52. bool myDownloadProgressPrintedFlag;
  53. bool myOnServerFlag;
  54. bool mySpamMutedFlag;
  55. bool myQWMutedFlag;
  56. QTimer* myJoinMessageTimer;
  57. QTimer* myKeepNickTimer;
  58. QTime myQWBroadcastFloodTime;
  59. QTime mySpamBroadcastFloodTime;
  60. bool myJoinMessagePrinted;
  61. bool myJoinMessageScheduled;
  62. PlayerList myPlayerList;
  63. int myMaxClients;
  64. void print(const QString& msg);
  65. void parsePrintedLine();
  66. int playerCount() const;
  67. int maxClients() const;
  68. static QString parseNameFun(const QString& string);
  69. };
  70. #endif // CLIENT_H