Merge branch 'sql' of github.com:TShock/TShock into sql
This commit is contained in:
commit
bb77a3baea
1 changed files with 81 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using Community.CsharpSqlite.SQLiteClient;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Xml;
|
||||
|
|
@ -45,6 +46,12 @@ namespace TShockAPI
|
|||
"CREATE TABLE IF NOT EXISTS \"Warps\" (\"X\" INTEGER(11) NOT NULL UNIQUE, \"Y\" INTEGER(11) NOT NULL UNIQUE , \"WarpName\" VARCHAR(32) NOT NULL UNIQUE , \"WorldName\" VARCHAR(255) NOT NULL );";
|
||||
com.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
if(!File.Exists(FileTools.WarpsPath))
|
||||
{
|
||||
ReadWarps();
|
||||
File.Delete(FileTools.WarpsPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -110,6 +117,80 @@ namespace TShockAPI
|
|||
}
|
||||
return new Warp();
|
||||
}
|
||||
|
||||
public static void ReadWarps()
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
|
||||
xmlReaderSettings.IgnoreWhitespace = true;
|
||||
|
||||
using (XmlReader settingr = XmlReader.Create(FileTools.WarpsPath, xmlReaderSettings))
|
||||
{
|
||||
while (settingr.Read())
|
||||
{
|
||||
if (settingr.IsStartElement())
|
||||
{
|
||||
switch (settingr.Name)
|
||||
{
|
||||
case "Warps":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "Warp":
|
||||
{
|
||||
if (settingr.Read())
|
||||
{
|
||||
string name = string.Empty;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
string worldname = string.Empty;
|
||||
|
||||
settingr.Read();
|
||||
if (settingr.Value != "" || settingr.Value != null)
|
||||
name = settingr.Value;
|
||||
else
|
||||
Log.Warn("Warp name is empty, This warp will not work");
|
||||
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
if (settingr.Value != "" || settingr.Value != null)
|
||||
Int32.TryParse(settingr.Value, out x);
|
||||
else
|
||||
Log.Warn("x for warp " + name + " is empty");
|
||||
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
if (settingr.Value != "" || settingr.Value != null)
|
||||
Int32.TryParse(settingr.Value, out y);
|
||||
else
|
||||
Log.Warn("y for warp " + name + " is empty");
|
||||
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
if (settingr.Value != "" || settingr.Value != null)
|
||||
worldname = settingr.Value;
|
||||
else
|
||||
Log.Warn("Worldname for warp " + name + " is empty");
|
||||
|
||||
TShock.Warps.AddWarp(x, y, name, worldname);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.Info("Read Warps");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Log.Info("Could not read Warps");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Warp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue