Skip to content

Commit

Permalink
更新到汉化版本v1.2.3 (APIv1.24)
Browse files Browse the repository at this point in the history
* 解决了独角兽坐骑会导致的传送错误
* 优化了区域判定
* 解决了玩家可以通过快速放物品, 造成区域保护箱子无效的问题
* 修复了绳子放置距离变大会被误判为作弊的问题
* 修复了挖掘机有时无法挖掘的问题(手里拿的不是镐子, 系统会误判为作弊)
* 增加了对数据包`SyncExtraValue`, `LoadNetModule`的有效性检测
  • Loading branch information
mistzzt committed Aug 18, 2016
2 parents a398448 + 66f5f9f commit c6e22f0
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
## Upcoming Changes

* API: Fixed chat line breaks when using chat tags and long strings of text (@ProfessorXZ)
* API: Added ItemForceIntoChest hook (@WhiteXZ)
* The setdungeon command correctly uses tshock.world.setdungeon as its permission (@OnsenManju)
* Fixed clients being able to "Catch" and remove NPCs (@ProfessorXZ)
* Fixed clients being able to remove other players' portals (@ProfessorXZ)
Expand All @@ -14,6 +15,11 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Fixed a bug involving Item Frames which allowed players to duplicate items (@ProfessorXZ)
* Fixed an issue allowing clients to teleport NPCs to arbitrary locations (@ProfessorXZ)
* Fixed a bug where players would get teleported to their previous location after dismounting the Unicorn Mount (@ProfessorXZ)
* Players can no longer quick stack items into region protected chests (@ProfessorXZ)
* Rope placement is no longer blocked by range checks (@ProfessorXZ)
* The Drill Containment Unit breaks blocks properly now (@ProfessorXZ)
* Fixed Expert mode coin duplication (@ProfessorXZ)
* Players are no longer able to place liquids using LoadNetModule packet (@ProfessorXZ)

## TShock 4.3.17

Expand Down
2 changes: 1 addition & 1 deletion TShockAPI/DB/RegionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ public bool HasPermissionToBuildInRegion(TSPlayer ply)
return false;
}

return AllowedIDs.Contains(ply.User.ID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.User.Name;
return ply.HasPermission(Permissions.editregion) || AllowedIDs.Contains(ply.User.ID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.User.Name;
}

/// <summary>
Expand Down
46 changes: 39 additions & 7 deletions TShockAPI/GetDataHandlers.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public class TileKillEventArgs : HandledEventArgs
public int TileY { get; set; }
}
/// <summary>
/// TileKill - When a tile is removed fromt he world
/// TileKill - When a tile is removed from the world
/// </summary>
public static HandlerList<TileKillEventArgs> TileKill;

Expand Down Expand Up @@ -1259,6 +1259,8 @@ public static void InitGetDataHandler()
{ PacketTypes.KillPortal, HandleKillPortal },
{ PacketTypes.PlaceTileEntity, HandlePlaceTileEntity },
{ PacketTypes.PlaceItemFrame, HandlePlaceItemFrame },
{ PacketTypes.SyncExtraValue, HandleSyncExtraValue },
{ PacketTypes.LoadNetModule, HandleLoadNetModule },
{ PacketTypes.ToggleParty, HandleToggleParty }
};
}
Expand Down Expand Up @@ -2013,15 +2015,15 @@ private static bool HandleTile(GetDataHandlerArgs args)
return true;
}
// If the tile is a pickaxe tile and they aren't selecting a pickaxe, they're hacking.
else if ((!Main.tileAxe[tile.type] && !Main.tileHammer[tile.type]) && tile.wall == 0 && (selectedItem.pick == 0 && !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0))
else if ((!Main.tileAxe[tile.type] && !Main.tileHammer[tile.type]) && tile.wall == 0 && ((args.TPlayer.mount.Type != 8 && selectedItem.pick == 0) && !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0))
{
args.Player.SendTileSquare(tileX, tileY, 4);
return true;
}
}
else if (action == EditAction.KillWall)
{
// If they aren't selecting an hammer, they could be hacking.
// If they aren't selecting a hammer, they could be hacking.
if (selectedItem.hammer == 0 && !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0 && selectedItem.createWall == 0)
{

Expand Down Expand Up @@ -2144,10 +2146,10 @@ private static bool HandleTile(GetDataHandlerArgs args)

// Ignore rope placement range
if ((editData != TileID.Rope
|| editData != TileID.SilkRope
|| editData != TileID.VineRope
|| editData != TileID.WebRope
|| action != EditAction.PlaceTile)
&& editData != TileID.SilkRope
&& editData != TileID.VineRope
&& editData != TileID.WebRope
&& action == EditAction.PlaceTile)
&& TShock.CheckRangePermission(args.Player, tileX, tileY))
{
args.Player.SendTileSquare(tileX, tileY, 4);
Expand Down Expand Up @@ -4203,6 +4205,36 @@ private static bool HandlePlaceItemFrame(GetDataHandlerArgs args)
return false;
}

private static bool HandleSyncExtraValue(GetDataHandlerArgs args)
{
var npcIndex = args.Data.ReadInt16();
var extraValue = args.Data.ReadSingle();
var position = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());

if (position.X < 0 || position.X >= Main.maxTilesX || position.Y < 0 || position.Y >= Main.maxTilesY)
{
return true;
}

if (!Main.expertMode)
{
return true;
}

if (TShock.CheckRangePermission(args.Player, (int)position.X, (int)position.Y))
{
return true;
}

return false;
}

