Skip to content

Commit

Permalink
Update STR handling to reject for-sure invalid framing values
Browse files Browse the repository at this point in the history
  • Loading branch information
punchready committed Mar 24, 2023
1 parent 69569a5 commit 5acc3af
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions TShockAPI/Handlers/SendTileRectHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ internal void IterateTileRect(NetTile[,] tiles, bool[,] processed, GetDataHandle
}

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
Expand Down Expand Up @@ -210,10 +211,26 @@ internal void IterateTileRect(NetTile[,] tiles, bool[,] processed, GetDataHandle
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;
}
}
Expand All @@ -233,10 +250,26 @@ internal void IterateTileRect(NetTile[,] tiles, bool[,] processed, GetDataHandle
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;
}
}
Expand Down

0 comments on commit 5acc3af

Please sign in to comment.