From 46a653da9992d961bad223ef35e68b71363ccda0 Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Sat, 4 Feb 2012 16:39:36 -0500 Subject: [PATCH] Added config option for how often to save ssi, and applied that to the save checker. Changed the OnTileEdit hook to take a player as well, so we know who is doing the edit. Changed the output of the Debug folder to go back to bin\Debug\ since I dont work 3 directories about TShock. --- TShockAPI/ConfigFile.cs | 2 ++ TShockAPI/GetDataHandlers.cs | 10 ++++++++-- TShockAPI/TShock.cs | 2 +- TShockAPI/TShockAPI.csproj | 6 +++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index f1caa8f8..4bb88a62 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -151,6 +151,8 @@ namespace TShockAPI [Description("Enable Server Side Inventory checks, EXPERIMENTAL")] public bool ServerSideInventory; + [Description("How often SSI should save, in minutes")] public int ServerSideInventorySave = 15; + [Description("Time, in milliseconds, to disallow discarding items after logging in when ServerSideInventory is ON")] public int LogonDiscardThreshold=250; [Description("Disables reporting of playercount to the stat system.")] public bool DisablePlayerCountReporting; diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 279ab251..96b9b19d 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -57,6 +57,11 @@ namespace TShockAPI /// public class TileEditEventArgs : HandledEventArgs { + /// + /// The TSPlayer who made the tile edit + /// + public TSPlayer Player { get; set; } + /// /// The tile coordinate on the X plane /// @@ -82,13 +87,14 @@ namespace TShockAPI /// TileEdit - called when a tile is placed or destroyed /// public static HandlerList TileEdit; - private static bool OnTileEdit(int x, int y, byte type, byte editType) + private static bool OnTileEdit(TSPlayer ply, int x, int y, byte type, byte editType) { if (TileEdit == null) return false; var args = new TileEditEventArgs { + Player = ply, X = x, Y = y, Type = type, @@ -1598,7 +1604,7 @@ namespace TShockAPI var tileX = args.Data.ReadInt32(); var tileY = args.Data.ReadInt32(); var tiletype = args.Data.ReadInt8(); - if (OnTileEdit(tileX, tileY, tiletype, type)) + if (OnTileEdit(args.Player, tileX, tileY, tiletype, type)) return true; if (tileX < 0 || tileX >= Main.maxTilesX || tileY < 0 || tileY >= Main.maxTilesY) return false; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 2f4394e8..9bdd096b 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -446,7 +446,7 @@ namespace TShockAPI LastCheck = DateTime.UtcNow; } - if ((DateTime.UtcNow - LastSave).TotalMinutes >= 15) + if ((DateTime.UtcNow - LastSave).TotalMinutes >= Config.ServerSideInventorySave) { foreach (TSPlayer player in Players) { diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 2f8b8a19..3968ad3f 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -32,12 +32,12 @@ true full false - ..\..\..\Tshock Debug\ServerPlugins\ + bin\Debug\ DEBUG;TRACE prompt 4 true - ..\..\..\Tshock Debug\ServerPlugins\TShockAPI.XML + bin\Debug\TShockAPI.XML pdbonly @@ -187,7 +187,7 @@ - +