public void f() { if (this.c()) { int key = 0; int e = -2147483648; foreach (int num3 in this.d.Keys) { if (this.d[num3].e > e) { key = num3; e = this.d[num3].e; } } this.d[key].a = true; cz.a local1 = this.d[key]; local1.g++; if (this.d[key].g > 20) { this.d.Remove(key); } else { PluginCore.cq.ax.get_Actions().UseItem(key, 0); } } }
private void a(object A_0, CreateObjectEventArgs A_1) { try { if (A_1.get_New().get_ObjectClass() == 0x1b) { CoordsObject obj2 = A_1.get_New().Coordinates(); dz dz = dz.a(obj2.get_EastWest(), obj2.get_NorthSouth(), 0.0); if (this.e.ContainsKey(A_1.get_New().get_Id()) && (dz.a(this.e[A_1.get_New().get_Id()].l, false) > 0.004167)) { this.e.Remove(A_1.get_New().get_Id()); } if (!this.e.ContainsKey(A_1.get_New().get_Id())) { b5.a a = new b5.a { l = dz, h = A_1.get_New().get_Name() == ("Corpse of " + CoreManager.get_Current().get_CharacterFilter().get_Name()) }; this.e.Add(A_1.get_New().get_Id(), a); PluginCore.cq.u.a(A_1.get_New().get_Id(), b0.a.c); } else { this.e[A_1.get_New().get_Id()].d = DateTimeOffset.Now; this.e[A_1.get_New().get_Id()].a = false; } } } catch (Exception exception) { ad.a(exception); } }
public void a(b0.a A_0) { MyList <int> list = new MyList <int>(0x59); foreach (KeyValuePair <int, b0.a> pair in this.g) { if (((b0.a)pair.Value) == A_0) { list.Add(pair.Key); } } foreach (int num in list) { if (this.e.Contains(num)) { this.e.Remove(num); } if (this.g.ContainsKey(num)) { Dictionary <b0.a, int> dictionary; b0.a a; (dictionary = this.h)[a = this.g[num]] = dictionary[a] - 1; this.g.Remove(num); } this.a(num, false); } l.i(); }
public cz(PluginCore A_0, CoreManager A_1, PluginHost A_2, cj A_3) { this.a = A_1.get_WorldFilter(); this.a.add_ChangeObject(new EventHandler <ChangeObjectEventArgs>(this.a)); this.a.add_ReleaseObject(new EventHandler <ReleaseObjectEventArgs>(this.a)); A_3.f(new cj.c(this.a)); A_3.l(new cj.c(this.b)); }
public b0(CoreManager A_0, PluginCore A_1, cj A_2) { this.a = A_0.get_WorldFilter(); A_2.l(new cj.c(this.a)); this.d.a(new EventHandler(this.a)); this.d.a(0x1f3); this.d.a(true); }
public void a() { if (!this.b) { this.b = true; GC.SuppressFinalize(this); this.a.remove_ReleaseObject(new EventHandler <ReleaseObjectEventArgs>(this.a)); this.a.remove_ChangeObject(new EventHandler <ChangeObjectEventArgs>(this.a)); this.a = null; } }
public b5(CoreManager A_0, PluginCore A_1) { this.b = A_1; this.a = A_0.get_WorldFilter(); this.a.add_CreateObject(new EventHandler <CreateObjectEventArgs>(this.a)); this.a.add_ChangeObject(new EventHandler <ChangeObjectEventArgs>(this.a)); this.a.add_ReleaseObject(new EventHandler <ReleaseObjectEventArgs>(this.a)); this.d.a(0x7879); this.d.a(new EventHandler(this.a)); this.b.a(new uTank2.PluginCore.a(this.a)); this.b.b(new PluginCore.EmptyDelegate(this.a)); }
private void a(object A_0, ReleaseObjectEventArgs A_1) { try { if (this.e.ContainsKey(A_1.get_Released().get_Id())) { this.e[A_1.get_Released().get_Id()].a = true; } } catch (Exception exception) { ad.a(exception); } }
public void a() { if (!this.b) { this.b = true; GC.SuppressFinalize(this); this.d.b(new EventHandler(this.a)); if (this.d != null) { this.d.e(); } PluginCore.cq.p.k(new cj.c(this.a)); this.a = null; } }
private void a(cv A_0) { int k = A_0.k; if (this.e.Contains(k)) { this.e.Remove(k); if (this.g.ContainsKey(k)) { Dictionary <b0.a, int> dictionary; b0.a a; (dictionary = this.h)[a = this.g[k]] = dictionary[a] - 1; this.g.Remove(k); } this.a(k, true); l.i(); } }
public void b() { if (!this.c) { this.c = true; GC.SuppressFinalize(this); this.b.b(new uTank2.PluginCore.a(this.a)); this.d.b(new EventHandler(this.a)); this.a.remove_CreateObject(new EventHandler <CreateObjectEventArgs>(this.a)); this.a.remove_ChangeObject(new EventHandler <ChangeObjectEventArgs>(this.a)); this.a.remove_ReleaseObject(new EventHandler <ReleaseObjectEventArgs>(this.a)); if (this.d != null) { this.d.e(); } this.b = null; this.a = null; } }
public void a(int A_0, b0.a A_1) { if (!this.e.Contains(A_0)) { if (this.h.ContainsKey(A_1)) { Dictionary <b0.a, int> dictionary; b0.a a; (dictionary = this.h)[a = A_1] = dictionary[a] + 1; } else { this.h[A_1] = 1; } this.g[A_0] = A_1; this.e.Add(A_0); l.i(); } }
public override void Process() { // 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. ResourceManager resourceManager = new ResourceManager(context.Server); SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu")); Sector sector; bool sscoords = GetBoolOption("sscoords", defaultValue: false); bool includeMetadata = GetBoolOption("metadata", defaultValue: true); bool includeHeader = GetBoolOption("header", defaultValue: true); if (context.Request.HttpMethod == "POST") { bool lint = GetBoolOption("lint", defaultValue: false); var errors = lint ? new ErrorLogger() : null; sector = new Sector(context.Request.InputStream, new ContentType(context.Request.ContentType).MediaType, errors); if (lint && !errors.Empty) { throw new HttpError(400, "Bad Request", errors.ToString()); } includeMetadata = false; } else if (HasOption("sx") && HasOption("sy")) { int sx = GetIntOption("sx", 0); int sy = GetIntOption("sy", 0); sector = map.FromLocation(sx, sy); if (sector == null) { throw new HttpError(404, "Not Found", string.Format("The sector at {0},{1} was not found.", sx, sy)); } } else if (HasOption("sector")) { string sectorName = GetStringOption("sector"); sector = map.FromName(sectorName); if (sector == null) { throw new HttpError(404, "Not Found", string.Format("The specified sector '{0}' was not found.", sectorName)); } } else { throw new HttpError(400, "Bad Request", "No sector specified."); } WorldFilter filter = null; if (HasOption("subsector")) { string subsector = GetStringOption("subsector"); int index = sector.SubsectorIndexFor(subsector); if (index == -1) { throw new HttpError(404, "Not Found", string.Format("The specified subsector '{0}' was not found.", subsector)); } filter = (World world) => (world.Subsector == index); } else if (HasOption("quadrant")) { string quadrant = GetStringOption("quadrant"); int index = Sector.QuadrantIndexFor(quadrant); if (index == -1) { throw new HttpError(400, "Bad Request", string.Format("The specified quadrant '{0}' is invalid.", quadrant)); } filter = (World world) => (world.Quadrant == index); } string mediaType = GetStringOption("type"); Encoding encoding; switch (mediaType) { case "SecondSurvey": case "TabDelimited": encoding = Util.UTF8_NO_BOM; break; default: encoding = Encoding.GetEncoding(1252); break; } string data; using (var writer = new StringWriter()) { // Content // sector.Serialize(resourceManager, writer, mediaType, includeMetadata: includeMetadata, includeHeader: includeHeader, sscoords: sscoords, filter: filter); data = writer.ToString(); } SendResult(context, data, encoding); }
private void Page_Load(object sender, System.EventArgs e) { if (!ServiceConfiguration.CheckEnabled("sec", Response)) { return; } // 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. ResourceManager resourceManager = new ResourceManager(Server, Cache); SectorMap map = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager); Sector sector; if (HasOption("sx") && HasOption("sy")) { int sx = GetIntOption("sx", 0); int sy = GetIntOption("sy", 0); sector = map.FromLocation(sx, sy); if (sector == null) { SendError(404, "Not Found", String.Format("The sector at {0},{1} was not found.", sx, sy)); return; } } else if (HasOption("sector")) { string sectorName = GetStringOption("sector"); sector = map.FromName(sectorName); if (sector == null) { SendError(404, "Not Found", String.Format("The specified sector '{0}' was not found.", sectorName)); return; } } else { SendError(404, "Not Found", "No sector specified."); return; } WorldFilter filter = null; if (HasOption("subsector")) { string ss = GetStringOption("subsector"); filter = (World world) => (world.SS == ss); } bool includeMetadata = GetBoolOption("metadata", defaultValue: true); bool includeHeader = GetBoolOption("header", defaultValue: true); string mediaType = GetStringOption("type"); Encoding encoding;; switch (mediaType) { case "SecondSurvey": case "TabDelimited": encoding = Util.UTF8_NO_BOM; break; default: encoding = Encoding.GetEncoding(1252); break; } string data; using (var writer = new StringWriter()) { // Content // sector.Serialize(resourceManager, writer, mediaType, includeMetadata: includeMetadata, includeHeader: includeHeader, filter: filter); data = writer.ToString(); } SendResult(data, encoding); }
private void a(object A_0, EventArgs A_1) { try { MyList <int> list = new MyList <int>(0x58); for (int i = 0; i < this.e.Count; i++) { if (!dh.b(this.e[i])) { list.Add(this.e[i]); if (i < this.c) { this.c--; } } } foreach (int num2 in list) { if (this.e.Contains(num2)) { this.e.Remove(num2); } if (this.g.ContainsKey(num2)) { Dictionary <b0.a, int> dictionary; b0.a a; (dictionary = this.h)[a = this.g[num2]] = dictionary[a] - 1; this.g.Remove(num2); } this.a(num2, false); } if (this.e.Count == 0) { l.i(); return; } this.c++; if (this.c < 0) { this.c = 0; } if (this.c >= this.e.Count) { this.c = 0; } int c = this.c; int num4 = 0; do { if (!this.a(this.e[c])) { int num5 = this.e[c]; PluginCore.cq.ax.get_Actions().RequestId(num5); break; } c++; if (c >= this.e.Count) { c = 0; } num4++; }while ((num4 <= this.e.Count) && (c != this.c)); this.c = c; } catch (Exception exception) { ad.a(exception); } l.i(); }
internal void Serialize(ResourceManager resourceManager, TextWriter writer, string mediaType, bool includeMetadata = true, bool includeHeader = true, bool sscoords = false, WorldFilter filter = null) { WorldCollection worlds = GetWorlds(resourceManager); // TODO: less hacky T5 support bool isT5 = (mediaType == "TabDelimited" || mediaType == "SecondSurvey"); if (mediaType == "TabDelimited") { if (worlds != null) { worlds.Serialize(writer, mediaType, includeHeader: includeHeader, filter: filter); } return; } if (includeMetadata) { // Header // writer.WriteLine("# Generated by http://travellermap.com"); writer.WriteLine("# " + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz", DateTimeFormatInfo.InvariantInfo)); writer.WriteLine(); writer.WriteLine("# {0}", Names[0]); writer.WriteLine("# {0},{1}", X, Y); writer.WriteLine(); foreach (var name in Names) { if (name.Lang != null) { writer.WriteLine("# Name: {0} ({1})", name.Text, name.Lang); } else { writer.WriteLine("# Name: {0}", name); } } if (Credits != null) { string stripped = Regex.Replace(Credits, "<.*?>", ""); stripped = Regex.Replace(stripped, @"\s+", " "); stripped = stripped.Trim(); writer.WriteLine(); writer.WriteLine("# Credits: {0}", stripped); } if (DataFile != null) { writer.WriteLine(); if (DataFile.Milieu != null) { writer.WriteLine("# Milieu: {0}", DataFile.Milieu); } writer.WriteLine(); if (DataFile.Author != null) { writer.WriteLine("# Author: {0}", DataFile.Author); } if (DataFile.Publisher != null) { writer.WriteLine("# Publisher: {0}", DataFile.Publisher); } if (DataFile.Copyright != null) { writer.WriteLine("# Copyright: {0}", DataFile.Copyright); } if (DataFile.Source != null) { writer.WriteLine("# Source: {0}", DataFile.Source); } if (DataFile.Ref != null) { writer.WriteLine("# Ref: {0}", DataFile.Ref); } } writer.WriteLine(); for (int i = 0; i < 16; ++i) { char c = (char)('A' + i); Subsector ss = Subsector(c); writer.WriteLine("# Subsector {0}: {1}", c, ss?.Name ?? ""); } writer.WriteLine(); } if (worlds == null) { if (includeMetadata) { writer.WriteLine("# No world data available"); } return; } // Allegiances if (includeMetadata) { // Use codes as present in the data, to match the worlds foreach (string code in worlds.AllegianceCodes().OrderBy(s => s)) { var alleg = GetAllegianceFromCode(code); if (alleg != null) { writer.WriteLine("# Alleg: {0}: \"{1}\"", isT5 ? code : SecondSurvey.T5AllegianceCodeToLegacyCode(code), alleg.Name); } } writer.WriteLine(); } // Worlds worlds.Serialize(writer, mediaType, includeHeader: includeHeader, sscoords: sscoords, filter: filter); }
public void Serialize(TextWriter writer, string mediaType, bool includeHeader = true, bool sscoords = false, WorldFilter filter = null) { SectorFileSerializer.ForType(mediaType).Serialize(writer, this.Where(world => filter == null || filter(world)), includeHeader: includeHeader, sscoords: sscoords); }
internal void Serialize(ResourceManager resourceManager, TextWriter writer, string mediaType, bool includeMetadata = true, bool includeHeader = true, bool sscoords = false, WorldFilter filter = null) { WorldCollection worlds = GetWorlds(resourceManager); // TODO: less hacky T5 support bool isT5 = (mediaType == "TabDelimited" || mediaType == "SecondSurvey"); if (mediaType == "TabDelimited") { if (worlds != null) worlds.Serialize(writer, mediaType, includeHeader: includeHeader, filter: filter); return; } if (includeMetadata) { // Header // writer.WriteLine("# Generated by http://travellermap.com"); writer.WriteLine("# " + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz", DateTimeFormatInfo.InvariantInfo)); writer.WriteLine(); writer.WriteLine("# {0}", Names[0]); writer.WriteLine("# {0},{1}", X, Y); writer.WriteLine(); foreach (var name in Names) { if (name.Lang != null) writer.WriteLine("# Name: {0} ({1})", name.Text, name.Lang); else writer.WriteLine("# Name: {0}", name); } if (Credits != null) { string stripped = Regex.Replace(Credits, "<.*?>", ""); stripped = Regex.Replace(stripped, @"\s+", " "); stripped = stripped.Trim(); writer.WriteLine(); writer.WriteLine("# Credits: {0}", stripped); } if (DataFile != null) { writer.WriteLine(); if (DataFile.Era != null) { writer.WriteLine("# Era: {0}", DataFile.Era); } writer.WriteLine(); if (DataFile.Author != null) { writer.WriteLine("# Author: {0}", DataFile.Author); } if (DataFile.Publisher != null) { writer.WriteLine("# Publisher: {0}", DataFile.Publisher); } if (DataFile.Copyright != null) { writer.WriteLine("# Copyright: {0}", DataFile.Copyright); } if (DataFile.Source != null) { writer.WriteLine("# Source: {0}", DataFile.Source); } if (DataFile.Ref != null) { writer.WriteLine("# Ref: {0}", DataFile.Ref); } } writer.WriteLine(); for (int i = 0; i < 16; ++i) { char c = (char)('A' + i); Subsector ss = Subsector(c); writer.WriteLine("# Subsector {0}: {1}", c, ss?.Name ?? ""); } writer.WriteLine(); } if (worlds == null) { if (includeMetadata) writer.WriteLine("# No world data available"); return; } // Allegiances if (includeMetadata) { // Use codes as present in the data, to match the worlds foreach (string code in worlds.AllegianceCodes().OrderBy(s => s)) { var alleg = GetAllegianceFromCode(code); if (alleg != null) writer.WriteLine("# Alleg: {0}: \"{1}\"", isT5 ? code : SecondSurvey.T5AllegianceCodeToLegacyCode(code), alleg.Name); } writer.WriteLine(); } // Worlds worlds.Serialize(writer, mediaType, includeHeader: includeHeader, sscoords: sscoords, filter: filter); }
public void Serialize(TextWriter writer, string mediaType, bool includeHeader, WorldFilter filter) { SectorFileSerializer.ForType(mediaType).Serialize(writer, this.Where(world => filter == null || filter(world)), includeHeader); }
public void Serialize(ResourceManager resourceManager, TextWriter writer, string mediaType, bool includeMetadata = true, bool includeHeader = true, WorldFilter filter = null) { WorldCollection worlds = GetWorlds(resourceManager); // TODO: less hacky T5 support if (mediaType == "TabDelimited") { if (worlds != null) { worlds.Serialize(writer, mediaType, includeHeader, filter); } return; } if (includeMetadata) { // Header // writer.WriteLine("# Generated by http://www.travellermap.com"); writer.WriteLine("# " + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz", DateTimeFormatInfo.InvariantInfo)); writer.WriteLine(); writer.WriteLine("# {0}", this.Names[0]); writer.WriteLine("# {0},{1}", this.X, this.Y); writer.WriteLine(); foreach (var name in Names) { if (name.Lang != null) { writer.WriteLine("# Name: {0} ({1})", name.Text, name.Lang); } else { writer.WriteLine("# Name: {0}", name); } } if (Credits != null) { string stripped = Regex.Replace(Credits, "<.*?>", ""); stripped = Regex.Replace(stripped, @"\s+", " "); stripped = stripped.Trim(); writer.WriteLine(); writer.WriteLine("# Credits: {0}", stripped); } if (DataFile != null) { writer.WriteLine(); if (DataFile.Era != null) { writer.WriteLine("# Era: {0}", DataFile.Era); } writer.WriteLine(); if (DataFile.Author != null) { writer.WriteLine("# Author: {0}", DataFile.Author); } if (DataFile.Publisher != null) { writer.WriteLine("# Publisher: {0}", DataFile.Publisher); } if (DataFile.Copyright != null) { writer.WriteLine("# Copyright: {0}", DataFile.Copyright); } if (DataFile.Source != null) { writer.WriteLine("# Source: {0}", DataFile.Source); } if (DataFile.Ref != null) { writer.WriteLine("# Ref: {0}", DataFile.Ref); } } writer.WriteLine(); for (int i = 0; i < 16; ++i) { char c = (char)('A' + i); Subsector ss = this[c]; writer.WriteLine("# Subsector {0}: {1}", c, (ss != null ? ss.Name : "")); } writer.WriteLine(); } if (worlds == null) { if (includeMetadata) { writer.WriteLine("# No world data available"); } return; } // Allegiances if (includeMetadata) { Dictionary <string, Allegiance> allegiances = new Dictionary <string, Allegiance>(); // TODO: Factor this logic out for MSEC/SectorMetaData serializers to use foreach (Allegiance alleg in worlds .Select(world => world.Allegiance) .Where(code => !allegiances.ContainsKey(code)) .Select(code => GetAllegiance(code)) .Where(alleg => alleg != null) .Distinct() .OrderBy(alleg => alleg.Code)) { writer.WriteLine("# Alleg: {0}: \"{1}\"", alleg.Code, alleg.Name); } writer.WriteLine(); } // Worlds worlds.Serialize(writer, mediaType, includeHeader, filter); }