private static bool HandleLoadNetModule(GetDataHandlerArgs args)
{
// Since this packet is never actually sent to us, every attempt at sending it can be considered as a liquid exploit attempt
return true;
}

private static bool HandleToggleParty(GetDataHandlerArgs args)
{
if (args.Player != null && !args.Player.HasPermission(Permissions.toggleparty))
Expand Down
34 changes: 29 additions & 5 deletions TShockAPI/TSPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,14 @@ public Group Group
/// </summary>
public int LoginAttempts { get; set; }

/// <summary>
/// Unused.
/// </summary>
public Vector2 TeleportCoords = new Vector2(-1, -1);

/// <summary>
/// The player's last known position from PlayerUpdate packet.
/// </summary>
public Vector2 LastNetPosition = Vector2.Zero;

/// <summary>
Expand Down Expand Up @@ -247,6 +253,9 @@ public int UserID
/// </summary>
public bool HasBeenNaggedAboutLoggingIn;

/// <summary>
/// Whether other players can teleport to the player.
/// </summary>
public bool TPAllow = true;

/// <summary>
Expand Down Expand Up @@ -435,7 +444,7 @@ public IEnumerable<Item> Accessories
}

/// <summary>
/// Saves the player's inventory to SSI
/// Saves the player's inventory to SSC
/// </summary>
/// <returns>bool - True/false if it saved successfully</returns>
public bool SaveServerCharacter()
Expand Down Expand Up @@ -534,21 +543,24 @@ public float Y
}

/// <summary>
/// Gets the player's X tile coordinate.
/// Player X coordinate divided by 16. Supposed X world coordinate.
/// </summary>
public int TileX
{
get { return (int) (X/16); }
}

/// <summary>
/// Gets the player's Y tile coordinate.
/// Player Y cooridnate divided by 16. Supposed Y world coordinate.
/// </summary>
public int TileY
{
get { return (int) (Y/16); }
}

/// <summary>
/// Unused.
/// </summary>
public bool TpLock;

/// <summary>
Expand Down Expand Up @@ -630,6 +642,10 @@ public object RemoveData(string key)
return null;
}

/// <summary>
/// Initializes a new instance of the <see cref="TSPlayer"/> class.
/// </summary>
/// <param name="index">The player's index in the.</param>
public TSPlayer(int index)
{
TilesDestroyed = new Dictionary<Vector2, Tile>();
Expand All @@ -640,6 +656,10 @@ public TSPlayer(int index)
AwaitingResponse = new Dictionary<string, Action<object>>();
}

/// <summary>
/// Initializes a new instance of the <see cref="TSPlayer"/> class.
/// </summary>
/// <param name="playerName">The player's name.</param>
protected TSPlayer(String playerName)
{
TilesDestroyed = new Dictionary<Vector2, Tile>();
Expand Down Expand Up @@ -686,7 +706,7 @@ public void TempGroupTimerElapsed(object sender, ElapsedEventArgs args)
}

/// <summary>
/// Teleports a player to the given coordinates in the world.
/// Teleports the player to the given coordinates in the world.
/// </summary>
/// <param name="x">The X coordinate.</param>
/// <param name="y">The Y coordinate.</param>
Expand Down Expand Up @@ -989,7 +1009,7 @@ public virtual void SendMessage(string msg, byte red, byte green, byte blue)
}

/// <summary>
/// Sends a message to a player with the specified RGB color.
/// Sends a message to the player with the specified RGB color.
/// </summary>
/// <param name="msg">The message.</param>
/// <param name="red">The amount of red color to factor in. Max: 255.</param>
Expand Down Expand Up @@ -1116,6 +1136,10 @@ private void LogStackFrame()
TShock.Log.Debug(frame.GetMethod().DeclaringType.Name + " called Disable().");
}

