Exemplo n.º 1
0
        void ListAction(CharacterListActionPacket pkt)
        {
            switch (pkt.Action)
            {
            case CharacterListAction.RequestCharacterDB:
            {
                var m = server.NetServer.CreateMessage();
                m.Write(new NewCharacterDBPacket()
                    {
                        Factions = server.GameData.Ini.NewCharDB.Factions,
                        Packages = server.GameData.Ini.NewCharDB.Packages,
                        Pilots   = server.GameData.Ini.NewCharDB.Pilots
                    });
                server.NetServer.SendMessage(m, connection, NetDeliveryMethod.ReliableOrdered);
                break;
            }

            case CharacterListAction.SelectCharacter:
            {
                var m  = server.NetServer.CreateMessage();
                var sc = Account.Characters[pkt.IntArg];
                Character = NetCharacter.FromDb(sc, server.GameData);
                Base      = Character.Base;
                m.Write(new BaseEnterPacket()
                    {
                        Base = Character.Base,
                        Ship = Character.EncodeLoadout()
                    });
                server.NetServer.SendMessage(m, connection, NetDeliveryMethod.ReliableOrdered);
                break;
            }

            case CharacterListAction.CreateNewCharacter:
            {
                var m  = server.NetServer.CreateMessage();
                var ac = new ServerCharacter()
                {
                    Name    = pkt.StringArg,
                    Base    = "li01_01_base",
                    Credits = 2000,
                    ID      = 0,
                    Ship    = "ge_fighter"
                };
                Account.Characters.Add(ac);
                m.Write(new AddCharacterPacket()
                    {
                        Character = NetCharacter.FromDb(ac, server.GameData).ToSelectable()
                    });
                server.NetServer.SendMessage(m, connection, NetDeliveryMethod.ReliableOrdered);
                break;
            }
            }
        }
Exemplo n.º 2
0
        public static CharacterListActionPacket Read(NetIncomingMessage message)
        {
            var cla = new CharacterListActionPacket();

            cla.Action = (CharacterListAction)message.ReadByte();
            switch (cla.Action)
            {
            case CharacterListAction.SelectCharacter:
                cla.IntArg = message.ReadVariableInt32();
                break;

            case CharacterListAction.CreateNewCharacter:
                cla.IntArg    = message.ReadVariableInt32();
                cla.StringArg = message.ReadString();
                break;
            }
            return(cla);
        }
        public static CharacterListActionPacket Read(NetPacketReader message)
        {
            var cla = new CharacterListActionPacket();

            cla.Action = (CharacterListAction)message.GetByte();
            switch (cla.Action)
            {
            case CharacterListAction.SelectCharacter:
                cla.IntArg = (int)message.GetVariableUInt32();
                break;

            case CharacterListAction.CreateNewCharacter:
                cla.IntArg    = (int)message.GetVariableUInt32();
                cla.StringArg = message.GetString();
                break;

            case CharacterListAction.DeleteCharacter:
                cla.IntArg = (int)message.GetVariableUInt32();
                break;
            }
            return(cla);
        }
Exemplo n.º 4
0
        void ListAction(CharacterListActionPacket pkt)
        {
            switch (pkt.Action)
            {
            case CharacterListAction.RequestCharacterDB:
            {
                Client.SendPacket(new NewCharacterDBPacket()
                    {
                        Factions = game.GameData.Ini.NewCharDB.Factions,
                        Packages = game.GameData.Ini.NewCharDB.Packages,
                        Pilots   = game.GameData.Ini.NewCharDB.Pilots
                    }, PacketDeliveryMethod.ReliableOrdered);
                break;
            }

            case CharacterListAction.SelectCharacter:
            {
                if (pkt.IntArg > 0 && pkt.IntArg < CharacterList.Count)
                {
                    var sc = CharacterList[pkt.IntArg];
                    FLLog.Info("Server", $"opening id {sc.Id}");
                    Character = NetCharacter.FromDb(sc.Id, game);
                    FLLog.Info("Server", $"sending packet");
                    Base = Character.Base;
                    Client.SendPacket(new BaseEnterPacket()
                        {
                            Base = Character.Base,
                            Ship = Character.EncodeLoadout()
                        }, PacketDeliveryMethod.ReliableOrdered);
                }
                else
                {
                    Client.SendPacket(new CharacterListActionResponsePacket()
                        {
                            Action = CharacterListAction.SelectCharacter,
                            Status = CharacterListStatus.ErrBadIndex
                        }, PacketDeliveryMethod.ReliableOrdered);
                }
                break;
            }

            case CharacterListAction.DeleteCharacter:
            {
                var sc = CharacterList[pkt.IntArg];
                game.Database.DeleteCharacter(sc.Id);
                CharacterList.Remove(sc);
                Client.SendPacket(new CharacterListActionResponsePacket()
                    {
                        Action = CharacterListAction.DeleteCharacter,
                        Status = CharacterListStatus.OK
                    }, PacketDeliveryMethod.ReliableOrdered);
                break;
            }

            case CharacterListAction.CreateNewCharacter:
            {
                if (!game.Database.NameInUse(pkt.StringArg))
                {
                    Character ch = null;
                    game.Database.AddCharacter(playerGuid, (db) =>
                        {
                            ch            = db;
                            var sg        = game.NewCharacter(pkt.StringArg, pkt.IntArg);
                            db.Name       = sg.Player.Name;
                            db.Base       = sg.Player.Base;
                            db.System     = sg.Player.System;
                            db.Rank       = 1;
                            db.Costume    = sg.Player.Costume;
                            db.ComCostume = sg.Player.ComCostume;
                            db.Money      = sg.Player.Money;
                            db.Ship       = sg.Player.ShipArchetype;
                            db.Equipment  = new HashSet <EquipmentEntity>();
                            db.Cargo      = new HashSet <CargoItem>();
                            foreach (var eq in sg.Player.Equip)
                            {
                                db.Equipment.Add(new EquipmentEntity()
                                {
                                    EquipmentNickname  = eq.EquipName,
                                    EquipmentHardpoint = eq.Hardpoint
                                });
                            }
                            foreach (var cg in sg.Player.Cargo)
                            {
                                db.Cargo.Add(new CargoItem()
                                {
                                    ItemName  = cg.CargoName,
                                    ItemCount = cg.Count
                                });
                            }
                        });
                    var sel = NetCharacter.FromDb(ch.Id, game).ToSelectable();
                    CharacterList.Add(sel);
                    Client.SendPacket(new AddCharacterPacket()
                        {
                            Character = sel
                        }, PacketDeliveryMethod.ReliableOrdered);
                }
                else
                {
                    Client.SendPacket(new CharacterListActionResponsePacket()
                        {
                            Action = CharacterListAction.CreateNewCharacter,
                            Status = CharacterListStatus.ErrUnknown
                        }, PacketDeliveryMethod.ReliableOrdered);
                }
                break;
            }
            }
        }