Seed quest name generation so retries cost one synced RNG draw - #980
Open
romangr wants to merge 1 commit into
Open
Seed quest name generation so retries cost one synced RNG draw#980romangr wants to merge 1 commit into
romangr wants to merge 1 commit into
Conversation
Quest naming retries while the generated name collides with an existing quest's name, and NameGenerator's GrammarRequest overload retries while the validator rejects the text. Both retry counts depend on the generated strings and therefore on the client's language — the Russian rule packs collide constantly where English rarely does. With mixed-language players the synced Rand streams diverge and quest sites land on different tiles. Wrap QuestNode_ResolveQuestName.Resolve and the GrammarRequest overload of NameGenerator.GenerateName in SeedGrammar so the whole retry loop costs exactly one synced draw regardless of language.
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.
Problem
Quest naming retries while the generated name collides with an existing quest's name, and
NameGenerator'sGrammarRequestoverload retries while its validator rejects the text. Both retry counts depend on the generated strings, and therefore on the client's language — the Russian rule packs collide constantly where English rarely does.Every retry consumes synced
Randdraws, so with mixed-language players in the same game the RNG streams diverge and quest sites land on different tiles.Fix
Two methods added to
SeedGrammar'sTargetMethodsinSource/Client/Patches/Seeds.cs:NameGenerator.GenerateName(GrammarRequest, Predicate<string>, bool, string, string)— this overload holds the validator retry loop and is called directly by quest naming, bypassing theRulePackDefoverload that is already seeded.QuestNode_ResolveQuestName.Resolve— the outer loop that retries wholeNameGeneratorcalls while the name collides with an existing quest's.Seeding both means the entire retry loop costs exactly one synced draw, regardless of language or how many collisions occur.
Verification
dotnet build Source/Multiplayer.sln -c Releasesucceeds with 0 errors againstdevalone; the change touches only vanilla RimWorld symbols