/// <summary>
/// Annoys the player for a specified amount of time.
/// </summary>
/// <param name="time">The</param>
public virtual void Whoopie(object time)
{
var time2 = (int) time;
Expand Down
50 changes: 44 additions & 6 deletions TShockAPI/TShock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace TShockAPI
/// This is the TShock main class. TShock is a plugin on the TerrariaServerAPI, so it extends the base TerrariaPlugin.
/// TShock also complies with the API versioning system, and defines its required API version here.
/// </summary>
[ApiVersion(1, 23)]
[ApiVersion(1, 24)]
public class TShock : TerrariaPlugin
{
/// <summary>VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.</summary>
Expand All @@ -55,7 +55,7 @@ public class TShock : TerrariaPlugin
/// <summary>CNMode - 显示当前汉化版本信息.</summary>
public static readonly string CNMode = "高级汉化-开发";
/// <summary>CNVersion - 显示当前汉化版本号.</summary>
public static readonly Version CNVersion = new Version(1, 2, 2, 0);
public static readonly Version CNVersion = new Version(1, 2, 3, 0);

/// <summary>SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins).</summary>
public static string SavePath = "tshock";
Expand Down Expand Up @@ -322,6 +322,7 @@ public override void Initialize()
ServerApi.Hooks.WorldChristmasCheck.Register(this, OnXmasCheck);
ServerApi.Hooks.WorldHalloweenCheck.Register(this, OnHalloweenCheck);
ServerApi.Hooks.NetNameCollision.Register(this, NetHooks_NameCollision);
ServerApi.Hooks.ItemForceIntoChest.Register(this, OnItemForceIntoChest);
Hooks.PlayerHooks.PlayerPreLogin += OnPlayerPreLogin;
Hooks.PlayerHooks.PlayerPostLogin += OnPlayerLogin;
Hooks.AccountHooks.AccountDelete += OnAccountDelete;
Expand Down Expand Up @@ -389,6 +390,7 @@ protected override void Dispose(bool disposing)
ServerApi.Hooks.WorldChristmasCheck.Deregister(this, OnXmasCheck);
ServerApi.Hooks.WorldHalloweenCheck.Deregister(this, OnHalloweenCheck);
ServerApi.Hooks.NetNameCollision.Deregister(this, NetHooks_NameCollision);
ServerApi.Hooks.ItemForceIntoChest.Deregister(this, OnItemForceIntoChest);
TShockAPI.Hooks.PlayerHooks.PlayerPostLogin -= OnPlayerLogin;

if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
Expand Down Expand Up @@ -476,6 +478,44 @@ private void NetHooks_NameCollision(NameCollisionEventArgs args)
}
}

/// <summary>OnItemForceIntoChest - Internal hook fired when a player quick stacks items into a chest.</summary>
/// <param name="args">The <see cref="ForceItemIntoChestEventArgs"/> object.</param>
private void OnItemForceIntoChest(ForceItemIntoChestEventArgs args)
{
if (args.Handled)
{
return;
}

if (args.Player == null)
{
args.Handled = true;
return;
}

TSPlayer tsplr = Players[args.Player.whoAmI];
if (tsplr == null)
{
args.Handled = true;
return;
}

if (args.Chest != null)
{
if (Config.RegionProtectChests && !Regions.CanBuild((int)args.Position.X, (int)args.Position.Y, tsplr))
{
args.Handled = true;
return;
}

if (CheckRangePermission(tsplr, (int)args.Position.X, (int)args.Position.Y))
{
args.Handled = true;
return;
}
}
}

/// <summary>OnXmasCheck - Internal hook fired when the XMasCheck happens.</summary>
/// <param name="args">args - The ChristmasCheckEventArgs object.</param>
private void OnXmasCheck(ChristmasCheckEventArgs args)
Expand Down Expand Up @@ -1705,8 +1745,7 @@ public static bool CheckTilePermission(TSPlayer player, int tileX, int tileY, sh
return true;
}

if (!player.HasPermission(Permissions.editregion) && !Regions.CanBuild(tileX, tileY, player) &&
Regions.InArea(tileX, tileY))
if (!Regions.CanBuild(tileX, tileY, player))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000)
{
Expand Down Expand Up @@ -1773,8 +1812,7 @@ public static bool CheckTilePermission(TSPlayer player, int tileX, int tileY, bo
return true;
}

if (!player.HasPermission(Permissions.editregion) && !Regions.CanBuild(tileX, tileY, player) &&
Regions.InArea(tileX, tileY))
if (!Regions.CanBuild(tileX, tileY, player))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000)
{
Expand Down
2 changes: 1 addition & 1 deletion TerrariaServerAPI

0 comments on commit c6e22f0

Please sign in to comment.