Skip to content

add handler for DisplayDollPoseSync#3273

Open
lost-werewolf wants to merge 1 commit intoPryaxis:general-develfrom
lost-werewolf:displaydoll-pose-handler
Open

add handler for DisplayDollPoseSync#3273
lost-werewolf wants to merge 1 commit intoPryaxis:general-develfrom
lost-werewolf:displaydoll-pose-handler

Conversation

@lost-werewolf
Copy link
Copy Markdown
Contributor

Adds a handler for DisplayDollPoseSync to prevent players from posing protected mannequins. Also makes a correction to DisplayDollInventoryID - Misc is actually 3 according to the game (can be found in Terraria.GameConent.Tile_Entities.TEDisplayDoll.Read), while Pose is 2. So Pose was added as 2 and Misc was moved to 3.

Please let me know if further changs should be made. Was reluctant to rename DisplayDollInventoryID, if it would be appropriate to, I can do so.

Also correct DisplayDollInventoryID
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds server-side handling for display doll (mannequin) pose sync packets so pose changes are blocked in protected areas, and corrects the display doll packet subtype/ID mapping to match the game’s values.

Changes:

  • Add DisplayDollPoseSyncHandler and register it in Bouncer to enforce build permissions on pose changes.
  • Fix DisplayDollInventoryID numeric values by introducing Pose = 2 and moving Misc to 3.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
TShockAPI/Handlers/DisplayDollPoseSyncHandler.cs New packet handler for mannequin pose sync with permission enforcement and attempted client resync.
TShockAPI/GetDataHandlers.cs Corrects display doll subtype/ID enum values and adds Pose.
TShockAPI/Bouncer.cs Wires the new handler into the existing packet handler subscription flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@hakusaro
Copy link
Copy Markdown
Member

@greptile review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 15, 2026

Greptile Summary

Adds a new DisplayDollPoseSyncHandler to prevent players from changing mannequin poses in protected areas, closing a gap where item sync was guarded but pose sync was not. Also corrects the DisplayDollInventoryID enum to match the actual Terraria wire protocol (Pose = 2, Misc = 3), which was already reflected in the switch-case routing in HandleTileEntityDisplayDollItemSync.

  • New handler (DisplayDollPoseSyncHandler): Checks HasBuildPermission and, on rejection, sends a resync packet (TileEntityDisplayDollItemSync with subtype Pose) to revert the client's unauthorized change. Follows the same pattern as the existing DisplayDollItemSyncHandler.
  • Enum fix (DisplayDollInventoryID): Misc corrected from 23; new Pose = 2 entry added. This is a breaking change for external plugin code that relied on the old integer value of Misc.
  • Handler registration (Bouncer): Standard wiring — property + event subscription, consistent with adjacent handlers.

Confidence Score: 4/5

  • This PR is safe to merge; it fills a security gap and corrects an enum to match the actual protocol.
  • The handler follows established patterns exactly, the enum correction aligns values with the existing switch-case routing that was already using the correct protocol numbers, and the only concern is the breaking change to the public enum value for external plugin consumers.
  • TShockAPI/GetDataHandlers.cs — the DisplayDollInventoryID enum change is a public API breaking change that should be documented for plugin authors.

Important Files Changed

Filename Overview
TShockAPI/Handlers/DisplayDollPoseSyncHandler.cs New handler that prevents unauthorized mannequin pose changes in protected areas. Follows the existing DisplayDollItemSyncHandler pattern and adds a resync packet to revert client-side pose changes.
TShockAPI/GetDataHandlers.cs Corrects DisplayDollInventoryID enum values to match the Terraria wire protocol: Pose=2, Misc=3 (was Misc=2). This is a breaking change for any plugin code using the old integer value of Misc. Trailing comma removed from Misc entry.
TShockAPI/Bouncer.cs Standard handler registration for the new DisplayDollPoseSyncHandler, following the exact same pattern as the adjacent DisplayDollItemSyncHandler registration. No issues.

Sequence Diagram

sequenceDiagram
    participant Client
    participant GetDataHandlers
    participant DisplayDollPoseSyncHandler
    participant Bouncer/Permissions

    Client->>GetDataHandlers: TileEntityDisplayDollItemSync (subtype=2, pose)
    GetDataHandlers->>GetDataHandlers: HandleTileEntityDisplayDollItemSync()
    GetDataHandlers->>GetDataHandlers: OnDisplayDollPoseSync()
    GetDataHandlers->>DisplayDollPoseSyncHandler: OnReceive(DisplayDollPoseSyncEventArgs)
    DisplayDollPoseSyncHandler->>Bouncer/Permissions: HasBuildPermission(X, Y)
    alt Permission Denied
        Bouncer/Permissions-->>DisplayDollPoseSyncHandler: false
        DisplayDollPoseSyncHandler->>Client: SendErrorMessage("No permission")
        DisplayDollPoseSyncHandler->>Client: SendData(TileEntityDisplayDollItemSync, subtype=Pose) [resync]
        DisplayDollPoseSyncHandler->>GetDataHandlers: args.Handled = true
    else Permission Granted
        Bouncer/Permissions-->>DisplayDollPoseSyncHandler: true
        Note over GetDataHandlers: Packet processed normally
    end
Loading

Last reviewed commit: edb1b2c

Copy link
Copy Markdown
Member

@ACaiCat ACaiCat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks and tests OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants