private static void LoadSystem(Section sec) { var sysNick = sec.GetFirstOf("nickname")[0].ToLowerInvariant(); _log.NewMessage(LogType.Garbage, "Universe: Parsing system {0}", sysNick); var stIDSName = GetIDSParm(sec.GetAnySetting("strid_name")[0]); var stIDSInfo1 = ""; if (sec.ContainsAnyOf("ids_info1","ids_short_name")) stIDSInfo1 = GetIDSParm(sec.GetAnySetting("ids_info")[0]); Gis.Systems.AddSystemsRow(sysNick, stIDSName,stIDSInfo1); //string file = Directory.GetParent(ini.filePath).FullName + "\\" + section.GetSetting("file").Str(0); //TODO: Warning, hardcoded system path! :S var sysFile = new DataFile(_flDataPath + @"\Universe\" + sec.GetFirstOf("file")[0]); foreach (var obj in sysFile.GetSections("Object")) { Setting curset; //string pos; var idsInfo = ""; var idsInfo1 = ""; //TODO: do we need pos? //if (obj.TryGetFirstOf("pos", out curset)) // pos = string.Join(", ", curset); //get infocard for the object if (obj.TryGetFirstOf("ids_info", out curset)) { uint id; if (!uint.TryParse(curset[0], out id)) { _log.NewMessage(LogType.Warning, "Can't find ID for object: {0}", curset[0]); } idsInfo = GetIDString(id); if (InfocardMap.ContainsKey(id)) idsInfo1 = GetIDString(InfocardMap[id]); } //add the icard to the base if object is base if (obj.TryGetFirstOf("base", out curset)) //TODO: really join the stuff, infos are in XML format. Gis.Bases.FindByNickname(curset[0]).Infocard = idsInfo + idsInfo1; } //TODO: zones needed? }
private static void LoadShip(Section sec) { var nickname = sec.GetFirstOf("nickname")[0]; _log.NewMessage(LogType.Garbage, "Universe: Parsing ship {0}", nickname); var hash = CreateID(nickname.ToLowerInvariant()); // fail if equip already presents if (Gis.Ships.FindByHash(hash) != null) return; uint holdSize = 0; if (sec.ContainsAnyOf("hold_size")) holdSize = uint.Parse(sec.GetFirstOf("hold_size")[0]); var shipReadableName = ""; if (sec.ContainsAnyOf("ids_name", "strid_name")) shipReadableName = GetIDSParm(sec.GetAnySetting("ids_name", "strid_name")[0]); var infocard = ""; if (sec.ContainsAnyOf("ids_info")) infocard = GetIDSParm(sec.GetFirstOf("ids_info")[0]); Gis.Ships.AddShipsRow(hash, nickname,shipReadableName, infocard,holdSize); foreach (var set in sec.GetSettings("da_archetype")) { var utf = new UtfFile(_flDataPath + Path.DirectorySeparatorChar + set[0]); foreach (var hp in utf.Hardpoints.Where(hp => hp.ToLowerInvariant().Contains("cloak"))) { var ghr = Gis.Ships.FindByHash(hash).GetHardpointsRows(); if (ghr.Any(hpS => hpS.Name == hp)) continue; //TODO cloak names Gis.Hardpoints.AddHardpointsRow(Gis.Ships.FindByHash(hash), hp, EquipTypes.Cloak.ToString(),"cloak"); } } foreach (var hpSet in sec.GetSettings("hp_type")) { var type = HpMap[hpSet[0]]; foreach (var hp in hpSet.Skip(1)) { var hp1 = hp; var q = 0; var ghr = Gis.Ships.FindByHash(hash).GetHardpointsRows().FirstOrDefault(hpS => hpS.Name == hp1); if (nickname == "dsy_no_elite") q++; if (ghr != null) { ghr.HPType += String.Format(" {0}", hpSet[0]); continue; } Gis.Hardpoints.AddHardpointsRow(Gis.Ships.FindByHash(hash), hp, type.ToString(),hpSet[0]); } } }
private static void LoadEquipSection(Section eqSection) { switch (eqSection.Name) { case "Engine": LoadEquip(eqSection, EquipTypes.Engine); break; case "Power": LoadEquip(eqSection, EquipTypes.Powerplant); break; case "Scanner": LoadEquip(eqSection, EquipTypes.Scanner); break; case "Tractor": LoadEquip(eqSection, EquipTypes.Tractor); break; case "CloakingDevice": LoadEquip(eqSection, EquipTypes.Cloak); break; case "Armor": LoadEquip(eqSection, EquipTypes.Armor); break; case "InternalFX": if (eqSection.ContainsAnyOf("use_sound")) { LoadEquip(eqSection, EquipTypes.InternalFX); } break; case "AttachedFX": LoadEquip(eqSection, EquipTypes.AttachedFX); break; case "Light": LoadEquip(eqSection, EquipTypes.Light); break; case "Gun": if (eqSection.ContainsAnyOf("hp_gun_type")) { LoadEquip(eqSection, EquipTypes.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); //} break; case "ShieldGenerator": if (eqSection.ContainsAnyOf("hp_type")) { LoadEquip(eqSection, EquipTypes.ShieldGen); } //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); //} break; case "CounterMeasureDropper": LoadEquip(eqSection, EquipTypes.CountermeasureDropper); break; case "Thruster": LoadEquip(eqSection, EquipTypes.Thruster); break; case "MineDropper": LoadEquip(eqSection, EquipTypes.MineDropper); break; case "Munition": LoadEquip(eqSection, EquipTypes.Munition); break; case "RepairKit": LoadEquip(eqSection, EquipTypes.RepairKit); break; case "CounterMeasure": LoadEquip(eqSection, EquipTypes.Countermeasure); break; case "ShieldBattery": LoadEquip(eqSection, EquipTypes.ShieldBattery); break; case "Mine": LoadEquip(eqSection, EquipTypes.Mine); break; case "Commodity": LoadEquip(eqSection, EquipTypes.Cargo); break; case "CargoPod": break; case "LootCrate": break; case "TradeLane": break; case "Shield": break; case "LOD": break; case "Motor": break; case "Explosion": break; //default: //break; } }
private static void LoadFaction(Section sec) { var nickname = sec.GetFirstOf("nickname")[0]; _log.NewMessage(LogType.Garbage, "Universe: Parsing faction {0}", nickname); var hash = CreateFactionID(nickname); if (Gis.Factions.FindByHash(hash) != null) return; var factionName = ""; if (sec.ContainsAnyOf("ids_name", "strid_name")) factionName = GetIDSParm(sec.GetAnySetting("ids_name", "strid_name")[0]); // TODO: ignore empty IDS based on setting if (factionName == "") return; var shortName = ""; if (sec.ContainsAnyOf("ids_info1", "ids_short_name")) shortName = GetIDSParm(sec.GetAnySetting("ids_info1", "ids_short_name")[0]); var infocard = ""; if (sec.ContainsAnyOf("ids_info")) infocard = GetIDSParm(sec.GetFirstOf("ids_info")[0]); Gis.Factions.AddFactionsRow(hash, nickname, factionName, shortName, infocard); }
private static void LoadEquip(Section sec, EquipTypes equipType) { var nickname = sec.GetFirstOf("nickname")[0]; _log.NewMessage(LogType.Garbage, "Universe: Parsing equipment {0}", nickname); var hash = CreateID(nickname.ToLowerInvariant()); // fail if equip already presents if (Gis.Equipment.FindByHash(hash) != null) return; var stIDSName = ""; if (sec.ContainsAnyOf("ids_name", "strid_name")) stIDSName = GetIDSParm(sec.GetAnySetting("ids_name", "strid_name")[0]); // TODO: ignore empty IDS based on setting //if (stIDSName == "") return; var infocard = ""; if (sec.ContainsAnyOf("ids_info")) infocard = GetIDSParm(sec.GetFirstOf("ids_info")[0]); float volume = 0; if (sec.ContainsAnyOf("volume")) volume = float.Parse(sec.GetFirstOf("volume")[0], Nfi); // Tested on Disco 4.87.6, no hits beyond this line. //var stIDSInfo1 = ""; //if (sec.ContainsAnyOf("ids_info1","ids_short_name")) // stIDSInfo1 = GetIDSParm(sec.GetAnySetting("ids_info1", "ids_short_name")[0]); // Careful with this one below! //if (stIDSInfo1 == "") return; //var stIDSInfo2 = ""; //if (sec.ContainsAnyOf("ids_info2")) // stIDSInfo2 = GetIDSParm(sec.GetFirstOf("ids_info2")[0]); //var stIDSInfo3 = ""; //if (sec.ContainsAnyOf("ids_info3")) // stIDSInfo3 = GetIDSParm(sec.GetFirstOf("ids_info3")[0]); //string keys = hash.ToString() + " 0x" + hash.ToString("X"); var hpType = ""; switch (equipType) { case EquipTypes.Engine: if (sec.ContainsAnyOf("hp_type")) hpType = sec.GetFirstOf("hp_type")[0]; break; case EquipTypes.Gun: hpType = sec.GetFirstOf("hp_gun_type")[0]; equipType = HpMap[hpType]; break; case EquipTypes.ShieldGen: hpType = sec.GetFirstOf("hp_type")[0]; equipType = HpMap[hpType]; break; case EquipTypes.CountermeasureDropper: hpType = "hp_countermeasure_dropper"; break; case EquipTypes.Thruster: hpType = "hp_thruster"; break; case EquipTypes.Cargo: break; default: break; } // ReSharper disable RedundantArgumentName Gis.Equipment.AddEquipmentRow( Hash: hash, Type: equipType.ToString(), Hardpoint: hpType, Nickname: nickname, Name: stIDSName, Infocard: infocard, Volume: volume); // ReSharper restore RedundantArgumentName }