Client.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. protected:
  31. 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);
  32. void onDisconnect();
  33. void onPrint(int level, const char *msg);
  34. void onChallenge();
  35. void onConnection();
  36. void onConnected();
  37. void onDownloadStarted(const char *fileName);
  38. void onDownloadFinished();
  39. void onDownloadProgress(int percent);
  40. void onStuffedCmd(const char *cmd);
  41. void onError(const char *description);
  42. void onOOBPrint(const char *msg);
  43. private:
  44. ActiveClient* myActiveClient;
  45. App* myApp;
  46. QTime myEndFloodTime;
  47. bool myFloodMsgPrinted;
  48. int myConnectionRetries;
  49. static const int ConnectionRetries = 10;
  50. QString myPrintLine;
  51. bool myDownloadProgressPrintedFlag;
  52. bool myOnServerFlag;
  53. bool mySpamMutedFlag;
  54. bool myQWMutedFlag;
  55. QTimer* myJoinMessageTimer;
  56. QTimer* myKeepNickTimer;
  57. QTime myQWBroadcastFloodTime;
  58. QTime mySpamBroadcastFloodTime;
  59. bool myJoinMessagePrinted;
  60. bool myJoinMessageScheduled;
  61. PlayerList myPlayerList;
  62. void print(const QString& msg);
  63. void parsePrintedLine();
  64. static QString parseNameFun(const QString& string);
  65. };
  66. #endif // CLIENT_H