Exemplo n.º 1
0
        public bool AddChannel(IPCReceiver receiver, IPCReader data)
        {
            lock (channels)
            {
                var serverId   = data.ReadByte();
                var channelId  = data.ReadByte();
                var type       = data.ReadInt32();
                var ip         = data.ReadUInt32();
                var port       = data.ReadInt16();
                var maxPlayers = data.ReadInt16();

                if (!channels.ContainsKey(serverId))
                {
                    channels.Add(serverId, new SortedDictionary <byte, ChannelData>());
                }

                var s = channels[serverId];

                if (s.ContainsKey(channelId))
                {
                    return(false);
                }

                s.Add(channelId, new ChannelData(channelId, type, ip, port, maxPlayers, 0));

                //if (!Configuration.ServerDBs.ContainsKey(serverId)) Ported to Global.Global.Config
                if (!Global.Config.ServerDBs.ContainsKey(serverId))
                {
                    //Configuration.LoadServer(serverId); Ported to Global.Global.Config
                    Global.Config.LoadMasterServer(serverId);

                    Log.Message("Connecting to Database for Server " + serverId.ToString() + "...", Log.DefaultFG);
                    //serverdbs[serverId] = new DatabaseHandler(Configuration.ServerDBTypes[serverId], Configuration.ServerDBIPs[serverId], Configuration.ServerDBs[serverId], Configuration.ServerDBUsers[serverId], Configuration.ServerDBPasses[serverId]); Ported to Global.Global.Config
                    serverdbs[serverId] = new DatabaseHandler(Global.Config.ServerDBTypes[serverId], Global.Config.ServerDBIPs[serverId], Global.Config.ServerDBs[serverId], Global.Config.ServerDBUsers[serverId], Global.Config.ServerDBPasses[serverId]);
                }


                Log.Notice(string.Format("Channel registered: {0}, {1}", serverId, channelId));

                return(true);
            }
        }