Merge branch 'general-devel' into consistency-playeractive-patch

This commit is contained in:
Stargazing Koishi 2023-04-28 15:53:43 -07:00 committed by GitHub
commit f1b67f8602
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 1106 additions and 1037 deletions

View file

@ -2659,9 +2659,12 @@ namespace TShockAPI
* If the player was not specified, that is, the player index is -1, then it is definitely a custom cause, as you can only deal damage with a projectile or another player.
* This is how everything else works. If an NPC is specified, its value is not -1, which is a custom cause.
*
* An exception to this is damage dealt by the Inferno potion to other players -- it is only identified by the other index value of 16,
* even lacking a source player index.
*
* Checking whether this damage came from the player is necessary, because the damage from the player can come even when it is hit by a NPC
*/
if (TShock.Config.Settings.DisableCustomDeathMessages && id != args.Player.Index &&
if (TShock.Config.Settings.DisableCustomDeathMessages && id != args.Player.Index && reason._sourceOtherIndex != 16 &&
(reason._sourcePlayerIndex == -1 || reason._sourceNPCIndex != -1 || reason._sourceOtherIndex != -1 || reason._sourceCustomReason != null))
{
TShock.Log.ConsoleDebug(GetString("Bouncer / OnPlayerDamage rejected custom death message from {0}", args.Player.Name));

View file

@ -189,6 +189,9 @@ namespace TShockAPI.DB
if (!player.IsLoggedIn)
return false;
if (player.State < 10)
return false;
if (player.HasPermission(Permissions.bypassssc) && !fromCommand)
{
TShock.Log.ConsoleInfo(GetParticularString("{0} is a player name", $"Skipping SSC save (due to tshock.ignore.ssc) for {player.Account.Name}"));

View file

@ -2248,6 +2248,7 @@ namespace TShockAPI
var args = new SyncTilePickingEventArgs
{
Player = player,
PlayerIndex = playerIndex,
TileX = tileX,
TileY = tileY,

View file

@ -38,6 +38,10 @@ namespace TShockAPI.Handlers
{
TileID.JungleGrass
} },
{ TileID.AshPlants, new HashSet<ushort>()
{
TileID.AshGrass
} },
};
/// <summary>
@ -67,6 +71,10 @@ namespace TShockAPI.Handlers
{
9, 10, 11, 12, 13, 14, 15, 16,
} },
{ TileID.AshPlants, new HashSet<ushort>()
{
6, 7, 8, 9, 10,
} },
};
/// <summary>
@ -173,6 +181,7 @@ namespace TShockAPI.Handlers
}
NetTile newTile = tiles[x, y];
TileObjectData data;
// If the new tile has an associated TileObjectData object, we take the tile and the surrounding tiles that make up the tile object
@ -210,10 +219,26 @@ namespace TShockAPI.Handlers
case TileID.ShimmerMonolith:
{
// Allowed changes
// Based on empirical tests, these should be some conservative upper bounds for framing values
if (newTile.FrameX != -1 || newTile.FrameY != -1)
{
if (newTile.FrameX is < 0 or > 1000)
{
processed[x, y] = true;
continue;
}
if (newTile.FrameY is < 0 or > 5000)
{
processed[x, y] = true;
continue;
}
}
}
break;
default:
{
processed[x, y] = true;
continue;
}
}
@ -233,10 +258,26 @@ namespace TShockAPI.Handlers
case TileID.TargetDummy:
{
// Allowed placements
// Based on empirical tests, these should be some conservative upper bounds for framing values
if (newTile.FrameX != -1 || newTile.FrameY != -1)
{
if (newTile.FrameX is < 0 or > 1000)
{
processed[x, y] = true;
continue;
}
if (newTile.FrameY is < 0 or > 500)
{
processed[x, y] = true;
continue;
}
}
}
break;
default:
{
processed[x, y] = true;
continue;
}
}
@ -390,6 +431,19 @@ namespace TShockAPI.Handlers
}
}
// Moss and MossBrick are not used in conversion
private static List<bool[]> _convertibleTiles = typeof(TileID.Sets.Conversion)
.GetFields()
.ExceptBy(new[] { nameof(TileID.Sets.Conversion.Moss), nameof(TileID.Sets.Conversion.MossBrick) }, f => f.Name)
.Select(f => (bool[])f.GetValue(null))
.ToList();
// PureSand is only used in WorldGen.SpreadDesertWalls, which is server side
private static List<bool[]> _convertibleWalls = typeof(WallID.Sets.Conversion)
.GetFields()
.ExceptBy(new[] { nameof(WallID.Sets.Conversion.PureSand) }, f => f.Name)
.Select(f => (bool[])f.GetValue(null))
.ToList();
/// <summary>
/// Updates a single tile on the server if it is a valid conversion from one tile or wall type to another (eg stone -> corrupt stone)
/// </summary>
@ -397,37 +451,43 @@ namespace TShockAPI.Handlers
/// <param name="newTile">The NetTile containing new tile properties</param>
internal void ProcessConversionSpreads(ITile tile, NetTile newTile)
{
// Update if the existing tile or wall is convertible and the new tile or wall is a valid conversion
if (
((TileID.Sets.Conversion.Stone[tile.type] || Main.tileMoss[tile.type]) && (TileID.Sets.Conversion.Stone[newTile.Type] || Main.tileMoss[newTile.Type])) ||
((tile.type == 0 || tile.type == 59) && (newTile.Type == 0 || newTile.Type == 59)) ||
TileID.Sets.Conversion.Grass[tile.type] && TileID.Sets.Conversion.Grass[newTile.Type] ||
TileID.Sets.Conversion.Ice[tile.type] && TileID.Sets.Conversion.Ice[newTile.Type] ||
TileID.Sets.Conversion.Sand[tile.type] && TileID.Sets.Conversion.Sand[newTile.Type] ||
TileID.Sets.Conversion.Sandstone[tile.type] && TileID.Sets.Conversion.Sandstone[newTile.Type] ||
TileID.Sets.Conversion.HardenedSand[tile.type] && TileID.Sets.Conversion.HardenedSand[newTile.Type] ||
TileID.Sets.Conversion.Thorn[tile.type] && TileID.Sets.Conversion.Thorn[newTile.Type] ||
TileID.Sets.Conversion.Moss[tile.type] && TileID.Sets.Conversion.Moss[newTile.Type] ||
TileID.Sets.Conversion.MossBrick[tile.type] && TileID.Sets.Conversion.MossBrick[newTile.Type]
)
var allowTile = false;
if (Main.tileMoss[tile.type] && TileID.Sets.Conversion.Stone[newTile.Type])
{
allowTile = true;
}
else if ((Main.tileMoss[tile.type] || TileID.Sets.Conversion.Stone[tile.type] || TileID.Sets.Conversion.Ice[tile.type] || TileID.Sets.Conversion.Sandstone[tile.type]) &&
(newTile.Type == TileID.Sandstone || newTile.Type == TileID.IceBlock))
{
// ProjectileID.SandSpray and ProjectileID.SnowSpray
allowTile = true;
}
else
{
foreach (var tileType in _convertibleTiles)
{
if (tileType[tile.type] && tileType[newTile.Type])
{
allowTile = true;
break;
}
}
}
if (allowTile)
{
TShock.Log.ConsoleDebug(GetString($"Bouncer / SendTileRect processing a tile conversion update - [{tile.type}] -> [{newTile.Type}]"));
UpdateServerTileState(tile, newTile, TileDataType.Tile);
}
if (WallID.Sets.Conversion.Stone[tile.wall] && WallID.Sets.Conversion.Stone[newTile.Wall] ||
WallID.Sets.Conversion.Grass[tile.wall] && WallID.Sets.Conversion.Grass[newTile.Wall] ||
WallID.Sets.Conversion.Sandstone[tile.wall] && WallID.Sets.Conversion.Sandstone[newTile.Wall] ||
WallID.Sets.Conversion.HardenedSand[tile.wall] && WallID.Sets.Conversion.HardenedSand[newTile.Wall] ||
WallID.Sets.Conversion.PureSand[tile.wall] && WallID.Sets.Conversion.PureSand[newTile.Wall] ||
WallID.Sets.Conversion.NewWall1[tile.wall] && WallID.Sets.Conversion.NewWall1[newTile.Wall] ||
WallID.Sets.Conversion.NewWall2[tile.wall] && WallID.Sets.Conversion.NewWall2[newTile.Wall] ||
WallID.Sets.Conversion.NewWall3[tile.wall] && WallID.Sets.Conversion.NewWall3[newTile.Wall] ||
WallID.Sets.Conversion.NewWall4[tile.wall] && WallID.Sets.Conversion.NewWall4[newTile.Wall]
)
foreach (var wallType in _convertibleWalls)
{
TShock.Log.ConsoleDebug(GetString($"Bouncer / SendTileRect processing a wall conversion update - [{tile.wall}] -> [{newTile.Wall}]"));
UpdateServerTileState(tile, newTile, TileDataType.Wall);
if (wallType[tile.wall] && wallType[newTile.Wall])
{
TShock.Log.ConsoleDebug(GetString($"Bouncer / SendTileRect processing a wall conversion update - [{tile.wall}] -> [{newTile.Wall}]"));
UpdateServerTileState(tile, newTile, TileDataType.Wall);
break;
}
}
}

View file

@ -676,17 +676,13 @@ namespace TShockAPI
if (args.Chest != null)
{
// After checking for protected regions, no further range checking is necessarily because the client packet only specifies the
// inventory slot to quick stack. The vanilla Terraria server itself determines what chests are close enough to the player.
if (Config.Settings.RegionProtectChests && !Regions.CanBuild((int)args.WorldPosition.X, (int)args.WorldPosition.Y, tsplr))
{
args.Handled = true;
return;
}
if (!tsplr.IsInRange(args.Chest.x, args.Chest.y))
{
args.Handled = true;
return;
}
}
}

View file

@ -330,7 +330,7 @@ namespace TShockAPI
/// <returns>The item represented by the tag.</returns>
public Item GetItemFromTag(string tag)
{
Regex regex = new Regex(@"\[i(tem)?(?:\/s(?<Stack>\d{1,3}))?(?:\/p(?<Prefix>\d{1,3}))?:(?<NetID>-?\d{1,4})\]");
Regex regex = new Regex(@"\[i(tem)?(?:\/s(?<Stack>\d{1,4}))?(?:\/p(?<Prefix>\d{1,3}))?:(?<NetID>-?\d{1,4})\]");
Match match = regex.Match(tag);
if (!match.Success)
return null;