fix: apply naming pattern after parent linking in Export Gun listen channel#1406
Conversation
…hannel
The Export Gun listen handler was applying the naming pattern before
parents were resolved and generation recalculated, causing {gena}, {gen},
{nr_in_gen}, {nr_in_gen_sex} and {genn} to always evaluate as gen 0 on
first import.
Reorders the import flow inside AsbServerDataSent to merge -> resolve
parents -> recompute generation -> apply pattern -> respond, matching the
existing file-import path in Form1.collection.cs.
|
Hi, thanks for this fix! Regarding the other suggestions:
|
|
|
Thanks both for the quick feedback! On idea #1 (bulk rename): @coldino — understood, the mod doesn't have a general listen capability and the queuing/rate-limiting concerns are real. Putting that one on the shelf. Current workaround on our side is just re-firing the Export Gun on each dino — tedious but it works. On idea #2 (server multipliers): @coldino's clarification was the missing piece — "the export gun should be exporting server multipliers ... it is also sent through the export server". That sent me to the ASB-side handling, and there's a regex off-by-one in So the mechanism is correct end-to-end — the push happens, the JSON arrives, ASB just wasn't parsing the hash. Verified on an ASA cluster: before the fix, Settings → Multipliers stayed at ASA Official defaults despite Fix is at #1407 — one character. Thanks again for the design context, it made finding the root cause much faster. |
|
Interesting. Would prefer if you disclosed the AI use, however. |
|
Fair point, my apologies for not mentioning it upfront. French speaker here, juggling several projects — I use AI assistance On these PRs specifically: bug observations on my ASA cluster, in-game Will flag AI assistance on future contributions here as a matter of policy. |
Summary
The auto-import handler for the Export Gun listen channel (
Form1.exportGun.cs→AsbServerDataSent) was applying the naming pattern and sending the generated name back to the game before the imported creature had its parents resolved and its generation recalculated.As a consequence, every pattern token that depends on the pedigree depth —
{gena},{gen},{nr_in_gen},{nr_in_gen_sex}, and{genn}— was evaluated as if the creature hadgeneration = 0. Users had to manually re-apply the naming pattern in ASB (Ctrl+A + Apply pattern) after each Export Gun shot to get the correct generation in the in-game name.This PR reorders the import flow inside
if (addCreature)to match the existing file-import flow inForm1.collection.cs(which already carries an explicit comment: "This can only be done after parent linking to get correct name pattern values related to parents").What changed
In
Form1.exportGun.cs→AsbServerDataSent:Before
SetNameOfImportedCreature(...)— pattern evaluated withgeneration = 0data.TaskNameGenerated?.SetResult(...)— sends back the wrong nameMergeCreatureList(...)UpdateCreatureParentLinkingSort(...)— finally resolves parentsAfter
alreadyExistingCreature(must happen before the merge, otherwise it ends up pointing at the freshly-added creature)MergeCreatureList(...)UpdateParents(new[] { creature })— resolvescreature.Mother/creature.Father(creates placeholders for unknown ancestors, consistent with the rest of the code). This is the primary unblocker:NamePattern.GenerateCreatureNamehas a fallback (generation <= 0→Math.Max(Mother?.generation + 1, Father?.generation + 1)), so once parents are linked, the pattern can already compute the right generation tokens.creature.RecalculateAncestorGenerations()— also setscreature.generationdirectly, matching the file-import flow and keeping the value consistent for any downstream consumer.SetNameOfImportedCreature(...)— pattern evaluated with the right valuesdata.TaskNameGenerated?.SetResult(...)— sends the correctly-generated nameUpdateCreatureParentLinkingSort(...)The
elsebranch (addCreature == false) now also receives the capturedalreadyExistingCreaturefor consistency.Pre-requisite for the visible effect
The pattern is only applied when one of the auto-import settings is enabled (Settings → Auto Import):
Apply name pattern on auto-import: always(applyNamePatternOnAutoImportAlways)Apply name pattern on auto-import: only for new creatures(applyNamePatternOnAutoImportForNewCreatures)Apply name pattern on auto-import: if creature has no name(applyNamePatternOnImportIfEmptyName)Mentioning this for reviewer convenience — without one of these enabled, the fix's effect won't be visible during manual testing.
Test plan
.\build.ps1— solution builds, 64/64 unit tests pass.applyNamePatternOnAutoImportAlways = true{gena}as first tokengen > 0→ in-game name now contains the correctgenaletter (B, C, D, ...) on the first shot, instead of always beingAgen = 1produced as expectedgen = 0/gena = Aas expectedRelated ideas (not in this PR, gauging interest)
Two ideas surfaced while debugging — sharing briefly in case they're of interest. Happy to open dedicated discussions before any implementation:
Opt-in auto bulk-rename when a species' top stat flips. Trigger a recalc + best-effort push of all in-game names for the affected species, with graceful fallback to a "pending rename" flag for cryopodded / offline creatures (the Export Gun mod can't reach a creature without an AActor reference).
Automatic server-rate retrieval via the Export Gun mod. The mod already supports a
ServerHashpayload — if it could push the current server multipliers (taming/breeding/XP/etc.) automatically on connect or hash change, players would get accurate stat extractions without having to ask the admin. Scope: only the rates the engine needs; naming pattern stays a per-user choice.Happy to address review feedback or split this PR if preferred.
Disclaimer
First time contributing to ARK Smart Breeding — happy to align this PR with any project conventions (commit style, branching, formatting) if something doesn't match your usual workflow, and to lend a hand elsewhere if useful.