Should now read servername from config.
This commit is contained in:
@@ -60,6 +60,7 @@ private:
|
|||||||
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
|
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
|
||||||
//Timers
|
//Timers
|
||||||
std::clock_t m_StartPingTime;
|
std::clock_t m_StartPingTime;
|
||||||
|
std::string m_ServerName = "";
|
||||||
|
|
||||||
// Packet loss logic
|
// Packet loss logic
|
||||||
PacketID m_PacketID = 0;
|
PacketID m_PacketID = 0;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
|
|||||||
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05f);
|
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05f);
|
||||||
pingIntervalMs = config->Get<float>("Networking.PingIntervalMs", 1000);
|
pingIntervalMs = config->Get<float>("Networking.PingIntervalMs", 1000);
|
||||||
|
m_ServerName = config->Get<std::string>("Networking.Name", "Unnamed");
|
||||||
|
|
||||||
// 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);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Server::OnPlayerSpawned);
|
||||||
@@ -410,7 +412,7 @@ void Server::parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint)
|
|||||||
Packet packet(MessageType::ServerlistRequest);
|
Packet packet(MessageType::ServerlistRequest);
|
||||||
packet.WriteString(m_Reliable.Address());
|
packet.WriteString(m_Reliable.Address());
|
||||||
packet.WritePrimitive<int>(m_Reliable.Port());
|
packet.WritePrimitive<int>(m_Reliable.Port());
|
||||||
packet.WriteString("SERVERNAME");
|
packet.WriteString(m_ServerName);
|
||||||
packet.WritePrimitive<int>(m_ConnectedPlayers.size());
|
packet.WritePrimitive<int>(m_ConnectedPlayers.size());
|
||||||
m_ServerlistRequest.Send(packet);
|
m_ServerlistRequest.Send(packet);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user