Ejemplo n.º 1
0
        public EditReps(FLGameData gameData, string itemNickName, FLDataFile cfgFile)
        {
            InitializeComponent();

            this.itemNickName = itemNickName;
            this.cfgFile      = cfgFile;
            this.Text         = "Edit Reputations: " + gameData.GetItemDescByNickNameX(itemNickName);

            GameDataSet.HashListRow[] factions = (GameDataSet.HashListRow[])gameData.DataStore.HashList.Select("ItemType = '" + FLGameData.GAMEDATA_FACTIONS + "'");
            foreach (GameDataSet.HashListRow faction in factions)
            {
                uIDataSet.RepFixerItemFactions.AddRepFixerItemFactionsRow(faction.IDSName, faction.ItemNickName, "");
            }

            foreach (FLDataFile.Setting set in cfgFile.GetSettings(itemNickName))
            {
                string factionNick = set.settingName;

                string repStr = "-";
                if (set.NumValues() > 0)
                {
                    string[] values = set.Str(0).Split(',');
                    if (values.Length == 2)
                    {
                        int mode;
                        if (!Int32.TryParse(values[1], out mode))
                        {
                            repStr = "ERR";
                        }
                        else if (mode == MODE_REP_GREATERTHAN)
                        {
                            repStr = ">";
                        }
                        else if (mode == MODE_REP_STATIC)
                        {
                            repStr = "=";
                        }
                        else
                        {
                            repStr = "<";
                        }

                        float rep;
                        if (!Single.TryParse(values[0], out rep))
                        {
                            repStr = "ERR";
                        }
                        else if (rep > 1.0 || rep < -1.0)
                        {
                            repStr = "ERR";
                        }
                        else
                        {
                            repStr += rep.ToString();
                        }
                    }
                    else if (values.Length == 1)
                    {
                        float rep;
                        if (!Single.TryParse(values[0], out rep))
                        {
                            repStr = "ERR";
                        }
                        else if (rep > 1.0 || rep < -1.0)
                        {
                            repStr = "ERR";
                        }
                        repStr = "<" + rep.ToString();
                    }
                }

                foreach (UIDataSet.RepFixerItemFactionsRow faction in uIDataSet.RepFixerItemFactions.Rows)
                {
                    if (faction.ItemNickName == factionNick)
                    {
                        faction.Reputation = repStr;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void  bgWkr_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            bgWkr = null;

            buttonRepAddItem.Enabled = true;
            buttonRepEditItem.Enabled = true;
            buttonRepDelItem.Enabled = true;
            button3.Enabled = true;
            buttonAddBase.Enabled = true;
            buttonDelBase.Enabled = true;
            buttonAddItem.Enabled = true;
            buttonDelItem.Enabled = true;
            buttonSave.Enabled = true;
            buttonPurchaseRestrictionAddItem.Enabled = true;
            buttonPurchaseRestrictionEdittem.Enabled = true;
            buttonPurchaseRestrictionDelItem.Enabled = true;
            buttonEquipPurchaseRestrictionAdd.Enabled = true;
            buttonEquipPurchaseRestrictionEdit.Enabled = true;
            buttonEquipPurchaseRestrictionDel.Enabled = true;
            buttonSysSensorEditItem.Enabled = true;
            buttonSysSensorAddItem.Enabled = true;
            buttonSysSensorDelItem.Enabled = true;

            // Load our ini file
            try
            {
                cfgFilePath = Path.GetFullPath(cfgFilePath);
                cfgFile = new FLDataFile(cfgFilePath, false);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error '" + ex.Message + "' occured when loading the configuration file. Using defaults.");
            }

            try
            {
                checkBoxEnableMoveChar.Checked = cfgFile.GetSettingBool("General", "EnableMoveChar", true);
                checkBoxEnableRenameMe.Checked = cfgFile.GetSettingBool("General", "EnableRenameMe", true);
                checkBoxEnablePimpShip.Checked = cfgFile.GetSettingBool("General", "EnablePimpShip", true);
                checkBoxEnableRestart.Checked = cfgFile.GetSettingBool("General", "EnableRestart", true);
                checkBoxEnableGiveCash.Checked = cfgFile.GetSettingBool("General", "EnableGiveCash", true);
                checkBoxEnableDropRepAndMisc.Checked = cfgFile.GetSettingBool("General", "EnableDropRep", true);

                textBoxDropRepCost.Text = cfgFile.GetSettingStr("General", "RepDropCost", "350000");
                textBoxStuckMsg.Text = cfgFile.GetSettingStr("General", "StuckMsg", "Attention! Stand clear. Towing %player");
                textBoxDiceMsg.Text = cfgFile.GetSettingStr("General", "DiceMsg", "%player rolled %number");
                textBoxCoinMsg.Text = cfgFile.GetSettingStr("General", "CoinMsg", "%player tossed %result");
                textBoxSmiteMusic.Text = cfgFile.GetSettingStr("General", "SmiteMusic", "music_danger");

                textBoxDisconnectingPlayersRange.Text = cfgFile.GetSettingStr("General", "DisconnectingPlayersRange", "5000");
                checkBoxReportDisconnectingPlayers.Checked = cfgFile.GetSettingBool("General", "ReportDisconnectingPlayers", true);
                checkBoxKillDisconnectingPlayers.Checked = cfgFile.GetSettingBool("General", "KillDisconnectingPlayers", true);
                checkBoxLootDisconnectingPlayers.Checked = cfgFile.GetSettingBool("General", "LootDisconnectingPlayers", true);

                textBoxHullDropFactor.Text = cfgFile.GetSettingStr("General", "HullDropFactor", "0.0");
                textBoxCargoDropContainer.Text = cfgFile.GetSettingStr("General", "CargoDropContainer", "lootcrate_ast_loot_metal");
                textBoxHullDrop1NickName.Text = cfgFile.GetSettingStr("General", "HullDrop1NickName", "commodity_super_alloys");
                textBoxHullDrop2NickName.Text = cfgFile.GetSettingStr("General", "HullDrop2NickName", "commodity_engine_components");
                textBoxDisconnectMsg.Text = cfgFile.GetSettingStr("General", "DisconnectMsg", "%player is attempting to engage cloaking device");

                textBoxSpinProtectMass.Text = cfgFile.GetSettingStr("General", "SpinProtectionMass", "-1.0");
                textBoxSpinImpulseMultiplier.Text = cfgFile.GetSettingStr("General", "SpinProtectionMultiplier", "-8.0");

                checkBoxEnableEscort.Checked = cfgFile.GetSettingBool("General", "EnableEscort", false);
                textBoxEscortedShipMinimumMass.Text = cfgFile.GetSettingStr("General", "EscortedShipMinimumMass", "100000");
                textBoxEscortedShipDamageFactor.Text = cfgFile.GetSettingStr("General", "EscortedShipDamageFactor", "0.3");

                textBoxRestartMaxRank.Text = cfgFile.GetSettingStr("Restart", "MaxRank", "5");
                textBoxRestartMaxCash.Text = cfgFile.GetSettingStr("Restart", "MaxCash", "1000000");

                textBoxRenameCost.Text = cfgFile.GetSettingStr("Rename", "RenameCost", "2000000");
                textBoxRenameTimeLimit.Text = cfgFile.GetSettingStr("Rename", "RenameTimeLimit", "86400");
                textBoxMoveCost.Text = cfgFile.GetSettingStr("Rename", "MoveCost", "2000000");
                checkBoxCharnameTag.Checked = cfgFile.GetSettingBool("Rename", "CharnameTag", false);
                textBoxCharnameTagCost.Text = cfgFile.GetSettingStr("Rename", "MakeTagCost", "50000000");
                checkBoxAsciiCharnameOnly.Checked = cfgFile.GetSettingBool("Rename", "AsciiCharnameOnly", false);
                

                textBoxMinTransfer.Text = cfgFile.GetSettingStr("GiveCash", "MinTransfer", "100000");
                textBoxMinTime.Text = cfgFile.GetSettingStr("GiveCash", "MinTime", "3600");
                textBoxBlockedSystem.Text = cfgFile.GetSettingStr("GiveCash", "BlockedSystem", "iw09");

                textBoxPimpShipCost.Text = cfgFile.GetSettingStr("ShipPimper", "cost", "2000000");
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("ShipPimper", "equip"))
                {
                    string[] args = set.Str(0).Split(',');
                    if (args.Length > 0)
                    {
                        GameDataSet.HashListRow item = gameData.GetItemByNickName(args[0]);
                        if (item != null)
                        {
                            uIDataSet.ShipPimperItemList.AddShipPimperItemListRow(item.IDSName, item.ItemNickName, item.ItemHash, item.IDSInfo, item.IDSInfo1);
                        }
                    }
                }

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("ShipPimper", "room"))
                {
                    GameDataSet.HashListRow item = gameData.GetItemByNickName(set.Str(0));
                    if (item != null)
                    {
                        uIDataSet.ShipPimperBaseList.AddShipPimperBaseListRow(item.IDSName, item.ItemNickName, item.ItemHash, item.IDSInfo, item.IDSInfo1);
                    }
                }

                checkBoxEnableRepFixUpdates.Checked = cfgFile.GetSettingBool("RepFixer", "EnableRepFixUpdates", true);
                checkBoxLogRepFixUpdates.Checked = cfgFile.GetSettingBool("RepFixer", "LogRepFixUpdates", true);
                checkBoxItemMustBeMounted.Checked = cfgFile.GetSettingBool("RepFixer", "ItemMustBeMounted", true);

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("RepFixerItems"))
                {
                    GameDataSet.HashListRow item = gameData.GetItemByNickName(set.settingName);
                    if (item != null)
                    {
                        uIDataSet.RepFixerItemList.AddRepFixerItemListRow(item.IDSName, item.ItemNickName, item.ItemHash, item.IDSInfo, item.IDSInfo1);
                    }
                }

                checkBoxCheckIDRestrictions.Checked = cfgFile.GetSettingBool("PurchaseRestrictions", "CheckIDRestrictions", false);
                checkBoxEnforceIDRestrictions.Checked = cfgFile.GetSettingBool("PurchaseRestrictions", "EnforceIDRestrictions", false);
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("ShipItemRestrictions"))
                {
                    GameDataSet.HashListRow shipItem = gameData.GetItemByNickName(set.settingName);
                    GameDataSet.HashListRow controlItem = gameData.GetItemByNickName(set.Str(0));
                    if (shipItem != null && controlItem != null)
                    {
                        uIDataSet.ShipPurchaseRestrictionItems.AddShipPurchaseRestrictionItemsRow(shipItem.IDSName, shipItem.ItemNickName, controlItem.IDSName, controlItem.ItemNickName);
                    }
                }

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("GoodItemRestrictions"))
                {
                    GameDataSet.HashListRow equipItem = gameData.GetItemByNickName(set.settingName);
                    GameDataSet.HashListRow controlItem = gameData.GetItemByNickName(set.Str(0));
                    if (equipItem != null && controlItem != null)
                    {
                        uIDataSet.EquipPurchaseRestrictionItems.AddEquipPurchaseRestrictionItemsRow(equipItem.IDSName, equipItem.ItemNickName, controlItem.IDSName, controlItem.ItemNickName);
                    }
                }

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("NoBuy"))
                {
                    GameDataSet.HashListRow baseItem = gameData.GetItemByNickName(set.settingName);
                    GameDataSet.HashListRow goodItem = gameData.GetItemByNickName(set.Str(0));
                    if (baseItem != null && goodItem != null)
                    {
                        uIDataSet.BaseGoodNoBuyList.AddBaseGoodNoBuyListRow(baseItem.IDSName, baseItem.ItemNickName, goodItem.IDSName, goodItem.ItemNickName);
                    }
                }

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("SystemSensor"))
                {
                    GameDataSet.HashListRow sysItem = gameData.GetItemByNickName(set.settingName);
                    string[] args = set.Str(0).Split(',');
                    if (args.Length > 0)
                    {
                        GameDataSet.HashListRow equipItem = gameData.GetItemByNickName(args[0]);
                        uint networkID = 1;
                        if (args.Length > 1)
                            networkID = UInt32.Parse(args[1]);
                        if (sysItem != null && equipItem != null)
                        {
                            uIDataSet.SysSensorList.AddSysSensorListRow(sysItem.IDSName, sysItem.ItemNickName, equipItem.IDSName, equipItem.ItemNickName, networkID);
                        }
                    }
                }

                checkBoxCustomHelp.Checked = cfgFile.GetSettingBool("Message", "CustomHelp", true);
                checkBoxCmdEcho.Checked = cfgFile.GetSettingBool("Message", "CmdEcho", true);
                checkBoxCmdHide.Checked = cfgFile.GetSettingBool("Message", "CmdHide", true);
                textBoxCmdEchoStyle.Text = cfgFile.GetSettingStr("Message", "CmdEchoStyle", "0x00AA0090");

                richTextBoxHelpLines.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("Help"))
                {
                    richTextBoxHelpLines.AppendText(set.settingName);
                    richTextBoxHelpLines.AppendText("\n");
                }

                richTextBoxSwearWords.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("SwearWords"))
                {
                    richTextBoxSwearWords.AppendText(set.Str(0));
                    richTextBoxSwearWords.AppendText("\n");
                }

                richTextBoxGreetingBannerLines.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("GreetingBanner"))
                {
                    richTextBoxGreetingBannerLines.AppendText(set.Str(0));
                    richTextBoxGreetingBannerLines.AppendText("\n");
                }

                textBoxSpecialBannerDelay.Text = cfgFile.GetSettingStr("Message", "SpecialBannerDelay", "3000");
                textBoxStandardBannerDelay.Text = cfgFile.GetSettingStr("Message", "StandardBannerDelay", "1200");

                richTextBoxSpecialBannerLines.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("SpecialBanner"))
                {
                    richTextBoxSpecialBannerLines.AppendText(set.Str(0));
                    richTextBoxSpecialBannerLines.AppendText("\n");
                }

                uIDataSet.StandardBannerList.Clear();
                foreach (FLDataFile.Section sect in cfgFile.sections)
                {
                    if (sect.sectionName == "StandardBanner")
                    {
                        StringBuilder sb = new StringBuilder();
                        foreach (FLDataFile.Setting set in sect.settings)
                        {
                            sb.AppendLine(set.Str(0));
                        }
                        uIDataSet.StandardBannerList.AddStandardBannerListRow(sb.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error '" + ex.Message + "' occured when parsing the configuration file.");
            }

            
        }
Ejemplo n.º 3
0
        public EditReps(FLGameData gameData, string itemNickName, FLDataFile cfgFile)
        {
            InitializeComponent();

            this.itemNickName = itemNickName;
            this.cfgFile = cfgFile;
            this.Text = "Edit Reputations: " + gameData.GetItemDescByNickNameX(itemNickName);

            GameDataSet.HashListRow[] factions = (GameDataSet.HashListRow[])gameData.DataStore.HashList.Select("ItemType = '" + FLGameData.GAMEDATA_FACTIONS + "'");
            foreach (GameDataSet.HashListRow faction in factions)
            {
                uIDataSet.RepFixerItemFactions.AddRepFixerItemFactionsRow(faction.IDSName, faction.ItemNickName, "");
            }

            foreach (FLDataFile.Setting set in cfgFile.GetSettings(itemNickName))
            {
                string factionNick = set.settingName;

                string repStr = "-";
                if (set.NumValues() > 0)
                {
                    string[] values = set.Str(0).Split(',');
                    if (values.Length == 2)
                    {
                        int mode;
                        if (!Int32.TryParse(values[1], out mode))
                            repStr = "ERR";
                        else if (mode == MODE_REP_GREATERTHAN)
                            repStr = ">";
                        else if (mode == MODE_REP_STATIC)
                            repStr = "=";
                        else
                            repStr = "<";

                        float rep;
                        if (!Single.TryParse(values[0], out rep))
                            repStr = "ERR";
                        else if (rep > 1.0 || rep < -1.0)
                            repStr = "ERR";
                        else
                            repStr += rep.ToString();
                    }
                    else if (values.Length == 1)
                    {
                        float rep;
                        if (!Single.TryParse(values[0], out rep))
                            repStr = "ERR";
                        else if (rep > 1.0 || rep < -1.0)
                            repStr = "ERR";
                        repStr = "<" + rep.ToString();
                    }
                }

                foreach (UIDataSet.RepFixerItemFactionsRow faction in uIDataSet.RepFixerItemFactions.Rows)
                {
                    if (faction.ItemNickName == factionNick)
                    {
                        faction.Reputation = repStr;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load all game data.
        /// </summary>
        public void LoadAll(string flExePath, LogRecorderInterface log)
        {
            DataStore.Clear();

            FLDataFile flIni = null;
            try
            {
                flIni = new FLDataFile(flExePath + Path.DirectorySeparatorChar + "Freelancer.ini", true);
            }
            catch (Exception e)
            {
                log.AddLog("Error '" + e.Message + "' when parsing '" + flExePath);
                return;
            }
            string flDataPath = Path.GetFullPath(Path.Combine(flExePath, flIni.GetSetting("Freelancer", "data path").Str(0)));

            log.AddLog("Loading strings...");

            // Load the string dlls.
            LoadLibrary(flExePath + Path.DirectorySeparatorChar + "resources.dll");
            foreach (FLDataFile.Setting flIniEntry in flIni.GetSettings("Resources", "DLL"))
                LoadLibrary(flExePath + Path.DirectorySeparatorChar + flIniEntry.Str(0));

            log.AddLog("Loading universe...");

            // Scan ini files and parse base entries
            foreach (FLDataFile.Setting flIniEntry in flIni.GetSettings("Data", "universe"))
            {
                string iniPath = flDataPath + Path.DirectorySeparatorChar + flIniEntry.Str(0);
                try
                {
                    FLDataFile ini = new FLDataFile(iniPath, true);
                    foreach (FLDataFile.Section section in ini.sections)
                    {
                        try
                        {
                            string sectionName = section.sectionName.ToLowerInvariant();
                            if (sectionName == "base")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_BASES, true);
                                string baseNick = section.GetSetting("nickname").Str(0);
                                string baseFilePath = flDataPath + Path.DirectorySeparatorChar + section.GetSetting("file").Str(0);
                                LoadRoomData(DataStore, baseNick, baseFilePath);
                            }
                            else if (sectionName == "system")
                            {
                                string baseNick = section.GetSetting("nickname").Str(0).ToLowerInvariant();
                                AddGameData(DataStore.HashList, section, GAMEDATA_SYSTEMS, true);
                                string file = Directory.GetParent(ini.filePath).FullName + "\\" + section.GetSetting("file").Str(0);
                                ParseSystem(file, log);
                            }
                        }
                        catch (Exception e)
                        {
                            log.AddLog("Error '" + e.Message + "' when parsing '" + iniPath);
                        }
                    }
                }
                catch (Exception e)
                {
                    log.AddLog("Error '" + e.Message + "' when parsing '" + iniPath);
                }
            }

            log.AddLog("Loading ships...");

            // Scan ship files and parse ship entries
            foreach (FLDataFile.Setting flIniEntry in flIni.GetSettings("Data", "ships"))
            {
                string iniPath = flDataPath + Path.DirectorySeparatorChar + flIniEntry.Str(0);
                try
                {
                    FLDataFile ini = new FLDataFile(iniPath, true);
                    foreach (FLDataFile.Section section in ini.sections)
                    {
                        if (section.sectionName.ToLowerInvariant() == "ship")
                        {
                            AddGameData(DataStore.HashList, section, GAMEDATA_SHIPS, true);

                            string nickName = section.GetSetting("nickname").Str(0);
                            uint hash = FLUtility.CreateID(nickName.ToLowerInvariant());

                            foreach (FLDataFile.Setting setting in section.settings)
                            {
                                try
                                {
                                    if (setting.settingName.ToLowerInvariant() == "da_archetype")
                                    {
                                        // UTF hardpoints are only really useful to validate the shiparch and ship default loadout.
                                        // Don't bother loading them.
                                        // UtfFile utf = new UtfFile(flDataPath + Path.DirectorySeparatorChar + setting.Str(0));
                                        // foreach (string hp in utf.hardpoints)
                                        // {
                                        //    DataStore.HardPointList.AddHardPointListRow(hash, hp, "");
                                        // }
                                    }
                                    else if (setting.settingName.ToLowerInvariant() == "hp_type")
                                    {

                                        string type = setting.Str(0);
                                        for (int i = 1; i < setting.NumValues(); i++)
                                        {
                                            string hp = setting.Str(i);
                                            GameDataSet.HardPointListRow hpInfo = GetHardPointByShipAndHPName(hash, hp);
                                            if (hpInfo == null)
                                                hpInfo = DataStore.HardPointList.AddHardPointListRow(hash, hp, HardpointClassToGameDataClass(type), "", 0);
                                            hpInfo.MountableTypes += " " + type;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    log.AddLog(String.Format("Error '{0}' when reading {1}", ex.Message, setting.desc));
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    log.AddLog("Error '" + e.Message + "' when parsing '" + iniPath);
                }
            }

            log.AddLog("Loading equipment...");

            // Scan ini files and parse equipment entries.
            foreach (FLDataFile.Setting flIniEntry in flIni.GetSettings("Data", "equipment"))
            {
                string iniPath = flDataPath + Path.DirectorySeparatorChar + flIniEntry.Str(0);
                try
                {
                    FLDataFile ini = new FLDataFile(iniPath, true);
                    foreach (FLDataFile.Section section in ini.sections)
                    {
                        try
                        {
                            string sectionName = section.sectionName.ToLowerInvariant();
                            // Internal equipment; these are mounted internally.
                            if (sectionName == "engine")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_ENGINES, true);
                            }
                            else if (sectionName == "power")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_POWERGEN, true);
                            }
                            else if (sectionName == "scanner")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_SCANNERS, true);
                            }
                            else if (sectionName == "tractor")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_TRACTORS, true);
                            }
                            else if (sectionName == "cloakingdevice")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_CLOAK, true);
                            }
                            else if (sectionName == "armor")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_ARMOR, true);
                            }
                            else if (sectionName == "internalfx")
                            {
                                if (section.SettingExists("use_sound"))
                                {
                                    AddGameData(DataStore.HashList, section, GAMEDATA_SOUND, false);
                                }
                            }
                            // External hardpoints.
                            else if (sectionName == "attachedfx")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_FX, false);
                            }
                            else if (sectionName == "light")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_LIGHTS, false);
                            }
                            else if (sectionName == "gun")
                            {
                                if (section.SettingExists("hp_gun_type"))
                                {
                                    string hpType = section.GetSetting("hp_gun_type").Str(0);
                                    AddGameData(DataStore.HashList, section, HardpointClassToGameDataClass(hpType), true);
                                    DataStore.EquipInfoList.AddEquipInfoListRow(
                                        FLUtility.CreateID(section.GetSetting("nickname").Str(0)),
                                        HardpointClassToGameDataClass(hpType), hpType);
                                }
                                // Probably an npc gun
                                else
                                {
                                    AddGameData(DataStore.HashList, section, GAMEDATA_GEN, false);
                                }
                            }
                            else if (sectionName == "shieldgenerator")
                            {
                                if (section.SettingExists("hp_type"))
                                {
                                    string hpType = section.GetSetting("hp_type").Str(0);
                                    AddGameData(DataStore.HashList, section, HardpointClassToGameDataClass(hpType), true);
                                    DataStore.EquipInfoList.AddEquipInfoListRow(
                                        FLUtility.CreateID(section.GetSetting("nickname").Str(0)),
                                        HardpointClassToGameDataClass(hpType), hpType);
                                }
                                // Probably an npc shield
                                else
                                {
                                    AddGameData(DataStore.HashList, section, GAMEDATA_GEN, false);
                                }
                            }
                            else if (sectionName == "countermeasuredropper")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_CM, true);
                            }
                            else if (sectionName == "thruster")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_THRUSTERS, true);
                            }
                            else if (sectionName == "minedropper")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_MINES, true);
                            }

                            // Cargo and ammo.
                            else if (sectionName == "munition")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_AMMO, true);
                            }
                            else if (sectionName == "repairkit")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_CARGO, true);
                            }
                            else if (sectionName == "countermeasure")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_AMMO, true);
                            }
                            else if (sectionName == "shieldbattery")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_CARGO, true);
                            }
                            else if (sectionName == "mine")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_AMMO, true);
                            }
                            else if (sectionName == "commodity")
                            {
                                AddGameData(DataStore.HashList, section, GAMEDATA_CARGO, true);
                            }

                            // Random stuff I don't know what to do with.
                            else if (sectionName == "shield")
                            { } // ignore this section
                            else if (sectionName == "lootcrate")
                            { } // ignore this section
                            else if (sectionName == "lod")
                            { } // ignore this section - it has no nickname
                            else if (sectionName == "tradelane")
                            { } // ignore this section
                            else if (sectionName == "motor")
                            { } // ignore this section
                            else if (sectionName == "explosion")
                            { } // ignore this section
                            else if (sectionName == "cargopod")
                            { } // ignore this section
                            else if (sectionName == "tradelane")
                            { } // ignore this section

                            else
                            {
                            }
                        }
                        catch (Exception e)
                        {
                            log.AddLog("Error '" + e.Message + "' when parsing '" + iniPath);
                        }
                    }
                }
                catch (Exception e)
                {
                    log.AddLog("Error '" + e.Message + "' when parsing '" + iniPath);
                }
            }

            log.AddLog("Loading factions...");

            // Scan ini files and parse faction entries
            foreach (FLDataFile.Setting flIniEntry in flIni.GetSettings("Data", "groups"))
            {
                string iniPath = flDataPath + Path.DirectorySeparatorChar + flIniEntry.Str(0);
                try
                {
                    FLDataFile ini = new FLDataFile(iniPath, true);
                    foreach (FLDataFile.Section section in ini.sections)
                    {
                        if (section.sectionName.ToLowerInvariant() == "group")
                        {
                            AddGameData(DataStore.HashList, section, GAMEDATA_FACTIONS, true);
                        }
                    }
                }
                catch (Exception e)
                {
                    log.AddLog("Error '" + e.Message + "' when parsing '" + iniPath);
                }
            }
            foreach (IntPtr hInstance in vDLLs)
                FreeLibrary(hInstance);
            vDLLs.Clear();
        }
