Sends entity names. Temporarily
This commit is contained in:
@@ -89,6 +89,7 @@ void Client::parseMessageType(Packet& packet)
|
|||||||
break;
|
break;
|
||||||
case MessageType::PlayerConnected:
|
case MessageType::PlayerConnected:
|
||||||
parsePlayerConnected(packet);
|
parsePlayerConnected(packet);
|
||||||
|
break;
|
||||||
case MessageType::Kick:
|
case MessageType::Kick:
|
||||||
parseKick();
|
parseKick();
|
||||||
break;
|
break;
|
||||||
@@ -177,8 +178,12 @@ void Client::parseSnapshot(Packet& packet)
|
|||||||
{
|
{
|
||||||
std::string componentType = packet.ReadString();
|
std::string componentType = packet.ReadString();
|
||||||
while (packet.DataReadSize() < packet.Size()) {
|
while (packet.DataReadSize() < packet.Size()) {
|
||||||
|
// HACK
|
||||||
|
std::string entityName = packet.ReadString();
|
||||||
// Components EntityID
|
// Components EntityID
|
||||||
EntityID receivedEntityID = packet.ReadPrimitive<EntityID>();
|
EntityID receivedEntityID = packet.ReadPrimitive<EntityID>();
|
||||||
|
// HACK
|
||||||
|
m_World->SetName(receivedEntityID, entityName);
|
||||||
// Parents EntityID
|
// Parents EntityID
|
||||||
EntityID receivedParentEntityID = packet.ReadPrimitive<EntityID>();
|
EntityID receivedParentEntityID = packet.ReadPrimitive<EntityID>();
|
||||||
ComponentInfo componentInfo = m_World->GetComponents(componentType)->ComponentInfo();
|
ComponentInfo componentInfo = m_World->GetComponents(componentType)->ComponentInfo();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "Network/Server.h"
|
#include "Network/Server.h"
|
||||||
|
|
||||||
Server::Server() : m_Socket(m_IOService, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 13))
|
Server::Server() : m_Socket(m_IOService, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 27666))
|
||||||
{
|
{
|
||||||
Network::initialize();
|
Network::initialize();
|
||||||
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
@@ -20,6 +20,7 @@ void Server::Start(World* world, EventBroker* eventBroker)
|
|||||||
m_EventBroker = eventBroker;
|
m_EventBroker = eventBroker;
|
||||||
// Subscribe to events
|
// Subscribe to events
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Server::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Server::OnInputCommand);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Server::OnPlayerSpawned);
|
||||||
for (size_t i = 0; i < m_MaxConnections; i++) {
|
for (size_t i = 0; i < m_MaxConnections; i++) {
|
||||||
m_PlayerDefinitions[i].StopTime = std::clock();
|
m_PlayerDefinitions[i].StopTime = std::clock();
|
||||||
}
|
}
|
||||||
@@ -180,9 +181,12 @@ void Server::sendSnapshot()
|
|||||||
Packet packet(MessageType::Snapshot);
|
Packet packet(MessageType::Snapshot);
|
||||||
ComponentPool* componentPool = it.second;
|
ComponentPool* componentPool = it.second;
|
||||||
ComponentInfo componentInfo = componentPool->ComponentInfo();
|
ComponentInfo componentInfo = componentPool->ComponentInfo();
|
||||||
|
|
||||||
// Component Type
|
// Component Type
|
||||||
packet.WriteString(componentInfo.Name);
|
packet.WriteString(componentInfo.Name);
|
||||||
for (auto& componentWrapper : *componentPool) {
|
for (auto& componentWrapper : *componentPool) {
|
||||||
|
// HACK: Send entity name
|
||||||
|
packet.WriteString(m_World->GetName(componentWrapper.EntityID));
|
||||||
// Components EntityID
|
// Components EntityID
|
||||||
packet.WritePrimitive(componentWrapper.EntityID);
|
packet.WritePrimitive(componentWrapper.EntityID);
|
||||||
// Parents EntityID
|
// Parents EntityID
|
||||||
|
|||||||
Reference in New Issue
Block a user