Added support for multiplayer.
Reactored code, clumped together variables in PlayerDefinition.h. Integrated server with entity system.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#ifndef PlayerDefinition_h__
|
||||
#define PlayerDefinition_h__
|
||||
#include <string>
|
||||
|
||||
struct PlayerDefinition {
|
||||
unsigned int EntityID;
|
||||
std::string Name;
|
||||
boost::asio::ip::udp::endpoint Endpoint;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -8,27 +8,31 @@
|
||||
#include <glm/common.hpp>
|
||||
#include "NetworkDefines.h"
|
||||
#include "MessageType.h"
|
||||
#include "Core/World.h"
|
||||
#include "Network/PlayerDefinition.h"
|
||||
|
||||
class Server
|
||||
{
|
||||
public:
|
||||
Server();
|
||||
~Server();
|
||||
void Start();
|
||||
void Start(World* m_world);
|
||||
|
||||
private:
|
||||
// udp stuff
|
||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||
boost::asio::io_service m_IOService;
|
||||
boost::asio::ip::udp::socket m_Socket;
|
||||
boost::asio::ip::udp::endpoint m_Connections[MAXCONNECTIONS];
|
||||
// boost::asio::ip::udp::endpoint m_Connections[MAXCONNECTIONS];
|
||||
PlayerDefinition m_PlayerDefinitions[MAXCONNECTIONS];
|
||||
//Timers
|
||||
std::clock_t m_StartPingTime;
|
||||
std::clock_t m_StopTimes[8];
|
||||
// Game logic
|
||||
std::string m_PlayerNames[MAXCONNECTIONS];
|
||||
// std::string m_PlayerNames[MAXCONNECTIONS];
|
||||
char m_GameBoard[BOARDSIZE][BOARDSIZE];
|
||||
glm::vec2 m_PlayerPositions[8];
|
||||
World* m_World;
|
||||
|
||||
// Threaded
|
||||
void DisplayLoop();
|
||||
|
||||
Reference in New Issue
Block a user