public Bodypart(Section s, FreelancerData gdata) { gameData = gdata; foreach (Entry e in s) { switch (e.Name.ToLowerInvariant()) { case "nickname": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (Nickname != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } Nickname = e[0].ToString(); break; case "mesh": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (MeshPath != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } MeshPath = VFS.GetPath(gdata.Freelancer.DataPath + e [0].ToString()); break; default: throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name); } } }
public Accessory(Section s, FreelancerData gdata) { GameData = gdata; foreach (Entry e in s) { switch (e.Name.ToLowerInvariant()) { case "nickname": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (Nickname != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } Nickname = e[0].ToString(); break; case "mesh": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (MeshPath != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } MeshPath = VFS.GetPath(GameData.Freelancer.DataPath + e[0].ToString(), false); //Fix demo crash break; case "hardpoint": // TODO: Accessory hardpoint break; case "body_hardpoint": // TODO: Accessory body_hardpoint break; default: throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name); } } }
public StarSystem(UniverseIni universe, Section section, FreelancerData data) : base(data) { if (universe == null) { throw new ArgumentNullException("universe"); } if (section == null) { throw new ArgumentNullException("section"); } string file = null; foreach (Entry e in section) { switch (e.Name.ToLowerInvariant()) { case "nickname": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (Nickname != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } Nickname = e[0].ToString(); break; case "file": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (file != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } file = e[0].ToString(); break; case "pos": if (e.Count != 2) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (Pos != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } Pos = new Vector2(e[0].ToSingle(), e[1].ToSingle()); break; case "msg_id_prefix": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (MsgIdPrefix != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } MsgIdPrefix = e[0].ToString(); break; case "visit": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (Visit != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } Visit = e[0].ToInt32(); break; case "strid_name": if (e.Count == 0) { break; } if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (IdsName != 0) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } IdsName = e[0].ToInt32(); break; case "ids_info": if (e.Count == 0) { break; } if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (IdsInfo != 0) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } IdsInfo = e[0].ToInt32(); break; case "navmapscale": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (NavMapScale != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } NavMapScale = e[0].ToSingle(); break; default: throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name); } } if (file == null) //TODO: MultiUniverse { FLLog.Warning("Ini", "Unimplemented: Possible MultiUniverse system " + Nickname); MultiUniverse = true; return; } foreach (Section s in ParseFile(GameData.Freelancer.DataPath + "universe\\" + file)) { switch (s.Name.ToLowerInvariant()) { case "systeminfo": foreach (Entry e in s) { switch (e.Name.ToLowerInvariant()) { case "name": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (Name != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } Name = e[0].ToString(); break; case "space_color": if (e.Count != 3) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (SpaceColor != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } SpaceColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f); break; case "local_faction": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (LocalFaction != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } LocalFaction = e[0].ToString(); break; case "rpop_solar_detection": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (RpopSolarDetection != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } RpopSolarDetection = e[0].ToBoolean(); break; case "space_farclip": if (SpaceFarClip != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } SpaceFarClip = e[0].ToSingle(); break; default: throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name); } } break; case "music": foreach (Entry e in s) { switch (e.Name.ToLowerInvariant()) { case "space": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (MusicSpace != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } MusicSpace = e[0].ToString(); break; case "danger": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (MusicDanger != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } MusicDanger = e[0].ToString(); break; case "battle": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (MusicBattle != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } MusicBattle = e[0].ToString(); break; default: throw new Exception("Invalid Entry in " + section.Name + ": " + e.Name); } } break; case "archetype": foreach (Entry e in s) { switch (e.Name.ToLowerInvariant()) { case "ship": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (ArchetypeShip == null) { ArchetypeShip = new List <string>(); } ArchetypeShip.Add(e[0].ToString()); break; case "simple": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (ArchetypeSimple == null) { ArchetypeSimple = new List <string>(); } ArchetypeSimple.Add(e[0].ToString()); break; case "solar": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (ArchetypeSolar == null) { ArchetypeSolar = new List <string>(); } ArchetypeSolar.Add(e[0].ToString()); break; case "equipment": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (ArchetypeEquipment == null) { ArchetypeEquipment = new List <string>(); } ArchetypeEquipment.Add(e[0].ToString()); break; case "snd": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (ArchetypeSnd == null) { ArchetypeSnd = new List <string>(); } ArchetypeSnd.Add(e[0].ToString()); break; case "voice": if (ArchetypeVoice == null) { ArchetypeVoice = new List <List <string> >(); } ArchetypeVoice.Add(new List <string>()); foreach (IValue i in e) { ArchetypeVoice[ArchetypeVoice.Count - 1].Add(i.ToString()); } break; default: throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name); } } break; case "dust": foreach (Entry e in s) { switch (e.Name.ToLowerInvariant()) { case "spacedust": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (Spacedust != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } Spacedust = e[0].ToString(); break; default: throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name); } } break; case "nebula": if (Nebulae == null) { Nebulae = new List <Nebula>(); } Nebulae.Add(new Nebula(this, s, GameData)); break; case "asteroids": if (Asteroids == null) { Asteroids = new List <AsteroidField>(); } Asteroids.Add(new AsteroidField(this, s, GameData)); break; case "ambient": foreach (Entry e in s) { switch (e.Name.ToLowerInvariant()) { case "color": if (e.Count != 3) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (AmbientColor != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } AmbientColor = new Color4(e[0].ToInt32() / 255f, e[1].ToInt32() / 255f, e[2].ToInt32() / 255f, 1f); break; default: throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name); } } break; case "lightsource": if (LightSources == null) { LightSources = new List <LightSource>(); } LightSources.Add(new LightSource(s, GameData)); break; case "object": if (Objects == null) { Objects = new List <SystemObject>(); } Objects.Add(new SystemObject(universe, this, s, GameData)); break; case "encounterparameters": if (EncounterParameters == null) { EncounterParameters = new List <EncounterParameter>(); } EncounterParameters.Add(new EncounterParameter(s)); break; case "texturepanels": TexturePanels = new TexturePanelsRef(s, GameData); break; case "background": foreach (Entry e in s) { switch (e.Name.ToLowerInvariant()) { case "basic_stars": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (BackgroundBasicStarsPath != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } BackgroundBasicStarsPath = VFS.GetPath(GameData.Freelancer.DataPath + e [0].ToString()); break; case "complex_stars": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } if (BackgroundComplexStarsPath != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } BackgroundComplexStarsPath = VFS.GetPath(GameData.Freelancer.DataPath + e [0].ToString()); break; case "nebulae": if (e.Count != 1) { throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count); } string temp = VFS.GetPath(GameData.Freelancer.DataPath + e[0].ToString(), false); if (BackgroundNebulaePath != null && BackgroundNebulaePath != temp) { throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name); } BackgroundNebulaePath = temp; break; default: throw new Exception("Invalid Entry in " + s.Name + ": " + e.Name); } } break; case "zone": if (Zones == null) { Zones = new List <Zone>(); } Zones.Add(new Zone(s, GameData)); break; case "field": Field = new Field(s); break; case "asteroidbillboards": AsteroidBillboards = new AsteroidBillboards(s); break; default: throw new Exception("Invalid Section in " + file + ": " + s.Name); } } }
public Ship(Section s, FreelancerData fldata) { foreach (Entry e in s) { switch (e.Name.ToLowerInvariant()) { case "nickname": Nickname = e [0].ToString(); break; case "ids_name": IdsName = e[0].ToInt32(); break; case "ids_info": IdsInfo = e[0].ToInt32(); break; case "ids_info1": IdsInfo1 = e[0].ToInt32(); break; case "ids_info2": IdsInfo2 = e[0].ToInt32(); break; case "ids_info3": IdsInfo3 = e[0].ToInt32(); break; case "da_archetype": DaArchetypeName = VFS.GetPath(fldata.Freelancer.DataPath + e [0].ToString()); break; case "hit_pts": Hitpoints = e [0].ToInt32(); break; case "nanobot_limit": NanobotLimit = e [0].ToInt32(); break; case "shield_battery_limit": ShieldBatteryLimit = e [0].ToInt32(); break; case "hold_size": HoldSize = e [0].ToInt32(); break; case "mass": Mass = e [0].ToInt32(); break; case "steering_torque": SteeringTorque = new Vector3(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle()); break; case "angular_drag": AngularDrag = new Vector3(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle()); break; case "rotation_inertia": RotationInertia = new Vector3(e[0].ToSingle(), e[1].ToSingle(), e[2].ToSingle()); break; case "strafe_force": StrafeForce = e[0].ToSingle(); break; case "ship_class": ShipClass = e [0].ToInt32(); break; case "type": Type = e [0].ToString(); break; case "material_library": MaterialLibraries.Add(VFS.GetPath(fldata.Freelancer.DataPath + e [0].ToString())); break; case "camera_offset": CameraOffset = new Vector3(0, e[0].ToSingle(), e[1].ToSingle()); break; case "camera_angular_acceleration": CameraAngularAcceleration = e[0].ToSingle(); break; case "camera_horizontal_turn_angle": CameraHorizontalTurnAngle = e[0].ToSingle(); break; case "camera_vertical_turn_up_angle": CameraVerticalTurnUpAngle = e[0].ToSingle(); break; case "camera_vertical_turn_down_angle": CameraVerticalTurnDownAngle = e[0].ToSingle(); break; case "camera_turn_look_ahead_slerp_amount": CameraTurnLookAheadSlerpAmount = e[0].ToSingle(); break; } } }
protected virtual bool parentEntry(Entry e) { switch (e.Name.ToLowerInvariant()) { case "nickname": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (Nickname != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } Nickname = e[0].ToString(); break; case "ids_name": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (IdsName != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } IdsName = FLData.Infocards.GetStringResource(e[0].ToInt32()); break; case "ids_info": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } IdsInfo.Add(FLData.Infocards.GetXmlResource(e[0].ToInt32())); break; case "hit_pts": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } Hitpoints = e [0].ToSingle(); break; case "phantom_physics": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } PhantomPhysics = e [0].ToBoolean(); break; case "type": break; case "material_library": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } string path = e[0].ToString(); switch (Path.GetExtension(path)) { case ".mat": MaterialPaths.Add(VFS.GetPath(FLData.Freelancer.DataPath + path)); break; case ".txm": TexturePaths.Add(VFS.GetPath(FLData.Freelancer.DataPath + path)); break; default: throw new Exception("Invalid value in " + section.Name + " Entry " + e.Name + ": " + path); } break; case "mass": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } //if (Mass != null) throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); //Hack around discovery errors Mass = e[0].ToSingle(); break; case "shape_name": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (ShapeName != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } ShapeName = e[0].ToString(); break; case "solar_radius": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (SolarRadius != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } SolarRadius = e[0].ToSingle(); break; case "da_archetype": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (DaArchetypeName != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } DaArchetypeName = VFS.GetPath(FLData.Freelancer.DataPath + e [0].ToString()); break; case "loadout": if (e.Count != 1) { throw new Exception("Invalid number of values in " + section.Name + " Entry " + e.Name + ": " + e.Count); } if (LoadoutName != null) { throw new Exception("Duplicate " + e.Name + " Entry in " + section.Name); } LoadoutName = e[0].ToString(); break; case "docking_sphere": string scr = e.Count == 4 ? e[3].ToString() : null; DockingSpheres.Add(new DockSphere() { Name = e[0].ToString(), Hardpoint = e[1].ToString(), Radius = e[2].ToInt32(), Script = scr }); break; case "open_anim": OpenAnim = e[0].ToString(); break; case "lodranges": LODRanges = new float[e.Count]; for (int i = 0; i < e.Count; i++) { LODRanges[i] = e[i].ToSingle(); } break; default: return(false); } return(true); }
public void LoadData() { if (Loaded) { return; } if (LoadDacom) { Dacom = new DacomIni(); } if (Freelancer.JsonResources != null) { var strs = JsonConvert.DeserializeObject <Dictionary <int, string> >(File.ReadAllText(VFS.GetPath("EXE\\" + Freelancer.JsonResources.Item1))); var ifcs = JsonConvert.DeserializeObject <Dictionary <int, string> >(File.ReadAllText(VFS.GetPath("EXE\\" + Freelancer.JsonResources.Item2))); Infocards = new InfocardManager(strs, ifcs); } else { Infocards = new InfocardManager(Freelancer.Resources); } //Dfm Bodyparts = new BodypartsIni(Freelancer.BodypartsPath, this); Costumes = new CostumesIni(Freelancer.CostumesPath, this); //Equipment Equipment = new EquipmentIni(); foreach (var eq in Freelancer.EquipmentPaths) { Equipment.AddEquipmentIni(eq, this); } //Solars Solar = new SolararchIni(Freelancer.SolarPath, this); if (Freelancer.StarsPath != null) { Stars = new StararchIni(Freelancer.StarsPath); } else { Stars = new StararchIni("DATA\\SOLAR\\stararch.ini"); } Asteroids = new AsteroidArchIni(); foreach (var ast in Freelancer.AsteroidPaths) { Asteroids.AddFile(ast); } //Loadouts Loadouts = new LoadoutsIni(); foreach (var lo in Freelancer.LoadoutPaths) { Loadouts.AddLoadoutsIni(lo, this); } //Universe Universe = new UniverseIni(Freelancer.UniversePath, this); //Ships Ships = new ShiparchIni(); foreach (var shp in Freelancer.ShiparchPaths) { Ships.AddShiparchIni(shp, this); } //Audio Audio = new AudioIni(); foreach (var snd in Freelancer.SoundPaths) { Audio.AddIni(snd, Freelancer); } Loaded = true; //Graphs Graphs = new GraphIni(); foreach (var g in Freelancer.GraphPaths) { Graphs.AddGraphIni(g); } //Shapes EffectShapes = new TexturePanels(Freelancer.EffectShapesPath); //Effects Effects = new EffectsIni(); foreach (var fx in Freelancer.EffectPaths) { Effects.AddIni(fx); } //Mouse Mouse = new MouseIni(Freelancer.DataPath + "//mouse.ini"); //Fonts RichFonts = new RichFontsIni(); foreach (var rf in Freelancer.RichFontPaths) { RichFonts.AddRichFontsIni(rf); } //PetalDb PetalDb = new PetalDbIni(); foreach (var pt in Freelancer.PetalDbPaths) { PetalDb.AddFile(pt); } //Hud Hud = new HudIni(); Hud.AddIni(Freelancer.HudPath); //navbar.ini BaseNavBar = new BaseNavBarIni(); //mbases.ini MBases = new MBasesIni(); }