Client.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 run();
  19. void disconnect();
  20. void say(const QString& msg);
  21. void sayTeam(const QString& msg);
  22. void setTeam(const QString& msg);
  23. void setSocket(class QTcpSocket* socket);
  24. void retryConnection(); //unused
  25. bool isOnServer() const;
  26. bool isQWMuted() const;
  27. bool isSpamMuted() const;
  28. void setPlayerList(PlayerList &playerList);
  29. protected:
  30. 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);
  31. void onDisconnect();
  32. void onPrint(int level, const char *msg);
  33. void onChallenge();
  34. void onConnection();
  35. void onConnected();
  36. void onDownloadStarted(const char *fileName);
  37. void onDownloadFinished();
  38. void onDownloadProgress(int percent);
  39. void onStuffedCmd(const char *cmd);
  40. void onError(const char *description);
  41. void onOOBPrint(const char *msg);
  42. private:
  43. ActiveClient* myActiveClient;
  44. App* myApp;
  45. QTime myEndFloodTime;
  46. bool myFloodMsgPrinted;
  47. int myConnectionRetries;
  48. static const int ConnectionRetries = 10;
  49. QString myPrintLine;
  50. bool myDownloadProgressPrintedFlag;
  51. bool myOnServerFlag;
  52. bool mySpamMutedFlag;
  53. bool myQWMutedFlag;
  54. QTimer* myJoinMessageTimer;
  55. QTime myQWBroadcastFloodTime;
  56. QTime mySpamBroadcastFloodTime;
  57. bool myJoinMessagePrinted;
  58. PlayerList myPlayerList;
  59. void print(const QString& msg);
  60. void parsePrintedLine();
  61. static QString parseNameFun(const QString& string);
  62. };
  63. #endif // CLIENT_H