Client.h 858 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include "../global.h"
  3. #include <boost/thread.hpp>
  4. struct StartInfo;
  5. class CGameState;
  6. class CGameInterface;
  7. class CConnection;
  8. class CCallback;
  9. namespace boost
  10. {
  11. class mutex;
  12. class condition_variable;
  13. }
  14. template <typename T>
  15. struct CSharedCond
  16. {
  17. boost::mutex *mx;
  18. boost::condition_variable *cv;
  19. T *res;
  20. CSharedCond(T*R)
  21. {
  22. res = R;
  23. mx = new boost::mutex;
  24. cv = new boost::condition_variable;
  25. }
  26. ~CSharedCond()
  27. {
  28. delete res;
  29. delete mx;
  30. delete cv;
  31. }
  32. };
  33. class CClient
  34. {
  35. CGameState *gs;
  36. std::map<ui8,CGameInterface *> playerint;
  37. CConnection *serv;
  38. void waitForMoveAndSend(int color);
  39. public:
  40. CClient(void);
  41. CClient(CConnection *con, StartInfo *si);
  42. ~CClient(void);
  43. void process(int what);
  44. void run();
  45. friend class CCallback;
  46. friend class CScriptCallback;
  47. };