diff --git a/src/net/clientthread.h b/src/net/clientthread.h index 6a6d8645..1a972bfd 100644 --- a/src/net/clientthread.h +++ b/src/net/clientthread.h @@ -27,11 +27,12 @@ class ClientData; class ClientState; +class GuiInterface; class ClientThread : public Thread { public: - ClientThread(); + ClientThread(GuiInterface &gui); virtual ~ClientThread(); // Set the parameters. Does not do any error checking. @@ -47,13 +48,15 @@ protected: const ClientData &GetData() const; ClientData &GetData(); + ClientState &GetState(); void SetState(ClientState &newState); private: std::auto_ptr m_data; - ClientState *m_curState; + GuiInterface &m_gui; + friend class ClientStateInit; friend class ClientStateResolve; diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index ebe9ec12..e8ade884 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -26,8 +26,8 @@ using namespace std; -ClientThread::ClientThread() -: m_curState(NULL) +ClientThread::ClientThread(GuiInterface &gui) +: m_curState(NULL), m_gui(gui) { m_data.reset(new ClientData); m_curState = &CLIENT_INITIAL_STATE::Instance(); @@ -53,6 +53,7 @@ ClientThread::Main() { while (!ShouldTerminate()) { + GetState().Process(*this, m_gui); } } @@ -70,6 +71,13 @@ ClientThread::GetData() return *m_data; } +ClientState & +ClientThread::GetState() +{ + assert(m_curState); + return *m_curState; +} + void ClientThread::SetState(ClientState &newState) { diff --git a/src/net/common/socket_helper_cmn.cpp b/src/net/common/socket_helper_cmn.cpp index 0d7bd0ea..3d068e52 100644 --- a/src/net/common/socket_helper_cmn.cpp +++ b/src/net/common/socket_helper_cmn.cpp @@ -29,12 +29,12 @@ socket_set_port(unsigned port, int addrFamily, struct sockaddr *addr, int addrLe if (addr) { - if (addrFamily == AF_INET && addrLen >= sizeof(sockaddr_in)) + if (addrFamily == AF_INET && addrLen >= (int)sizeof(sockaddr_in)) { ((sockaddr_in *)&addr)->sin_port = htons(port); retVal = true; } - else if (addrFamily == AF_INET6 && addrLen >= sizeof(sockaddr_in6)) + else if (addrFamily == AF_INET6 && addrLen >= (int)sizeof(sockaddr_in6)) { ((sockaddr_in6 *)&addr)->sin6_port = htons(port); retVal = true; diff --git a/src/net/genericsocket.h b/src/net/genericsocket.h index 7c4fa2ed..a7eea065 100644 --- a/src/net/genericsocket.h +++ b/src/net/genericsocket.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #endif