regions.xml and warps.xml are now located in tshock dir. Will auto move them on first run

This commit is contained in:
Twitchy 2011-06-25 04:37:55 +12:00
parent 0a69d1ae3b
commit 57627f6846
3 changed files with 24 additions and 4 deletions

View file

@ -32,6 +32,8 @@ namespace TShockAPI
public static readonly string ItemBansPath = Path.Combine(TShock.SavePath, "itembans.txt");
public static readonly string RememberedPosPath = Path.Combine(TShock.SavePath, "oldpos.xml");
public static readonly string ConfigPath = Path.Combine(TShock.SavePath, "config.json");
public static readonly string RegionsPath = Path.Combine(TShock.SavePath, "regions.xml");
public static readonly string WarpsPath = Path.Combine(TShock.SavePath, "warps.xml");
public static void CreateFile(string file)
{
@ -64,6 +66,24 @@ namespace TShockAPI
CreateIfNot(UsersPath, Resources.users);
CreateIfNot(ItemBansPath, Resources.itembans);
//Copies if using old paths (Remove in future releases, after everyone is running this version +)
if (File.Exists("regions.xml") && !File.Exists(RegionsPath))
{
File.Move("regions.xml", RegionsPath);
}
else
{
CreateIfNot(RegionsPath);
}
if (File.Exists("warps.xml") && !File.Exists(WarpsPath))
{
File.Move("warps.xml", WarpsPath);
}
else
{
CreateIfNot(WarpsPath);
}
try
{
if (File.Exists(ConfigPath))

View file

@ -114,7 +114,7 @@ namespace TShockAPI
xmlWriterSettings.Indent = true;
xmlWriterSettings.NewLineChars = Environment.NewLine;
using (XmlWriter settingsw = XmlWriter.Create("regions.xml", xmlWriterSettings))
using (XmlWriter settingsw = XmlWriter.Create(FileTools.RegionsPath, xmlWriterSettings))
{
settingsw.WriteStartDocument();
settingsw.WriteStartElement("Regions");
@ -155,7 +155,7 @@ namespace TShockAPI
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.IgnoreWhitespace = true;
using (XmlReader settingr = XmlReader.Create("regions.xml", xmlReaderSettings))
using (XmlReader settingr = XmlReader.Create(FileTools.RegionsPath, xmlReaderSettings))
{
while (settingr.Read())
{

View file

@ -59,7 +59,7 @@ namespace TShockAPI
xmlWriterSettings.Indent = true;
xmlWriterSettings.NewLineChars = Environment.NewLine;
using (XmlWriter settingsw = XmlWriter.Create("warps.xml", xmlWriterSettings))
using (XmlWriter settingsw = XmlWriter.Create(FileTools.WarpsPath, xmlWriterSettings))
{
settingsw.WriteStartDocument();
settingsw.WriteStartElement("Warps");
@ -92,7 +92,7 @@ namespace TShockAPI
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.IgnoreWhitespace = true;
using (XmlReader settingr = XmlReader.Create("warps.xml", xmlReaderSettings))
using (XmlReader settingr = XmlReader.Create(FileTools.WarpsPath, xmlReaderSettings))
{
while (settingr.Read())
{