Ejemplo n.º 5
0
        void  BgWkr_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            bgWkr = null;

            buttonRepAddItem.Enabled  = true;
            buttonRepEditItem.Enabled = true;
            buttonRepDelItem.Enabled  = true;
            button3.Enabled           = true;
            buttonAddBase.Enabled     = true;
            buttonDelBase.Enabled     = true;
            buttonAddItem.Enabled     = true;
            buttonDelItem.Enabled     = true;
            buttonSave.Enabled        = true;
            buttonPurchaseRestrictionAddItem.Enabled   = true;
            buttonPurchaseRestrictionEdittem.Enabled   = true;
            buttonPurchaseRestrictionDelItem.Enabled   = true;
            buttonEquipPurchaseRestrictionAdd.Enabled  = true;
            buttonEquipPurchaseRestrictionEdit.Enabled = true;
            buttonEquipPurchaseRestrictionDel.Enabled  = true;
            buttonSysSensorEditItem.Enabled            = true;
            buttonSysSensorAddItem.Enabled             = true;
            buttonSysSensorDelItem.Enabled             = true;

            // Load our ini file
            try
            {
                cfgFilePath = Path.GetFullPath(cfgFilePath);
                cfgFile     = new FLDataFile(cfgFilePath, false);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error '" + ex.Message + "' occured when loading the configuration file. Using defaults.");
            }

            try
            {
                checkBoxEnableMoveChar.Checked       = cfgFile.GetSettingBool("General", "EnableMoveChar", true);
                checkBoxEnableRenameMe.Checked       = cfgFile.GetSettingBool("General", "EnableRenameMe", true);
                checkBoxEnablePimpShip.Checked       = cfgFile.GetSettingBool("General", "EnablePimpShip", true);
                checkBoxEnableRestart.Checked        = cfgFile.GetSettingBool("General", "EnableRestart", true);
                checkBoxEnableGiveCash.Checked       = cfgFile.GetSettingBool("General", "EnableGiveCash", true);
                checkBoxEnableDropRepAndMisc.Checked = cfgFile.GetSettingBool("General", "EnableDropRep", true);

                textBoxDropRepCost.Text = cfgFile.GetSettingStr("General", "RepDropCost", "350000");
                textBoxStuckMsg.Text    = cfgFile.GetSettingStr("General", "StuckMsg", "Attention! Stand clear. Towing %player");
                textBoxDiceMsg.Text     = cfgFile.GetSettingStr("General", "DiceMsg", "%player rolled %number");
                textBoxCoinMsg.Text     = cfgFile.GetSettingStr("General", "CoinMsg", "%player tossed %result");
                textBoxSmiteMusic.Text  = cfgFile.GetSettingStr("General", "SmiteMusic", "music_danger");

                textBoxDisconnectingPlayersRange.Text      = cfgFile.GetSettingStr("General", "DisconnectingPlayersRange", "5000");
                checkBoxReportDisconnectingPlayers.Checked = cfgFile.GetSettingBool("General", "ReportDisconnectingPlayers", true);
                checkBoxKillDisconnectingPlayers.Checked   = cfgFile.GetSettingBool("General", "KillDisconnectingPlayers", true);
                checkBoxLootDisconnectingPlayers.Checked   = cfgFile.GetSettingBool("General", "LootDisconnectingPlayers", true);

                textBoxHullDropFactor.Text     = cfgFile.GetSettingStr("General", "HullDropFactor", "0.0");
                textBoxCargoDropContainer.Text = cfgFile.GetSettingStr("General", "CargoDropContainer", "lootcrate_ast_loot_metal");
                textBoxHullDrop1NickName.Text  = cfgFile.GetSettingStr("General", "HullDrop1NickName", "commodity_super_alloys");
                textBoxHullDrop2NickName.Text  = cfgFile.GetSettingStr("General", "HullDrop2NickName", "commodity_engine_components");
                textBoxDisconnectMsg.Text      = cfgFile.GetSettingStr("General", "DisconnectMsg", "%player is attempting to engage cloaking device");

                textBoxSpinProtectMass.Text       = cfgFile.GetSettingStr("General", "SpinProtectionMass", "-1.0");
                textBoxSpinImpulseMultiplier.Text = cfgFile.GetSettingStr("General", "SpinProtectionMultiplier", "-8.0");

                checkBoxEnableEscort.Checked         = cfgFile.GetSettingBool("General", "EnableEscort", false);
                textBoxEscortedShipMinimumMass.Text  = cfgFile.GetSettingStr("General", "EscortedShipMinimumMass", "100000");
                textBoxEscortedShipDamageFactor.Text = cfgFile.GetSettingStr("General", "EscortedShipDamageFactor", "0.3");

                textBoxRestartMaxRank.Text = cfgFile.GetSettingStr("Restart", "MaxRank", "5");
                textBoxRestartMaxCash.Text = cfgFile.GetSettingStr("Restart", "MaxCash", "1000000");

                textBoxRenameCost.Text            = cfgFile.GetSettingStr("Rename", "RenameCost", "2000000");
                textBoxRenameTimeLimit.Text       = cfgFile.GetSettingStr("Rename", "RenameTimeLimit", "86400");
                textBoxMoveCost.Text              = cfgFile.GetSettingStr("Rename", "MoveCost", "2000000");
                checkBoxCharnameTag.Checked       = cfgFile.GetSettingBool("Rename", "CharnameTag", false);
                textBoxCharnameTagCost.Text       = cfgFile.GetSettingStr("Rename", "MakeTagCost", "50000000");
                checkBoxAsciiCharnameOnly.Checked = cfgFile.GetSettingBool("Rename", "AsciiCharnameOnly", false);


                textBoxMinTransfer.Text   = cfgFile.GetSettingStr("GiveCash", "MinTransfer", "100000");
                textBoxMinTime.Text       = cfgFile.GetSettingStr("GiveCash", "MinTime", "3600");
                textBoxBlockedSystem.Text = cfgFile.GetSettingStr("GiveCash", "BlockedSystem", "iw09");

                textBoxPimpShipCost.Text = cfgFile.GetSettingStr("ShipPimper", "cost", "2000000");
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("ShipPimper", "equip"))
                {
                    string[] args = set.Str(0).Split(',');
                    if (args.Length > 0)
                    {
                        GameDataSet.HashListRow item = gameData.GetItemByNickName(args[0]);
                        if (item != null)
                        {
                            uIDataSet.ShipPimperItemList.AddShipPimperItemListRow(item.IDSName, item.ItemNickName, item.ItemHash, item.IDSInfo, item.IDSInfo1);
                        }
                    }
                }

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("ShipPimper", "room"))
                {
                    GameDataSet.HashListRow item = gameData.GetItemByNickName(set.Str(0));
                    if (item != null)
                    {
                        uIDataSet.ShipPimperBaseList.AddShipPimperBaseListRow(item.IDSName, item.ItemNickName, item.ItemHash, item.IDSInfo, item.IDSInfo1);
                    }
                }

                checkBoxEnableRepFixUpdates.Checked = cfgFile.GetSettingBool("RepFixer", "EnableRepFixUpdates", true);
                checkBoxLogRepFixUpdates.Checked    = cfgFile.GetSettingBool("RepFixer", "LogRepFixUpdates", true);
                checkBoxItemMustBeMounted.Checked   = cfgFile.GetSettingBool("RepFixer", "ItemMustBeMounted", true);

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("RepFixerItems"))
                {
                    GameDataSet.HashListRow item = gameData.GetItemByNickName(set.settingName);
                    if (item != null)
                    {
                        uIDataSet.RepFixerItemList.AddRepFixerItemListRow(item.IDSName, item.ItemNickName, item.ItemHash, item.IDSInfo, item.IDSInfo1);
                    }
                }

                checkBoxCheckIDRestrictions.Checked   = cfgFile.GetSettingBool("PurchaseRestrictions", "CheckIDRestrictions", false);
                checkBoxEnforceIDRestrictions.Checked = cfgFile.GetSettingBool("PurchaseRestrictions", "EnforceIDRestrictions", false);
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("ShipItemRestrictions"))
                {
                    GameDataSet.HashListRow shipItem    = gameData.GetItemByNickName(set.settingName);
                    GameDataSet.HashListRow controlItem = gameData.GetItemByNickName(set.Str(0));
                    if (shipItem != null && controlItem != null)
                    {
                        uIDataSet.ShipPurchaseRestrictionItems.AddShipPurchaseRestrictionItemsRow(shipItem.IDSName, shipItem.ItemNickName, controlItem.IDSName, controlItem.ItemNickName);
                    }
                }

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("GoodItemRestrictions"))
                {
                    GameDataSet.HashListRow equipItem   = gameData.GetItemByNickName(set.settingName);
                    GameDataSet.HashListRow controlItem = gameData.GetItemByNickName(set.Str(0));
                    if (equipItem != null && controlItem != null)
                    {
                        uIDataSet.EquipPurchaseRestrictionItems.AddEquipPurchaseRestrictionItemsRow(equipItem.IDSName, equipItem.ItemNickName, controlItem.IDSName, controlItem.ItemNickName);
                    }
                }

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("NoBuy"))
                {
                    GameDataSet.HashListRow baseItem = gameData.GetItemByNickName(set.settingName);
                    GameDataSet.HashListRow goodItem = gameData.GetItemByNickName(set.Str(0));
                    if (baseItem != null && goodItem != null)
                    {
                        uIDataSet.BaseGoodNoBuyList.AddBaseGoodNoBuyListRow(baseItem.IDSName, baseItem.ItemNickName, goodItem.IDSName, goodItem.ItemNickName);
                    }
                }

                foreach (FLDataFile.Setting set in cfgFile.GetSettings("SystemSensor"))
                {
                    GameDataSet.HashListRow sysItem = gameData.GetItemByNickName(set.settingName);
                    string[] args = set.Str(0).Split(',');
                    if (args.Length > 0)
                    {
                        GameDataSet.HashListRow equipItem = gameData.GetItemByNickName(args[0]);
                        uint networkID = 1;
                        if (args.Length > 1)
                        {
                            networkID = UInt32.Parse(args[1]);
                        }
                        if (sysItem != null && equipItem != null)
                        {
                            uIDataSet.SysSensorList.AddSysSensorListRow(sysItem.IDSName, sysItem.ItemNickName, equipItem.IDSName, equipItem.ItemNickName, networkID);
                        }
                    }
                }

                checkBoxCustomHelp.Checked = cfgFile.GetSettingBool("Message", "CustomHelp", true);
                checkBoxCmdEcho.Checked    = cfgFile.GetSettingBool("Message", "CmdEcho", true);
                checkBoxCmdHide.Checked    = cfgFile.GetSettingBool("Message", "CmdHide", true);
                textBoxCmdEchoStyle.Text   = cfgFile.GetSettingStr("Message", "CmdEchoStyle", "0x00AA0090");

                richTextBoxHelpLines.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("Help"))
                {
                    richTextBoxHelpLines.AppendText(set.settingName);
                    richTextBoxHelpLines.AppendText("\n");
                }

                richTextBoxSwearWords.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("SwearWords"))
                {
                    richTextBoxSwearWords.AppendText(set.Str(0));
                    richTextBoxSwearWords.AppendText("\n");
                }

                richTextBoxGreetingBannerLines.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("GreetingBanner"))
                {
                    richTextBoxGreetingBannerLines.AppendText(set.Str(0));
                    richTextBoxGreetingBannerLines.AppendText("\n");
                }

                textBoxSpecialBannerDelay.Text  = cfgFile.GetSettingStr("Message", "SpecialBannerDelay", "3000");
                textBoxStandardBannerDelay.Text = cfgFile.GetSettingStr("Message", "StandardBannerDelay", "1200");

                richTextBoxSpecialBannerLines.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("SpecialBanner"))
                {
                    richTextBoxSpecialBannerLines.AppendText(set.Str(0));
                    richTextBoxSpecialBannerLines.AppendText("\n");
                }

                uIDataSet.StandardBannerList.Clear();
                foreach (FLDataFile.Section sect in cfgFile.sections)
                {
                    if (sect.sectionName == "StandardBanner")
                    {
                        StringBuilder sb = new StringBuilder();
                        foreach (FLDataFile.Setting set in sect.settings)
                        {
                            sb.AppendLine(set.Str(0));
                        }
                        uIDataSet.StandardBannerList.AddStandardBannerListRow(sb.ToString());
                    }
                }

                checkBoxEnableLoginSound.Checked = cfgFile.GetSettingBool("General", "EnableLoginSound", false);
                richTextBoxSounds.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("Sounds"))
                {
                    richTextBoxSounds.AppendText(set.Str(0));
                    richTextBoxSounds.AppendText("\n");
                }
                if (richTextBoxSounds.TextLength == 0)
                {
                    richTextBoxSounds.AppendText(
                        "dx_s075x_03a03_or_pilot_03\n" +
                        "dx_s032a_01a01_hvis_xtr_1\n" +
                        "dx_s075x_03a01_or_pilot_01\n" +
                        "dx_s075x_03a02_or_pilot_02\n" +
                        "dx_s003x_0801_trent\n" +
                        "dx_s003x_0802_trent\n" +
                        "dx_s004x_1302_juni\n" +
                        "dx_s009d_0101_trent\n" +
                        "dx_s071c_0101_trent"
                        );
                }

                checkBoxEnableWardrobe.Checked = cfgFile.GetSettingBool("General", "EnableWardrobe", false);
                richTextBoxHeads.Clear();
                richTextBoxBodies.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("Wardrobe"))
                {
                    if (set.settingName == "head")
                    {
                        richTextBoxHeads.AppendText(set.Str(0));
                        richTextBoxHeads.AppendText("\n");
                    }
                    else if (set.settingName == "body")
                    {
                        richTextBoxBodies.AppendText(set.Str(0));
                        richTextBoxBodies.AppendText("\n");
                    }
                }
                if (richTextBoxHeads.TextLength == 0)
                {
                    richTextBoxHeads.AppendText("monkey, sh_male5_head");
                }
                if (richTextBoxBodies.TextLength == 0)
                {
                    richTextBoxBodies.AppendText("orillion, pi_orillion_body");
                }

                checkBoxEnableMe.Checked = cfgFile.GetSettingBool("General", "EnableMe", false);
                checkBoxEnableDo.Checked = cfgFile.GetSettingBool("General", "EnableDo", false);

                checkBoxEnableRestartCost.Checked = cfgFile.GetSettingBool("General", "EnableRestartCost", false);
                richTextBoxRestarts.Clear();
                foreach (FLDataFile.Setting set in cfgFile.GetSettings("Restart"))
                {
                    if (set.settingName == "restart")
                    {
                        richTextBoxRestarts.AppendText(set.Str(0));
                        richTextBoxRestarts.AppendText("\n");
                    }
                }
                if (richTextBoxRestarts.TextLength == 0)
                {
                    richTextBoxRestarts.AppendText("zoner, 10000");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error '" + ex.Message + "' occured when parsing the configuration file.");
            }
        }