Client.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. QTime myQWBroadcastFloodTime;
  57. QTime mySpamBroadcastFloodTime;
  58. bool myJoinMessagePrinted;
  59. bool myJoinMessageScheduled;
  60. PlayerList myPlayerList;
  61. void print(const QString& msg);
  62. void parsePrintedLine();
  63. static QString parseNameFun(const QString& string);
  64. };
  65. #endif // CLIENT_H