Skip to content

Commit

Permalink
合并稳定分支进度 (汉化v2.2)
Browse files Browse the repository at this point in the history
* 增加TSPlayer.Logout(void)
* 修复了服务器密码会进不去的问题
* 修复了SSC人物存档混乱的问题
* 处理RopeCoil相关问题
* 加入时区 (上次登录时间)
* 更新Api2.0/OTAPI2.0.0.16
  • Loading branch information
mistzzt committed Jan 4, 2017
2 parents 085944b + 06f813c commit f6dd111
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 132 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin

## Upcoming Changes

## TShock 4.3.22
* Compatibility with Terraria 1.3.4.4
* API: Version tick 2.0
* API: Reduced RAM usage by ~80MB (Large server) (@deathcradle)
* API: Added TSPlayer.KillPlayer() (@WhiteXZ)
* API: Added TSPlayer.Logout() (@ProfessorXZ)
* Fixed connections after max slot is reached (@DeathCradle)
* Fixed server crashes caused by client disconnections when attempting to read closed sockets (@Enerdy)
* Added some code to make trapdoors work better (@DogooFalchion)
* AllowCutTilesAndBreakables config option now correctly allows flowers/vines/herbs to be cut in regions without breaking walls (@WhiteXZ)
* REST: `/status` has been re-added. It will now always point to `/v2/server/status` and includes an `upgrade` field describing the newest status route (@WhiteXZ)
* REST: `/v3/players/read` now includes a `muted` field (@WhiteXZ)
* Fixed fishing quests not saving/loading correctly when login before join, UUID login, and SSC were enabled together (@DogooFalchion)

## TShock 4.3.21
* Compatibility with Terraria 1.3.4.3 (@Patrikkk, @Zaicon).
* API: Version tick 1.26.
Expand All @@ -26,7 +40,6 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Added `/uploadssc [player]` which allows someone to upload SSC data for [player] and store it on the server. Adds `tshock.ssc.upload` and `tshock.ssc.upload.others` permission nodes to match (@DogooFalchion).
* Added hardened stone to the whitelist of tiles editable by players (@DogooFalchion).
* Added conversion system to send convert old MOTD format into smart text, while preserving initial line starting values to keep byte optimization for background colors Thanks to (@WhiteXZ, @Simon311, and especially @DogooFalchion) for the hard work on this issue.
* Fixed server-sided inventory issues caused by bank3 (@ProfessorXZ)

## TShock 4.3.20
* Security improvement: The auth system is now automatically disabled if a superadmin exists in the database (@Enerdy).
Expand Down
38 changes: 10 additions & 28 deletions TShockAPI/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -892,29 +892,7 @@ private static void Logout(CommandArgs args)
return;
}

PlayerHooks.OnPlayerLogout(args.Player);


if (Main.ServerSideCharacter)
{
args.Player.IgnoreActionsForInventory = String.Format("云端存档/强制开荒 模式. 请使用 {0}register \\ {0}login 加入游戏!", Commands.Specifier);
if (!args.Player.IgnoreActionsForClearingTrashCan && (!args.Player.Dead || args.Player.TPlayer.difficulty != 2))
{
args.Player.PlayerData.CopyCharacter(args.Player);
TShock.CharacterDB.InsertPlayerData(args.Player);
}
}

args.Player.PlayerData = new PlayerData(args.Player);
args.Player.Group = TShock.Groups.GetGroupByName(TShock.Config.DefaultGuestGroupName);
args.Player.tempGroup = null;
if (args.Player.tempGroupTimer != null)
{
args.Player.tempGroupTimer.Stop();
}
args.Player.User = null;
args.Player.IsLoggedIn = false;

