// Copyright 2018 RED Software, LLC. All Rights Reserved. using IgniteEngine; using IgniteEngine.Networking; using IgniteEngine.Protocols; namespace LoginServer.Handlers { internal static class MiscHandlers { internal static void NC_MISC_S2SCONNECTION_REQ(NetworkMessage message, NetworkConnection connection) { var from = message.ReadByte(); var to = message.ReadByte(); var worldNumber = message.ReadByte(); var worldName = message.ReadString(20); var unused = message.ReadByte(); var ip = message.ReadString(16); var port = message.ReadUInt16(); var key = message.ReadUInt16(); if (key != from + to) { Debug.LogWarning("Invalid key used with S2S connection."); connection.Disconnect(); return; } if ((NetworkConnectionType)from == NetworkConnectionType.NCT_WORLDMANAGER) { if (Program.Worlds.Exists(world => world.Connection == connection || world.Number == worldNumber)) { return; } Program.Worlds.Add(new World(connection, worldName, worldNumber, ip, port)); new PROTO_NC_MISC_S2SCONNECTION_ACK().Send(connection); } } } }