Change the way we ignore packets from clients while swapping with SSC inv.

Add dump for SSC, and terminate the application (maybe).
This commit is contained in:
Zack Piispanen 2015-03-16 20:36:32 -04:00
parent 7fe761bacb
commit b031f45cb0
3 changed files with 44 additions and 2 deletions

View file

@ -1284,9 +1284,15 @@ namespace TShockAPI
bypassTrashCanCheck = true;
}
if (OnPlayerSlot(plr, slot, stack, prefix, type) || plr != args.Player.Index || slot < 0 || slot > NetItem.maxNetInventory || args.Player.IgnoreSSCPackets)
if (OnPlayerSlot(plr, slot, stack, prefix, type) || plr != args.Player.Index || slot < 0 ||
slot > NetItem.maxNetInventory)
return true;
if (args.Player.IgnoreSSCPackets)
{
args.Player.SendData(PacketTypes.PlayerSlot, "", args.Player.Index, slot);
return true;
}
// Garabage? Or will it cause some internal initialization or whatever?
var item = new Item();
item.netDefaults(type);

View file

@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.IO;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
namespace TShockAPI.ServerSideCharacters
@ -61,5 +63,37 @@ namespace TShockAPI.ServerSideCharacters
writer.Write(JsonConvert.SerializeObject(this, Formatting.Indented));
}
}
/// <summary>
/// Dumps all configuration options to a text file in Markdown format
/// </summary>
public static void DumpDescriptions()
{
var sb = new StringBuilder();
var defaults = new ServerSideConfig();
foreach (var field in defaults.GetType().GetFields().OrderBy(f => f.Name))
{
if (field.IsStatic)
continue;
var name = field.Name;
var type = field.FieldType.Name;
var descattr =
field.GetCustomAttributes(false).FirstOrDefault(o => o is DescriptionAttribute) as DescriptionAttribute;
var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : "None";
var def = field.GetValue(defaults);
sb.AppendLine("{0} ".SFormat(name));
sb.AppendLine("Type: {0} ".SFormat(type));
sb.AppendLine("Description: {0} ".SFormat(desc));
sb.AppendLine("Default: \"{0}\" ".SFormat(def));
sb.AppendLine();
}
File.WriteAllText("ServerSideConfigDescriptions.txt", sb.ToString());
}
}
}

View file

@ -518,6 +518,8 @@ namespace TShockAPI
case "-dump":
ConfigFile.DumpDescriptions();
Permissions.DumpDescriptions();
ServerSideConfig.DumpDescriptions();
Environment.Exit(1);
break;
}
}