public RpcSystemProcessIncomingPackets(WorldCollection collection) : base(collection) { garbageNotificationSet = World.Mgr.GetEntities() .With <RpcSystem.NotificationTag>() .With <RpcSystem.DestroyOnProcessedTag>() .AsSet(); }
public SharpDxInputSystem(WorldCollection collection) : base(collection) { DependencyResolver.Add(() => ref backendSystem); DependencyResolver.Add(() => ref scheduler); DependencyResolver.Add(() => ref taskScheduler); DependencyResolver.Add(() => ref logger); }
public override void Parse(TextReader reader, WorldCollection worlds) { int lineNumber = 0; string line; string[] header = null; while (true) { line = reader.ReadLine(); if (line == null) { return; } ++lineNumber; if (line.Length == 0) { continue; } if (line.StartsWith("#")) { continue; } if (header == null) { header = line.Split(TAB_DELIMITER); continue; } ParseLine(worlds, header, line, lineNumber); } }
public override void Parse(TextReader reader, WorldCollection worlds, ErrorLogger?errors) { int lineNumber = 0; for (string line = reader.ReadLine(); line != null; line = reader.ReadLine()) { ++lineNumber; if (line.Length == 0) { continue; } switch (line[0]) { case '#': break; // comment case '$': break; // route case '@': break; // subsector default: ParseWorld(worlds, line, lineNumber, errors ?? worlds.ErrorList); break; } } }
public TitleScene(GraphicsDevice graphicsDevice, IContentProvider content, IMouseEvents mouse, IGameStateFactory gameStateFactory, CImage img, CSound snd, WorldCollection worlds, HighscoreCollection highscores, BBXConfig config) { this.graphicsDevice = graphicsDevice; this.content = content; this.gameStateFactory = gameStateFactory; this.img = img; this.snd = snd; this.config = config; this.spriteBatch = new SpriteBatch(graphicsDevice); this.random = new Random(); this.worlds = worlds; this.highscores = highscores; this.worlds.LoadWorlds(content); this.mouse = mouse; mouse.MouseMove += Mouse_MouseMove; mouse.MouseUp += Mouse_MouseUp; keyboard = new KeyboardEvents(); keyboard.KeyDown += Keyboard_KeyDown; font = new Font(img.Fonts.Default); }
public void Parse(Stream stream, WorldCollection worlds, ErrorLogger errors) { using (var reader = new StreamReader(stream, Encoding, detectEncodingFromByteOrderMarks: true, bufferSize: BUFFER_SIZE)) { Parse(reader, worlds, errors ?? worlds.ErrorList); } }
protected static void ParseWorld(WorldCollection worlds, Dictionary <string, string> dict, string line, int lineNumber, ErrorLogger errors) { try { FieldChecker checker = new FieldChecker(dict, errors, lineNumber, line); World world = new World(); world.Hex = checker.Check("Hex", HEX_REGEX); world.Name = checker.Check("Name"); world.UWP = checker.Check("UWP", UWP_REGEX); world.Remarks = checker.Check(new string[] { "Remarks", "Trade Codes", "Comments" }); world.Importance = checker.Check(new string[] { "{Ix}", "{ Ix }", "Ix" }, options: CheckOptions.Optional); world.Economic = checker.Check(new string[] { "(Ex)", "( Ex )", "Ex" }, options: CheckOptions.Optional); world.Cultural = checker.Check(new string[] { "[Cx]", "[ Cx ]", "Cx" }, options: CheckOptions.Optional); world.Nobility = checker.Check(new string[] { "N", "Nobility" }, NOBILITY_REGEX, CheckOptions.EmptyIfDash | CheckOptions.Optional); world.Bases = checker.Check(new string[] { "B", "Bases" }, BASES_REGEX, CheckOptions.EmptyIfDash); world.Zone = checker.Check(new string[] { "Z", "Zone" }, ZONE_REGEX, CheckOptions.EmptyIfDash); world.PBG = checker.Check("PBG", PBG_REGEX); world.Allegiance = checker.Check(new string[] { "A", "Al", "Allegiance" }, a => worlds.IsUserData || a.Length != 4 || SecondSurvey.IsKnownT5Allegiance(a)); world.Stellar = checker.Check(new string[] { "Stellar", "Stars", "Stellar Data" }, STARS_REGEX, CheckOptions.Warning); byte w; if (byte.TryParse(checker.Check(new string[] { "W", "Worlds" }, options: CheckOptions.Optional), NumberStyles.Integer, CultureInfo.InvariantCulture, out w)) { world.Worlds = w; } int ru; if (int.TryParse(checker.Check("RU", options: CheckOptions.Optional), NumberStyles.Integer | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out ru)) { world.ResourceUnits = ru; } // Cleanup known placeholders if (world.Name == world.Name.ToUpperInvariant() && world.IsHi) { world.Name = Util.FixCapitalization(world.Name); } if (worlds[world.X, world.Y] != null) { errors?.Warning("Duplicate World", lineNumber, line); } if (!checker.HadError) { worlds[world.X, world.Y] = world; } if (errors != null) { world.Validate(errors, lineNumber, line); } } catch (Exception e) when(errors != null) { errors.Error("Parse Error: " + e.Message, lineNumber, line); //throw new Exception($"UWP Parse Error in line {lineNumber}:\n{e.Message}\n{line}"); } }
public override void Parse(TextReader reader, WorldCollection worlds, ErrorLogger?errors) { foreach (var row in new ColumnParser(reader).Data) { ParseWorld(worlds, row.dict, row.line, row.lineNumber, errors); } }
private static void ParseWorld(WorldCollection worlds, string line, int lineNumber, ErrorLogger?errors) { if (!UWP_REGEX.IsMatch(line)) { errors?.Warning("Ignoring non-UWP data", lineNumber, line); return; } Match match = WORLD_REGEX.Match(line); if (!match.Success) { errors?.Error("SEC Parse", lineNumber, line); return; } try { World world = new World() { // Allegiance may affect interpretation of other values, e.g. bases, zones Allegiance = match.Groups["allegiance"].Value.Trim(), // Crack the RegExpr data Name = NAME_FIXUP_REGEX.Replace(match.Groups["name"].Value.Trim(), ""), Hex = match.Groups["hex"].Value.Trim(), UWP = match.Groups["uwp"].Value.Trim(), LegacyBaseCode = EmptyIfDash(match.Groups["base"].Value.Trim()), Remarks = match.Groups["codes"].Value.Trim(), Zone = EmptyIfDash(match.Groups["zone"].Value), PBG = match.Groups["pbg"].Value.Trim() }; // Cleanup known placeholders if (world.Name == match.Groups["hex"].Value || PLACEHOLDER_NAME_REGEX.IsMatch(world.Name)) { world.Name = ""; } if (world.Name == world.Name.ToUpperInvariant() && world.IsHi) { world.Name = world.Name.FixCapitalization(); } worlds[world.X, world.Y] = world; string rest = match.Groups["rest"].Value; if (!string.IsNullOrEmpty(rest)) { ParseRest(rest, lineNumber, line, world, errors); } if (errors != null) { world.Validate(errors, lineNumber, line); } } catch (Exception e) when(errors != null) { errors.Error("Parse error: " + e.Message, lineNumber, line); //throw new Exception($"UWP Parse Error in line {lineNumber}:\n{e.Message}\n{line}"); } }
protected override void Process(System.Web.HttpContext context, ResourceManager resourceManager) { context.Response.ContentType = ContentTypes.Text.Plain; context.Response.StatusCode = 200; string sectorName = GetStringOption(context, "sector"); string type = GetStringOption(context, "type"); string regex = GetStringOption(context, "regex"); string milieu = GetStringOption(context, "milieu"); // NOTE: This (re)initializes a static data structure used for // resolving names into sector locations, so needs to be run // before any other objects (e.g. Worlds) are loaded. SectorMap.Flush(); SectorMap map = SectorMap.GetInstance(resourceManager); var sectorQuery = from sector in map.Sectors where (sectorName == null || sector.Names[0].Text.StartsWith(sectorName, ignoreCase: true, culture: CultureInfo.InvariantCulture)) && (sector.DataFile != null) && (type == null || sector.DataFile.Type == type) && (!sector.Tags.Contains("ZCR")) && (!sector.Tags.Contains("meta")) && (milieu == null || sector.CanonicalMilieu == milieu) orderby sector.Names[0].Text select sector; Dictionary <string, HashSet <string> > codes = new Dictionary <string, HashSet <string> >(); Regex filter = new Regex(regex ?? ".*"); foreach (var sector in sectorQuery) { WorldCollection worlds = sector.GetWorlds(resourceManager, cacheResults: false); if (worlds == null) { continue; } foreach (var code in worlds .SelectMany(world => world.Codes) .Where(code => filter.IsMatch(code) && !s_knownCodes.IsMatch(code))) { if (!codes.ContainsKey(code)) { codes.Add(code, new HashSet <string>()); } codes[code].Add($"{sector.Names[0].Text} [{sector.CanonicalMilieu}]"); } } foreach (var code in codes.Keys.OrderBy(s => s)) { context.Response.Output.Write(code + " - "); foreach (var sector in codes[code].OrderBy(s => s)) { context.Response.Output.Write(sector + " "); } context.Response.Output.WriteLine(""); } }
public override void Parse(TextReader reader, WorldCollection worlds) { ColumnParser parser = new ColumnParser(reader); foreach (var row in parser.Data) { ParseWorld(worlds, row.dict, row.line, row.lineNumber); } }
public ClientReceiveAudioResourceDataSystem(WorldCollection collection) : base(collection) { resourceSet = collection.Mgr.GetEntities() .With <AudioResource>() .With <IsResourceLoaded <AudioResource> >() .AsSet(); }
public System(WorldCollection collection) : base(collection) { connectionSet = World.Mgr.GetEntities() .With <DisplayedConnection>() .With <TransportAddress>() .AsSet(); }
public WorldSyncData GetWorldSyncData(string worldId) { return(new WorldSyncData() { World = WorldCollection.FindById(worldId), Areas = AreaCollection.GetAllAreasFromWorld(worldId) }); }
public GlobalWorld(Context context = null, World world = null) { Collection = new WorldCollection(context ?? new Context(null), world ?? new World()); Scheduler = new Scheduler(); Context.BindExisting(Scheduler); Context.BindExisting(this); }
// we require an absolute type public StartGameHostListener(WorldCollection collection) : base(f => f.GetType() == typeof(ReceiveGameHostClientFeature), collection) { Server = new(); DependencyResolver.Add(() => ref logger); DependencyResolver.Add(() => ref lowLevel); DependencyResolver.Add(() => ref rpcSystem); }
public UniverseSyncData GetUniverseSyncData() { return(new UniverseSyncData() { Universe = UniverseCollection.GetDefaultUniverse(), Worlds = WorldCollection.GetAll().ToList() }); }
public override void Parse(TextReader reader, WorldCollection worlds, ErrorLogger?errors) { TSVParser parser = new TSVParser(reader); foreach (var row in parser.Data) { ParseWorld(worlds, row.dict, row.line, row.lineNumber, errors); } }
public override void Parse(TextReader reader, WorldCollection worlds) { ColumnParser parser = new ColumnParser(reader); foreach (var row in parser.Data) { ParseWorld(worlds, row.dict, row.line, row.lineNumber); } }
protected RpcPacketSystem(WorldCollection collection) : base(collection) { notificationSet = World.Mgr.GetEntities() .With <T>() .With <RpcSystem.NotificationTag>() .AsSet(); DependencyResolver.Add(() => ref RpcSystem); }
public ClientSendAudioResourceSystem(WorldCollection collection) : base(collection) { resourceSet = collection.Mgr.GetEntities() .With <AudioResource>() .With <IsResourceLoaded <AudioResource> >() .AsSet(); clientLastMaxId = new Dictionary <AudioClientFeature, int>(); }
protected RpcPacketWithResponseSystem(WorldCollection collection) : base(collection) { awaitingResponseSet = collection.Mgr.GetEntities() .With <T>() .With <RpcSystem.ClientRequestTag>() .Without <Task>() .AsSet(); DependencyResolver.Add(() => ref RpcSystem); }
public PrintSystem(WorldCollection collection) : base(collection) { // Get the logger, for logging to the console (we don't use Console.WriteLine) DependencyResolver.Add(() => ref logger); // Get a set that will return entities with PrintTextComponent entitySet = World.Mgr.GetEntities() .With <PrintTextComponent>() .AsSet(); }
public MasterDataModel GetMasterData() { MasterDataModel model = new MasterDataModel(); model.Universes = UniverseCollection.GetAll(); model.Worlds = WorldCollection.GetAll(); model.Areas = AreaCollection.GetAll(); model.Sections = SectionCollection.Bundle; return(model); }
private static void ParseUWP(WorldCollection worlds, string line, int lineNumber) { Match match = worldRegex.Match(line); if (!match.Success) { #if DEBUG worlds.ErrorList.Add("ERROR (SEC Parse): " + line); #endif return; } try { World world = new World(); // Allegiance may affect interpretation of other values, e.g. bases, zones world.Allegiance = match.Groups["allegiance"].Value.Trim(); // Crack the RegExpr data world.Name = nameFixupRegex.Replace(match.Groups["name"].Value.Trim(), ""); world.Hex = Int32.Parse(match.Groups["hex"].Value, CultureInfo.InvariantCulture); world.UWP = match.Groups["uwp"].Value.Trim(); world.CompactLegacyBases = EmptyIfDash(match.Groups["base"].Value.Trim()); world.Remarks = match.Groups["codes"].Value.Trim(); world.Zone = EmptyIfDash(match.Groups["zone"].Value); world.PBG = match.Groups["pbg"].Value.Trim(); // Cleanup known placeholders if (world.Name == match.Groups["hex"].Value || placeholderNameRegex.IsMatch(world.Name)) { world.Name = ""; } if (world.Name == world.Name.ToUpperInvariant()) { world.Name = Util.FixCapitalization(world.Name); } //world.Name = world.Name.Replace('~', '\u00e9'); // Used for Ferré (Cadion/Core 0704) //world.Pbg = world.Pbg.Replace( ' ', '0' ); // Shouldn't be necessary worlds[world.X, world.Y] = world; string rest = match.Groups["rest"].Value; if (!String.IsNullOrEmpty(rest)) { ParseRest(rest, worlds, line, world); } } catch (Exception e) { throw new Exception(String.Format("UWP Parse Error in line {0}:\n{1}\n{2}", lineNumber, e.Message, line)); } }
public SoLoudStandardPlayerSystem(WorldCollection collection) : base(collection) { DependencyResolver.Add(() => ref playerManager); DependencyResolver.Add(() => ref resourceManager); DependencyResolver.Add(() => ref worldTime); AddDisposable(recorder = new EntityCommandRecorder()); AddDisposable(controllerSet = collection.Mgr.GetEntities() .With <StandardAudioPlayerComponent>() .AsSet()); }
private void Page_Load(object sender, System.EventArgs e) { if (!AdminAuthorized()) { return; } Response.ContentType = MediaTypeNames.Text.Plain; ResourceManager resourceManager = new ResourceManager(Server, Cache); string sectorName = GetStringOption("sector"); string type = GetStringOption("type"); // NOTE: This (re)initializes a static data structure used for // resolving names into sector locations, so needs to be run // before any other objects (e.g. Worlds) are loaded. SectorMap.Flush(); SectorMap map = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager); var sectorQuery = from sector in map.Sectors where (sectorName == null || sector.Names[0].Text.StartsWith(sectorName, ignoreCase: true, culture: CultureInfo.InvariantCulture)) && (sector.DataFile != null) && (type == null || sector.DataFile.Type == type) && (sector.Tags.Contains("OTU")) orderby sector.Names[0].Text select sector; foreach (var sector in sectorQuery) { Response.Output.WriteLine(sector.Names[0].Text); #if DEBUG WorldCollection worlds = sector.GetWorlds(resourceManager, cacheResults: false); if (worlds != null) { Response.Output.WriteLine("{0} world(s)", worlds.Count()); foreach (string s in worlds.ErrorList.Where(s => candidate.IsMatch(s))) { Response.Output.WriteLine(s); } } else { Response.Output.WriteLine("{0} world(s)", 0); } #endif Response.Output.WriteLine(); } return; }
private static void ParseRest(string rest, WorldCollection worlds, string line, World world) { // Assume stellar data, try to parse it try { world.Stellar = StellarDataParser.Parse(rest, StellarDataParser.OutputFormat.Compact); } catch (StellarDataParser.InvalidSystemException) { #if DEBUG worlds.ErrorList.Add("WARNING (Stellar Data): " + line); #endif } }
public WorldCollection ToWorldCollection() { var collection = new WorldCollection(); collection.Layers = this.Layers; collection.GroundTiles = this.GroundTiles; collection.Outline = this.Outline; collection.TrapMagic = this.TrapMagic; collection.EntitiesParent = this.EntitiesParent; collection.GeneralPrefabs = this.GeneralPrefabs; collection.NavigatorPrefabs = this.NavigatorPrefabs; collection.BasePrefabs = this.BasePrefabs; return(collection); }
public ClientSendAudioPlayerSystem(WorldCollection collection) : base(collection) { withoutIdSet = collection.Mgr.GetEntities() .With <AudioPlayerType>() .Without <AudioPlayerId>() .AsSet(); playerSet = collection.Mgr.GetEntities() .With <AudioPlayerType>() .With <AudioPlayerId>() .AsSet(); selfLastMaxId = 1; clientLastMaxId = new Dictionary <AudioClientFeature, int>(); }
public static async Task <World> LoadWorld(string worldName) { var worldColl = await WorldCollection.FindAsync(x => x.Name == worldName); var world = await worldColl.FirstOrDefaultAsync(); if (world != null) { world.Players = new List <Player>(); return(world); } else { return(new World(worldName, 100, 60)); } }
public override void Parse(TextReader reader, WorldCollection worlds, ErrorLogger errors) { int lineNumber = 0; for (string line = reader.ReadLine(); line != null; line = reader.ReadLine()) { ++lineNumber; if (line.Length == 0) continue; switch (line[0]) { case '#': break; // comment case '$': break; // route case '@': break; // subsector default: ParseWorld(worlds, line, lineNumber, errors ?? worlds.ErrorList); break; } } }
public abstract void Parse(TextReader reader, WorldCollection worlds);
protected static void ParseWorld(WorldCollection worlds, StringDictionary dict, string line, int lineNumber) { try { World world = new World(); world.Hex = Int32.Parse(dict["Hex"], CultureInfo.InvariantCulture); world.Name = dict["Name"]; world.UWP = Check(dict, "UWP", UWP_REGEX); world.PBG = Check(dict, "PBG", PBG_REGEX); world.Stellar = Check(dict, new string[] { "Stellar", "Stars", "Stellar Data" }, STARS_REGEX); // Allegiance may affect interpretation of other values, e.g. bases, zones world.Allegiance = Check(dict, new string[] { "A", "Allegiance" }); world.CompactLegacyBases = EmptyIfDash(Check(dict, new string[] { "B", "Bases" })); // TODO: World.T5Bases ? world.Zone = EmptyIfDash(Check(dict, new string[] { "Z", "Zone" })); world.Remarks = Check(dict, new string[] { "Remarks", "Trade Codes", "Comments" } ); // T5 world.Importance = Check(dict, new string[] { "{Ix}", "{ Ix }", "Ix" }); world.Economic = Check(dict, new string[] { "(Ex)", "( Ex )", "Ex" }); world.Cultural = Check(dict, new string[] { "[Cx]", "[ Cx ]", "Cx" }); world.Nobility = EmptyIfDash(Check(dict, new string[] { "N", "Nobility" })); string w = Check(dict, new string[] { "W", "Worlds" }); if (!String.IsNullOrEmpty(w)) world.Worlds = Int32.Parse(w, NumberStyles.Integer, CultureInfo.InvariantCulture); string ru = dict["RU"]; if (!String.IsNullOrEmpty(ru)) world.ResourceUnits = Int32.Parse(w, NumberStyles.Integer, CultureInfo.InvariantCulture); // Cleanup known placeholders if (world.Name == world.Name.ToUpperInvariant()) { world.Name = Util.FixCapitalization(world.Name); } // Fix "smart" apostrophe world.Name = world.Name.Replace('\x92', '\''); #if DEBUG if (worlds[world.X, world.Y] != null) { worlds.ErrorList.Add("ERROR (Duplicate): " + line); } #endif worlds[world.X, world.Y] = world; } #if DEBUG catch (Exception e) { worlds.ErrorList.Add(String.Format("ERROR (TAB Parse - {0}): ", e.Message) + line); } #else catch (Exception) { } #endif }
public override void Parse(TextReader reader, WorldCollection worlds) { int lineNumber = 0; string line; string[] header = null; while (true) { line = reader.ReadLine(); if (line == null) return; ++lineNumber; if (line.Length == 0) continue; if (line.StartsWith("#")) continue; if (header == null) { header = line.Split(TAB_DELIMITER); continue; } ParseLine(worlds, header, line, lineNumber); } }
private static void ParseLine(WorldCollection worlds, string[] header, string line, int lineNumber) { string[] cols = line.Split(TAB_DELIMITER); if (cols.Length != header.Length) { #if DEBUG worlds.ErrorList.Add("ERROR (TAB Parse): " + line); #endif return; } StringDictionary dict = new StringDictionary(); for (var i = 0; i < cols.Length; ++i ) { dict[header[i]] = cols[i].Trim(); } ParseWorld(worlds, dict, line, lineNumber); }
private static void ParseRest(string rest, WorldCollection worlds, string line, World world) { // Assume stellar data, try to parse it try { world.Stellar = StellarDataParser.Parse(rest, StellarDataParser.OutputFormat.Compact); } catch (StellarDataParser.InvalidSystemException) { #if DEBUG worlds.ErrorList.Add("WARNING (Stellar Data): " + line); #endif } }
internal WorldCollection GetWorlds(ResourceManager resourceManager, bool cacheResults = true) { lock (this) { // Have it cached - just return it if (worlds != null) return worlds; // Can't look it up; failure case if (DataFile == null) return null; // Otherwise, look it up WorldCollection data = resourceManager.GetDeserializableFileObject(@"~/res/Sectors/" + DataFile, typeof(WorldCollection), cacheResults: false, mediaType: DataFile.Type) as WorldCollection; foreach (World world in data) world.Sector = this; if (cacheResults) worlds = data; return data; } }
private static void ParseRest(string rest, WorldCollection worlds, int lineNumber, string line, World world, ErrorLogger errors) { // Assume stellar data, try to parse it try { world.Stellar = StellarDataParser.Parse(rest, StellarDataParser.OutputFormat.Compact); } catch (StellarDataParser.InvalidSystemException) { if (errors != null) errors.Warning(String.Format("Invalid stellar data: '{0}'", rest), lineNumber, line); } }
public void Parse(Stream stream, WorldCollection worlds, ErrorLogger errors) { using (var reader = new StreamReader(stream, Encoding, detectEncodingFromByteOrderMarks: true, bufferSize: BUFFER_SIZE)) { Parse(reader, worlds, errors ?? worlds.ErrorList); } }
public SectorMetadata(Sector sector, WorldCollection worlds) { this.m_sector = sector; this.m_worlds = worlds; this.m_dataFile = new DataFileMetadata(sector); }
public abstract void Parse(TextReader reader, WorldCollection worlds, ErrorLogger errors);
protected static void ParseWorld(WorldCollection worlds, StringDictionary dict, string line, int lineNumber, ErrorLogger errors) { try { FieldChecker checker = new FieldChecker(dict, errors, lineNumber, line); World world = new World(); world.Hex = checker.Check("Hex", HEX_REGEX); world.Name = dict["Name"]; world.UWP = checker.Check("UWP", UWP_REGEX); world.Remarks = checker.Check(new string[] { "Remarks", "Trade Codes", "Comments" }); world.Importance = checker.Check(new string[] { "{Ix}", "{ Ix }", "Ix" }); world.Economic = checker.Check(new string[] { "(Ex)", "( Ex )", "Ex" }); world.Cultural = checker.Check(new string[] { "[Cx]", "[ Cx ]", "Cx" }); world.Nobility = checker.Check(new string[] { "N", "Nobility" }, NOBILITY_REGEX, CheckOptions.EmptyIfDash); world.Bases = checker.Check(new string[] { "B", "Bases" }, BASES_REGEX, CheckOptions.EmptyIfDash); world.Zone = checker.Check(new string[] { "Z", "Zone" }, ZONE_REGEX, CheckOptions.EmptyIfDash); world.PBG = checker.Check("PBG", PBG_REGEX); world.Allegiance = checker.Check(new string[] { "A", "Al", "Allegiance" }, // TODO: Allow unofficial sectors to have locally declared allegiances. a => a.Length != 4 || SecondSurvey.IsKnownT5Allegiance(a)); world.Stellar = checker.Check(new string[] { "Stellar", "Stars", "Stellar Data" }, STARS_REGEX, CheckOptions.Warning); int w; if (Int32.TryParse(checker.Check(new string[] { "W", "Worlds" }), NumberStyles.Integer, CultureInfo.InvariantCulture, out w)) world.Worlds = w; int ru; if (Int32.TryParse(dict["RU"], NumberStyles.Integer | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out ru)) world.ResourceUnits = ru; // Cleanup known placeholders if (world.Name == world.Name.ToUpperInvariant() && world.IsHi) world.Name = Util.FixCapitalization(world.Name); if (worlds[world.X, world.Y] != null && errors != null) errors.Warning("Duplicate World", lineNumber, line); if (!checker.HadError) { worlds[world.X, world.Y] = world; } } catch (Exception e) { errors.Error("Parse Error: " + e.Message, lineNumber, line); //throw new Exception(String.Format("UWP Parse Error in line {0}:\n{1}\n{2}", lineNumber, e.Message, line)); } }
public override void Parse(TextReader reader, WorldCollection worlds, ErrorLogger errors) { TSVParser parser = new TSVParser(reader); foreach (var row in parser.Data) ParseWorld(worlds, row.dict, row.line, row.lineNumber, errors); }
internal Sector(Stream stream, string mediaType, ErrorLogger errors) : this() { WorldCollection wc = new WorldCollection(); wc.Deserialize(stream, mediaType, errors); foreach (World world in wc) world.Sector = this; worlds = wc; }
private static void ParseUWP(WorldCollection worlds, string line, int lineNumber) { Match match = worldRegex.Match(line); if (!match.Success) { #if DEBUG worlds.ErrorList.Add("ERROR (SEC Parse): " + line); #endif return; } try { World world = new World(); // Allegiance may affect interpretation of other values, e.g. bases, zones world.Allegiance = match.Groups["allegiance"].Value.Trim(); // Crack the RegExpr data world.Name = nameFixupRegex.Replace(match.Groups["name"].Value.Trim(), ""); world.Hex = Int32.Parse(match.Groups["hex"].Value, CultureInfo.InvariantCulture); world.UWP = match.Groups["uwp"].Value.Trim(); world.CompactLegacyBases = EmptyIfDash(match.Groups["base"].Value.Trim()); world.Remarks = match.Groups["codes"].Value.Trim(); world.Zone = EmptyIfDash(match.Groups["zone"].Value); world.PBG = match.Groups["pbg"].Value.Trim(); // Cleanup known placeholders if (world.Name == match.Groups["hex"].Value || placeholderNameRegex.IsMatch(world.Name)) world.Name = ""; if (world.Name == world.Name.ToUpperInvariant()) world.Name = Util.FixCapitalization(world.Name); //world.Name = world.Name.Replace('~', '\u00e9'); // Used for Ferré (Cadion/Core 0704) //world.Pbg = world.Pbg.Replace( ' ', '0' ); // Shouldn't be necessary worlds[world.X, world.Y] = world; string rest = match.Groups["rest"].Value; if (!String.IsNullOrEmpty(rest)) { ParseRest(rest, worlds, line, world); } } catch (Exception e) { throw new Exception(String.Format("UWP Parse Error in line {0}:\n{1}\n{2}", lineNumber, e.Message, line)); } }
private static void ParseWorld(WorldCollection worlds, string line, int lineNumber, ErrorLogger errors) { if (!uwpRegex.IsMatch(line)) { if (errors != null) errors.Warning("Ignoring non-UWP data", lineNumber, line); return; } Match match = worldRegex.Match(line); if (!match.Success) { if (errors != null) errors.Error("SEC Parse", lineNumber, line); return; } try { World world = new World(); // Allegiance may affect interpretation of other values, e.g. bases, zones world.Allegiance = match.Groups["allegiance"].Value.Trim(); // Crack the RegExpr data world.Name = nameFixupRegex.Replace(match.Groups["name"].Value.Trim(), ""); world.Hex = match.Groups["hex"].Value.Trim(); world.UWP = match.Groups["uwp"].Value.Trim(); world.LegacyBaseCode = EmptyIfDash(match.Groups["base"].Value.Trim()); world.Remarks = match.Groups["codes"].Value.Trim(); world.Zone = EmptyIfDash(match.Groups["zone"].Value); world.PBG = match.Groups["pbg"].Value.Trim(); // Cleanup known placeholders if (world.Name == match.Groups["hex"].Value || placeholderNameRegex.IsMatch(world.Name)) world.Name = ""; if (world.Name == world.Name.ToUpperInvariant() && world.IsHi) world.Name = Util.FixCapitalization(world.Name); worlds[world.X, world.Y] = world; string rest = match.Groups["rest"].Value; if (!String.IsNullOrEmpty(rest)) ParseRest(rest, worlds, lineNumber, line, world, errors); } catch (Exception e) { errors.Error("Parse error: " + e.Message, lineNumber, line); //throw new Exception(String.Format("UWP Parse Error in line {0}:\n{1}\n{2}", lineNumber, e.Message, line)); } }
internal SectorMetadata(Sector sector, WorldCollection worlds) { this.sector = sector; this.worlds = worlds; dataFile = new DataFileMetadata(sector); }