diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs
index 819be966..b4ca7a5e 100755
--- a/TShockAPI/TShock.cs
+++ b/TShockAPI/TShock.cs
@@ -677,6 +677,7 @@ namespace TShockAPI
StatTracker.Initialize();
}
+ /// ComputeMaxStyles - Computes the max styles...
private void ComputeMaxStyles()
{
var item = new Item();
@@ -695,10 +696,12 @@ namespace TShockAPI
}
}
}
+
+ /// FixChestStacks - Verifies that each stack in each chest is valid and not over the max stack count.
private void FixChestStacks()
{
- if (Config.IgnoreChestStacksOnLoad)
- return;
+ if (Config.IgnoreChestStacksOnLoad)
+ return;
foreach (Chest chest in Main.chest)
{
@@ -713,9 +716,14 @@ namespace TShockAPI
}
}
+ /// LastCheck - Used to keep track of the last check for basically all time based checks.
private DateTime LastCheck = DateTime.UtcNow;
+
+ /// LastSave - Used to keep track of SSC save intervals.
private DateTime LastSave = DateTime.UtcNow;
+ /// OnUpdate - Called when ever the server ticks.
+ /// args - EventArgs args
private void OnUpdate(EventArgs args)
{
if (Backups.IsBackupTime)
@@ -742,6 +750,7 @@ namespace TShockAPI
}
}
+ /// OnSecondUpdate - Called effectively every second for all time based checks.
private void OnSecondUpdate()
{
if (Config.ForceTime != "normal")
@@ -907,14 +916,18 @@ namespace TShockAPI
SetConsoleTitle(false);
}
+ /// SetConsoleTitle - Updates the console title with some pertinent information.
+ /// empty - True/false if the server is empty; determines if we should use Utils.ActivePlayers() for player count or 0.
private void SetConsoleTitle(bool empty)
{
Console.Title = string.Format("{0}{1}/{2} @ {3}:{4} (TShock for Terraria v{5})",
- !string.IsNullOrWhiteSpace(Config.ServerName) ? Config.ServerName + " - " : "",
- empty ? 0 : Utils.ActivePlayers(),
- Config.MaxSlots, Netplay.serverListenIP, Netplay.serverPort, Version);
+ !string.IsNullOrWhiteSpace(Config.ServerName) ? Config.ServerName + " - " : "",
+ empty ? 0 : Utils.ActivePlayers(),
+ Config.MaxSlots, Netplay.serverListenIP, Netplay.serverPort, Version);
}
+ /// OnHardUpdate - Fired when a hardmode tile update event happens.
+ /// args - The HardmodeTileUpdateEventArgs object.
private void OnHardUpdate(HardmodeTileUpdateEventArgs args)
{
if (args.Handled)
@@ -941,6 +954,8 @@ namespace TShockAPI
}
}
+ /// OnStatueSpawn - Fired when a statue spawns.
+ /// args - The StatueSpawnEventArgs object.
private void OnStatueSpawn(StatueSpawnEventArgs args)
{
if (args.Within200 < Config.StatueSpawn200 && args.Within600 < Config.StatueSpawn600 && args.WorldWide < Config.StatueSpawnWorld)
@@ -953,6 +968,8 @@ namespace TShockAPI
}
}
+ /// OnConnect - Fired when a player connects to the server.
+ /// args - The ConnectEventArgs object.
private void OnConnect(ConnectEventArgs args)
{
var player = new TSPlayer(args.Who);
@@ -988,6 +1005,8 @@ namespace TShockAPI
Players[args.Who] = player;
}
+ /// OnJoin - Internal hook called when a player joins. This is called after OnConnect.
+ /// args - The JoinEventArgs object.
private void OnJoin(JoinEventArgs args)
{
var player = Players[args.Who];
@@ -1066,6 +1085,8 @@ namespace TShockAPI
}
}
+ /// OnLeave - Called when a player leaves the server.
+ /// args - The LeaveEventArgs object.
private void OnLeave(LeaveEventArgs args)
{
var tsplr = Players[args.Who];
@@ -1094,6 +1115,7 @@ namespace TShockAPI
}
}
+ // Fire the OnPlayerLogout hook too, if the player was logged in and they have a TSPlayer object.
if (tsplr != null && tsplr.IsLoggedIn)
{
Hooks.PlayerHooks.OnPlayerLogout(tsplr);
@@ -1108,6 +1130,8 @@ namespace TShockAPI
}
}
+ /// OnChat - Fired when a player chats. Used for handling chat and commands.
+ /// args - The ServerChatEventArgs object.
private void OnChat(ServerChatEventArgs args)
{
if (args.Handled)
@@ -1122,17 +1146,11 @@ namespace TShockAPI
if (args.Text.Length > 500)
{
- Utils.Kick(tsplr, "Crash attempt", true);
+ Utils.Kick(tsplr, "Crash attempt via long chat packet.", true);
args.Handled = true;
return;
}
- /*if (!Utils.ValidString(text))
- {
- e.Handled = true;
- return;
- }*/
-
if ((args.Text.StartsWith(Config.CommandSpecifier) || args.Text.StartsWith(Config.CommandSilentSpecifier))
&& !string.IsNullOrWhiteSpace(args.Text.Substring(1)))
{
@@ -1191,7 +1209,7 @@ namespace TShockAPI
}
///
- /// When a server command is run.
+ /// Called when a command is issued from the server console.
///
/// The CommandEventArgs object
private void ServerHooks_OnCommand(CommandEventArgs args)
@@ -1225,6 +1243,8 @@ namespace TShockAPI
args.Handled = true;
}
+ /// OnGetData - Called when the server gets raw data packets.
+ /// e - The GetDataEventArgs object.
private void OnGetData(GetDataEventArgs e)
{
if (e.Handled)
@@ -1261,6 +1281,8 @@ namespace TShockAPI
}
}
+ /// OnGreetPlayer - Fired when a player is greeted by the server. Handles things like the MOTD, join messages, etc.
+ /// args - The GreetPlayerEventArgs object.
private void OnGreetPlayer(GreetPlayerEventArgs args)
{
var player = Players[args.Who];
@@ -1327,6 +1349,8 @@ namespace TShockAPI
args.Handled = true;
}
+ /// NpcHooks_OnStrikeNpc - Fired when an NPC strike packet happens.
+ /// e - The NpcStrikeEventArgs object.
private void NpcHooks_OnStrikeNpc(NpcStrikeEventArgs e)
{
if (Config.InfiniteInvasion)
@@ -1339,6 +1363,8 @@ namespace TShockAPI
}
}
+ /// OnProjectileSetDefaults - Called when a projectile sets the default attributes for itself.
+ /// e - The SetDefaultsEventArgs object praameterized with Projectile and int.
private void OnProjectileSetDefaults(SetDefaultsEventArgs e)
{
//tombstone fix.
@@ -1392,6 +1418,8 @@ namespace TShockAPI
return false;
}
+ /// NetHooks_SendData - Fired when the server sends data.
+ /// e - The SendDataEventArgs object.
private void NetHooks_SendData(SendDataEventArgs e)
{
if (e.MsgId == PacketTypes.Disconnect)
@@ -1517,16 +1545,18 @@ namespace TShockAPI
}
}
+ /// OnStartHardMode - Fired when hard mode is started.
+ /// e - The HandledEventArgs object.
private void OnStartHardMode(HandledEventArgs e)
{
if (Config.DisableHardmode)
e.Handled = true;
}
- /*
- * Useful stuff:
- * */
+ /// StartInvasion - Starts an invasion on the server.
+ /// type - The invasion type id.
+ //TODO: Why is this in TShock's main class?
public static void StartInvasion(int type)
{
Main.invasionType = type;
@@ -1550,8 +1580,11 @@ namespace TShockAPI
}
}
+ /// KillCount - Invasion kill count local storage variable.
private static int KillCount;
+ /// IncrementKills - Increments the number of kills used in invasion tracking.
+ //TODO: Why is this in TShock at all, still?
public static void IncrementKills()
{
KillCount++;
@@ -1583,6 +1616,11 @@ namespace TShockAPI
}
}
+ /// CheckProjectilePermission - Checks if a projectile is banned.
+ /// player - The TSPlayer object that created the projectile.
+ /// index - The projectile index.
+ /// type - The projectile type.
+ /// bool - True if the player does not have permission to use a projectile.
public static bool CheckProjectilePermission(TSPlayer player, int index, int type)
{
if (type == 43)
@@ -1613,6 +1651,12 @@ namespace TShockAPI
return false;
}
+ /// CheckRangePermission - Checks if a player has permission to modify a tile dependent on range checks.
+ /// player - The TSPlayer object.
+ /// x - The x coordinate of the tile.
+ /// y - The y coordinate of the tile.
+ /// range - The range to check for.
+ /// bool - True if the player should not be able to place the tile. False if they can, or if range checks are off.
public static bool CheckRangePermission(TSPlayer player, int x, int y, int range = 32)
{
if (Config.RangeChecks && ((Math.Abs(player.TileX - x) > range) || (Math.Abs(player.TileY - y) > range)))
@@ -1622,6 +1666,13 @@ namespace TShockAPI
return false;
}
+ /// CheckTilePermission - Checks to see if a player has permission to modify a tile in general.
+ /// player - The TSPlayer object.
+ /// tileX - The x coordinate of the tile.
+ /// tileY - The y coordinate of the tile.
+ /// tileType - The tile type.
+ /// actionType - The type of edit that took place.
+ /// bool - True if the player should not be able to modify a tile.
public static bool CheckTilePermission(TSPlayer player, int tileX, int tileY, short tileType, GetDataHandlers.EditAction actionType)
{
if (!player.Group.HasPermission(Permissions.canbuild))
@@ -1701,6 +1752,12 @@ namespace TShockAPI
return false;
}
+ /// CheckTilePermission - Checks to see if a player has the ability to modify a tile at a given position.
+ /// player - The TSPlayer object.
+ /// tileX - The x coordinate of the tile.
+ /// tileY - The y coordinate of the tile.
+ /// paint - Whether or not the tile is paint.
+ /// bool - True if the player should not be able to modify a the tile.
public static bool CheckTilePermission(TSPlayer player, int tileX, int tileY, bool paint = false)
{
if ((!paint && !player.Group.HasPermission(Permissions.canbuild)) ||
@@ -1756,6 +1813,10 @@ namespace TShockAPI
return false;
}
+ /// CheckSpawn - Checks to see if a location is inside the spawn protection zone.
+ /// x - The x coordinate to check.
+ /// y - The y coordinate to check.
+ /// bool - True if the location is inside the spawn protection zone.
public static bool CheckSpawn(int x, int y)
{
Vector2 tile = new Vector2(x, y);
@@ -1763,6 +1824,10 @@ namespace TShockAPI
return Distance(spawn, tile) <= Config.SpawnProtectionRadius;
}
+ /// Distance - Determines the distance between two vectors.
+ /// value1 - The first vector location.
+ /// value2 - The second vector location.
+ /// float - The distance between the two vectors.
public static float Distance(Vector2 value1, Vector2 value2)
{
float num2 = value1.X - value2.X;
@@ -1771,6 +1836,9 @@ namespace TShockAPI
return (float) Math.Sqrt(num3);
}
+ /// HackedInventory - Checks to see if a user has a hacked inventory. In addition, messages players the result.
+ /// player - The TSPlayer object.
+ /// bool - True if the player has a hacked inventory.
public static bool HackedInventory(TSPlayer player)
{
bool check = false;
@@ -1838,11 +1906,16 @@ namespace TShockAPI
return check;
}
+ /// CheckIgnores - Checks a players ignores...?
+ /// player - The TSPlayer object.
+ /// bool - True if any ignore is not none, false, or login state differs from the required state.
public static bool CheckIgnores(TSPlayer player)
{
return player.IgnoreActionsForInventory != "none" || player.IgnoreActionsForCheating != "none" || player.IgnoreActionsForDisabledArmor != "none" || player.IgnoreActionsForClearingTrashCan || !player.IsLoggedIn && Config.RequireLogin;
}
+ /// OnConfigRead - Fired when the config file has been read.
+ /// file - The config file object.
public void OnConfigRead(ConfigFile file)
{
NPC.defaultMaxSpawns = file.DefaultMaximumSpawns;