WIP implemented Interpolation (server logic)
This commit is contained in:
@@ -4,9 +4,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
#include <glm/common.hpp>
|
#include <glm/common.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
#include <boost/shared_array.hpp>
|
||||||
|
|
||||||
#include "Network/Network.h"
|
#include "Network/Network.h"
|
||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
@@ -68,10 +70,11 @@ private:
|
|||||||
void ping();
|
void ping();
|
||||||
void parseMessageType(Packet& packet);
|
void parseMessageType(Packet& packet);
|
||||||
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID, const std::string& componentType);
|
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID, const std::string& componentType);
|
||||||
void parseConnect(Packet& packet);
|
void parseConnect(Packet& packet);
|
||||||
void parsePlayerConnected(Packet& packet);
|
void parsePlayerConnected(Packet& packet);
|
||||||
void parsePing();
|
void parsePing();
|
||||||
void parseServerPing();
|
void parseServerPing();
|
||||||
|
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||||
void parseSnapshot(Packet& packet);
|
void parseSnapshot(Packet& packet);
|
||||||
void identifyPacketLoss();
|
void identifyPacketLoss();
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
|
|||||||
@@ -112,6 +112,21 @@ void Client::parseServerPing()
|
|||||||
send(packet);
|
send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fields with strings will not work right now
|
||||||
|
void Client::InterpolateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID, const std::string& componentType)
|
||||||
|
{
|
||||||
|
int sizeOfFields = 0;
|
||||||
|
for (auto field : componentInfo.FieldsInOrder) {
|
||||||
|
ComponentInfo::Field_t fieldInfo = componentInfo.Fields.at(field);
|
||||||
|
sizeOfFields = fieldInfo.Stride;
|
||||||
|
}
|
||||||
|
// Is the size correct?
|
||||||
|
boost::shared_array<char> eventData(new char[componentInfo.Meta.Stride]);
|
||||||
|
memcpy(eventData.get(), packet.ReadData(componentInfo.Meta.Stride), componentInfo.Meta.Stride);
|
||||||
|
//Send event to interpolat system
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID, const std::string& componentType)
|
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID, const std::string& componentType)
|
||||||
{
|
{
|
||||||
for (auto field : componentInfo.FieldsInOrder) {
|
for (auto field : componentInfo.FieldsInOrder) {
|
||||||
@@ -125,7 +140,6 @@ void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field parse
|
|
||||||
void Client::parseSnapshot(Packet& packet)
|
void Client::parseSnapshot(Packet& packet)
|
||||||
{
|
{
|
||||||
std::string componentType = packet.ReadString();
|
std::string componentType = packet.ReadString();
|
||||||
@@ -142,7 +156,11 @@ void Client::parseSnapshot(Packet& packet)
|
|||||||
// Check if the component exists
|
// Check if the component exists
|
||||||
if (m_World->HasComponent(entityID, componentType)) {
|
if (m_World->HasComponent(entityID, componentType)) {
|
||||||
// If the entity and the component exists update it
|
// If the entity and the component exists update it
|
||||||
updateFields(packet, componentInfo, entityID, componentType);
|
if (componentType == "Transform") {
|
||||||
|
InterpolateFields(packet, componentInfo, entityID, componentType);
|
||||||
|
} else {
|
||||||
|
updateFields(packet, componentInfo, entityID, componentType);
|
||||||
|
}
|
||||||
// if entity exists but not the component
|
// if entity exists but not the component
|
||||||
} else {
|
} else {
|
||||||
// Create component
|
// Create component
|
||||||
|
|||||||
Reference in New Issue
Block a user