Repository navigation
Conversation
Bot texts substitute placeholders with plain string replacement in map order (lexicographic). A short key therefore corrupts any longer key that starts with it: %max is eaten by %maxcount, %z by %zone and %skill by %skillByLockType, which qgo's diagnostics showed as "maxcount=2count", "zone=190.428one" and "skillByLockType=0ByLockType". Apply placeholders longest key first in all three replacement paths, so texts no longer depend on their key names.
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.
Pull Request Description
Bot texts substitute placeholders with plain string replacement, iterating the
std::mapof placeholders in lexicographic key order, so a short placeholder corrupts every longer placeholder that starts with it.Live example from the qgo diagnostics added in a companion PR:
Texts should not depend on their placeholder names; this fixes the shared replacement for every current and future text.
Feature Evaluation
Minimum logic: the three paths that apply placeholders (
GetBotText(name, placeholders), theGetBotTextOrDefaultfallback and the chat-reply path) now share a helper that sorts the placeholder keys by descending length before the existingreplaceAllloop.Processing cost: one small sort over a handful of keys, only when a text with placeholders is produced. No per-tick cost.
How to Test the Changes
qgooutput showszone=<id>,maxcount=<n>andskillByLockType=<n>intact instead of the corrupted values above.%target,%item,%gameobject, ...) are unchanged; without a prefix pair the replacement order cannot matter.Impact Assessment
Does this change increase per-bot/per-tick processing or risk scaling poorly with thousands of bots?
Does this change modify default bot behavior?
Does this change add new decision branches or increase maintenance complexity?
AI Assistance
Was AI assistance used while working on this change?
opencode (model deepseek-flash) wrote the change and this description. The author reviewed it; the corruption was reproduced and fixed live on a local realm via the qgo command, and the translation unit compiles warning-free.
Code Provenance / Attribution
Was any code in this PR copied or adapted from a sister / upstream project?
Final Checklist
Notes for Reviewers