Merge branch 'general-devel' of github.com:TShock/TShock into general-devel

This commit is contained in:
high 2012-01-01 15:37:59 -05:00
commit 37a913d7a3
70 changed files with 1215 additions and 496 deletions

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace TShockDBEditor namespace TShockDBEditor

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;

View file

@ -1,4 +1,21 @@
namespace TShockDBEditor /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace TShockDBEditor
{ {
partial class TShockDBEditor partial class TShockDBEditor
{ {

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;

View file

@ -1,4 +1,21 @@
using System.Reflection; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -1,4 +1,22 @@
//------------------------------------------------------------------------------ /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.1

View file

@ -1,4 +1,22 @@
//------------------------------------------------------------------------------ /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.1

View file

@ -14,6 +14,7 @@
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
@ -26,7 +27,6 @@
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
@ -110,6 +110,7 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<None Include="TShockDBEditor.licenseheader" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<WCFMetadata Include="Service References\" /> <WCFMetadata Include="Service References\" />

View file

@ -0,0 +1,18 @@
extensions: .cs
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,8 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.IO; using System.IO;
using System.Threading; using System.Threading;

View file

@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@ -191,16 +190,15 @@ namespace TShockAPI
add(Permissions.rootonly, GrabUserUserInfo, "userinfo", "ui"); add(Permissions.rootonly, GrabUserUserInfo, "userinfo", "ui");
add(Permissions.rootonly, AuthVerify, "auth-verify"); add(Permissions.rootonly, AuthVerify, "auth-verify");
ChatCommands.Add(new Command(Permissions.canlogin, AttemptLogin, "login") {DoLog = false}); ChatCommands.Add(new Command(Permissions.canlogin, AttemptLogin, "login") {DoLog = false});
add(Permissions.cfg, Broadcast, "broadcast", "bc", "say", "yell", "scream", "yellinanguish", "speak"); add(Permissions.cfg, Broadcast, "broadcast", "bc", "say");
add(Permissions.whisper, Whisper, "whisper", "w", "tell"); add(Permissions.whisper, Whisper, "whisper", "w", "tell");
add(Permissions.whisper, Reply, "reply", "r"); add(Permissions.whisper, Reply, "reply", "r");
add(Permissions.annoy, Annoy, "annoy"); add(Permissions.annoy, Annoy, "annoy");
add(Permissions.cfg, ConvertWaR, "convert");
add(Permissions.kill, Kill, "kill"); add(Permissions.kill, Kill, "kill");
add(Permissions.butcher, Butcher, "butcher"); add(Permissions.butcher, Butcher, "butcher");
add(Permissions.item, Item, "item", "i"); add(Permissions.item, Item, "item", "i");
add(Permissions.item, Give, "give"); add(Permissions.item, Give, "give", "g");
add(Permissions.clearitems, ClearItems, "clearitems"); add(Permissions.clearitems, ClearItems, "clear", "clearitems");
add(Permissions.heal, Heal, "heal"); add(Permissions.heal, Heal, "heal");
add(Permissions.buff, Buff, "buff"); add(Permissions.buff, Buff, "buff");
add(Permissions.buffplayer, GBuff, "gbuff", "buffplayer"); add(Permissions.buffplayer, GBuff, "gbuff", "buffplayer");
@ -924,23 +922,6 @@ namespace TShockAPI
#region Server Maintenence Commands #region Server Maintenence Commands
public static void ConvertWaR(CommandArgs args)
{
if (args.Parameters.Count < 1)
{
args.Player.SendMessage("This command will dump all users from both Regions and Warps.");
args.Player.SendMessage("This command will also change all Worlds to reference this WorldID.");
args.Player.SendMessage("You must manually fix multi-world configurations.");
args.Player.SendMessage("To confirm this: /convert yes");
}
else if (args.Parameters[0] == "yes")
{
TShock.Warps.ConvertDB();
TShock.Regions.ConvertDB();
args.Player.SendMessage("Convert complete. You need to re-allow users after they register.");
}
}
private static void Broadcast(CommandArgs args) private static void Broadcast(CommandArgs args)
{ {
string message = ""; string message = "";
@ -1057,6 +1038,7 @@ namespace TShockAPI
} }
} }
[Obsolete("This specific command for spawning mobs will replaced soon.")]
private static void Eater(CommandArgs args) private static void Eater(CommandArgs args)
{ {
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)
@ -1076,6 +1058,7 @@ namespace TShockAPI
TShock.Utils.Broadcast(string.Format("{0} has spawned eater of worlds {1} times!", args.Player.Name, amount)); TShock.Utils.Broadcast(string.Format("{0} has spawned eater of worlds {1} times!", args.Player.Name, amount));
} }
[Obsolete("This specific command for spawning mobs will replaced soon.")]
private static void Eye(CommandArgs args) private static void Eye(CommandArgs args)
{ {
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)
@ -1096,6 +1079,7 @@ namespace TShockAPI
TShock.Utils.Broadcast(string.Format("{0} has spawned eye {1} times!", args.Player.Name, amount)); TShock.Utils.Broadcast(string.Format("{0} has spawned eye {1} times!", args.Player.Name, amount));
} }
[Obsolete("This specific command for spawning mobs will replaced soon.")]
private static void King(CommandArgs args) private static void King(CommandArgs args)
{ {
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)
@ -1115,6 +1099,7 @@ namespace TShockAPI
TShock.Utils.Broadcast(string.Format("{0} has spawned king slime {1} times!", args.Player.Name, amount)); TShock.Utils.Broadcast(string.Format("{0} has spawned king slime {1} times!", args.Player.Name, amount));
} }
[Obsolete("This specific command for spawning mobs will replaced soon.")]
private static void Skeletron(CommandArgs args) private static void Skeletron(CommandArgs args)
{ {
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)
@ -1135,6 +1120,7 @@ namespace TShockAPI
TShock.Utils.Broadcast(string.Format("{0} has spawned skeletron {1} times!", args.Player.Name, amount)); TShock.Utils.Broadcast(string.Format("{0} has spawned skeletron {1} times!", args.Player.Name, amount));
} }
[Obsolete("This specific command for spawning mobs will replaced soon.")]
private static void WoF(CommandArgs args) private static void WoF(CommandArgs args)
{ {
if (Main.wof >= 0 || (args.Player.Y/16f < (Main.maxTilesY - 205))) if (Main.wof >= 0 || (args.Player.Y/16f < (Main.maxTilesY - 205)))
@ -1146,6 +1132,7 @@ namespace TShockAPI
TShock.Utils.Broadcast(string.Format("{0} has spawned Wall of Flesh!", args.Player.Name)); TShock.Utils.Broadcast(string.Format("{0} has spawned Wall of Flesh!", args.Player.Name));
} }
[Obsolete("This specific command for spawning mobs will replaced soon.")]
private static void Twins(CommandArgs args) private static void Twins(CommandArgs args)
{ {
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)
@ -1168,6 +1155,7 @@ namespace TShockAPI
TShock.Utils.Broadcast(string.Format("{0} has spawned the twins {1} times!", args.Player.Name, amount)); TShock.Utils.Broadcast(string.Format("{0} has spawned the twins {1} times!", args.Player.Name, amount));
} }
[Obsolete("This specific command for spawning mobs will replaced soon.")]
private static void Destroyer(CommandArgs args) private static void Destroyer(CommandArgs args)
{ {
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)
@ -1188,6 +1176,7 @@ namespace TShockAPI
TShock.Utils.Broadcast(string.Format("{0} has spawned the destroyer {1} times!", args.Player.Name, amount)); TShock.Utils.Broadcast(string.Format("{0} has spawned the destroyer {1} times!", args.Player.Name, amount));
} }
[Obsolete("This specific command for spawning mobs will replaced soon.")]
private static void SkeletronPrime(CommandArgs args) private static void SkeletronPrime(CommandArgs args)
{ {
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)
@ -1208,6 +1197,7 @@ namespace TShockAPI
TShock.Utils.Broadcast(string.Format("{0} has spawned skeletron prime {1} times!", args.Player.Name, amount)); TShock.Utils.Broadcast(string.Format("{0} has spawned skeletron prime {1} times!", args.Player.Name, amount));
} }
[Obsolete("This specific command for spawning mobs will replaced soon.")]
private static void Hardcore(CommandArgs args) // TODO: Add all 8 bosses private static void Hardcore(CommandArgs args) // TODO: Add all 8 bosses
{ {
if (args.Parameters.Count > 1) if (args.Parameters.Count > 1)

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Data; using System.Data;
using System.IO; using System.IO;
@ -41,32 +40,6 @@ namespace TShockAPI.DB
? (IQueryBuilder) new SqliteQueryCreator() ? (IQueryBuilder) new SqliteQueryCreator()
: new MysqlQueryCreator()); : new MysqlQueryCreator());
creator.EnsureExists(table); creator.EnsureExists(table);
String file = Path.Combine(TShock.SavePath, "bans.txt");
if (File.Exists(file))
{
using (StreamReader sr = new StreamReader(file))
{
String line;
while ((line = sr.ReadLine()) != null)
{
String[] info = line.Split('|');
string query;
if (TShock.Config.StorageType.ToLower() == "sqlite")
query = "INSERT OR IGNORE INTO Bans (IP, Name, Reason) VALUES (@0, @1, @2);";
else
query = "INSERT IGNORE INTO Bans SET IP=@0, Name=@1, Reason=@2;";
db.Query(query, info[0].Trim(), info[1].Trim(), info[2].Trim());
}
}
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "bans.txt");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
}
} }
public Ban GetBanByIp(string ip) public Ban GetBanByIp(string ip)

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.IO; using System.IO;
@ -39,45 +56,6 @@ namespace TShockAPI.DB
"ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere"); "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere");
AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,usebanneditem,manageusers"); AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,usebanneditem,manageusers");
AddGroup("vip", "default", "reservedslot"); AddGroup("vip", "default", "reservedslot");
String file = Path.Combine(TShock.SavePath, "groups.txt");
if (File.Exists(file))
{
using (StreamReader sr = new StreamReader(file))
{
String line;
while ((line = sr.ReadLine()) != null)
{
if (!line.Equals("") && !line.Substring(0, 1).Equals("#"))
{
String[] info = line.Split(' ');
String comms = "";
int size = info.Length;
for (int i = 1; i < size; i++)
{
if (!comms.Equals(""))
comms = comms + ",";
comms = comms + info[i].Trim();
}
string query = "";
if (TShock.Config.StorageType.ToLower() == "sqlite")
query = "INSERT OR IGNORE INTO GroupList (GroupName, Commands) VALUES (@0, @1);";
else if (TShock.Config.StorageType.ToLower() == "mysql")
query = "INSERT IGNORE INTO GroupList SET GroupName=@0, Commands=@1;";
db.Query(query, info[0].Trim(), comms);
}
}
}
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "groups.txt");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
}
} }

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Data; using System.Data;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.IO; using System.IO;
@ -25,38 +42,6 @@ namespace TShockAPI.DB
? (IQueryBuilder) new SqliteQueryCreator() ? (IQueryBuilder) new SqliteQueryCreator()
: new MysqlQueryCreator()); : new MysqlQueryCreator());
creator.EnsureExists(table); creator.EnsureExists(table);
String file = Path.Combine(TShock.SavePath, "itembans.txt");
if (File.Exists(file))
{
using (StreamReader sr = new StreamReader(file))
{
String line;
while ((line = sr.ReadLine()) != null)
{
if (!line.Equals("") && !line.Substring(0, 1).Equals("#"))
{
string query = (TShock.Config.StorageType.ToLower() == "sqlite")
? "INSERT OR IGNORE INTO 'ItemBans' (ItemName, AllowedGroups) VALUES (@0, @1);"
: "INSERT IGNORE INTO ItemBans SET ItemName=@0,AllowedGroups=@1 ;";
int id = 0;
int.TryParse(line, out id);
database.Query(query, TShock.Utils.GetItemById(id).name, "");
}
}
}
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "itembans.txt");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
}
UpdateItemBans(); UpdateItemBans();
} }

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@ -55,117 +54,9 @@ namespace TShockAPI.DB
: new MysqlQueryCreator()); : new MysqlQueryCreator());
creator.EnsureExists(table); creator.EnsureExists(table);
ImportOld();
ReloadAllRegions(); ReloadAllRegions();
} }
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
public void ImportOld()
{
String file = Path.Combine(TShock.SavePath, "regions.xml");
if (!File.Exists(file))
return;
Region region;
Rectangle rect;
using (var reader = XmlReader.Create(new StreamReader(file), new XmlReaderSettings {CloseInput = true}))
{
// Parse the file and display each of the nodes.
while (reader.Read())
{
if (reader.NodeType != XmlNodeType.Element || reader.Name != "ProtectedRegion")
continue;
region = new Region();
rect = new Rectangle();
bool endregion = false;
while (reader.Read() && !endregion)
{
if (reader.NodeType != XmlNodeType.Element)
continue;
string name = reader.Name;
while (reader.Read() && reader.NodeType != XmlNodeType.Text) ;
int t = 0;
switch (name)
{
case "RegionName":
region.Name = reader.Value;
break;
case "Point1X":
int.TryParse(reader.Value, out t);
rect.X = t;
break;
case "Point1Y":
int.TryParse(reader.Value, out t);
rect.Y = t;
break;
case "Point2X":
int.TryParse(reader.Value, out t);
rect.Width = t;
break;
case "Point2Y":
int.TryParse(reader.Value, out t);
rect.Height = t;
break;
case "Protected":
region.DisableBuild = reader.Value.ToLower().Equals("true");
break;
case "WorldName":
region.WorldID = reader.Value;
break;
case "AllowedUserCount":
break;
case "IP":
region.AllowedIDs.Add(int.Parse(reader.Value));
break;
default:
endregion = true;
break;
}
}
region.Area = rect;
string query = (TShock.Config.StorageType.ToLower() == "sqlite")
? "INSERT OR IGNORE INTO Regions VALUES (@0, @1, @2, @3, @4, @5, @6, @7);"
: "INSERT IGNORE INTO Regions SET X1=@0, Y1=@1, height=@2, width=@3, RegionName=@4, WorldID=@5, UserIds=@6, Protected=@7;";
database.Query(query, region.Area.X, region.Area.Y, region.Area.Width, region.Area.Height, region.Name,
region.WorldID, "", region.DisableBuild);
//Todo: What should this be? We don't really have a way to go from ips to userids
/*string.Join(",", region.AllowedIDs)*/
}
}
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "regions.xml");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
ReloadAllRegions();
}
public void ConvertDB()
{
try
{
database.Query("UPDATE Regions SET WorldID=@0, UserIds=''", Main.worldID.ToString());
ReloadAllRegions();
}
catch (Exception ex)
{
Log.Error(ex.ToString());
}
}
public void ReloadAllRegions() public void ReloadAllRegions()
{ {
try try

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Data; using System.Data;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;

View file

@ -1,4 +1,21 @@
using MySql.Data.MySqlClient; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using MySql.Data.MySqlClient;
namespace TShockAPI.DB namespace TShockAPI.DB
{ {

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;

View file

@ -1,4 +1,21 @@
using System.Collections.Generic; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
using System.Data; using System.Data;
namespace TShockAPI.DB namespace TShockAPI.DB

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Data; using System.Data;
using System.IO; using System.IO;
@ -43,53 +42,6 @@ namespace TShockAPI.DB
? (IQueryBuilder) new SqliteQueryCreator() ? (IQueryBuilder) new SqliteQueryCreator()
: new MysqlQueryCreator()); : new MysqlQueryCreator());
creator.EnsureExists(table); creator.EnsureExists(table);
String file = Path.Combine(TShock.SavePath, "users.txt");
if (File.Exists(file))
{
using (StreamReader sr = new StreamReader(file))
{
String line;
while ((line = sr.ReadLine()) != null)
{
if (line.Equals("") || line.Substring(0, 1).Equals("#"))
continue;
String[] info = line.Split(' ');
String username = "";
String sha = "";
String group = "";
String ip = "";
String[] nameSha = info[0].Split(':');
if (nameSha.Length < 2)
{
username = nameSha[0];
ip = nameSha[0];
group = info[1];
}
else
{
username = nameSha[0];
sha = nameSha[1];
group = info[1];
}
string query = (TShock.Config.StorageType.ToLower() == "sqlite")
? "INSERT OR IGNORE INTO Users (Username, Password, Usergroup, IP) VALUES (@0, @1, @2, @3)"
: "INSERT IGNORE INTO Users SET Username=@0, Password=@1, Usergroup=@2, IP=@3";
database.Query(query, username.Trim(), sha.Trim(), group.Trim(), ip.Trim());
}
}
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "users.txt");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
}
} }
/// <summary> /// <summary>

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,13 +15,10 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Xml;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Terraria; using Terraria;
@ -48,93 +45,6 @@ namespace TShockAPI.DB
? (IQueryBuilder) new SqliteQueryCreator() ? (IQueryBuilder) new SqliteQueryCreator()
: new MysqlQueryCreator()); : new MysqlQueryCreator());
creator.EnsureExists(table); creator.EnsureExists(table);
String file = Path.Combine(TShock.SavePath, "warps.xml");
String name = "";
String world = "";
int x1 = 0;
int y1 = 0;
if (!File.Exists(file))
return;
using (var reader = XmlReader.Create(new StreamReader(file), new XmlReaderSettings {CloseInput = true}))
{
// Parse the file and display each of the nodes.
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
switch (reader.Name)
{
case "Warp":
name = "";
world = "";
x1 = 0;
y1 = 0;
break;
case "WarpName":
while (reader.NodeType != XmlNodeType.Text)
reader.Read();
name = reader.Value;
break;
case "X":
while (reader.NodeType != XmlNodeType.Text)
reader.Read();
int.TryParse(reader.Value, out x1);
break;
case "Y":
while (reader.NodeType != XmlNodeType.Text)
reader.Read();
int.TryParse(reader.Value, out y1);
break;
case "WorldName":
while (reader.NodeType != XmlNodeType.Text)
reader.Read();
world = reader.Value;
break;
}
break;
case XmlNodeType.Text:
break;
case XmlNodeType.XmlDeclaration:
case XmlNodeType.ProcessingInstruction:
break;
case XmlNodeType.Comment:
break;
case XmlNodeType.EndElement:
if (reader.Name.Equals("Warp"))
{
string query = (TShock.Config.StorageType.ToLower() == "sqlite")
? "INSERT OR IGNORE INTO Warps VALUES (@0, @1,@2, @3);"
: "INSERT IGNORE INTO Warps SET X=@0, Y=@1, WarpName=@2, WorldID=@3;";
database.Query(query, x1, y1, name, world);
}
break;
}
}
}
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "warps.xml");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
}
public void ConvertDB()
{
try
{
database.Query("UPDATE Warps SET WorldID=@0", Main.worldID.ToString());
}
catch (Exception ex)
{
Log.Error(ex.ToString());
}
} }
public bool AddWarp(int x, int y, string name, string worldid) public bool AddWarp(int x, int y, string name, string worldid)

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace TShockAPI namespace TShockAPI

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Text; using System.Text;
namespace TShockAPI.Extensions namespace TShockAPI.Extensions

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace TShockAPI namespace TShockAPI
{ {

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team

View file

@ -17,6 +17,23 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -401,6 +400,263 @@ namespace TShockAPI
return args.Handled; return args.Handled;
} }
public class ChestOpenEventArgs : HandledEventArgs
{
public int X { get; set; }
public int Y { get; set; }
}
public static HandlerList<ChestOpenEventArgs> ChestOpen;
private static bool OnChestOpen(int x, int y)
{
if (ChestOpen == null)
return false;
var args = new ChestOpenEventArgs
{
X = x,
Y = y,
};
ChestOpen.Invoke(null, args);
return args.Handled;
}
public class ChestItemEventArgs : HandledEventArgs
{
public short ID { get; set; }
public byte Slot { get; set; }
public byte Stacks { get; set; }
public byte Prefix { get; set; }
public short Type { get; set; }
}
public static HandlerList<ChestItemEventArgs> ChestItemChange;
private static bool OnChestItemChange(short id, byte slot, byte stacks, byte prefix, short type)
{
if (PlayerSpawn == null)
return false;
var args = new ChestItemEventArgs
{
ID = id,
Slot = slot,
Stacks = stacks,
Prefix = prefix,
Type = type,
};
ChestItemChange.Invoke(null, args);
return args.Handled;
}
public class SignEventArgs : HandledEventArgs
{
public short ID { get; set; }
public int X { get; set; }
public int Y { get; set; }
}
public static HandlerList<SignEventArgs> Sign;
private static bool OnSignEvent(short id, int x, int y)
{
if (Sign == null)
return false;
var args = new SignEventArgs
{
ID = id,
X = x,
Y = y,
};
Sign.Invoke(null, args);
return args.Handled;
}
public class NPCHomeChangeEventArgs : HandledEventArgs
{
public short ID { get; set; }
public short X { get; set; }
public short Y { get; set; }
public byte Homeless { get; set; }
}
public static HandlerList<NPCHomeChangeEventArgs> NPCHome;
private static bool OnUpdateNPCHome(short id, short x, short y, byte homeless)
{
if (NPCHome == null)
return false;
var args = new NPCHomeChangeEventArgs
{
ID = id,
X = x,
Y = y,
Homeless = homeless,
};
NPCHome.Invoke(null, args);
return args.Handled;
}
public class PlayerBuffEventArgs : HandledEventArgs
{
public byte ID { get; set; }
public byte Type { get; set; }
public short Time { get; set; }
}
public static HandlerList<PlayerBuffEventArgs> PlayerBuff;
private static bool OnPlayerBuff(byte id, byte type, short time)
{
if (PlayerBuff == null)
return false;
var args = new PlayerBuffEventArgs
{
ID = id,
Type = type,
Time = time,
};
PlayerBuff.Invoke(null, args);
return args.Handled;
}
public class ItemDropEventArgs : HandledEventArgs
{
public short ID { get; set; }
public Vector2 Position { get; set; }
public Vector2 Velocity { get; set; }
public byte Stacks { get; set; }
public byte Prefix { get; set; }
public short Type { get; set; }
}
public static HandlerList<ItemDropEventArgs> ItemDrop;
private static bool OnItemDrop(short id, Vector2 pos, Vector2 vel, byte stacks, byte prefix, short type)
{
if (ItemDrop == null)
return false;
var args = new ItemDropEventArgs
{
ID = id,
Position = pos,
Velocity = vel,
Stacks = stacks,
Prefix = prefix,
Type = type,
};
ItemDrop.Invoke(null, args);
return args.Handled;
}
public class PlayerDamageEventArgs : HandledEventArgs
{
public byte ID { get; set; }
public byte Direction { get; set; }
public short Damage { get; set; }
public byte PVP { get; set; }
public byte Critical { get; set; }
}
public static HandlerList<PlayerDamageEventArgs> PlayerDamage;
private static bool OnPlayerDamage(byte id, byte dir, short dmg, byte pvp, byte crit)
{
if (PlayerDamage == null)
return false;
var args = new PlayerDamageEventArgs
{
ID = id,
Direction = dir,
Damage = dmg,
PVP = pvp,
Critical = crit,
};
PlayerDamage.Invoke(null, args);
return args.Handled;
}
public class NPCStrikeEventArgs : HandledEventArgs
{
public byte ID { get; set; }
public byte Direction { get; set; }
public short Damage { get; set; }
public byte PVP { get; set; }
public byte Critical { get; set; }
}
public static HandlerList<NPCStrikeEventArgs> NPCStrike;
private static bool OnNPCStrike(byte id, byte dir, short dmg, byte pvp, byte crit)
{
if (NPCStrike == null)
return false;
var args = new NPCStrikeEventArgs
{
ID = id,
Direction = dir,
Damage = dmg,
PVP = pvp,
Critical = crit,
};
NPCStrike.Invoke(null, args);
return args.Handled;
}
public class NPCSpecialEventArgs : HandledEventArgs
{
public byte ID { get; set; }
public byte Type { get; set; }
}
public static HandlerList<NPCSpecialEventArgs> NPCSpecial;
private static bool OnNPCSpecial(byte id, byte type)
{
if (NPCSpecial == null)
return false;
var args = new NPCSpecialEventArgs
{
ID = id,
Type = type,
};
NPCSpecial.Invoke(null, args);
return args.Handled;
}
public class PlayerAnimationEventArgs : HandledEventArgs
{
}
public static HandlerList<PlayerAnimationEventArgs> PlayerAnimation;
private static bool OnPlayerAnimation()
{
if (PlayerAnimation == null)
return false;
var args = new PlayerAnimationEventArgs {};
PlayerAnimation.Invoke(null, args);
return args.Handled;
}
public class PlayerBuffUpdateEventArgs : HandledEventArgs
{
public byte ID { get; set; }
}
public static HandlerList<PlayerBuffUpdateEventArgs> PlayerBuffUpdate;
private static bool OnPlayerBuffUpdate(byte id)
{
if (PlayerBuffUpdate == null)
return false;
var args = new PlayerBuffUpdateEventArgs
{
ID = id,
};
PlayerBuffUpdate.Invoke(null, args);
return args.Handled;
}
#endregion #endregion
public static void InitGetDataHandler() public static void InitGetDataHandler()
{ {
@ -1547,6 +1803,9 @@ namespace TShockAPI
var x = args.Data.ReadInt32(); var x = args.Data.ReadInt32();
var y = args.Data.ReadInt32(); var y = args.Data.ReadInt32();
if (OnChestOpen(x, y))
return true;
if (TShock.CheckIgnores(args.Player)) if (TShock.CheckIgnores(args.Player))
{ {
return true; return true;
@ -1573,6 +1832,9 @@ namespace TShockAPI
var prefix = args.Data.ReadInt8(); var prefix = args.Data.ReadInt8();
var type = args.Data.ReadInt16(); var type = args.Data.ReadInt16();
if (OnChestItemChange(id, slot, stacks, prefix, type))
return true;
if (args.TPlayer.chest != id) if (args.TPlayer.chest != id)
{ {
return false; return false;
@ -1610,6 +1872,9 @@ namespace TShockAPI
var x = args.Data.ReadInt32(); var x = args.Data.ReadInt32();
var y = args.Data.ReadInt32(); var y = args.Data.ReadInt32();
if (OnSignEvent(id, x, y))
return true;
if (TShock.CheckTilePermission(args.Player, x, y)) if (TShock.CheckTilePermission(args.Player, x, y))
{ {
args.Player.SendData(PacketTypes.SignNew, "", id); args.Player.SendData(PacketTypes.SignNew, "", id);
@ -1631,6 +1896,9 @@ namespace TShockAPI
var y = args.Data.ReadInt16(); var y = args.Data.ReadInt16();
var homeless = args.Data.ReadInt8(); var homeless = args.Data.ReadInt8();
if (OnUpdateNPCHome(id, x, y, homeless))
return true;
if (!args.Player.Group.HasPermission(Permissions.movenpc)) if (!args.Player.Group.HasPermission(Permissions.movenpc))
{ {
args.Player.SendMessage("You do not have permission to relocate NPCs.", Color.Red); args.Player.SendMessage("You do not have permission to relocate NPCs.", Color.Red);
@ -1661,6 +1929,9 @@ namespace TShockAPI
var type = args.Data.ReadInt8(); var type = args.Data.ReadInt8();
var time = args.Data.ReadInt16(); var time = args.Data.ReadInt16();
if (OnPlayerBuff(id, type, time))
return true;
if (TShock.CheckIgnores(args.Player)) if (TShock.CheckIgnores(args.Player))
{ {
args.Player.SendData(PacketTypes.PlayerBuff, "", id); args.Player.SendData(PacketTypes.PlayerBuff, "", id);
@ -1700,6 +1971,9 @@ namespace TShockAPI
var prefix = args.Data.ReadInt8(); var prefix = args.Data.ReadInt8();
var type = args.Data.ReadInt16(); var type = args.Data.ReadInt16();
if (OnItemDrop(id, pos, vel, stacks, prefix, type))
return true;
if (type == 0) //Item removed, let client do this to prevent item duplication client side if (type == 0) //Item removed, let client do this to prevent item duplication client side
{ {
return false; return false;
@ -1736,6 +2010,9 @@ namespace TShockAPI
var pvp = args.Data.ReadInt8(); var pvp = args.Data.ReadInt8();
var crit = args.Data.ReadInt8(); var crit = args.Data.ReadInt8();
if (OnPlayerDamage(id, direction, dmg, pvp, crit))
return true;
int textlength = (int) (args.Data.Length - args.Data.Position - 1); int textlength = (int) (args.Data.Length - args.Data.Position - 1);
string deathtext = ""; string deathtext = "";
if (textlength > 0) if (textlength > 0)
@ -1797,6 +2074,9 @@ namespace TShockAPI
var pvp = args.Data.ReadInt8(); var pvp = args.Data.ReadInt8();
var crit = args.Data.ReadInt8(); var crit = args.Data.ReadInt8();
if (OnNPCStrike(id, direction, dmg, pvp, crit))
return true;
if (Main.npc[id] == null) if (Main.npc[id] == null)
return true; return true;
@ -1841,6 +2121,9 @@ namespace TShockAPI
var id = args.Data.ReadInt8(); var id = args.Data.ReadInt8();
var type = args.Data.ReadInt8(); var type = args.Data.ReadInt8();
if (OnNPCSpecial(id, type))
return true;
if (type == 1 && TShock.Config.DisableDungeonGuardian) if (type == 1 && TShock.Config.DisableDungeonGuardian)
{ {
args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point", Color.Purple); args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point", Color.Purple);
@ -1853,6 +2136,10 @@ namespace TShockAPI
private static bool HandlePlayerAnimation(GetDataHandlerArgs args) private static bool HandlePlayerAnimation(GetDataHandlerArgs args)
{ {
if (OnPlayerAnimation())
return true;
if (TShock.CheckIgnores(args.Player)) if (TShock.CheckIgnores(args.Player))
{ {
args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index); args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
@ -1871,6 +2158,10 @@ namespace TShockAPI
private static bool HandlePlayerBuffUpdate(GetDataHandlerArgs args) private static bool HandlePlayerBuffUpdate(GetDataHandlerArgs args)
{ {
var id = args.Data.ReadInt8(); var id = args.Data.ReadInt8();
if (OnPlayerBuffUpdate(id))
return true;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
var buff = args.Data.ReadInt8(); var buff = args.Data.ReadInt8();

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System.IO; using System.IO;
namespace TShockAPI namespace TShockAPI

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.IO; using System.IO;
using System.IO.Streams; using System.IO.Streams;

View file

@ -1,4 +1,21 @@
using System.IO; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.IO;
using System.IO.Streams; using System.IO.Streams;
using System.Text; using System.Text;

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.IO; using System.IO;
using System.IO.Streams; using System.IO.Streams;

View file

@ -1,4 +1,21 @@
using System.IO; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.IO;
using System.IO.Streams; using System.IO.Streams;
namespace TShockAPI.Net namespace TShockAPI.Net

View file

@ -1,4 +1,21 @@
using System.IO; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.IO;
using System.IO.Streams; using System.IO.Streams;
namespace TShockAPI.Net namespace TShockAPI.Net

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.IO; using System.IO;
using System.IO.Streams; using System.IO.Streams;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;

View file

@ -1,4 +1,21 @@
using System.Reflection; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@ -31,5 +48,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// MMdd of the build // MMdd of the build
[assembly: AssemblyVersion("3.4.2.1231")] [assembly: AssemblyVersion("3.4.2.0101")]
[assembly: AssemblyFileVersion("3.4.2.1231")] [assembly: AssemblyFileVersion("3.4.2.0101")]

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View file

@ -1,4 +1,22 @@
//------------------------------------------------------------------------------ /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.235 // Runtime Version:4.0.30319.235

View file

@ -1,11 +1,30 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using HttpServer; using HttpServer;
using HttpServer.Headers; using HttpServer.Headers;
using Newtonsoft.Json; using Newtonsoft.Json;
using TShockAPI;
using HttpListener = HttpServer.HttpListener; using HttpListener = HttpServer.HttpListener;
namespace Rests namespace Rests
@ -68,12 +87,38 @@ namespace Rests
commands.Add(com); commands.Add(com);
} }
#region Event
public class RestRequestEventArgs : HandledEventArgs
{
public RequestEventArgs Request { get; set; }
}
public static HandlerList<RestRequestEventArgs> RestRequestEvent;
private static bool OnRestRequestCall(RequestEventArgs request)
{
if (RestRequestEvent == null)
return false;
var args = new RestRequestEventArgs
{
Request = request,
};
RestRequestEvent.Invoke(null, args);
return args.Handled;
}
#endregion
protected virtual void OnRequest(object sender, RequestEventArgs e) protected virtual void OnRequest(object sender, RequestEventArgs e)
{ {
var obj = ProcessRequest(sender, e); var obj = ProcessRequest(sender, e);
if (obj == null) if (obj == null)
throw new NullReferenceException("obj"); throw new NullReferenceException("obj");
//if (OnRestRequestCall(e))
// return;
var str = JsonConvert.SerializeObject(obj, Formatting.Indented); var str = JsonConvert.SerializeObject(obj, Formatting.Indented);
e.Response.Connection.Type = ConnectionType.Close; e.Response.Connection.Type = ConnectionType.Close;
e.Response.Body.Write(Encoding.ASCII.GetBytes(str), 0, str.Length); e.Response.Body.Write(Encoding.ASCII.GetBytes(str), 0, str.Length);

View file

@ -1,3 +1,20 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using HttpServer; using HttpServer;

View file

@ -1,3 +1,20 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View file

@ -1,3 +1,20 @@
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
@ -12,16 +29,16 @@ namespace TShockAPI
public DateTime lastcheck = DateTime.MinValue; public DateTime lastcheck = DateTime.MinValue;
private readonly int checkinFrequency = 5; private readonly int checkinFrequency = 5;
public void checkin() public void CheckIn()
{ {
if ((DateTime.Now - lastcheck).TotalMinutes >= checkinFrequency) if ((DateTime.Now - lastcheck).TotalMinutes >= checkinFrequency)
{ {
ThreadPool.QueueUserWorkItem(callHome); ThreadPool.QueueUserWorkItem(CallHome);
lastcheck = DateTime.Now; lastcheck = DateTime.Now;
} }
} }
private void callHome(object state) private void CallHome(object state)
{ {
string fp; string fp;
string lolpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/.tshock/"; string lolpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/.tshock/";

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,14 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* TShock wouldn't be possible without:
* Github
* Microsoft Visual Studio 2011
* And you, for your continued support and devotion to the evolution of TShock
* Kerplunc Gaming
* TerrariaGSP
* XNS Technology Group (Xenon Servers)
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -115,7 +107,7 @@ namespace TShockAPI
Directory.CreateDirectory(SavePath); Directory.CreateDirectory(SavePath);
#if DEBUG #if DEBUG
Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false); Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false);
#else #else
Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All & ~LogLevel.Debug, false); Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All & ~LogLevel.Debug, false);
#endif #endif
@ -149,11 +141,11 @@ namespace TShockAPI
DB = new MySqlConnection(); DB = new MySqlConnection();
DB.ConnectionString = DB.ConnectionString =
String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};", String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
hostport[0], hostport[0],
hostport.Length > 1 ? hostport[1] : "3306", hostport.Length > 1 ? hostport[1] : "3306",
Config.MySqlDbName, Config.MySqlDbName,
Config.MySqlUsername, Config.MySqlUsername,
Config.MySqlPassword Config.MySqlPassword
); );
} }
catch (MySqlException ex) catch (MySqlException ex)
@ -234,22 +226,22 @@ namespace TShockAPI
if (userAccount == null) if (userAccount == null)
{ {
return new RestObject("401") return new RestObject("401")
{Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair."}; {Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair."};
} }
if (Utils.HashPassword(password).ToUpper() != userAccount.Password.ToUpper()) if (Utils.HashPassword(password).ToUpper() != userAccount.Password.ToUpper())
{ {
return new RestObject("401") return new RestObject("401")
{Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair."}; {Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair."};
} }
if (!Utils.GetGroup(userAccount.Group).HasPermission("api") && userAccount.Group != "superadmin") if (!Utils.GetGroup(userAccount.Group).HasPermission("api") && userAccount.Group != "superadmin")
{ {
return new RestObject("403") return new RestObject("403")
{ {
Error = Error =
"Although your account was successfully found and identified, your account lacks the permission required to use the API. (api)" "Although your account was successfully found and identified, your account lacks the permission required to use the API. (api)"
}; };
} }
return new RestObject("200") {Response = "Successful login"}; //Maybe return some user info too? return new RestObject("200") {Response = "Successful login"}; //Maybe return some user info too?
@ -295,7 +287,7 @@ namespace TShockAPI
Log.Error(e.ExceptionObject.ToString()); Log.Error(e.ExceptionObject.ToString());
if (e.ExceptionObject.ToString().Contains("Terraria.Netplay.ListenForClients") || if (e.ExceptionObject.ToString().Contains("Terraria.Netplay.ListenForClients") ||
e.ExceptionObject.ToString().Contains("Terraria.Netplay.ServerLoop")) e.ExceptionObject.ToString().Contains("Terraria.Netplay.ServerLoop"))
{ {
var sb = new List<string>(); var sb = new List<string>();
for (int i = 0; i < Netplay.serverSock.Length; i++) for (int i = 0; i < Netplay.serverSock.Length; i++)
@ -381,9 +373,9 @@ namespace TShockAPI
} }
/* /*
* Hooks: * Hooks:
* *
*/ */
public static int AuthToken = -1; public static int AuthToken = -1;
@ -424,7 +416,7 @@ namespace TShockAPI
if (Config.RestApiEnabled) if (Config.RestApiEnabled)
RestApi.Start(); RestApi.Start();
StatTracker.checkin(); StatTracker.CheckIn();
FixChestStacks(); FixChestStacks();
} }
@ -450,7 +442,7 @@ namespace TShockAPI
private void OnUpdate() private void OnUpdate()
{ {
UpdateManager.UpdateProcedureCheck(); UpdateManager.UpdateProcedureCheck();
StatTracker.checkin(); StatTracker.CheckIn();
if (Backups.IsBackupTime) if (Backups.IsBackupTime)
Backups.Backup(); Backups.Backup();
@ -545,7 +537,7 @@ namespace TShockAPI
foreach (Item item in player.TPlayer.inventory) foreach (Item item in player.TPlayer.inventory)
{ {
if (!player.Group.HasPermission(Permissions.ignorestackhackdetection) && item.stack > item.maxStack && if (!player.Group.HasPermission(Permissions.ignorestackhackdetection) && item.stack > item.maxStack &&
item.type != 0) item.type != 0)
{ {
check = "Remove Item " + item.name + " (" + item.stack + ") exceeds max stack of " + item.maxStack; check = "Remove Item " + item.name + " (" + item.stack + ") exceeds max stack of " + item.maxStack;
} }
@ -569,14 +561,14 @@ namespace TShockAPI
player.SetBuff(23, 120); //Cursed player.SetBuff(23, 120); //Cursed
} }
else if (!player.Group.HasPermission(Permissions.usebanneditem) && else if (!player.Group.HasPermission(Permissions.usebanneditem) &&
Itembans.ItemIsBanned(player.TPlayer.inventory[player.TPlayer.selectedItem].name, player)) Itembans.ItemIsBanned(player.TPlayer.inventory[player.TPlayer.selectedItem].name, player))
{ {
player.SetBuff(23, 120); //Cursed player.SetBuff(23, 120); //Cursed
} }
} }
} }
Console.Title = string.Format("TerrariaShock Version {0} ({1}) ({2}/{3})", Version, VersionCodename, count, Console.Title = string.Format("TerrariaShock Version {0} ({1}) ({2}/{3})", Version, VersionCodename, count,
Config.MaxSlots); Config.MaxSlots);
} }
private void OnConnect(int ply, HandledEventArgs handler) private void OnConnect(int ply, HandledEventArgs handler)
@ -752,7 +744,7 @@ namespace TShockAPI
{ {
count++; count++;
TSPlayer.Server.SendMessage(string.Format("{0} ({1}) [{2}] <{3}>", player.Name, player.IP, TSPlayer.Server.SendMessage(string.Format("{0} ({1}) [{2}] <{3}>", player.Name, player.IP,
player.Group.Name, player.UserAccountName)); player.Group.Name, player.UserAccountName));
} }
} }
TSPlayer.Server.SendMessage(string.Format("{0} players connected.", count)); TSPlayer.Server.SendMessage(string.Format("{0} players connected.", count));
@ -802,7 +794,7 @@ namespace TShockAPI
} }
if ((player.State < 10 || player.Dead) && (int) type > 12 && (int) type != 16 && (int) type != 42 && (int) type != 50 && if ((player.State < 10 || player.Dead) && (int) type > 12 && (int) type != 16 && (int) type != 42 && (int) type != 50 &&
(int) type != 38) (int) type != 38)
{ {
e.Handled = true; e.Handled = true;
return; return;
@ -946,16 +938,16 @@ namespace TShockAPI
if (e.MsgID == PacketTypes.Disconnect) if (e.MsgID == PacketTypes.Disconnect)
{ {
Action<ServerSock, string> senddisconnect = (sock, str) => Action<ServerSock, string> senddisconnect = (sock, str) =>
{ {
if (sock == null || !sock.active) if (sock == null || !sock.active)
return; return;
sock.kill = true; sock.kill = true;
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
{ {
new DisconnectMsg {Reason = str}.PackFull(ms); new DisconnectMsg {Reason = str}.PackFull(ms);
SendBytesBufferless(sock, ms.ToArray()); SendBytesBufferless(sock, ms.ToArray());
} }
}; };
if (e.remoteClient != -1) if (e.remoteClient != -1)
{ {
@ -990,8 +982,8 @@ namespace TShockAPI
} }
/* /*
* Useful stuff: * Useful stuff:
* */ * */
public static void StartInvasion() public static void StartInvasion()
{ {
@ -1063,7 +1055,7 @@ namespace TShockAPI
} }
if ((type == 42 || type == 65 || type == 68) && !player.Group.HasPermission(Permissions.usebanneditem) && if ((type == 42 || type == 65 || type == 68) && !player.Group.HasPermission(Permissions.usebanneditem) &&
Itembans.ItemIsBanned("Sandgun", player)) //Sandgun Projectiles Itembans.ItemIsBanned("Sandgun", player)) //Sandgun Projectiles
{ {
return true; return true;
} }
@ -1101,7 +1093,7 @@ namespace TShockAPI
return true; return true;
} }
if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) && if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) &&
Regions.InArea(tileX, tileY)) Regions.InArea(tileX, tileY))
{ {
player.SendMessage("Region protected from changes.", Color.Red); player.SendMessage("Region protected from changes.", Color.Red);
return true; return true;
@ -1147,9 +1139,9 @@ namespace TShockAPI
public static bool HackedHealth(TSPlayer player) public static bool HackedHealth(TSPlayer player)
{ {
return (player.TPlayer.statManaMax > 400) || return (player.TPlayer.statManaMax > 400) ||
(player.TPlayer.statMana > 400) || (player.TPlayer.statMana > 400) ||
(player.TPlayer.statLifeMax > 400) || (player.TPlayer.statLifeMax > 400) ||
(player.TPlayer.statLife > 400); (player.TPlayer.statLife > 400);
} }
public static bool HackedInventory(TSPlayer player) public static bool HackedInventory(TSPlayer player)
@ -1207,7 +1199,7 @@ namespace TShockAPI
if (player.TPlayer.statLifeMax > playerData.maxHealth) if (player.TPlayer.statLifeMax > playerData.maxHealth)
{ {
player.SendMessage("Error: Your max health exceeded (" + playerData.maxHealth + ") which is stored on server", player.SendMessage("Error: Your max health exceeded (" + playerData.maxHealth + ") which is stored on server",
Color.Cyan); Color.Cyan);
check = false; check = false;
} }
@ -1227,7 +1219,7 @@ namespace TShockAPI
item.Prefix(inventory[i].prefix); item.Prefix(inventory[i].prefix);
item.AffixName(); item.AffixName();
player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.", player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.",
Color.Cyan); Color.Cyan);
check = false; check = false;
} }
else if (playerData.inventory[i].prefix != inventory[i].prefix) else if (playerData.inventory[i].prefix != inventory[i].prefix)
@ -1236,7 +1228,7 @@ namespace TShockAPI
item.Prefix(inventory[i].prefix); item.Prefix(inventory[i].prefix);
item.AffixName(); item.AffixName();
player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.", player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.",
Color.Cyan); Color.Cyan);
check = false; check = false;
} }
else if (inventory[i].stack > playerData.inventory[i].stack) else if (inventory[i].stack > playerData.inventory[i].stack)
@ -1264,7 +1256,7 @@ namespace TShockAPI
item.Prefix(armor[i - 48].prefix); item.Prefix(armor[i - 48].prefix);
item.AffixName(); item.AffixName();
player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.", player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.",
Color.Cyan); Color.Cyan);
check = false; check = false;
} }
else if (playerData.inventory[i].prefix != armor[i - 48].prefix) else if (playerData.inventory[i].prefix != armor[i - 48].prefix)
@ -1273,7 +1265,7 @@ namespace TShockAPI
item.Prefix(armor[i - 48].prefix); item.Prefix(armor[i - 48].prefix);
item.AffixName(); item.AffixName();
player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.", player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.",
Color.Cyan); Color.Cyan);
check = false; check = false;
} }
else if (armor[i - 48].stack > playerData.inventory[i].stack) else if (armor[i - 48].stack > playerData.inventory[i].stack)

View file

@ -139,6 +139,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="config\groups.txt" /> <None Include="config\groups.txt" />
<None Include="TShockAPI.licenseheader" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="config\users.txt" /> <None Include="config\users.txt" />
@ -186,7 +187,7 @@
</PropertyGroup> </PropertyGroup>
<ProjectExtensions> <ProjectExtensions>
<VisualStudio> <VisualStudio>
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" /> <UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
</VisualStudio> </VisualStudio>
</ProjectExtensions> </ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -0,0 +1,18 @@
extensions: .cs
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team Copyright (C) 2011 The TShock Team
@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;

View file

@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View file

@ -1,4 +1,21 @@
using System.Reflection; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -1,4 +1,21 @@
using System; /*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View file

@ -101,6 +101,7 @@
<None Include="RegionManagerTest.orderedtest"> <None Include="RegionManagerTest.orderedtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="UnitTests.licenseheader" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0"> <BootstrapperPackage Include=".NETFramework,Version=v4.0">

View file

@ -0,0 +1,18 @@
extensions: .cs
/*
TShock, a server mod for Terraria
Copyright (C) 2011 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/