Fix dump methods that were disabled earlier

This commit is contained in:
Lucas Nicodemus 2017-04-21 10:15:28 -06:00
parent fd6c98e934
commit 33d34f3f0b
No known key found for this signature in database
GPG key ID: CEE668CCE1BF2C7C

View file

@ -1166,237 +1166,240 @@ namespace TShockAPI
return points; return points;
} }
// /// <summary> /// <summary>
// /// Dumps information and optionally exits afterwards /// Dumps information and optionally exits afterwards
// /// </summary> /// </summary>
// /// <param name="exit"></param> /// <param name="exit"></param>
// public void Dump(bool exit = true) public void Dump(bool exit = true)
// { {
// PrepareLangForDump(); PrepareLangForDump();
// Lang.setLang(true); // Lang.setLang(true);
// ConfigFile.DumpDescriptions(); ConfigFile.DumpDescriptions();
// Permissions.DumpDescriptions(); Permissions.DumpDescriptions();
// ServerSideCharacters.ServerSideConfig.DumpDescriptions(); ServerSideCharacters.ServerSideConfig.DumpDescriptions();
// RestManager.DumpDescriptions(); RestManager.DumpDescriptions();
// DumpBuffs("BuffList.txt"); DumpBuffs("BuffList.txt");
// DumpItems("Items-1_0.txt", -48, 235); DumpItems("Items-1_0.txt", -48, 235);
// DumpItems("Items-1_1.txt", 235, 604); DumpItems("Items-1_1.txt", 235, 604);
// DumpItems("Items-1_2.txt", 604, 2749); DumpItems("Items-1_2.txt", 604, 2749);
// DumpItems("Items-1_3.txt", 2749, Main.maxItemTypes); DumpItems("Items-1_3.txt", 2749, Main.maxItemTypes);
// DumpNPCs("NPCs.txt"); DumpNPCs("NPCs.txt");
// DumpProjectiles("Projectiles.txt"); DumpProjectiles("Projectiles.txt");
// DumpPrefixes("Prefixes.txt"); DumpPrefixes("Prefixes.txt");
// if (exit) if (exit)
// { {
// Environment.Exit(1); Environment.Exit(1);
// } }
// } }
// internal void PrepareLangForDump() internal void PrepareLangForDump()
// { {
// for(int i = 0; i < Main.recipe.Length; i++) for(int i = 0; i < Main.recipe.Length; i++)
// Main.recipe[i] = new Recipe(); Main.recipe[i] = new Recipe();
// } }
// public void DumpBuffs(string path) public void DumpBuffs(string path)
// { {
// StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
// buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {"); buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {");
// buffer.AppendLine(" \"h-0\": \"ID\","); buffer.AppendLine(" \"h-0\": \"ID\",");
// buffer.AppendLine(" \"h-1\": \"Name\","); buffer.AppendLine(" \"h-1\": \"Name\",");
// buffer.AppendLine(" \"h-2\": \"Description\","); buffer.AppendLine(" \"h-2\": \"Description\",");
// List<object[]> elements = new List<object[]>(); List<object[]> elements = new List<object[]>();
// for (int i = 0; i < Main.maxBuffTypes; i++) for (int i = 0; i < Main.maxBuffTypes; i++)
// { {
// if (!String.IsNullOrEmpty(Lang.GetBuffName(i))) if (!String.IsNullOrEmpty(Lang.GetBuffName(i)))
// { {
// object[] element = new object[] { i, Lang.GetBuffName(i), Main.buffTip[i] }; object[] element = new object[] { i, Lang.GetBuffName(i), Lang.GetBuffDescription(i) };
// elements.Add(element); elements.Add(element);
// } }
// } }
// var rows = elements.Count; var rows = elements.Count;
// var columns = 0; var columns = 0;
// if (rows > 0) if (rows > 0)
// { {
// columns = elements[0].Length; columns = elements[0].Length;
// } }
// OutputElementsForDump(buffer, elements, rows, columns); OutputElementsForDump(buffer, elements, rows, columns);
// buffer.AppendLine(); buffer.AppendLine();
// buffer.AppendLine(" },"); buffer.AppendLine(" },");
// buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows)); buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows));
// buffer.AppendLine("}").Append("[/block]"); buffer.AppendLine("}").Append("[/block]");
// File.WriteAllText(path, buffer.ToString()); File.WriteAllText(path, buffer.ToString());
// } }
// public void DumpItems(string path, int start, int end) public void DumpItems(string path, int start, int end)
// { {
// Main.player[Main.myPlayer] = new Player(); Main.player[Main.myPlayer] = new Player();
// StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
// Regex newLine = new Regex(@"\n"); Regex newLine = new Regex(@"\n");
// buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {"); buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {");
// buffer.AppendLine(" \"h-0\": \"ID\","); buffer.AppendLine(" \"h-0\": \"ID\",");
// buffer.AppendLine(" \"h-1\": \"Name\","); buffer.AppendLine(" \"h-1\": \"Name\",");
// buffer.AppendLine(" \"h-2\": \"Tooltip\","); buffer.AppendLine(" \"h-2\": \"Tooltip\",");
// buffer.AppendLine(" \"h-3\": \"Tooltip 2\",");
List<object[]> elements = new List<object[]>();
// List<object[]> elements = new List<object[]>(); for (int i = start; i < end; i++)
// for (int i = start; i < end; i++) {
// { Item item = new Item();
// Item item = new Item(); item.SetDefaults(i);
// item.netDefaults(i);
// if (!String.IsNullOrEmpty(item.Name)) string tt = "";
// { for (int x = 0; x < item.ToolTip.Lines; x++) {
// object[] element = new object[] { i, tt += item.ToolTip.GetLine(x) + "\n";
// newLine.Replace(item.Name, @" "), }
// newLine.Replace(item.toolTip, @" "), if (!String.IsNullOrEmpty(item.Name))
// newLine.Replace(item.toolTip2, @" ") {
// }; object[] element = new object[] { i,
// elements.Add(element); newLine.Replace(item.Name, @" "),
// } newLine.Replace(tt, @" "),
// } };
elements.Add(element);
// var rows = elements.Count; }
// var columns = 0; }
// if (rows > 0)
// { var rows = elements.Count;
// columns = elements[0].Length; var columns = 0;
// } if (rows > 0)
// OutputElementsForDump(buffer, elements, rows, columns); {
columns = elements[0].Length;
// buffer.AppendLine(); }
// buffer.AppendLine(" },"); OutputElementsForDump(buffer, elements, rows, columns);
// buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows));
// buffer.AppendLine("}").Append("[/block]"); buffer.AppendLine();
buffer.AppendLine(" },");
// File.WriteAllText(path, buffer.ToString()); buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows));
// } buffer.AppendLine("}").Append("[/block]");
// public void DumpNPCs(string path) File.WriteAllText(path, buffer.ToString());
// { }
// StringBuilder buffer = new StringBuilder();
// buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {"); public void DumpNPCs(string path)
// buffer.AppendLine(" \"h-0\": \"ID\","); {
// buffer.AppendLine(" \"h-1\": \"Name\","); StringBuilder buffer = new StringBuilder();
// buffer.AppendLine(" \"h-2\": \"Display Name\","); buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {");
buffer.AppendLine(" \"h-0\": \"ID\",");
// List<object[]> elements = new List<object[]>(); buffer.AppendLine(" \"h-1\": \"Full Name\",");
// for (int i = -65; i < Main.maxNPCTypes; i++) buffer.AppendLine(" \"h-2\": \"Type Name\",");
// {
// NPC npc = new NPC(); List<object[]> elements = new List<object[]>();
// npc.netDefaults(i); for (int i = -65; i < Main.maxNPCTypes; i++)
// if (!String.IsNullOrEmpty(npc.FullName)) {
// { NPC npc = new NPC();
// object[] element = new object[] { i, npc.FullName, npc.displayName }; npc.SetDefaults(i);
// elements.Add(element); if (!String.IsNullOrEmpty(npc.FullName))
// } {
// } object[] element = new object[] { i, npc.FullName, npc.TypeName };
elements.Add(element);
// var rows = elements.Count; }
// var columns = 0; }
// if (rows > 0)
// { var rows = elements.Count;
// columns = elements[0].Length; var columns = 0;
// } if (rows > 0)
// OutputElementsForDump(buffer, elements, rows, columns); {
columns = elements[0].Length;
// buffer.AppendLine(); }
// buffer.AppendLine(" },"); OutputElementsForDump(buffer, elements, rows, columns);
// buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows));
// buffer.AppendLine("}").Append("[/block]"); buffer.AppendLine();
buffer.AppendLine(" },");
// File.WriteAllText(path, buffer.ToString()); buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows));
// } buffer.AppendLine("}").Append("[/block]");
// public void DumpProjectiles(string path) File.WriteAllText(path, buffer.ToString());
// { }
// Main.rand = new UnifiedRandom();
// StringBuilder buffer = new StringBuilder(); public void DumpProjectiles(string path)
// buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {"); {
// buffer.AppendLine(" \"h-0\": \"ID\","); Main.rand = new UnifiedRandom();
// buffer.AppendLine(" \"h-1\": \"Name\","); StringBuilder buffer = new StringBuilder();
buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {");
// List<object[]> elements = new List<object[]>(); buffer.AppendLine(" \"h-0\": \"ID\",");
// for (int i = 0; i < Main.maxProjectileTypes; i++) buffer.AppendLine(" \"h-1\": \"Name\",");
// {
// Projectile projectile = new Projectile(); List<object[]> elements = new List<object[]>();
// projectile.SetDefaults(i); for (int i = 0; i < Main.maxProjectileTypes; i++)
// if (!String.IsNullOrEmpty(projectile.Name)) {
// { Projectile projectile = new Projectile();
// object[] element = new object[] { i, projectile.Name }; projectile.SetDefaults(i);
// elements.Add(element); if (!String.IsNullOrEmpty(projectile.Name))
// } {
// } object[] element = new object[] { i, projectile.Name };
elements.Add(element);
// var rows = elements.Count; }
// var columns = 0; }
// if (rows > 0)
// { var rows = elements.Count;
// columns = elements[0].Length; var columns = 0;
// } if (rows > 0)
// OutputElementsForDump(buffer, elements, rows, columns); {
columns = elements[0].Length;
// buffer.AppendLine(); }
// buffer.AppendLine(" },"); OutputElementsForDump(buffer, elements, rows, columns);
// buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows));
// buffer.AppendLine("}").Append("[/block]"); buffer.AppendLine();
buffer.AppendLine(" },");
// File.WriteAllText(path, buffer.ToString()); buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows));
// } buffer.AppendLine("}").Append("[/block]");
// public void DumpPrefixes(string path) File.WriteAllText(path, buffer.ToString());
// { }
// StringBuilder buffer = new StringBuilder();
// buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {"); public void DumpPrefixes(string path)
// buffer.AppendLine(" \"h-0\": \"ID\","); {
// buffer.AppendLine(" \"h-1\": \"Name\","); StringBuilder buffer = new StringBuilder();
buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {");
// List<object[]> elements = new List<object[]>(); buffer.AppendLine(" \"h-0\": \"ID\",");
// for (int i = 0; i < Item.maxPrefixes; i++) buffer.AppendLine(" \"h-1\": \"Name\",");
// {
// string prefix = Lang.prefix[i].ToString(); List<object[]> elements = new List<object[]>();
for (int i = 0; i < PrefixID.Count; i++)
// if (!String.IsNullOrEmpty(prefix)) {
// { string prefix = Lang.prefix[i].ToString();
// object[] element = new object[] {i, prefix};
// elements.Add(element); if (!String.IsNullOrEmpty(prefix))
// } {
// } object[] element = new object[] {i, prefix};
elements.Add(element);
// var rows = elements.Count; }
// var columns = 0; }
// if (rows > 0)
// { var rows = elements.Count;
// columns = elements[0].Length; var columns = 0;
// } if (rows > 0)
// OutputElementsForDump(buffer, elements, rows, columns); {
columns = elements[0].Length;
// buffer.AppendLine(); }
// buffer.AppendLine(" },"); OutputElementsForDump(buffer, elements, rows, columns);
// buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows));
// buffer.AppendLine("}").Append("[/block]"); buffer.AppendLine();
buffer.AppendLine(" },");
// File.WriteAllText(path, buffer.ToString()); buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows));
// } buffer.AppendLine("}").Append("[/block]");
// private void OutputElementsForDump(StringBuilder buffer, List<object[]> elements, int rows, int columns) File.WriteAllText(path, buffer.ToString());
// { }
// if (rows > 0)
// { private void OutputElementsForDump(StringBuilder buffer, List<object[]> elements, int rows, int columns)
// columns = elements[0].Length; {
// for (int i = 0; i < columns; i++) if (rows > 0)
// { {
// for (int j = 0; j < rows; j++) columns = elements[0].Length;
// { for (int i = 0; i < columns; i++)
// buffer.Append(String.Format(" \"{0}-{1}\": \"{2}\"", j, i, elements[j][i])); {
// if (j != rows - 1 || i != columns - 1) for (int j = 0; j < rows; j++)
// buffer.AppendLine(","); {
// } buffer.Append(String.Format(" \"{0}-{1}\": \"{2}\"", j, i, elements[j][i]));
// } if (j != rows - 1 || i != columns - 1)
// } buffer.AppendLine(",");
// } }
}
}
}
} }
} }