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.netDefaults(i); item.SetDefaults(i);
// if (!String.IsNullOrEmpty(item.Name))
// {
// object[] element = new object[] { i,
// newLine.Replace(item.Name, @" "),
// newLine.Replace(item.toolTip, @" "),
// newLine.Replace(item.toolTip2, @" ")
// };
// elements.Add(element);
// }
// }
// var rows = elements.Count; string tt = "";
// var columns = 0; for (int x = 0; x < item.ToolTip.Lines; x++) {
// if (rows > 0) tt += item.ToolTip.GetLine(x) + "\n";
// { }
// columns = elements[0].Length; if (!String.IsNullOrEmpty(item.Name))
// } {
// OutputElementsForDump(buffer, elements, rows, columns); object[] element = new object[] { i,
newLine.Replace(item.Name, @" "),
newLine.Replace(tt, @" "),
};
elements.Add(element);
}
}
// buffer.AppendLine(); var rows = elements.Count;
// buffer.AppendLine(" },"); var columns = 0;
// buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows)); if (rows > 0)
// buffer.AppendLine("}").Append("[/block]"); {
columns = elements[0].Length;
}
OutputElementsForDump(buffer, elements, rows, columns);
// File.WriteAllText(path, buffer.ToString()); buffer.AppendLine();
// } buffer.AppendLine(" },");
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\": {");
// buffer.AppendLine(" \"h-0\": \"ID\",");
// buffer.AppendLine(" \"h-1\": \"Name\",");
// buffer.AppendLine(" \"h-2\": \"Display Name\",");
// List<object[]> elements = new List<object[]>(); public void DumpNPCs(string path)
// for (int i = -65; i < Main.maxNPCTypes; i++) {
// { StringBuilder buffer = new StringBuilder();
// NPC npc = new NPC(); buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {");
// npc.netDefaults(i); buffer.AppendLine(" \"h-0\": \"ID\",");
// if (!String.IsNullOrEmpty(npc.FullName)) buffer.AppendLine(" \"h-1\": \"Full Name\",");
// { buffer.AppendLine(" \"h-2\": \"Type Name\",");
// object[] element = new object[] { i, npc.FullName, npc.displayName };
// elements.Add(element);
// }
// }
// var rows = elements.Count; List<object[]> elements = new List<object[]>();
// var columns = 0; for (int i = -65; i < Main.maxNPCTypes; i++)
// if (rows > 0) {
// { NPC npc = new NPC();
// columns = elements[0].Length; npc.SetDefaults(i);
// } if (!String.IsNullOrEmpty(npc.FullName))
// OutputElementsForDump(buffer, elements, rows, columns); {
object[] element = new object[] { i, npc.FullName, npc.TypeName };
elements.Add(element);
}
}
// buffer.AppendLine(); var rows = elements.Count;
// buffer.AppendLine(" },"); var columns = 0;
// buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows)); if (rows > 0)
// buffer.AppendLine("}").Append("[/block]"); {
columns = elements[0].Length;
}
OutputElementsForDump(buffer, elements, rows, columns);
// File.WriteAllText(path, buffer.ToString()); buffer.AppendLine();
// } buffer.AppendLine(" },");
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();
// buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {");
// buffer.AppendLine(" \"h-0\": \"ID\",");
// buffer.AppendLine(" \"h-1\": \"Name\",");
// List<object[]> elements = new List<object[]>(); public void DumpProjectiles(string path)
// for (int i = 0; i < Main.maxProjectileTypes; i++) {
// { Main.rand = new UnifiedRandom();
// Projectile projectile = new Projectile(); StringBuilder buffer = new StringBuilder();
// projectile.SetDefaults(i); buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {");
// if (!String.IsNullOrEmpty(projectile.Name)) buffer.AppendLine(" \"h-0\": \"ID\",");
// { buffer.AppendLine(" \"h-1\": \"Name\",");
// object[] element = new object[] { i, projectile.Name };
// elements.Add(element);
// }
// }
// var rows = elements.Count; List<object[]> elements = new List<object[]>();
// var columns = 0; for (int i = 0; i < Main.maxProjectileTypes; i++)
// if (rows > 0) {
// { Projectile projectile = new Projectile();
// columns = elements[0].Length; projectile.SetDefaults(i);
// } if (!String.IsNullOrEmpty(projectile.Name))
// OutputElementsForDump(buffer, elements, rows, columns); {
object[] element = new object[] { i, projectile.Name };
elements.Add(element);
}
}
// buffer.AppendLine(); var rows = elements.Count;
// buffer.AppendLine(" },"); var columns = 0;
// buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows)); if (rows > 0)
// buffer.AppendLine("}").Append("[/block]"); {
columns = elements[0].Length;
}
OutputElementsForDump(buffer, elements, rows, columns);
// File.WriteAllText(path, buffer.ToString()); buffer.AppendLine();
// } buffer.AppendLine(" },");
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\": {");
// buffer.AppendLine(" \"h-0\": \"ID\",");
// buffer.AppendLine(" \"h-1\": \"Name\",");
// List<object[]> elements = new List<object[]>(); public void DumpPrefixes(string path)
// for (int i = 0; i < Item.maxPrefixes; i++) {
// { StringBuilder buffer = new StringBuilder();
// string prefix = Lang.prefix[i].ToString(); buffer.AppendLine("[block:parameters]").AppendLine("{").AppendLine(" \"data\": {");
buffer.AppendLine(" \"h-0\": \"ID\",");
buffer.AppendLine(" \"h-1\": \"Name\",");
// if (!String.IsNullOrEmpty(prefix)) List<object[]> elements = new List<object[]>();
// { for (int i = 0; i < PrefixID.Count; i++)
// object[] element = new object[] {i, prefix}; {
// elements.Add(element); string prefix = Lang.prefix[i].ToString();
// }
// }
// var rows = elements.Count; if (!String.IsNullOrEmpty(prefix))
// var columns = 0; {
// if (rows > 0) object[] element = new object[] {i, prefix};
// { elements.Add(element);
// columns = elements[0].Length; }
// } }
// OutputElementsForDump(buffer, elements, rows, columns);
// buffer.AppendLine(); var rows = elements.Count;
// buffer.AppendLine(" },"); var columns = 0;
// buffer.AppendLine(String.Format(" \"cols\": {0},", columns)).AppendLine(String.Format(" \"rows\": {0}", rows)); if (rows > 0)
// buffer.AppendLine("}").Append("[/block]"); {
columns = elements[0].Length;
}
OutputElementsForDump(buffer, elements, rows, columns);
// File.WriteAllText(path, buffer.ToString()); buffer.AppendLine();
// } buffer.AppendLine(" },");
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(",");
// } }
}
}
}
} }
} }