Repository navigation
Conversation
…ooltip Ctrl+Shift+left-click on an identified item puts "[Name] #i<token>" in the chat input. The token is base64url of the item's save record (without "JM") plus its socket fillers' records. Receive: the PrintGameString entry is hooked; every "#i<token>" word is parsed by a bounded validator against the live data tables, canonicalized and re-encoded, and only those bytes reach the engine decoder (D2Common #11145) to build a transient item unit (never hashed, no room). Valid links are drawn as "[Item Name]" in the item's quality colour; invalid tokens stay plain text. Clicking a link opens the game's own item tooltip for the transient copy (D2Client 0x93450 + D2Win #10110); Esc, right-click or another click closes it. The tooltip matches PD2's inventory hover: PD2's hover leaves "Quantity: N" out for stacks of an equippable item type (ItemTypes Body set: javelins, throwing weapons), so the link tooltip drops that line too and re-stages the popup at the builder's anchor for the shorter text. Keys and other non-equippable stacks keep it. The register-convention D2Client helpers are naked __fastcall stubs, so the compiler treats eax/ecx/edx as clobbered across them. Link hit boxes leave a trailing colour code out of the measured span (D2Win's TextNWidth measures one that ends the span as glyphs). API for other chat UIs: BH/Modules/ItemLinks/ChatLinkApi.h (FormatMessage, Release, OnClick). Config: item_links.enabled (default true). 1.13c only; the feature stays off if any code site differs. A site another module has detoured (jmp rel32 + int3 padding, as PD2's D2GL renderer does to D2Win #10085/#10177) still matches when every byte after the padding does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds chat item links: Ctrl+Shift+click an identified item to put
[Item Name]in the chat box, send it, and anyone running BH sees the name in the item's quality colour. Clicking the link opens the game's own item tooltip, with the same stats, sockets and colours as hovering the item in your inventory.It's client-only. The item travels inside the chat message, so nothing is needed on the server.
demo-link.mp4
Problem
Trading and gear questions in chat are all "wts shako 3 ist" or a screenshot pasted somewhere else. There's no way to show the actual item, with its exact rolls, to the people you're talking to.
Changes
New module
BH/Modules/ItemLinks/(4 files + a small API header), registered like the other modules. No changes to existing modules.ItemLinks.cpp)[Name] #i<token>to the chat input. The token is base64url of the item's save record (withoutJM) plus its socketed items. At most 248 characters, so it fits the 255-character chat box.ItemLinkCodec.cpp)#itoken is parsed by a strict, bounded validator against the live data tables (item codes, stat ids, skill/class parameters, socket rules), then re-encoded in canonical form. Only those canonical bytes ever reach the engine. Invalid or realm-only data stays plain text.ItemLinkGame.cpp)DrawTextcalls show[Name]in the quality colour and record each link's box. Clicking a box opens the native hover popup for that item. Esc, right-click or another click closes it.D2Win #10085/#10177for HD text) is still accepted when everything after the detour matches.item_links.enabled(default on).ChatLinkApi.h:FormatMessage/Release/OnClick, so a future chat UI can reuse the links.Testing
-3dfx)A couple of things the tests caught, now fixed in this PR:
Quantity: Nfor stacks of equippable types (javelins, throwing weapons). The link tooltip does the same, so the two match.__fastcallstubs, so the compiler knows eax/ecx/edx are clobbered.