コード例 #1
0
 public DebugAI(Old.Object.Ship.Ship ship) : base(ship)
 {
     waypoints.Add(new Waypoint(new Vector(-29292, -892, -27492), 0, FLUtility.CreateID("li01")));
     waypoints.Add(new Waypoint(new Vector(-30689, -600, -28092), 0, FLUtility.CreateID("li01")));
     waypoints.Add(new Waypoint(new Vector(-33021, -124, -27880), 0, FLUtility.CreateID("li01")));
     waypoints.Add(new Waypoint(new Vector(-35185, -138, -26487), 0, FLUtility.CreateID("li01")));
 }
コード例 #2
0
 private static void LoadBase(string fldatapath, string path, BaseData basedata, ILogController log)
 {
     try
     {
         var ini = new FLDataFile(path, true);
         foreach (FLDataFile.Section sec in ini.Sections)
         {
             string sectionName = sec.SectionName.ToLowerInvariant();
             if (sectionName == "baseinfo")
             {
                 basedata.StartRoom = String.Format("{0:x}_{1}", basedata.BaseID,
                                                    sec.GetSetting("start_room").Str(0));
                 basedata.StartRoomID = FLUtility.CreateID(basedata.StartRoom);
             }
             else if (sectionName == "room")
             {
                 var room = new Room {
                     Nickname = sec.GetSetting("nickname").Str(0).ToLowerInvariant()
                 };
                 room.RoomID = FLUtility.CreateID(room.Nickname);
                 path        = fldatapath + Path.DirectorySeparatorChar + sec.GetSetting("file").Str(0);
                 //I don't need room data at the moment. Yay.
                 //TODO: make LoadRoom?
                 //LoadRoom(fldatapath, path, basedata, room, log);
                 basedata.Rooms[room.Nickname] = room;
             }
         }
     }
     catch (Exception e)
     {
         log.AddLog(LogType.ERROR, "error: '" + e.Message + "' when parsing '" + path);
     }
 }
コード例 #3
0
        /// <summary>
        /// Load goods list for every base: buy\sell list, price mods, etc.
        /// </summary>
        /// <param name="file"></param>
        public static void LoadBaseMarketData(DataFile file)
        {
            foreach (var basesect in file.GetSections("BaseGood"))
            {
                var sbase = GetBase(basesect.GetFirstOf("base")[0]);
                if (sbase == null)
                {
                    Logger.Warn("Market info for unknown base skipped: {0}", basesect.GetFirstOf("base")[0]);
                    continue;
                }

                foreach (var set in basesect.GetSettings("MarketGood"))
                {
                    var hash = FLUtility.CreateID(set[0]);
                    var good = new Base.Base.MarketGood(hash)
                    {
                        MinLevelToBuy = float.Parse(set[1]),
                        MinRepToBuy   = float.Parse(set[2]),
                    };
                    var baseSells = (set[5] == "1");
                    if (set.Count >= 7)
                    {
                        good.PriceMod = float.Parse(set[6]);
                    }

                    sbase.GoodsToBuy[hash] = good;
                    if (baseSells)
                    {
                        sbase.GoodsForSale[hash] = good;
                    }
                }
            }
        }
コード例 #4
0
        public LauncherArchetype(Section sec) : base(sec)
        {
            Setting tmpSet;

            if (sec.TryGetFirstOf("damage_per_fire", out tmpSet))
            {
                DamagePerFire = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("power_usage", out tmpSet))
            {
                PowerUsage = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("refire_delay", out tmpSet))
            {
                RefireDelay = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("muzzle_velocity", out tmpSet))
            {
                MuzzleVelocity = new JVector(0, 0, -float.Parse(tmpSet[0]));
            }

            if (sec.TryGetFirstOf("projectile_archetype", out tmpSet))
            {
                _projectileArchHash = FLUtility.CreateID(tmpSet[0]);
            }
        }
コード例 #5
0
 public Solar(StarSystem system, string nickname)
     : base(null)
 {
     System   = system;
     Nickname = nickname;
     Objid    = FLUtility.CreateID(Nickname);
 }
