Implement SendSayMessage function and hookchain #1134
+80
−19
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.
Purpose
Host_Saycurrently contains the full chat pipeline (sanitization + formatting + message dispatch). While it already performs important text cleanup, its monolithic design makes it difficult for modders to safely customize chat behavior (e.g., chat formats, location prefixes, alternate chat systems) via HookChains. In practice, many custom chat implementations bypassHost_Sayentirely to gain flexibility, which often leads to losing the built-in sanitization and character filtering thatHost_Sayprovides.This PR introduces
SendSayMessageas a dedicated, hookable dispatch step. The goal is to allow modders to alter chat output after it has already been sanitized by Host_Say, without re-implementing or skipping the original cleanup logic.Approach
This change refactors the chat path by splitting
Host_Sayinto two responsibilities:Host_Sayretains the sanitization and safe preparation of the raw player text (character filtering, cleanup, buffer handling).SendSayMessagebecomes the isolated “send” stage that receives the already-processed text and handles the final assembly/dispatch. This new function is exposed through HookChains so sub-plugins can adjust parameters (e.g., output formats, location text, console format) safely and consistently.To minimize memory-safety risks in a hookable interface,
SendSayMessagetreats incoming string pointers as read-only and performs any required modifications (currently only truncation to protocol limits) on local bounded copies. This avoids writing into unknown buffers and prevents unsafe in-place edits that could be introduced by third-party hooks.P.S. This PR is close to being a draft: I’d appreciate a review from a core collaborator specifically on the memory-handling aspects of the new split and the hookable surface, since small regressions in pointer/length assumptions could lead to exploitable behavior. @s1lentq
P.S.2. I’m intentionally not using
REGAMEDLL_FIXESmacros here, as the intended behavior should remain identical to the existing implementation; this change is meant as a refactor/extension for hookability rather than a behavioral fix or new gameplay feature.