args.Player.Logout();
args.Player.SendSuccessMessage("成功登出游戏.");
if (Main.ServerSideCharacter)
{
Expand Down Expand Up @@ -1224,16 +1202,20 @@ private static void ViewAccountInfo(CommandArgs args)
var user = TShock.Users.GetUserByName(username);
if (user != null)
{
DateTime LastSeen = DateTime.Parse(user.LastAccessed).ToLocalTime();
DateTime LastSeen;
string Timezone = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours.ToString("+#;-#");

args.Player.SendSuccessMessage("{0} 的上次登录时间为 {1} {2} UTC{3}.", user.Name, LastSeen.ToShortDateString(),
LastSeen.ToShortTimeString(), Timezone);
if (DateTime.TryParse(user.LastAccessed, out LastSeen))
{
LastSeen = DateTime.Parse(user.LastAccessed).ToLocalTime();
args.Player.SendSuccessMessage("{0} 的上次登录时间为 {1} {2} UTC{3}.", user.Name, LastSeen.ToShortDateString(),
LastSeen.ToShortTimeString(), Timezone);
}

if (args.Player.Group.HasPermission(Permissions.advaccountinfo))
{
List<string> KnownIps = JsonConvert.DeserializeObject<List<string>>(user.KnownIps);
string ip = KnownIps[KnownIps.Count - 1];
List<string> KnownIps = JsonConvert.DeserializeObject<List<string>>(user.KnownIps?.ToString() ?? string.Empty);
string ip = KnownIps?[KnownIps.Count - 1] ?? "N/A";
DateTime Registered = DateTime.Parse(user.Registered).ToLocalTime();

args.Player.SendSuccessMessage("{0} 的用户组是 {1}.", user.Name, user.Group);
Expand Down
41 changes: 29 additions & 12 deletions TShockAPI/GetDataHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1719,15 +1719,7 @@ private static bool HandleSendTileSquare(GetDataHandlerArgs args)
var tileX = args.Data.ReadInt16();
var tileY = args.Data.ReadInt16();

bool isTrapdoor = false;

if (Main.tile[tileX, tileY].type == TileID.TrapdoorClosed
|| Main.tile[tileX, tileY].type == TileID.TrapdoorOpen)
{
isTrapdoor = true;
}

if (args.Player.HasPermission(Permissions.allowclientsideworldedit) && !isTrapdoor)
if (args.Player.HasPermission(Permissions.allowclientsideworldedit))
return false;

if (OnSendTileSquare(size, tileX, tileY))
Expand Down Expand Up @@ -1826,7 +1818,7 @@ private static bool HandleSendTileSquare(GetDataHandlerArgs args)
changed = true;
}

if (tile.active() && newtile.Active)
if (tile.active() && newtile.Active && tile.type != newtile.Type)
{
// Grass <-> Grass
if ((TileID.Sets.Conversion.Grass[tile.type] && TileID.Sets.Conversion.Grass[newtile.Type]) ||
Expand Down Expand Up @@ -1859,6 +1851,17 @@ private static bool HandleSendTileSquare(GetDataHandlerArgs args)
Main.tile[realx, realy].wall = newtile.Wall;
changed = true;
}

if ((tile.type == TileID.TrapdoorClosed && (newtile.Type == TileID.TrapdoorOpen || !newtile.Active)) ||
(tile.type == TileID.TrapdoorOpen && (newtile.Type == TileID.TrapdoorClosed || !newtile.Active)) ||
(!tile.active() && newtile.Active && (newtile.Type == TileID.TrapdoorOpen||newtile.Type == TileID.TrapdoorClosed)))
{
Main.tile[realx, realy].type = newtile.Type;
Main.tile[realx, realy].frameX = newtile.FrameX;
Main.tile[realx, realy].frameY = newtile.FrameY;
Main.tile[realx, realy].active(newtile.Active);
changed = true;
}
}
}

Expand Down Expand Up @@ -1940,6 +1943,14 @@ public enum EditType
{ ProjectileID.CrimsandBallGun, TileID.Crimsand },
};

private static Dictionary<int, int> ropeCoilPlacements = new Dictionary<int, int>
{
{ItemID.RopeCoil, TileID.Rope},
{ItemID.SilkRopeCoil, TileID.SilkRope},
{ItemID.VineRopeCoil, TileID.VineRope},
{ItemID.WebRopeCoil, TileID.WebRope}
};

/// <summary>
/// Extra place style limits for strange hardcoded values in Terraria
/// </summary>
Expand Down Expand Up @@ -2115,7 +2126,8 @@ private static bool HandleTile(GetDataHandlerArgs args)

// If they aren't selecting the item which creates the tile or wall, they're hacking.
if (!(selectedItem.netID == ItemID.IceRod && editData == TileID.MagicalIceBlock) &&
editData != (action == EditAction.PlaceTile ? selectedItem.createTile : selectedItem.createWall))
(editData != (action == EditAction.PlaceTile ? selectedItem.createTile : selectedItem.createWall) &&
!(ropeCoilPlacements.ContainsKey(selectedItem.netID) && editData == ropeCoilPlacements[selectedItem.netID])))
{
args.Player.SendTileSquare(tileX, tileY, 4);
return true;
Expand Down Expand Up @@ -2191,8 +2203,13 @@ private static bool HandleTile(GetDataHandlerArgs args)
return true;
}
}
if (TShock.Config.AllowCutTilesAndBreakables && Main.tileCut[Main.tile[tileX, tileY].type])
if (TShock.Config.AllowCutTilesAndBreakables && Main.tileCut[tile.type])
{
if (action == EditAction.KillWall)
{
args.Player.SendTileSquare(tileX, tileY, 1);
return true;
}
return false;
}

Expand Down
8 changes: 7 additions & 1 deletion TShockAPI/NetItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public struct NetItem
/// </summary>
public static readonly int MiscDyeSlots = MiscEquipSlots;

/// <summary>
/// 1 - The number of trash can slots.
/// </summary>
public static readonly int TrashSlots = 1;

/// <summary>
/// 180 - The inventory size (inventory, held item, armour, dies, coins, ammo, piggy, safe, and trash)
/// </summary>
Expand All @@ -83,7 +88,8 @@ public struct NetItem
public static readonly Tuple<int, int> MiscDyeIndex = new Tuple<int, int>(MiscEquipIndex.Item2, MiscEquipIndex.Item2 + MiscDyeSlots);
public static readonly Tuple<int, int> PiggyIndex = new Tuple<int, int>(MiscDyeIndex.Item2, MiscDyeIndex.Item2 + PiggySlots);
public static readonly Tuple<int, int> SafeIndex = new Tuple<int, int>(PiggyIndex.Item2, PiggyIndex.Item2 + SafeSlots);
public static readonly Tuple<int, int> ForgeIndex = new Tuple<int, int>(SafeIndex.Item2, SafeIndex.Item2 + ForgeSlots);
public static readonly Tuple<int, int> TrashIndex = new Tuple<int, int>(SafeIndex.Item2, SafeIndex.Item2 + TrashSlots);
public static readonly Tuple<int, int> ForgeIndex = new Tuple<int, int>(TrashIndex.Item2, TrashIndex.Item2 + ForgeSlots);

[JsonProperty("物品")]
private int _netId;
Expand Down
Loading

0 comments on commit f6dd111

Please sign in to comment.