diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 4e7f6d39..9fc50466 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -184,6 +184,7 @@ namespace TShockAPI add(Permissions.heal, Heal, "heal"); add(Permissions.buff, Buff, "buff"); add(Permissions.buffplayer, GBuff, "gbuff", "buffplayer"); + add(Permissions.grow, Grow, "grow"); } public static bool HandleCommand(TSPlayer player, string text) @@ -2411,11 +2412,11 @@ namespace TShockAPI { if (args.Parameters.Count < 1 || args.Parameters.Count > 2) { - args.Player.SendMessage("Invalid syntax! Proper syntax: /buff [time(seconds*60)]", Color.Red); + args.Player.SendMessage("Invalid syntax! Proper syntax: /buff [time(seconds)]", Color.Red); return; } int id = 0; - int time = 3600; + int time = 60; if (!int.TryParse(args.Parameters[0], out id)) { var found = Tools.GetBuffByName(args.Parameters[0]); @@ -2430,16 +2431,16 @@ namespace TShockAPI return; } id = found[0]; - if (args.Parameters.Count == 2) - int.TryParse(args.Parameters[1], out time); } + if (args.Parameters.Count == 2) + int.TryParse(args.Parameters[1], out time); if (id > 0 && id < Main.maxBuffs) { if (time < 0 || time > short.MaxValue) - time = 3600; - args.Player.SetBuff(id, time); + time = 60; + args.Player.SetBuff(id, time * 60); args.Player.SendMessage(string.Format("You have buffed yourself with {0}({1}) for {2} seconds!", - Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time / 60)), Color.Green); + Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time)), Color.Green); } else args.Player.SendMessage("Invalid buff ID!", Color.Red); @@ -2449,11 +2450,11 @@ namespace TShockAPI { if (args.Parameters.Count < 2 || args.Parameters.Count > 3) { - args.Player.SendMessage("Invalid syntax! Proper syntax: /gbuff [time(seconds*60)]", Color.Red); + args.Player.SendMessage("Invalid syntax! Proper syntax: /gbuff [time(seconds)]", Color.Red); return; } int id = 0; - int time = 3600; + int time = 60; var foundplr = Tools.FindPlayer(args.Parameters[0]); if (foundplr.Count == 0) { @@ -2481,23 +2482,89 @@ namespace TShockAPI return; } id = found[0]; - if (args.Parameters.Count == 3) - int.TryParse(args.Parameters[2], out time); } + if (args.Parameters.Count == 3) + int.TryParse(args.Parameters[2], out time); if (id > 0 && id < Main.maxBuffs) { if (time < 0 || time > short.MaxValue) - time = 3600; - foundplr[0].SetBuff(id, time); + time = 60; + foundplr[0].SetBuff(id, time * 60); args.Player.SendMessage(string.Format("You have buffed {0} with {1}({2}) for {3} seconds!", - foundplr[0].Name, Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time / 60)), Color.Green); + foundplr[0].Name, Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time)), Color.Green); foundplr[0].SendMessage(string.Format("{0} has buffed you with {1}({2}) for {3} seconds!", - args.Player.Name, Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time / 60)), Color.Green); + args.Player.Name, Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time)), Color.Green); } else args.Player.SendMessage("Invalid buff ID!", Color.Red); } } + + private static void Grow(CommandArgs args) + { + if (args.Parameters.Count != 1) + { + args.Player.SendMessage("Invalid syntax! Proper syntax: /grow [tree/epictree/mushroom/cactus/herb]", Color.Red); + return; + } + var name = "Fail"; + var x = args.Player.TileX; + var y = args.Player.TileY + 3; + switch (args.Parameters[0].ToLower()) + { + case "tree": + for (int i = x - 1; i < x + 2; i++) + { + Main.tile[i, y].active = true; + Main.tile[i, y].type = 2; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowTree(x, y); + name = "Tree"; + break; + case "epictree": + for (int i = x - 1; i < x + 2; i++) + { + Main.tile[i, y].active = true; + Main.tile[i, y].type = 2; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + Main.tile[x, y - 1].liquid = 0; + Main.tile[x, y - 1].active = true; + WorldGen.GrowEpicTree(x, y); + name = "Epic Tree"; + break; + case "mushroom": + for (int i = x - 1; i < x + 2; i++) + { + Main.tile[i, y].active = true; + Main.tile[i, y].type = 70; + Main.tile[i, y].wall = 0; + } + Main.tile[x, y - 1].wall = 0; + WorldGen.GrowShroom(x, y); + name = "Mushroom"; + break; + case "cactus": + Main.tile[x, y].type = 53; + WorldGen.GrowCactus(x, y); + name = "Cactus"; + break; + case "herb": + Main.tile[x, y].active = true; + Main.tile[x, y].frameX = 36; + Main.tile[x, y].type = 83; + WorldGen.GrowAlch(x, y); + name = "Herb"; + break; + default: + args.Player.SendMessage("Unknown plant!", Color.Red); + return; + } + args.Player.SendMessage("You have grown a " + name, Color.Green); + } #endregion Cheat Comamnds } } diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 428f1d8e..3faf935f 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -184,6 +184,9 @@ namespace TShockAPI [Description("This is kick players who have custom items in their inventory (via a mod)")] public bool KickCustomItems = false; + [Description("This will announce a player's location on join")] + public bool EnableGeoIP = false; + public static ConfigFile Read(string path) { if (!File.Exists(path)) diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs index 8e2166c4..cd4c2faf 100644 --- a/TShockAPI/DB/RegionManager.cs +++ b/TShockAPI/DB/RegionManager.cs @@ -262,7 +262,7 @@ namespace TShockAPI.DB public bool AddRegion(int tx, int ty, int width, int height, string regionname, string worldid) { - if (TShock.Regions.GetRegionByName(regionname) != null) + if (GetRegionByName(regionname) != null) { return false; } @@ -452,6 +452,16 @@ namespace TShockAPI.DB { return Regions.FirstOrDefault(r => r.Name.Equals(name) && r.WorldID == Main.worldID.ToString()); } + + public Region ZacksGetRegionByName(String name) + { + foreach (Region r in Regions) + { + if (r.Name.Equals(name)) + return r; + } + return null; + } } public class Region diff --git a/TShockAPI/GeoIPCountry.cs b/TShockAPI/GeoIPCountry.cs new file mode 100644 index 00000000..a5db53fd --- /dev/null +++ b/TShockAPI/GeoIPCountry.cs @@ -0,0 +1,259 @@ +/* GeoIPCountry.cs + * + * Copyright (C) 2008 MaxMind, Inc. All Rights Reserved. + * + * This library 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 2 of the License, or (at your option) any later version. + * + * This library 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 library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +using System; +using System.IO; +using System.Net; + +// This code is based on MaxMind's original C# code, which was ported from Java. +// This version is very simplified and does not support a majority of features for speed. + +namespace MaxMind +{ + /// + /// Allows for looking up a country based on an IP address. See www.maxmind.com for more details. + /// + /// + /// static void Main(string[] args) + /// { + /// using(GeoIPCountry geo = new GeoIPCountry("GeoIP.dat")) + /// { + /// try + /// { + /// Console.WriteLine("Country code of IP address 67.15.94.80: " + geo.GetCountryCode("67.15.94.80")); + /// } + /// catch(Exception ex) + /// { + /// Console.WriteLine(ex.ToString()); + /// } + /// } + /// } + /// + public sealed class GeoIPCountry : IDisposable + { + Stream _geodata; + bool _close; + + // hard coded position of where country data starts in the data file. + const long COUNTRY_BEGIN = 16776960; + + static readonly string[] CountryCodes = { + "--","AP","EU","AD","AE","AF","AG","AI","AL","AM","AN","AO","AQ","AR","AS", + "AT","AU","AW","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BM","BN", + "BO","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI", + "CK","CL","CM","CN","CO","CR","CU","CV","CX","CY","CZ","DE","DJ","DK","DM", + "DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR", + "FX","GA","GB","GD","GE","GF","GH","GI","GL","GM","GN","GP","GQ","GR","GS", + "GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IN","IO", + "IQ","IR","IS","IT","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR", + "KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA", + "MC","MD","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU", + "MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR", + "NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT", + "PW","PY","QA","RE","RO","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI", + "SJ","SK","SL","SM","SN","SO","SR","ST","SV","SY","SZ","TC","TD","TF","TG", + "TH","TJ","TK","TM","TN","TO","TL","TR","TT","TV","TW","TZ","UA","UG","UM", + "US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","RS", + "ZA","ZM","ME","ZW","A1","A2","O1","AX","GG","IM","JE","BL","MF" + }; + + static readonly string[] CountryNames = { + "N/A","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan", + "Antigua and Barbuda","Anguilla","Albania","Armenia","Netherlands Antilles","Angola", + "Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan", + "Bosnia and Herzegovina","Barbados","Bangladesh","Belgium","Burkina Faso","Bulgaria", + "Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia","Brazil","Bahamas", + "Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands", + "Congo, The Democratic Republic of the","Central African Republic","Congo","Switzerland", + "Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica","Cuba", + "Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark", + "Dominica","Dominican Republic","Algeria","Ecuador","Estonia","Egypt","Western Sahara", + "Eritrea","Spain","Ethiopia","Finland","Fiji","Falkland Islands (Malvinas)", + "Micronesia, Federated States of","Faroe Islands","France","France, Metropolitan","Gabon", + "United Kingdom","Grenada","Georgia","French Guiana","Ghana","Gibraltar","Greenland", + "Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece", + "South Georgia and the South Sandwich Islands","Guatemala","Guam","Guinea-Bissau","Guyana", + "Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary", + "Indonesia","Ireland","Israel","India","British Indian Ocean Territory","Iraq", + "Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan","Japan","Kenya", + "Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis", + "Korea, Democratic People's Republic of","Korea, Republic of","Kuwait","Cayman Islands", + "Kazakstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein", + "Sri Lanka","Liberia","Lesotho","Lithuania","Luxembourg","Latvia","Libyan Arab Jamahiriya", + "Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia", + "Mali","Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania", + "Montserrat","Malta","Mauritius","Maldives","Malawi","Mexico","Malaysia","Mozambique", + "Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua","Netherlands", + "Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia", + "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon", + "Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau","Paraguay", + "Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia", + "Solomon Islands","Seychelles","Sudan","Sweden","Singapore","Saint Helena","Slovenia", + "Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia", + "Suriname","Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland", + "Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand", + "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey", + "Trinidad and Tobago","Tuvalu","Taiwan","Tanzania, United Republic of","Ukraine","Uganda", + "United States Minor Outlying Islands","United States","Uruguay","Uzbekistan", + "Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela", + "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna", + "Samoa","Yemen","Mayotte","Serbia","South Africa","Zambia","Montenegro","Zimbabwe", + "Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man", + "Jersey","Saint Barthelemy","Saint Martin" + }; + + // + // Constructor + // + + /// + /// Initialises a new instance of this class. + /// + /// An already open stream pointing to the contents of a GeoIP.dat file. + /// The stream is not closed when this class is disposed. Be sure to clean up afterwards! + public GeoIPCountry(Stream datafile) + { + _geodata = datafile; + _close = false; + } + + /// + /// Initialises a new instance of this class, using an on-disk database. + /// + /// Path to database file. + /// The file will be closed when this class is disposed. + public GeoIPCountry(string filename) + { + FileStream fs = new FileStream(filename, FileMode.Open); + _geodata = (Stream)fs; + _close = true; + } + + /// + /// Retrieves a two-letter code, defined by MaxMind, which details the country the specified IP address is located. + /// + /// IP address to query. + /// A two-letter code string. Throws exceptions on failure. + /// The IP address must be IPv4. + public string GetCountryCode(IPAddress ip) + { + return CountryCodes[FindIndex(ip)]; + } + + /// + /// Retrieves a two-letter code, defined by MaxMind, which details the country the specified IP address is located. Does not throw exceptions on failure. + /// + /// IP address to query. + /// Two-letter country code or null on failure. + public string TryGetCountryCode(IPAddress ip) + { + try + { + return CountryCodes[FindIndex(ip)]; + } + catch (Exception) + { + return null; + } + } + + /// + /// Gets the English name of a country, by a country code. + /// + /// Country code to look up, returned by GetCountryCode or TryGetCountryCode. + /// English name of the country, or null on failure. + public static string GetCountryNameByCode(string countrycode) + { + int index = Array.IndexOf(CountryCodes, countrycode); + return index == -1 ? null : CountryNames[index]; + } + + int FindIndex(IPAddress ip) + { + return (int)FindCountryCode(0, AddressToLong(ip), 31); + } + + // Converts an IPv4 address into a long, for reading from geo database + long AddressToLong(IPAddress ip) + { + if (ip.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork) + throw new InvalidOperationException("IP address is not IPv4"); + + long num = 0; + byte[] bytes = ip.GetAddressBytes(); + for (int i = 0; i < 4; ++i) + { + long y = bytes[i]; + if (y < 0) + y += 256; + num += y << ((3 - i) * 8); + } + + return num; + } + + // Traverses the GeoIP binary data looking for a country code based + // on the IP address mask + long FindCountryCode(long offset, long ipnum, int depth) + { + byte[] buffer = new byte[6]; // 2 * MAX_RECORD_LENGTH + long[] x = new long[2]; + if (depth < 0) + throw new IOException("Cannot seek GeoIP database"); + + _geodata.Seek(6 * offset, SeekOrigin.Begin); + _geodata.Read(buffer, 0, 6); + + for (int i = 0; i < 2; i++) + { + x[i] = 0; + for (int j = 0; j < 3; j++) + { + int y = buffer[i * 3 + j]; + if (y < 0) + y += 256; + x[i] += (y << (j * 8)); + } + } + + if ((ipnum & (1 << depth)) > 0) + { + if (x[1] >= COUNTRY_BEGIN) + return x[1] - COUNTRY_BEGIN; + return FindCountryCode(x[1], ipnum, depth - 1); + } + else + { + if (x[0] >= COUNTRY_BEGIN) + return x[0] - COUNTRY_BEGIN; + return FindCountryCode(x[0], ipnum, depth - 1); + } + } + + public void Dispose() + { + if (_close && _geodata != null) + { + _geodata.Close(); + _geodata = null; + } + } + } +} + diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 98d52670..d6341b86 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -213,7 +213,7 @@ namespace TShockAPI Tools.ForceKick(args.Player, "Server is set to hardcore characters only!"); return true; } - + args.Player.Difficulty = difficulty; args.Player.ReceivedInfo = true; return false; } @@ -480,7 +480,7 @@ namespace TShockAPI return true; } - if (type == 23 && float.IsNaN((float)Math.Sqrt((double)(velx * velx + vely * vely)))) + if (type == 23 && (vely == 0f || velx == 0f)) //float.IsNaN((float)Math.Sqrt((double)(velx * velx + vely * vely)))) { Tools.HandleGriefer(args.Player, TShock.Config.ProjectileAbuseReason); return true; @@ -511,7 +511,8 @@ namespace TShockAPI return Tools.HandleGriefer(args.Player, TShock.Config.KillMeAbuseReason); } args.Player.LastDeath = DateTime.Now; - args.Player.ForceSpawn = true; + if (args.Player.Difficulty != 2) + args.Player.ForceSpawn = true; return false; } diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index de55ebc6..3d757948 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -132,6 +132,9 @@ namespace TShockAPI [Description("User can buff other players")] public static readonly string buffplayer; + [Description("")] + public static readonly string grow; + static Permissions() { foreach (var field in typeof(Permissions).GetFields()) diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index 29d67f40..8b3cf488 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.2.8.0903")] -[assembly: AssemblyFileVersion("3.2.8.0903")] +[assembly: AssemblyVersion("3.3.0.0903")] +[assembly: AssemblyFileVersion("3.3.0.0903")] diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 65cbada2..30abe815 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -60,6 +60,8 @@ namespace TShockAPI public bool RequestedSection = false; public DateTime LastDeath { get; set; } public bool ForceSpawn = false; + public string Country = "??"; + public int Difficulty; public bool RealPlayer { diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 85cc0a5b..1b06aaef 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -18,10 +18,11 @@ along with this program. If not, see . /* TShock wouldn't be possible without: * Github * Microsoft Visual Studio 2010 - * HostPenda + * Adrenic * 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.Collections.Generic; @@ -48,7 +49,7 @@ namespace TShockAPI public class TShock : TerrariaPlugin { public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version; - public static readonly string VersionCodename = "Yes, we're adding Logblock style functionality soon, don't worry."; + public static readonly string VersionCodename = "And believe me, we are still alive."; public static string SavePath = "tshock"; @@ -65,6 +66,7 @@ namespace TShockAPI public static IDbConnection DB; public static bool OverridePort; public static PacketBufferer PacketBuffer; + public static MaxMind.GeoIPCountry Geo; /// /// Called after TShock is initialized. Useful for plugins that needs hooks before tshock but also depend on tshock being loaded. @@ -170,6 +172,8 @@ namespace TShockAPI Regions = new RegionManager(DB); Itembans = new ItemManager(DB); RememberedPos = new RemeberedPosManager(DB); + if (Config.EnableGeoIP) + Geo = new MaxMind.GeoIPCountry(Path.Combine(SavePath, "GeoIP.dat")); Log.ConsoleInfo(string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename)); @@ -620,7 +624,15 @@ namespace TShockAPI NetMessage.SendData((int)PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY); NetMessage.syncPlayers(); - Log.Info(string.Format("{0} ({1}) from '{2}' group joined.", player.Name, player.IP, player.Group.Name)); + if (Config.EnableGeoIP) + { + var code = Geo.TryGetCountryCode(IPAddress.Parse(player.IP)); + player.Country = code == null ? "N/A" : MaxMind.GeoIPCountry.GetCountryNameByCode(code); + Log.Info(string.Format("{0} ({1}) from '{2}' group from '{3}' joined.", player.Name, player.IP, player.Group.Name, player.Country)); + Tools.Broadcast(player.Name + " is from the " + player.Country, Color.Yellow); + } + else + Log.Info(string.Format("{0} ({1}) from '{2}' group joined.", player.Name, player.IP, player.Group.Name)); Tools.ShowFileToUser(player, "motd.txt"); if (HackedHealth(player)) diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 8cded74b..523752e5 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -1,189 +1,190 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {49606449-072B-4CF5-8088-AA49DA586694} - Library - Properties - TShockAPI - TShockAPI - v4.0 - 512 - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - true - full - false - ..\..\serverplugins\ - DEBUG;TRACE - prompt - 4 - true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - - - - False - ..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll - - - False - ..\SqlBins\MySql.Data.dll - True - - - False - ..\SqlBins\MySql.Web.dll - True - - - .\Newtonsoft.Json.dll - - - - - - - - - - - False - .exe - ..\TerrariaServerBins\TerrariaServer.exe - False - - - False - ..\TerrariaServerBins\TerrariaServerAPI.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - - - - - - - - - ResXFileCodeGenerator - Designer - Resources.Designer.cs - - - - - False - Microsoft .NET Framework 4 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 3.1 - true - - - - - - - - - - - - - "$(ProjectDir)postbuild.bat" - - - - - - - + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {49606449-072B-4CF5-8088-AA49DA586694} + Library + Properties + TShockAPI + TShockAPI + v4.0 + 512 + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + true + full + false + ..\..\serverplugins\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + + False + ..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll + + + False + ..\SqlBins\MySql.Data.dll + True + + + False + ..\SqlBins\MySql.Web.dll + True + + + .\Newtonsoft.Json.dll + + + + + + + + + + + False + .exe + ..\TerrariaServerBins\TerrariaServer.exe + False + + + False + ..\TerrariaServerBins\TerrariaServerAPI.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + + + + + + + + + + + + + ResXFileCodeGenerator + Designer + Resources.Designer.cs + + + + + False + Microsoft .NET Framework 4 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + + + + + + + + + + + "$(ProjectDir)postbuild.bat" + + + + + + + \ No newline at end of file diff --git a/UnitTests/RegionManagerTest.cs b/UnitTests/RegionManagerTest.cs index 0c2fd8cf..38def949 100644 --- a/UnitTests/RegionManagerTest.cs +++ b/UnitTests/RegionManagerTest.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Text; using System.Collections.Generic; using System.Linq; @@ -7,7 +8,7 @@ using System.Data; using TShockAPI; using Community.CsharpSqlite.SQLiteClient; using TShockAPI.DB; -using Microsoft.Xna.Framework; +using Region = TShockAPI.DB.Region; namespace UnitTests { @@ -29,6 +30,7 @@ namespace UnitTests DB.Open(); manager = new RegionManager(DB); + TShock.Regions = manager; manager.ReloadForUnitTest("test"); } @@ -39,12 +41,12 @@ namespace UnitTests Region r = new Region( new Rectangle(100,100,100,100), "test", true, "test"); Assert.IsTrue(manager.AddRegion(r.Area.X, r.Area.Y, r.Area.Width, r.Area.Height, r.Name, r.WorldID)); Assert.AreEqual(1, manager.Regions.Count); - Assert.IsNotNull(manager.getRegion("test")); + Assert.IsNotNull(manager.ZacksGetRegionByName("test")); Region r2 = new Region(new Rectangle(201, 201, 100, 100), "test2", true, "test"); manager.AddRegion(r2.Area.X, r2.Area.Y, r2.Area.Width, r2.Area.Height, r2.Name, r2.WorldID); Assert.AreEqual(2, manager.Regions.Count); - Assert.IsNotNull(manager.getRegion("test2")); + Assert.IsNotNull(manager.ZacksGetRegionByName("test2")); } [TestMethod] @@ -73,16 +75,16 @@ namespace UnitTests [TestMethod] public void SetRegionState() { - Assert.IsTrue(manager.getRegion("test").DisableBuild); + Assert.IsTrue(manager.ZacksGetRegionByName("test").DisableBuild); manager.SetRegionStateTest("test", "test", false); - Assert.IsTrue(!manager.getRegion("test").DisableBuild); + Assert.IsTrue(!manager.ZacksGetRegionByName("test").DisableBuild); manager.SetRegionStateTest("test", "test", true); - Assert.IsTrue(manager.getRegion("test").DisableBuild); - Assert.IsTrue(manager.getRegion("test2").DisableBuild); + Assert.IsTrue(manager.ZacksGetRegionByName("test").DisableBuild); + Assert.IsTrue(manager.ZacksGetRegionByName("test2").DisableBuild); manager.SetRegionStateTest("test2", "test", false); - Assert.IsTrue(!manager.getRegion("test2").DisableBuild); + Assert.IsTrue(!manager.ZacksGetRegionByName("test2").DisableBuild); manager.SetRegionStateTest("test2", "test", true); - Assert.IsTrue(manager.getRegion("test2").DisableBuild); + Assert.IsTrue(manager.ZacksGetRegionByName("test2").DisableBuild); } [TestMethod] diff --git a/UnitTests/RegionManagerTest.orderedtest b/UnitTests/RegionManagerTest.orderedtest index c9d1a48f..980cc5da 100644 --- a/UnitTests/RegionManagerTest.orderedtest +++ b/UnitTests/RegionManagerTest.orderedtest @@ -1,6 +1,6 @@  - - + + diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index 6ece350a..30af5656 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -14,6 +14,7 @@ v4.0 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + false publish\ true Disk @@ -26,7 +27,6 @@ true 0 1.0.0.%2a - false false true @@ -55,10 +55,6 @@ ..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll - - False - ..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_32\Microsoft.Xna.Framework\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.dll - ..\SqlBins\MySql.Data.dll @@ -71,14 +67,11 @@ + False ..\TerrariaServerBins\TerrariaServerAPI.dll - - False - ..\TerrariaServerBins\XNAHelpers.dll -