Added logic for sending input from Client to Server.

Fixed so that snapshots set their parent correctly. Will get problems if we have more components
than unsigned int max size, but that was already a problem.
Client now maps Entitys received from server with local Entitys by mapping their EntityIDs.
This commit is contained in:
Jocke
2016-01-13 16:09:16 +01:00
parent 2284399538
commit f47f913bf5
4 changed files with 65 additions and 80 deletions
+7 -2
View File
@@ -3,6 +3,7 @@
#include <string>
#include <ctime>
#include <limits>
#include <glm/common.hpp>
#include <boost/asio.hpp>
@@ -45,6 +46,10 @@ private:
std::string m_PlayerName;
int m_PlayerID = -1;
// Server Client Lookup map
// Assumes that root node for client and server is EntityID 0.
std::unordered_map<EntityID, EntityID> m_ServerToClientMap;
// Network logic
PlayerDefinition m_PlayerDefinitions[MAXCONNECTIONS];
SnapshotDefinitions m_NextSnapshot;
@@ -56,7 +61,7 @@ private:
// Private member functions
void readFromServer();
void sendSnapshotToServer();
void sendInputEvents();
int receive(char* data, size_t length);
void send(Packet& packet);
void connect();
@@ -73,7 +78,7 @@ private:
void identifyPacketLoss();
bool isConnected();
EntityID createPlayer();
bool hasMappedEntity(EntityID entityID);
// Events
EventBroker* m_EventBroker;
EventRelay<Client, Events::InputCommand> m_EInputCommand;