Beispiel #1
0
        void HandleRequestFactionData(NetIncomingMessage message)
        {
            NetConnection sender   = message.SenderConnection;
            string        name     = message.ReadString();
            string        pass     = message.ReadString();
            List <Entity> factions = Game.GlobalManager.GetAllEntitiesWithDataBlob <FactionInfoDB>();

            if (factions.Exists(item => item.GetDataBlob <NameDB>().DefaultName == name))
            {
                Entity faction = factions.Find(item => item.GetDataBlob <NameDB>().DefaultName == name);

                if (AuthProcessor.Validate(faction, pass))
                {
                    AddFactionNetconLink(faction, sender);
                    SendGameSettings(sender, Game);
                    //TODO negotiate and get a delta between the server's data and the client's data, and only update the client with changed data.
                    //(the client should be able to save/keep a cashe of it's own data so there's less to send when reconnecting to a server.)
                    SendFactionData(sender, faction);
                    Messages.Add("Sent Faction " + name);
                }
                else
                {
                    SendStringMessage(sender, "Server could not auth faction, check your password and try again"); //TODO: should probibly check the number of bad passwords and handle that properly
                }
            }
            else
            {
                SendStringMessage(sender, "Server could not find faction with name: " + name);
            }
        }
Beispiel #2
0
 public void ReloadProcessors()
 {
     lock (ProcessorsLock)
     {
         AuthProcessor = Reload(AuthProcessor);
     }
 }
Beispiel #3
0
        public override byte[] WritedData()
        {
            var rnd = new Random((int)DateTime.Now.Ticks);

            using (var stream = new MemoryStream())
                using (var writer = new BinaryWriter(stream))
                {
                    writer.Write((int)0);
                    writer.Write((long)1457907576); // server started time

                    var realms = NetworkService.WorldServers.Values.ToList();
                    writer.Write((short)realms.Count);

                    foreach (var realm in realms)
                    {
                        writer.Write((short)realm.ChannelId);                                                   // channel id
                        writer.Write((short)realm.Id);                                                          // server id
                        writer.Write((short)16384);                                                             // test random values

                        writer.Write(BinaryExt.WriteFixedString($"{realm.ChannelName}", Encoding.Unicode, 62)); // channel name
                        writer.Write(BinaryExt.WriteFixedString($"{realm.RealmName}", Encoding.Unicode, 62));   // server name

                        writer.Write((byte)0);
                        writer.Write(BinaryExt.WriteFixedString(realm.RealmIp, Encoding.ASCII, 16)); // ip
                        writer.Write((byte)0);

                        writer.Write(new byte[84]);                                       // padded bytes - possible string inside - never used

                        writer.Write((short)realm.RealmPort);                             // server port

                        writer.Write((byte)1);                                            // server population status
                        writer.Write((byte)1);                                            // can be joined by public
                        writer.Write((byte)1);                                            // unk

                        writer.Write((byte)AuthProcessor.GetCharacterCount(_accInfo.Id)); // created characters count
                        writer.Write((byte)0);                                            // characters to be delete count

                        writer.Write((short)0);                                           // weird limitation / block

                        writer.Write((long)0);                                            // channel relogin delay time
                        writer.Write((long)0);                                            // last login to channel time

                        writer.Write((byte)0);                                            // exp/drop bonus

                        writer.Write(new byte[13]);                                       // padded bytes - never used

                        writer.Write((byte)0);                                            // medal
                    }

                    return(stream.ToArray());
                }
        }
 public AuthServiceProvider()
 {
     _aprocessor = new AuthProcessor();
 }