Purpose and fixes
Adds a clickable PM link to shout/global-chat messages and opens a whisper dialog for the named player. The supplied Python handler indexes tokens[1] without checking that it exists. M2City r1 accepts only a two-part pm:name link with a nonempty name and still excludes the local player.
The native snippet added snprintf's return value directly to len. A truncated write returns the required length, so that can overstate the valid buffer length. The revised fragment checks the append position, increases len only for a complete suffix, and discards a partial hyperlink while preserving the original chat text. It does not claim to repair earlier unrelated chat-buffer construction in your branch.

Integration
Enable ENABLE_PM_IN_GLOBAL_CHAT consistently in the server and client, export the Python flag and merge input_main.cpp plus Interface.MakeHyperlinkTooltip. Preserve item-link handling and the rest of Chat. Confirm your server already validates character names and packet/chat lengths; the feature is not a replacement for those checks. Test maximum-length shouts, empire/channel routing, malformed links, self links, feature disabled and normal item hyperlinks.

Validation
All five text fragments were reviewed. The revised native append logic passed every initial message length from 0 to 64 and an overlong suffix in a 65-byte fake buffer. The Python handler passed malformed, empty, self, extra-field and disabled cases and opened a valid recipient once. No full game/client build or network chat test was performed. The supplied iBeast attribution is retained; public research did not establish an exact upstream release for this copy.

Editorial resource — M2City
Version: Legacy integration fragments; exact fork unspecified; M2City r1 (2026-11-04)
Rights: Public redistribution confirmed by owner; upstream notices retained. No blanket open-source relicensing.
Validation: Malformed/empty/self/extra-field/disabled hyperlinks rejected; valid other player opens once. Fake UI, no live client. Exact reviewed logic compiled with clang++ C++11 and passed isolated fake-engine assertions. No complete binary build/gameplay test.
Source: Owner-supplied source; public creator/feature reference where established
SHA-256: 331ce97b8cb5f53840743783250c32071caa515f0519ecaa05b73fde25faae45