Skip to content

Enhance item linking and make item linking server-authoritative

hazel requested to merge hazel_meow/isleward:1904-item-linking into master
Demo gifs (expand) iwd-item-linking iwd-item-linking-2

Implementation:

  • Ctrl+clicking or linking an item from the context menu sends a message like {{123}} (with the item id) in the current chat channel
  • Social component on server looks for occurrences of /{{\d+}}/ and finds the item with that ID in the player's inventory
  • Server collects real linked items into an array and replaces {{123}} with {{0}}, {{1}}, etc, re-indexed to the list of real linked items (item IDs that don't exist are stripped from the message. negative IDs {{-123}} are not touched, empty {{}} is not touched. If the message is empty after removing nonexistent items, nothing is sent)
  • Server sends chat message with re-indexed message and array of items
  • Client replaces occurrences of /{{\d+}}/ with <span>'s with the item name in brackets, styled with the quality color, and with the correct tooltip for each separate item
  • When ctrl+clicking an item to link it, if the chat is open, the {{123}} item id will be added to the chat

Outcomes:

  • Clients can't link arbitrary/fake items
  • Players can link items and write details about them in the same message (maybe needs better ux still)
  • Players can manually write bracketed IDs in the chat. Maybe not desired?
  • Players can link items in any chat channel and the most recent channel is used by default

Missing (can add to this PR if desired or do later):

  • Still can't link items without unequipping them
  • When adding items to the chat input without sending them directly, players see {{123}} instead of the item name. Could be fixed but would take some weird work

Other:

  • Updated the message sent by inventory.getItem to send the old quantity (fixes the behavior shown below)
  • getItem previously customized the text to include the stack quantity or fish weight, now all linked items will show the quantity/weight in the name
  • Linking items with bracketed ids works in general chat, custom channels, party chat, and whispers too
  • Ctrl+clicking to link sends in the currently selected chat channel (borrowed from !518)
  • If an item is linked, social uses the atlas to request the items from the player's zone, since it has the updated inventory and the main thread does not

Old behavior (fixed by MR): image

Closes #1904, closes #335, replaces !518

Edited by hazel

Merge request reports