Two step initialization for engine. First step: Create and initialize objects (constructor). Second step: Start the engine, update the UI.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
#include <net/sendercallback.h>
|
||||
#include <net/receiverhelper.h>
|
||||
#include <net/socket_msg.h>
|
||||
#include <gamedata.h>
|
||||
#include <game.h>
|
||||
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class ServerSenderCallback : public SenderCallback
|
||||
{
|
||||
public:
|
||||
@@ -141,7 +142,7 @@ ServerRecvThread::NotificationLoop()
|
||||
switch(notification.message)
|
||||
{
|
||||
case NOTIFY_GAME_START:
|
||||
SetState(SERVER_START_GAME_STATE::Instance());
|
||||
InternalStartGame();
|
||||
break;
|
||||
case NOTIFY_WAIT_FOR_CLIENT_ACTION:
|
||||
break;
|
||||
@@ -243,6 +244,13 @@ ServerRecvThread::CleanupSessionMap()
|
||||
m_sessionMap.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ServerRecvThread::InternalStartGame()
|
||||
{
|
||||
// m_game.reset(...);
|
||||
SetState(SERVER_START_GAME_STATE::Instance());
|
||||
}
|
||||
|
||||
boost::shared_ptr<SessionData>
|
||||
ServerRecvThread::GetSession(SOCKET sock)
|
||||
{
|
||||
@@ -468,6 +476,13 @@ ServerRecvThread::GetReceiver()
|
||||
return *m_receiver;
|
||||
}
|
||||
|
||||
Game &
|
||||
ServerRecvThread::GetGame()
|
||||
{
|
||||
assert(m_game.get());
|
||||
return *m_game;
|
||||
}
|
||||
|
||||
const GameData &
|
||||
ServerRecvThread::GetGameData() const
|
||||
{
|
||||
|
||||
@@ -45,6 +45,7 @@ class ReceiverHelper;
|
||||
class ServerSenderCallback;
|
||||
class NetPacket;
|
||||
struct GameData;
|
||||
class Game;
|
||||
|
||||
class ServerRecvThread : public Thread
|
||||
{
|
||||
@@ -86,6 +87,8 @@ protected:
|
||||
void CleanupConnectQueue();
|
||||
void CleanupSessionMap();
|
||||
|
||||
void InternalStartGame();
|
||||
|
||||
boost::shared_ptr<SessionData> GetSession(SOCKET sock);
|
||||
void AddSession(boost::shared_ptr<SessionData> sessionData);
|
||||
void SessionError(boost::shared_ptr<SessionData> sessionData, int errorCode);
|
||||
@@ -108,6 +111,7 @@ protected:
|
||||
SenderThread &GetSender();
|
||||
ReceiverHelper &GetReceiver();
|
||||
|
||||
Game &GetGame();
|
||||
const GameData &GetGameData() const;
|
||||
bool CheckPassword(const std::string &password) const;
|
||||
|
||||
@@ -130,8 +134,9 @@ private:
|
||||
std::auto_ptr<ReceiverHelper> m_receiver;
|
||||
std::auto_ptr<SenderThread> m_sender;
|
||||
|
||||
std::auto_ptr<ServerSenderCallback> m_senderCallback;
|
||||
std::auto_ptr<Game> m_game;
|
||||
std::auto_ptr<GameData> m_gameData;
|
||||
std::auto_ptr<ServerSenderCallback> m_senderCallback;
|
||||
|
||||
std::string m_password;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user