-
-
Notifications
You must be signed in to change notification settings - Fork 414
Fix issues with Torch God event #3279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: general-devel
Are you sure you want to change the base?
Changes from 3 commits
7027339
aa03694
1ef89e2
b0941cf
a95e88c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -591,14 +591,20 @@ private static bool IsRectPositionValid(TSPlayer player, TileRect rect) | |
| /// <returns><see langword="true"/>, if the rect at a valid distance, otherwise <see langword="false"/>.</returns> | ||
| private static bool IsRectDistanceValid(TSPlayer player, TileRect rect) | ||
| { | ||
| int range = 32; | ||
|
|
||
| // Torches can be modified from far away through a water gun, or if the player is experiencing the torch god event. | ||
| if (IsRectATorch(player, rect)) | ||
| range = 104; // Base value of 100 comes from Player.TorchAttack, bumped by 4 blocks to be safe. | ||
|
|
||
| for (int x = 0; x < rect.Width; x++) | ||
| { | ||
| for (int y = 0; y < rect.Height; y++) | ||
| { | ||
| int realX = rect.X + x; | ||
| int realY = rect.Y + y; | ||
|
|
||
| if (!player.IsInRange(realX, realY)) | ||
| if (!player.IsInRange(realX, realY, range)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
@@ -608,6 +614,21 @@ private static bool IsRectDistanceValid(TSPlayer player, TileRect rect) | |
| return true; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Checks whether the tile rect is modifying a torch. | ||
| /// </summary> | ||
| /// <param name="player">The player the operation originates from.</param> | ||
| /// <param name="rect">The tile rectangle of the operation.</param> | ||
| /// <returns><see langword="true"/>, if the rect is modifying a torch, otherwise <see langword="false"/>.</returns> | ||
| private static bool IsRectATorch(TSPlayer player, TileRect rect) | ||
|
lost-werewolf marked this conversation as resolved.
Outdated
|
||
| { | ||
| // Rect is definitely not a torch... | ||
| if (rect.Width != 1 || rect.Height != 1) | ||
| return false; | ||
|
|
||
| // Is the rect actually modifying a torch? | ||
| return rect[0, 0].Type == TileID.Torches && Main.tile[rect.X, rect.Y].type == TileID.Torches; | ||
| } | ||
|
Comment on lines
+628
to
+630
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The condition If the Torch God event removes or replaces a torch tile (rather than only modifying its frame/paint), the server tile at that position would no longer have type It's worth clarifying whether the vanilla
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the torch is removed before the client relights it, it's not a problem. |
||
|
|
||
| /// <summary> | ||
| /// Checks whether the tile rect is a valid conversion spread (Clentaminator, Powders, etc.). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition
!args.Player.TPlayer.unlockedBiomeTorchesallows any player who has not yet unlocked biome torches to sendTorchGodprojectiles, regardless of whether they are currently in the event. Because this check is placed before theMain.projHostile[type]gate, it effectively lets a malicious client bypass the hostile-projectile filter simply by never completing the torch unlocking mechanic.A griefer on a server with multiple users who haven't unlocked biome torches could spam
TorchGodprojectile packets at will. Even if the projectile itself does not deal direct player damage, it can still trigger server-side effects (tile modifications, audio/visual spam to other clients, etc.) that were intentionally gated behind the hostile-projectile check.Consider adding an additional server-side guard — for example, a cooldown, a per-player projectile count limit, or logging/rate-limiting suspicious creation spikes — to mitigate abuse until a more authoritative event-state sync is available from the client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially addressed in a95e88c.
It isn't possible to check if the player is in the torch god event, since the client doesn't send PlayerInfo when setting the flag to true, only when setting it to false.