コード例 #6
0
        public MunitionArchetype(Section sec) : base(sec)
        {
            Setting tmpSet;

            if (sec.TryGetFirstOf("hull_damage", out tmpSet))
            {
                HullDamage = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("energy_damage", out tmpSet))
            {
                EnergyDamage = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("weapon_type", out tmpSet))
            {
                _weaponTypeHash = FLUtility.CreateID(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("seeker", out tmpSet))
            {
                Seeker = tmpSet[0];
            }

            if (sec.TryGetFirstOf("time_to_lock", out tmpSet))
            {
                TimeToLock = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("seeker_range", out tmpSet))
            {
                SeekerRange = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("seeker_fov_deg", out tmpSet))
            {
                SeekerFovDeg = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("detonation_dist", out tmpSet))
            {
                DetonationDist = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("max_angular_velocity", out tmpSet))
            {
                MaxAngularVelocity = float.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("cruise_disruptor", out tmpSet))
            {
                CruiseDisruptor = bool.Parse(tmpSet[0]);
            }

            if (sec.TryGetFirstOf("motor", out tmpSet))
            {
                _motorHash = FLUtility.CreateID(tmpSet[0]);
            }
        }
コード例 #7
0
 /// <summary>
 /// Get all the [Base] sections here so we can load the base info.
 /// </summary>
 /// <param name="secs">List of [Base] sections.</param>
 /// <param name="flDataPath">Path to FL's DATA folder.</param>
 public static void LoadBases(IEnumerable <Section> secs, string flDataPath)
 {
     Parallel.ForEach(secs, sec =>
     {
         var path  = Path.Combine(flDataPath, sec.GetFirstOf("file")[0]);
         var bdata = new Base.Base(new DataFile(path), flDataPath);
         Bases[FLUtility.CreateID(bdata.Nickname)] = bdata;
     });
 }
コード例 #8
0
        public static StarSystem FindSystem(string nickname)
        {
            uint systemid = FLUtility.CreateID(nickname);

            if (!Systems.ContainsKey(systemid))
            {
                return(null);
            }
            return(Systems[systemid]);
        }
コード例 #9
0
        public static BaseData FindBase(string nickname)
        {
            uint baseid = FLUtility.CreateID(nickname);

            if (!Bases.ContainsKey(baseid))
            {
                return(null);
            }
            return(Bases[baseid]);
        }
コード例 #10
0
        public static Good FindGood(string nickname)
        {
            uint goodid = FLUtility.CreateID(nickname);

            if (!Goods.ContainsKey(goodid))
            {
                return(null);
            }
            return(Goods[goodid]);
        }
コード例 #11
0
        /// <summary>
        ///     Load base market data and setup the prices for goods at each base.
        /// </summary>
        /// <param name="path"></param>
        private static void LoadBaseMarketData(string path, ILogController log)
        {
            var ini = new FLDataFile(path, true);

            foreach (var sec in ini.Sections)
            {
                string sectionName = sec.SectionName.ToLowerInvariant();

                if (sectionName != "basegood")
                {
                    continue;
                }

                var basedata = FindBase(sec.GetSetting("base").Str(0));
                if (basedata == null)
                {
                    log.AddLog(LogType.ERROR, "error: " + sec.Desc);
                    continue;
                }

                foreach (FLDataFile.Setting set in sec.Settings)
                {
                    var settingName = set.SettingName.ToLowerInvariant();
                    if (settingName != "marketgood")
                    {
                        continue;
                    }
                    var nickname                 = set.Str(0);
                    var level_needed_to_buy      = set.Float(1);
                    var reputation_needed_to_buy = set.Float(2);
                    var baseSells                = (set.UInt(5) == 1);
                    var basePriceMultiplier      = 1.0f;
                    if (set.NumValues() > 6)
                    {
                        basePriceMultiplier = set.Float(6);
                    }

                    var goodid = FLUtility.CreateID(nickname);
                    var good   = FindGood(goodid);
                    if (good == null)
                    {
                        log.AddLog(LogType.ERROR, "error: " + set.Desc);
                        continue;
                    }

                    if (baseSells)
                    {
                        basedata.GoodsForSale[goodid] = good.BasePrice * basePriceMultiplier;
                    }

                    basedata.GoodsToBuy[goodid] = good.BasePrice * basePriceMultiplier;
                }
            }
        }
コード例 #12
0
        public static void LoadWeaponType(Section sec)
        {
            var type = new WeaponType()
            {
                Nickname = sec.GetFirstOf("nickname")[0]
            };

            foreach (var entry in sec.GetSettings("shield_mod"))
            {
                type.ShieldMods.Add(FLUtility.CreateID(entry[0]), float.Parse(entry[1]));
            }
            WeaponDamageModifier[FLUtility.CreateID(type.Nickname)] = type;
        }
コード例 #13
0
        /// <summary>
        ///     Load shop information for equipment and commodities.
        /// </summary>
        /// <param name="path"></param>
        private static void LoadGoodData(string path, ILogController log)
        {
            var ini = new FLDataFile(path, true);

            foreach (FLDataFile.Section sec in ini.Sections)
            {
                var sectionName = sec.SectionName.ToLowerInvariant();
                if (sectionName != "good")
                {
                    continue;
                }
                var good = new Good {
                    Nickname = sec.GetSetting("nickname").Str(0)
                };
                good.GoodID = FLUtility.CreateID(good.Nickname);
                string category = sec.GetSetting("category").Str(0);
                if (category == "equipment")
                {
                    good.category  = Good.Category.Equipment;
                    good.BasePrice = sec.GetSetting("price").Float(0);
                    uint archid = FLUtility.CreateID(sec.GetSetting("equipment").Str(0));
                    good.EquipmentOrShipArch = ArchetypeDB.Find(archid);
                }
                else if (category == "commodity")
                {
                    good.category  = Good.Category.Commodity;
                    good.BasePrice = sec.GetSetting("price").Float(0);
                    uint archid = FLUtility.CreateID(sec.GetSetting("equipment").Str(0));
                    good.EquipmentOrShipArch = ArchetypeDB.Find(archid);
                }
                else if (category == "shiphull")
                {
                    good.category  = Good.Category.ShipHull;
                    good.BasePrice = sec.GetSetting("price").Float(0);
                    uint archid = FLUtility.CreateID(sec.GetSetting("ship").Str(0));
                    good.EquipmentOrShipArch = ArchetypeDB.Find(archid);
                }
                else if (category == "ship")
                {
                    good.category = Good.Category.ShipPackage;
                    uint goodid = FLUtility.CreateID(sec.GetSetting("hull").Str(0));
                    good.Shiphull = Goods[goodid];
                }
                else
                {
                    log.AddLog(LogType.ERROR, "error: unknown category " + sec.Desc);
                }

                Goods[good.GoodID] = good;
            }
        }
コード例 #14
0
        public Base(DataFile datafile, string flDataPath)
        {
            Nickname  = datafile.GetSetting("BaseInfo", "nickname")[0];
            BaseID    = FLUtility.CreateID(Nickname);
            StartRoom = String.Format("{0:x}_{1}", BaseID,
                                      datafile.GetSetting("BaseInfo", "start_room")[0].ToLowerInvariant());
            StartRoomID = FLUtility.CreateID(StartRoom);

            foreach (var sec in datafile.GetSections("Room"))
            {
                var nick = sec.GetFirstOf("nickname")[0].ToLowerInvariant();
                var file = new DataFile(Path.Combine(flDataPath, sec.GetFirstOf("file")[0]));
                var room = new Room(nick, file, flDataPath);
                Rooms.Add(nick, room);
            }
        }
コード例 #15
0
        public void Handle(EnterBase message)
        {
            _log.Debug("FLID {0} enters base {1}", _flplayerID, message.BaseID);
            //TODO: debug if null or ""
            var baseid = FLUtility.CreateID(_account.ShipState.Base);

            if (_account.ShipState.Base != null && baseid != message.BaseID)
            {
                _log.Warn("{0} CHEAT: tried to enter {1} when saved at {2} ({3}",
                          _account.CharName, message.BaseID, baseid,
                          _account.ShipState.Base);
                //TODO: kick for cheating
            }
            var sdata = Context.Child("ship").Ask <ShipData>(new AskShipData(), TimeSpan.FromMilliseconds(850));

            Context.Sender.Tell(new AccountShipData(_account, sdata.Result));
            Context.Child("ship").Tell(new AskHullStatus(), _socket);
        }
コード例 #16
0
        /// <summary>
        /// Load goods and commodities that are sold throughout the universe.
        /// </summary>
        /// <param name="file"></param>
        public static void LoadGoods(DataFile file)
        {
            foreach (var sec in file.GetSections("Good"))
            {
                var good  = new UniGood();
                var ghash = FLUtility.CreateID(sec.GetFirstOf("nickname")[0]);

                switch (sec.GetFirstOf("category")[0])
                {
                case "equipment":
                    good.Category  = UniGood.Cat.Equipment;
                    good.BasePrice = float.Parse(sec.GetFirstOf("price")[0]);
                    good.ArchID    = FLUtility.CreateID(sec.GetFirstOf("equipment")[0]);
                    break;

                case "commodity":
                    good.Category  = UniGood.Cat.Commodity;
                    good.BasePrice = float.Parse(sec.GetFirstOf("price")[0]);
                    good.ArchID    = FLUtility.CreateID(sec.GetFirstOf("equipment")[0]);
                    break;

                case "shiphull":
                    good.Category  = UniGood.Cat.ShipHull;
                    good.BasePrice = float.Parse(sec.GetFirstOf("price")[0]);
                    good.ArchID    = FLUtility.CreateID(sec.GetFirstOf("ship")[0]);
                    break;

                case "ship":
                    good.Category = UniGood.Cat.ShipPackage;
                    good.ArchID   = FLUtility.CreateID(sec.GetFirstOf("hull")[0]);
                    break;

                default:
                    Logger.Warn("Unknown good type for {0}: {1}", sec.GetFirstOf("nickname")[0], sec.GetFirstOf("category")[0]);
                    break;
                }
                UniGoods[ghash] = good;
            }
        }
コード例 #17
0
        void SendPlayerGFUpdateChar(uint roomid, uint charid)
        {
            byte[] omsg = { 0x26, 0x02 };

            const string movementScript = "scripts\\extras\\player_fidget.thn";
            const string roomLocation   = "";

            FLMsgType.AddUInt32(ref omsg,
                                74 + (uint)_charAccount.CharName.Length + (uint)movementScript.Length + (uint)roomLocation.Length);
            FLMsgType.AddUInt32(ref omsg, charid);
            FLMsgType.AddUInt32(ref omsg, 0x01);                                                // 1 = player, 0 = npc
            FLMsgType.AddUInt32(ref omsg, roomid);
            FLMsgType.AddUInt32(ref omsg, 0);                                                   // npc name
            FLMsgType.AddUInt32(ref omsg, FLUtility.CreateID(_charAccount.ShipState.RepGroup)); // faction
            FLMsgType.AddUnicodeStringLen32(ref omsg, _charAccount.CharName);
            FLMsgType.AddUInt32(ref omsg, _charAccount.Appearance.Head);
            FLMsgType.AddUInt32(ref omsg, _charAccount.Appearance.Body);
            FLMsgType.AddUInt32(ref omsg, _charAccount.Appearance.LeftHand);
            FLMsgType.AddUInt32(ref omsg, _charAccount.Appearance.RightHand);
            FLMsgType.AddUInt32(ref omsg, 0); // accessories count + list
            FLMsgType.AddAsciiStringLen32(ref omsg, movementScript);
            FLMsgType.AddInt32(ref omsg, -1); // behaviourid

            if (roomLocation.Length == 0)
            {
                FLMsgType.AddInt32(ref omsg, -1);
            }
            else
            {
                FLMsgType.AddAsciiStringLen32(ref omsg, roomLocation);
            }

            FLMsgType.AddUInt32(ref omsg, 0x01);                                              // 1 = player, 0 = npc
            FLMsgType.AddUInt32(ref omsg, 0x00);                                              // 1 = sitlow, 0 = stand
            FLMsgType.AddUInt32(ref omsg, FLUtility.CreateID(_charAccount.Appearance.Voice)); // voice

            Context.Sender.Tell(omsg);
        }
コード例 #18
0
        public Room(string nickname, DataFile file, string flDataPath)
        {
            Nickname = nickname;
            RoomID   = FLUtility.CreateID(Nickname);
            //TODO: base room loading!
            //THN parsing is ass slow, disabled for now.
            return;

#pragma warning disable 162
// ReSharper disable HeuristicUnreachableCode
            Setting tset;

            var sec = file.Sections.FirstOrDefault(sect => sect.Name == "Room_Info");
            if (sec == null)
            {
                var log = LogManager.GetCurrentClassLogger();
                log.Warn("Base room without Room_Info: {1} in {0}", file.Path, nickname);
                return;
            }
            if (!sec.TryGetFirstOf("set_script", out tset))
            {
                return;
            }

            var thnPath = tset[0];
            var thnText = File.ReadAllText(Path.Combine(flDataPath, thnPath));

            var thn = new ThnParse();
            thn.Parse(thnText);
            foreach (var e in thn.entities.Where(e => e.type.ToLowerInvariant() == "marker"))
            {
                //TODO: do something with base thns
            }
// ReSharper restore HeuristicUnreachableCode
#pragma warning restore 162
        }
コード例 #19
0
        private static void LoadLoadout(string path, ILogController log)
        {
            var ini = new FLDataFile(path, true);

            foreach (FLDataFile.Section sec in ini.Sections)
            {
                string sectionName = sec.SectionName.ToLowerInvariant();
                if (sectionName == "loadout")
                {
                    var  loadout = new Loadout();
                    uint hpid    = 34;
                    foreach (FLDataFile.Setting set in sec.Settings)
                    {
                        if (set.SettingName == "nickname")
                        {
                            loadout.Nickname  = set.Str(0);
                            loadout.LoadoutID = FLUtility.CreateID(loadout.Nickname);
                        }
                        else if (set.SettingName == "equip")
                        {
                            var item = new ShipItem {
                                arch = ArchetypeDB.Find(FLUtility.CreateID(set.Str(0)))
                            };
                            if (item.arch == null)
                            {
                                continue; // TODO: log
                            }
                            item.hpname = "";
                            if (set.NumValues() > 1)
                            {
                                item.hpname = set.Str(1);
                            }
                            item.health  = 1.0f;
                            item.mission = false;
                            item.mounted = true;
                            item.count   = 1;
                            item.hpid    = hpid++;
                            loadout.Items.Add(item);
                        }
                        else if (set.SettingName == "cargo")
                        {
                            var item = new ShipItem {
                                arch = ArchetypeDB.Find(FLUtility.CreateID(set.Str(0)))
                            };
                            if (item.arch == null)
                            {
                                continue; // TODO: log
                            }
                            item.hpname  = "";
                            item.health  = 1.0f;
                            item.mission = false;
                            item.mounted = false;
                            item.count   = set.UInt(1);
                            item.hpid    = hpid++;
                            loadout.Items.Add(item);
                        }
                    }
                    Loadouts[loadout.LoadoutID] = loadout;
                }
            }
        }
コード例 #20
0
 public static Archetype GetArchetype(string nickname)
 {
     return(GetArchetype(FLUtility.CreateID(nickname)));
 }
コード例 #21
0
        /// <summary>
        /// Sends character list for current account.
        /// </summary>
        private void SendCharInfoResponse()
        {
            var accs = Database.GetAccount(_accountID);

            byte[] omsg = { 0x03, 0x02 };
            FLMsgType.AddUInt8(ref omsg, 0);     // chars
            if (accs != null)
            {
                foreach (var acct in accs)
                {
                    //try
                    //{

                    FLMsgType.AddAsciiStringLen16(ref omsg, FLMsgType.FLNameToFile(acct.CharName));
                    FLMsgType.AddUInt16(ref omsg, 0);
                    FLMsgType.AddUnicodeStringLen16(ref omsg, acct.CharName);
                    FLMsgType.AddUnicodeStringLen16(ref omsg, "");
                    FLMsgType.AddUInt32(ref omsg, 0);
                    FLMsgType.AddUInt32(ref omsg, 0);
                    FLMsgType.AddUInt32(ref omsg, 0);
                    FLMsgType.AddUInt32(ref omsg, acct.Ship);
                    if (acct.Money > 2000000000)
                    {
                        FLMsgType.AddInt32(ref omsg, 2000000000);
                    }
                    else
                    {
                        FLMsgType.AddInt32(ref omsg, acct.Money);
                    }

                    //TODO: ideally we should check if base, system and equip exists
                    FLMsgType.AddUInt32(ref omsg, FLUtility.CreateID(acct.System));
                    if (acct.ShipState.Base != null)
                    {
                        FLMsgType.AddUInt32(ref omsg, FLUtility.CreateID(acct.ShipState.Base));
                    }
                    else
                    {
                        FLMsgType.AddUInt32(ref omsg, 0);
                    }
                    FLMsgType.AddUInt32(ref omsg, 0);
                    FLMsgType.AddUInt32(ref omsg, FLUtility.CreateID(acct.Appearance.Voice));
                    FLMsgType.AddUInt32(ref omsg, acct.Rank);
                    FLMsgType.AddUInt32(ref omsg, 0);
                    FLMsgType.AddFloat(ref omsg, acct.ShipState.Hull);
                    FLMsgType.AddUInt32(ref omsg, 0);
                    FLMsgType.AddUInt32(ref omsg, 0);
                    FLMsgType.AddUInt32(ref omsg, 0);

                    FLMsgType.AddUInt8(ref omsg, 1);
                    FLMsgType.AddUInt32(ref omsg, acct.Appearance.Body);
                    FLMsgType.AddUInt32(ref omsg, acct.Appearance.Head);
                    FLMsgType.AddUInt32(ref omsg, acct.Appearance.LeftHand);
                    FLMsgType.AddUInt32(ref omsg, acct.Appearance.RightHand);
                    FLMsgType.AddUInt32(ref omsg, 0);

                    FLMsgType.AddUInt8(ref omsg, 1);
                    FLMsgType.AddUInt32(ref omsg, acct.Appearance.Body);
                    FLMsgType.AddUInt32(ref omsg, acct.Appearance.Head);
                    FLMsgType.AddUInt32(ref omsg, acct.Appearance.LeftHand);
                    FLMsgType.AddUInt32(ref omsg, acct.Appearance.RightHand);
                    FLMsgType.AddUInt32(ref omsg, 0);

                    FLMsgType.AddUInt8(ref omsg, (uint)acct.Equipment.Count);
                    uint hpid = 2;
                    foreach (var item in acct.Equipment)
                    {
                        //item.count?
                        FLMsgType.AddUInt32(ref omsg, 1);
                        FLMsgType.AddFloat(ref omsg, item.Health);
                        FLMsgType.AddUInt32(ref omsg, item.Arch);
                        FLMsgType.AddUInt16(ref omsg, hpid);
                        hpid++;
                        //item.mounted
                        FLMsgType.AddUInt16(ref omsg, (1u));
                        if (item.HpName != "")
                        {
                            FLMsgType.AddAsciiStringLen16(ref omsg, item.HpName + "\0");
                        }
                        else
                        {
                            FLMsgType.AddAsciiStringLen16(ref omsg, "BAY\0");
                        }
                    }

                    FLMsgType.AddUInt32(ref omsg, 0);

                    omsg[2]++;
                    //}
                    //catch (Exception e)
                    //{
                    //    _log.Error("Corrupt character when processing charinforequest '{0}'",
                    //        e.Message);
                    //}
                }
            }
            FLMsgType.AddUInt32(ref omsg, 0);
            Context.Sender.Tell(omsg);
        }
コード例 #22
0
        public static void LoadMBase(DataFile file)
        {
            Base.Base bd = null;
            //That's lame but the mbases retarded file format gives us no chance
            foreach (var sec in file.Sections)
            {
                switch (sec.Name.ToLowerInvariant())
                {
                case "mbase":
                    bd = GetBase(sec.GetFirstOf("nickname")[0]);
                    if (bd == null)
                    {
                        Logger.Warn("LOAD Unknown base in MBases: {0}", sec.GetFirstOf("nickname")[0]);
                    }
                    break;

                case "mvendor":
                    break;

                case "basefaction":
                    break;

                case "gf_npc":
                    if (bd == null)
                    {
                        continue;
                    }

                    var bc = new Character
                    {
                        Nickname = sec.GetFirstOf("nickname")[0]
                    };



                    Setting set;
                    if (sec.TryGetFirstOf("base_appr", out set))
                    {
                        //TODO: get from base_appr
                    }
                    else
                    {
                        bc.Body      = FLUtility.CreateID(sec.GetFirstOf("body")[0]);
                        bc.Head      = FLUtility.CreateID(sec.GetFirstOf("head")[0]);
                        bc.Lefthand  = FLUtility.CreateID(sec.GetFirstOf("lefthand")[0]);
                        bc.Righthand = FLUtility.CreateID(sec.GetFirstOf("righthand")[0]);
                    }
                    bc.Voice          = FLUtility.CreateID(sec.GetFirstOf("voice")[0]);
                    bc.IndividualName = FLUtility.CreateID(sec.GetFirstOf("individual_name")[0]);

                    bc.Faction = sec.GetFirstOf("affiliation")[0];

                    if (sec.TryGetFirstOf("room", out set))
                    {
                        bc.Room = String.Format("{0:x}_{1}", bd.BaseID, set[0].ToLowerInvariant());
                        //bc.RoomID = Utilities.CreateID(bc.Room);
                    }

                    foreach (var bb in sec.GetSettings("bribe").Select(bset => new CharBribe
                    {
                        Faction = bset[0],
                        Cost = uint.Parse(bset[1]),
                        Text = uint.Parse(bset[2])
                    }))
                    {
                        bc.Bribes.Add(bb);
                    }

                    //TODO: unused fields in rumor
                    foreach (var br in sec.GetSettings("rumor").
                             Select(rset => new BaseRumor {
                        Text = uint.Parse(rset[3])
                    }))
                    {
                        bc.Rumors.Add(br);
                    }

                    bd.Chars[bc.Nickname] = bc;
                    break;

                case "mroom":
                    if (bd == null)
                    {
                        continue;
                    }
                    var rnick = sec.GetFirstOf("nickname")[0].ToLowerInvariant();

                    Setting tSetting;

                    if (sec.TryGetFirstOf("character_density", out tSetting))
                    {
                        if (!bd.Rooms.ContainsKey(rnick))
                        {
                            Logger.Warn("LOAD MRoom definition for nonexistent room {0} in {1}", rnick, bd.Nickname);
                            continue;
                        }

                        bd.Rooms[rnick].CharacterDensity = uint.Parse(tSetting[0]);
                    }

                    if (sec.TryGetFirstOf("fixture", out tSetting))
                    {
                        //TODO: all tolower?
                        string name          = tSetting[0];
                        string roomLocation  = tSetting[1];
                        string fidget_script = tSetting[2];
                        string type          = tSetting[3];

                        if (!bd.Chars.ContainsKey(name))
                        {
                            //log.AddLog(LogType.ERROR, "character not found at {0}", set.Desc);
                            Logger.Warn("LOAD Fixture for unknown character in MBases: {0} {1}", name, bd.Nickname);
                            continue;
                        }

                        bd.Chars[name].Room = String.Format("{0:x}_{1}", bd.BaseID, rnick);
                        //bd.Chars[name].RoomID = Utilities.CreateID(bd.Chars[name].Room);
                        bd.Chars[name].RoomLocation = roomLocation;
                        bd.Chars[name].FidgetScript = fidget_script;
                        bd.Chars[name].Type         = type;
                    }

                    break;
                }
            }
        }
コード例 #23
0
 public static Base.Base GetBase(string nickname)
 {
     return(GetBase(FLUtility.CreateID(nickname)));
 }
コード例 #24
0
        /// <summary>
        ///     Load the specified character file, resetting all character specific
        ///     content for this player and notifying all players of the name.
        /// </summary>
        /// <param name="account">Player account</param>
        /// <param name="log"></param>
        /// <returns>Returns null on successful load otherwise returns error message as a string.</returns>
        public string LoadCharFile(Account account, ILogController log)
        {
            if (account == null)
            {
                log.AddLog(LogType.ERROR, "Broken account found!");
                return("Account is null!");
            }
            //null checks made earlier
            // ReSharper disable once PossibleInvalidOperationException
            PlayerAccount = account;
            Wgrp          = new WeaponGroup();

// ReSharper disable once PossibleNullReferenceException
            Name  = PlayerAccount.CharName;
            Money = PlayerAccount.Money;

            var arch = ArchetypeDB.Find(PlayerAccount.Ship);

            if (arch is ShipArchetype)
            {
                Ship.Arch = arch;
            }
            else
            {
                return("invalid ship");
            }

            if (ShipState.RepGroup == "")
            {
                Ship.faction = new Faction();
            }
            else
            {
                Ship.faction = UniverseDB.FindFaction(ShipState.RepGroup);
                if (Ship.faction == null)
                {
                    return("invalid faction");
                }
            }

            Ship.System = UniverseDB.FindSystem(PlayerAccount.System);
            if (Ship.System == null)
            {
                return("invalid system");
            }

            if (ShipState.Base == null)
            {
                Ship.Basedata = null;
            }
            else
            {
                Ship.Basedata = UniverseDB.FindBase(ShipState.Base);
                if (Ship.Basedata == null)
                {
                    return("invalid base");
                }
            }

            if (ShipState.LastBase == "")
            {
                Ship.RespawnBasedata = null;
                return("no respawn base");
            }

            Ship.RespawnBasedata = UniverseDB.FindBase(ShipState.LastBase);
            if (Ship.RespawnBasedata == null)
            {
                return("invalid respawn base");
            }



            if (Ship.Basedata == null)
            {
                if (ShipState.Position != null)
                {
                    Ship.Position = ShipState.Position;
                }

                if (ShipState.Rotate != null)
                {
                    Ship.Orientation = Matrix.EulerDegToMatrix(ShipState.Rotate);
                }
            }

            //TODO: why ShipState.Hull is always true
            Ship.Health = ShipState.Hull;
            if (Ship.Health <= 0)
            {
                Ship.Health = 0.05f;
            }

            Ship.voiceid = FLUtility.CreateID(Appearance.Voice);

            //TODO: calculate rank
// ReSharper disable once PossibleNullReferenceException
            Ship.Rank = PlayerAccount.Rank;

            Ship.com_body      = Appearance.Body;
            Ship.com_head      = Appearance.Head;
            Ship.com_lefthand  = Appearance.LeftHand;
            Ship.com_righthand = Appearance.RightHand;

            Ship.Items.Clear();

            uint hpid = 34;

            foreach (var set in Equipment)
            {
                var si = new ShipItem
                {
                    arch    = ArchetypeDB.Find(set.Arch),
                    hpname  = set.HpName,
                    health  = set.Health,
                    count   = 1,
                    mission = false,
                    mounted = true,
                    hpid    = hpid++
                };
                Ship.Items[si.hpid] = si;
            }

            foreach (var set in Cargo)
            {
                var si = new ShipItem
                {
                    arch    = ArchetypeDB.Find(set.Arch),
                    hpname  = "",
                    count   = set.Count,
                    health  = 1.0f,
                    mission = false,
                    mounted = false,
                    hpid    = hpid++
                };
                Ship.Items[si.hpid] = si;
            }

            Ship.Reps.Clear();


            foreach (var set in RepDictionary)
            {
                float rep     = set.Value;
                var   faction = UniverseDB.FindFaction(set.Key);
                if (faction == null)
                {
// ReSharper disable once PossibleNullReferenceException
                    log.AddLog(LogType.ERROR, "error: faction not found char={0} faction={1}", account.CharName,
                               set.Value);
                }
                else
                {
                    Ship.Reps[faction] = rep;
                }
            }


            //Visits.Clear();
            //foreach (var set in Visits)
            //{
            //    Visits[set.Key] = set.Value;
            //}

            Ship.CurrentAction = null;

            return(null);
        }
コード例 #25
0
        /// <summary>
        ///     Load a single system
        /// </summary>
        /// <param name="path"></param>
        /// <param name="system"></param>
        /// <param name="log"></param>
        private static void LoadSystem(string path, StarSystem system, ILogController log)
        {
            try
            {
                var ini = new FLDataFile(path, true);
                foreach (FLDataFile.Section sec in ini.Sections)
                {
                    string sectionName = sec.SectionName.ToLowerInvariant();
                    if (sectionName == "zone")
                    {
                        var zone = new Zone {
                            shape = null, nickname = sec.GetSetting("nickname").Str(0)
                        };
                        zone.zoneid = FLUtility.CreateID(zone.nickname);

                        Vector position    = sec.GetSetting("pos").Vector();
                        var    orientation = new Matrix();

                        double[] size = null;

                        string shape = sec.GetSetting("shape").Str(0).ToLowerInvariant();

                        foreach (FLDataFile.Setting set in sec.Settings)
                        {
                            string settingName = set.SettingName.ToLowerInvariant();
                            switch (settingName)
                            {
                            case "rotation":
                                orientation = Matrix.EulerDegToMatrix(set.Vector());
                                break;

                            case "size":
                                size = new double[set.NumValues()];
                                for (int a = 0; a < size.Length; a++)
                                {
                                    size[a] = set.Float(a);
                                }
                                break;

                            case "damage":
                                zone.damage = set.Float(0);
                                break;

                            case "interference":
                                zone.interference = set.Float(0);
                                break;

                            case "encounter":
                                break;

                            case "faction":
                                break;

                            case "density":
                                zone.density = set.Float(0);
                                break;
                            }
                        }

                        if (size != null)
                        {
                            if (shape == "sphere" && size.Length == 1)
                            {
                                zone.shape = new Sphere(position, orientation, size[0]);
                            }
                            else if (shape == "cylinder" && size.Length == 2)
                            {
                                zone.shape = new Cylinder(position, orientation, size[0], size[1]);
                            }
                            else if (shape == "ellipsoid" && size.Length == 3)
                            {
                                zone.shape = new Ellipsoid(position, orientation, new Vector(size[0], size[1], size[2]));
                            }
                            else if (shape == "box" && size.Length == 3)
                            {
                                zone.shape = new Box(position, orientation, new Vector(size[0], size[1], size[2]));
                            }
                            else if (shape == "ring" && size.Length == 3)
                            {
                                zone.shape = new Ring(position, orientation, size[0], size[1], size[2]);
                            }
                        }

                        system.Zones.Add(zone);
                    }
                    else if (sectionName == "object")
                    {
                        var solar = new Object.Solar.Solar(system, sec.GetSetting("nickname").Str(0));

                        if (sec.SettingExists("pos"))
                        {
                            solar.Position = sec.GetSetting("pos").Vector();
                        }

                        if (sec.SettingExists("rotate"))
                        {
                            Vector euler = sec.GetSetting("rotate").Vector();
                            solar.Orientation = Matrix.EulerDegToMatrix(euler);
                        }

                        if (sec.SettingExists("base"))
                        {
                            // When a ship undocks, it undocks from the solar specified by baseid.
                            // uint baseid = FLUtility.CreateID(sec.GetSetting("base").Str(0));
                            // FIXME: check base exists
                            // solar.base_data = bases[baseid];
                            // bases[baseid].solar = solar;
                        }

                        if (sec.SettingExists("archetype"))
                        {
                            uint archetypeid = FLUtility.CreateID(sec.GetSetting("archetype").Str(0));
                            solar.Arch = ArchetypeDB.Find(archetypeid);
                            solar.GetLoadout();
                            // FIXME: check archetype exists
                        }

                        if (sec.SettingExists("dock_with"))
                        {
                            uint baseid = FLUtility.CreateID(sec.GetSetting("dock_with").Str(0));
                            solar.BaseData = Bases[baseid];
                        }

                        if (sec.SettingExists("goto"))
                        {
                            solar.DestinationObjid    = FLUtility.CreateID(sec.GetSetting("goto").Str(1));
                            solar.DestinationSystemid = FLUtility.CreateID(sec.GetSetting("goto").Str(0));
                        }

                        if (sec.SettingExists("prev_ring"))
                        {
                            solar.PrevRing = FLUtility.CreateID(sec.GetSetting("prev_ring").Str(0));
                        }

                        if (sec.SettingExists("next_ring"))
                        {
                            solar.NextRing = FLUtility.CreateID(sec.GetSetting("next_ring").Str(0));
                        }

                        if (sec.SettingExists("reputation"))
                        {
                            Faction faction = FindFaction(sec.GetSetting("reputation").Str(0));
                            if (faction == null)
                            {
                                log.AddLog(LogType.ERROR, "error: not valid faction={0}",
                                           sec.GetSetting("reputation").Str(0));
                            }
                            else
                            {
                                solar.Faction = faction;
                            }
                        }

                        // Rebuild the docking points from the archetype
                        // to the solar position and rotation.
                        foreach (DockingPoint dockingPoint in solar.Arch.DockingPoints)
                        {
                            var dockingObj = new DockingObject
                            {
                                Type          = dockingPoint.Type,
                                Solar         = solar,
                                Index         = (uint)solar.Arch.DockingPoints.IndexOf(dockingPoint),
                                DockingRadius = dockingPoint.DockingRadius,
                                Position      = solar.Orientation * dockingPoint.Position
                            };

                            // rotate the hardpoint by the base orientation and then
                            dockingObj.Position += solar.Position;

                            // the ship launch rotation is the base rotation rotated by the hardpoint rotation
                            dockingObj.Rotation = dockingPoint.Rotation * solar.Orientation;

                            if (solar.BaseData != null)
                            {
                                solar.BaseData.LaunchObjs.Add(dockingObj);
                            }

                            solar.DockingObjs.Add(dockingObj);
                        }


                        // Store the solar.
                        system.Solars[solar.Objid] = solar;
                        Solars[solar.Objid]        = solar;

                        if (solar.Arch.Type == Archetype.ObjectType.JUMP_GATE ||
                            solar.Arch.Type == Archetype.ObjectType.JUMP_HOLE)
                        {
                            system.Gates.Add(solar);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                log.AddLog(LogType.ERROR, "error: '" + e.Message + "' when parsing '" + path);
                if (e.InnerException != null)
                {
                    log.AddLog(LogType.ERROR, "error: '" + e.InnerException.Message + "' when parsing '" + path);
                }
            }
        }
コード例 #26
0
        /// <summary>
        ///     Load the universe
        /// </summary>
        /// <param name="path"></param>
        /// <param name="log"></param>
        private static void LoadUniverse(string path, ILogController log)
        {
            var universePath = Path.GetDirectoryName(path);
            var fldatapath   = Directory.GetParent(universePath).FullName;

            var ini = new FLDataFile(path, true);

            foreach (FLDataFile.Section sec in ini.Sections)
            {
                string sectionName = sec.SectionName.ToLowerInvariant();
                if (sectionName == "system")
                {
                    var system = new StarSystem {
                        Nickname = sec.GetSetting("nickname").Str(0)
                    };
                    system.SystemID = FLUtility.CreateID(system.Nickname);
                    LoadSystem(universePath + Path.DirectorySeparatorChar + sec.GetSetting("file").Str(0), system, log);
                    Systems[system.SystemID] = system;
                }
                else if (sectionName == "base")
                {
                    var basedata = new BaseData {
                        Nickname = sec.GetSetting("nickname").Str(0)
                    };
                    basedata.BaseID   = FLUtility.CreateID(basedata.Nickname);
                    basedata.SystemID = FLUtility.CreateID(sec.GetSetting("system").Str(0));
                    LoadBase(fldatapath, fldatapath + Path.DirectorySeparatorChar + sec.GetSetting("file").Str(0),
                             basedata, log);
                    Bases[basedata.BaseID] = basedata;
                }
            }

            // FIXME: Might want to dump this information to disk

            foreach (var syspair1 in Systems)
            {
                var systemMinDist = new Dictionary <uint, PathData>();
                var systemNext    = new Dictionary <uint, PathData>();
                foreach (var syspair2 in Systems)
                {
                    systemMinDist.Add(syspair2.Key, syspair1.Key == syspair2.Key ? 0 : ((uint)Systems.Count + 1));
                    systemNext.Add(syspair2.Key, 0);
                }
                MinimumDistances.Add(syspair1.Key, systemMinDist);
                NextIndex.Add(syspair1.Key, systemNext);

                syspair1.Value.CalculatePathfinding();
            }

            foreach (var syspair in Systems)
            {
                foreach (Object.Solar.Solar s in syspair.Value.Gates)
                {
                    PathData pd = MinimumDistances[syspair.Key][s.DestinationSystemid];
                    if (s.Arch.Type == Archetype.ObjectType.JUMP_GATE)
                    {
                        pd.Shortest = pd.Legal = 1;
                    }
                    else
                    {
                        pd.Shortest = pd.Illegal = 1;
                    }
                    MinimumDistances[syspair.Key][s.DestinationSystemid] = pd;
                }
            }

            foreach (var k in Systems)
            {
                foreach (var i in Systems)
                {
                    foreach (var j in Systems)
                    {
                        for (int x = -1; x <= 1; x++)
                        {
                            uint testDistance = MinimumDistances[i.Key][k.Key][x] + MinimumDistances[k.Key][j.Key][x];
                            if (testDistance < MinimumDistances[i.Key][j.Key][x])
                            {
                                PathData min = MinimumDistances[i.Key][j.Key];
                                min[x] = testDistance;
                                MinimumDistances[i.Key][j.Key] = min;

                                PathData index = NextIndex[i.Key][j.Key];
                                index[x] = k.Key;
                                NextIndex[i.Key][j.Key] = index;
                            }
                        }
                    }
                }
            }
        }
コード例 #27
0
        public void Handle(CharSelected message)
        {
            _account = message.Account;
            _socket  = Context.Sender;

            Context.Child("listhandler").Tell(_socket);
            Context.Child("listhandler").Tell(new SetListData(_flplayerID, 0, _account.Rank, FLUtility.CreateID(_account.System), _account.CharName));
            //Sender is socket

            // Reset the player list. I'm not certain that this is necessary.
            {
                byte[] omsg = { 0x52, 0x02 };
                FLMsgType.AddUInt32(ref omsg, 0);
                FLMsgType.AddUInt32(ref omsg, 0);
                FLMsgType.AddUInt8(ref omsg, 0);
                FLMsgType.AddUInt8(ref omsg, 0);
                Sender.Tell(omsg);
            }

            //TODO: should we hide em sometime? Admins etc.
            Context.ActorSelection("../*/listhandler").Tell(new PlayerJoined(_account.CharName, message.FLPlayerID), Context.Child("listhandler"));
            //TODO: initiate ShipData and pass to ./ship
        }
コード例 #28
0
            public override void HandleTimerEvent(double deltaSeconds)
            {
                if (runner.System == UniverseDB.FindSystem("li01"))
                {
                    //TODO: AI debug here
                    for (int i = 0; i < 1; i++)
                    {
                        var npc = new Old.Object.Ship.Ship(runner);
                        npc.AI   = new AI.DebugAI(npc);
                        npc.Arch = ArchetypeDB.Find(FLUtility.CreateID("dsy_csv"));
                        if (npc.Arch == null)
                        {
                            return;
                        }

                        npc.Position = new Vector(-30000 + i * 300, i * 100, -25000);
                        //npc.orientation = ;
                        npc.Rank    = 20;
                        npc.System  = runner.System;
                        npc.Health  = 1.0f;
                        npc.faction = UniverseDB.FindFaction("fc_wild");
                        Loadout loadout = UniverseDB.FindLoadout("fc_j_ge_csv_loadout01");
                        if (loadout != null)
                        {
                            uint hpid = 34;
                            foreach (ShipItem item in loadout.Items)
                            {
                                var new_item = new ShipItem();
                                new_item.arch    = item.arch;
                                new_item.count   = item.count;
                                new_item.health  = 1.0f;
                                new_item.hpid    = hpid++;
                                new_item.hpname  = item.hpname;
                                new_item.mounted = item.mounted;
                                npc.Items.Add(new_item.hpid, new_item);
                            }
                        }
                        npc.InitialiseEquipmentSimulation();
                        runner.CreateSimObject(npc);
                    }
                }
                //    int total = 0;
                //    if (runner.players.Count > 0)
                //    {
                //        if (delta_seconds > 1.5)
                //            runner.log.AddLog(LogType.FL_MSG, "bad delta " + delta_seconds);

                //        // wow, this'll really suck if there are lots of NPCs
                //        foreach (Zone z in runner.system.zones)
                //        {
                //            if (z.shape != null && z.density > 0)
                //            {
                //                while (z.interference < z.density) // borrow this
                //                {
                //                    Ship npc = new Ship(runner);
                //                    npc.position = z.shape.position;
                //                    npc.orientation = z.shape.orientation;
                //                    npc.rank = 20;
                //                    npc.arch = ArchetypeDB.Find(FLUtility.CreateID("dsy_csv"));
                //                    npc.system = runner.system;
                //                    npc.health = 1.0f;
                //                    runner.CreateSimObject(npc);

                //                    z.interference++;
                //                    total++;
                //                }
                //            }
                //        }

                //        int working_npcs = 0;
                //        foreach (SimObject o in runner.objects.Values)
                //        {
                //            if (o.health > 0)
                //            {
                //                working_npcs++;

                //                foreach (Player player in runner.players.Values)
                //                {
                //                    if (player.ship != o)
                //                    {
                //                        Vector position = player.ship.position;
                //                        position.x += rand.Next(100);
                //                        position.z += rand.Next(100);
                //                        o.SetUpdateObject(position, player.ship.orientation, 1.0f, 0);
                //                    }
                //                }
                //            }
                //        }

                //        runner.log.AddLog(LogType.GENERAL, "system={0} npcs={1} objects={2} running={3}",
                //            runner.system.nickname, total, runner.objects.Count, working_npcs));

                //    }

                //    ExpireAfter(1);
            }
コード例 #29
0
 public static Loadout FindLoadout(string nickname)
 {
     return(FindLoadout(FLUtility.CreateID(nickname)));
 }