User:JayJeckel
Jump to navigation
Jump to search
Jeckel is a desktop application programmer, a moderator of TerrariaOnline.com (Jeckel), and has logged thousands of hours playing Terraria.
WIP Projects
- User:JayJeckel/Shortcuts
- User:JayJeckel/Banlist.txt File Format
- User:JayJeckel/Servers.dat File Format
Stuff
Code Snippets
Steam Terraria Directory
public static string SteamTerrariaPath = Path.GetFullPath(Path.Combine((string)Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam").GetValue("SteamPath"), "steamapps", "common", "terraria"))
Terraria Directories
#if LINUX
public static string TerrariaPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".local", "share", "Terraria");
#elif MACOSX
public static string TerrariaPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library", "Application Support", "Terraria");
#else
public static string TerrariaPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "My Games", "Terraria");
#endif
public static string TerrariaCapturesPath = Path.Combine(Paths.Terraria.DataRoot, "Captures");
public static string TerrariaLogsPath = Path.Combine(Paths.Terraria.DataRoot, "Logs");
public static string TerrariaWorldsPath = Path.Combine(TerrariaPath, "Worlds");
public static string TerrariaPlayersPath = Path.Combine(TerrariaPath, "Players");
Get World Name
public static string GetWorldName(string path)
{
using (FileStream stream = new FileStream(path, FileMode.Open))
{
using (BinaryReader reader = new BinaryReader(stream))
{
int release = reader.ReadInt32();
if (release <= 0) { return Path.GetFileNameWithoutExtension(path); }
if (release <= 87) { return reader.ReadString(); }
else
{
reader.ReadInt16();
stream.Position = (long)reader.ReadInt32();
return reader.ReadString();
}
}
}
}