Removed some comments. Basically did nothing
This commit is contained in:
@@ -14,6 +14,7 @@ public:
|
||||
virtual ~Network() { };
|
||||
virtual void Start(World* m_world, EventBroker *eventBroker) = 0;
|
||||
virtual void Update() = 0;
|
||||
virtual void Close() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -62,7 +62,7 @@ void InputProxy::Process()
|
||||
e.Command = command;
|
||||
e.Value = currentValue;
|
||||
m_EventBroker->Publish(e);
|
||||
LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
//LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
m_LastCommandValues[command] = currentValue;
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ void InputProxy::Process()
|
||||
}
|
||||
//e.Value = std::max(-1.f, std::min(e.Value, 1.f));
|
||||
m_EventBroker->Publish(e);
|
||||
LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
//LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
}
|
||||
m_CommandQueue.clear();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ Client::Client(ConfigFile* config) : m_Socket(m_IOService)
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
|
||||
m_EventBroker->Unsubscribe(m_EInputCommand);
|
||||
}
|
||||
|
||||
void Client::Start(World* world, EventBroker* eventBroker)
|
||||
@@ -27,14 +27,10 @@ void Client::Start(World* world, EventBroker* eventBroker)
|
||||
m_World = world;
|
||||
|
||||
// Subscribe to events
|
||||
m_EInputCommand = decltype(m_EInputCommand)(std::bind(&Client::OnInputCommand, this, std::placeholders::_1));
|
||||
m_EventBroker->Subscribe(m_EInputCommand);
|
||||
//m_EInputCommand = decltype(m_EInputCommand)(std::bind(&Client::OnInputCommand, this, std::placeholders::_1));
|
||||
//m_EventBroker->Subscribe(m_EInputCommand);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand);
|
||||
|
||||
|
||||
//while (m_PlayerName.size() > 7) {
|
||||
// LOG_INFO("Please enter your name (No longer than 7 characters):");
|
||||
// std::cin >> m_PlayerName;
|
||||
//}
|
||||
m_Socket.connect(m_ReceiverEndpoint);
|
||||
LOG_INFO("I am client. BIP BOP");
|
||||
}
|
||||
@@ -73,7 +69,7 @@ void Client::readFromServer()
|
||||
|
||||
void Client::sendSnapshotToServer()
|
||||
{
|
||||
// Reset previouse key state in snapshot.
|
||||
// Reset previous key state in snapshot.
|
||||
m_NextSnapshot.InputForward = "";
|
||||
m_NextSnapshot.InputRight = "";
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ Server::Server() : m_Socket(m_IOService, boost::asio::ip::udp::endpoint(boost::a
|
||||
{ }
|
||||
|
||||
Server::~Server()
|
||||
{ }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Server::Start(World* world, EventBroker* eventBroker)
|
||||
@@ -25,6 +27,8 @@ void Server::Update()
|
||||
void Server::Close()
|
||||
{
|
||||
m_ThreadIsRunning = false;
|
||||
m_Socket.close();
|
||||
|
||||
}
|
||||
|
||||
void Server::readFromClients()
|
||||
@@ -271,7 +275,7 @@ void Server::parseConnect(Packet& packet)
|
||||
|
||||
m_StopTimes[i] = std::clock();
|
||||
|
||||
LOG_INFO("Player \"%s\" connected on IP: %s", m_PlayerDefinitions[i].Name, m_PlayerDefinitions[i].Endpoint.address().to_string());
|
||||
LOG_INFO("Player \"%s\" connected on IP: %s", m_PlayerDefinitions[i].Name.c_str(), m_PlayerDefinitions[i].Endpoint.address().to_string().c_str());
|
||||
|
||||
Packet packet(MessageType::Connect, m_SendPacketID);
|
||||
packet.WritePrimitive<int>(i); // Player ID
|
||||
|
||||
+6
-7
@@ -128,11 +128,15 @@ bool Game::debugOnInputCommand(const Events::InputCommand& e)
|
||||
}
|
||||
}
|
||||
if (e.Command == "SwitchToServer" && e.Value > 0) {
|
||||
m_ClientOrServer->Close(); // memory leak for now, use delete when it works
|
||||
//delete m_ClientOrServer;
|
||||
m_ClientOrServer = new Server();
|
||||
LOG_INFO("Switching to server");
|
||||
m_ClientOrServer->Start(m_World, m_EventBroker);
|
||||
}
|
||||
if (e.Command == "SwitchToClient" && e.Value > 0) {
|
||||
else if (e.Command == "SwitchToClient" && e.Value > 0) {
|
||||
m_ClientOrServer->Close(); // memory leak for now, use delete when it works
|
||||
//delete m_ClientOrServer;
|
||||
m_ClientOrServer = new Client(m_Config);
|
||||
m_ClientOrServer->Start(m_World, m_EventBroker);
|
||||
LOG_INFO("Switching to client");
|
||||
@@ -163,10 +167,5 @@ void Game::networkFunction()
|
||||
m_ClientOrServer = new Server();
|
||||
}
|
||||
m_ClientOrServer->Start(m_World, m_EventBroker);
|
||||
// I don't think we are reaching this part of the code right now.
|
||||
// ~Game() is not called if the game is exited by closing console windows
|
||||
// When server or client is done set it to false.
|
||||
//m_IsClientOrServer = false;
|
||||
// Destroy it
|
||||
//delete m_ClientOrServer;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user