Skip to content

Factory Queue Counter Token Cleanup

rayswaynl edited this page Jun 21, 2026 · 5 revisions

Factory Queue Counter Token Cleanup

Status: RESOLVED in origin/master (Chernarus). Both DR-33a (crewless-vehicle counter leak) and DR-33b (low-entropy FIFO token) are patched in the Chernarus master source. Line 168 uses varQueu = Format["%1_%2", getPlayerUID player, diag_tickTime] (high-entropy UID+tickTime token). Lines 446-453 decrement unitQueu and WFBE_C_QUEUE_<type> before the crewless-vehicle exit (Release fix #3). Vanilla Takistan propagation, public queu broadcast reduction and Arma smoke are still pending.

What To Read

Current Behavior

The buy menu increments WFBE_C_QUEUE_<type> before spawning BuildUnit. Client_BuildUnit.sqf adds the purchase to the building FIFO stored in public variable queu, waits for the token to reach the front, removes that token, builds the unit/vehicle, then decrements unitQueu and WFBE_C_QUEUE_<type> at the normal tail.

Two parts are fragile:

  • Client_BuildUnit.sqf:168-169 previously used a low-entropy random(10)+random(100)+random(1000) numeric token; master now uses varQueu = Format["%1_%2", getPlayerUID player, diag_tickTime]; _unique = varQueu; (DR-33b resolved in master Chernarus).
  • Client_BuildUnit.sqf:446 can hit if (!_driver && !_gunner && !_commander) exitWith {}; after the FIFO token is removed but before the normal tail decrement. Repeated crewless vehicle buys can leak the buyer's local WFBE_C_QUEUE_<type> counter and soft-lock that category.
  • Wave R added an extra-crew nuance: _extracrew is parsed earlier from the vehicle crew options, but the empty-vehicle exitWith checks only driver/gunner/commander. If a config/UI path can expose extra-turret-crew-only purchases, that branch exits before the extra crew creation block and before queue cleanup.

The source line check on 2026-06-02 still shows both issues in source Chernarus. Do not treat this lane as patched until Client_BuildUnit.sqf changes and LoadoutManager propagation are both verified.

Current Branch Matrix

Root / branch Queue-counter cleanup FIFO token cleanup Practical meaning
Current docs/source Chernarus Crewless-vehicle exit fix present at Client_BuildUnit.sqf:446-453; exit already decrements unitQueu and WFBE_C_QUEUE_<type> (DR-33a resolved). Normal tail decrement at :555-557. Token at :168 is now Format["%1_%2", getPlayerUID player, diag_tickTime] (UID + tick composite; DR-33b resolved). Both queue-counter and token fixes are present in current master Chernarus source.
Maintained Vanilla Takistan DR-33a crewless-exit fix is present at Client_BuildUnit.sqf:446-453 (unitQueu = unitQueu - _cpt; and the WFBE_C_QUEUE_<type> decrement inside the empty-vehicle exitWith). DR-33b patched token is present at :168-169 (varQueu = Format["%1_%2", getPlayerUID player, diag_tickTime];). Both patches are already applied in master Vanilla Takistan. No propagation gap from Chernarus.
Stable origin/master / Miksuu upstream Master is patched for DR-33a (crewless-exit counter release, :446-453) and DR-33b (UID+tickTime token, :168-169) in both Chernarus and Vanilla. UID+tickTime token at :168 replaces the old random(10)+random(100)+random(1000) in master. Master is ahead of current docs/source for this lane.
origin/perf/quick-wins Chernarus patches the crewless exit with the missing local queue decrement (Client_BuildUnit.sqf:365-368), but Vanilla remains unpatched. Token remains unchanged (:167-168). Useful patch candidate for DR-33a only; still needs Vanilla propagation and DR-33b token work.
origin/release/2026-06-feature-bundle Release Chernarus has the same class of crewless-exit cleanup plus a refund comment/path (Client_BuildUnit.sqf:366-370); release Vanilla remains unpatched. Token remains unchanged in Chernarus and Vanilla (:168-169 / :167-168). Treat release as partial Chernarus queue-counter cleanup, not the full factory queue/token fix.

This branch split is why the first implementation should stay small: port or reimplement the crewless counter decrement, replace the token, then propagate maintained Vanilla and smoke both together.

Suggested Patch Shape

Keep this patch local and narrow:

  1. Replace the low-entropy token with a monotonically increasing or otherwise per-client unique token.
  2. Add the same local cleanup used by the normal tail before the empty-vehicle exitWith.
  3. Decide whether extra-turret-crew-only purchases are valid. If they are valid, the empty-vehicle condition must include _extracrew so turret crew can still be created; if they are not valid, block that UI/config combination explicitly.
  4. Leave public setVariable ["queu", _queu, true] behavior alone in the first patch.

Example cleanup shape for the empty-vehicle exit:

if (!_driver && !_gunner && !_commander) exitWith {
    unitQueu = unitQueu - _cpt;
    missionNamespace setVariable [Format["WFBE_C_QUEUE_%1", _factory], (missionNamespace getVariable Format["WFBE_C_QUEUE_%1", _factory]) - 1];
};

Use exact local style after inspecting the surrounding code. Do not introduce a server-authority migration in the same patch.

If extra-turret-crew-only buys are intentionally supported, use the same cleanup idea but do not exit just because driver/gunner/commander are false; let the later extra-crew block run.

Why It Matters

This is a player-facing correctness fix with a small performance side benefit. A player can repeatedly buy crewless light/heavy/air vehicles and eventually hit the local queue cap even though nothing is queued. The token change removes a low-probability front-of-queue collision class without redesigning the factory producer.

This is not public-server hardening. Player purchases are still client-local and funds are still deducted client-side. Use Server authority migration map and Economy authority first cut before treating buy/build flows as hardened.

Remaining Opportunity

Client_BuildUnit.sqf still broadcasts the whole building queu array with setVariable ["queu", _queu, true] on enqueue, timeout cleanup and completion. That broadcast is still visible to the buy menu and queue hint behavior, so reducing it should be a separate UI-aware performance patch, not a silent removal.

Validation Needed

Source-only:

  • Source Chernarus no longer uses random(10)+random(100)+random(1000) in Client_BuildUnit.sqf.
  • Source Chernarus decrements unitQueu and WFBE_C_QUEUE_<type> before the crewless-vehicle exit.
  • Extra-turret-crew-only selection, if any valid UI/config exposes it, either produces turret crew or is explicitly rejected without leaking queue counters.
  • Vanilla Takistan propagation is produced by LoadoutManager from a correctly named a2waspwarfare checkout.
  • git diff --check remains clean.

Arma smoke:

  • Buy repeated crewless light/heavy vehicles and verify the queue cap does not soft-lock.
  • Buy crewed vehicles and infantry after crewless vehicles to verify normal production still decrements.
  • Queue multiple buyers at the same factory and verify FIFO order and queue hints still behave.
  • Destroy the factory mid-build and verify the existing factory-dead cleanup still decrements.
  • Test JIP/client reconnect behavior around a queued purchase if possible.

Handoff

Future owner: patch the local queue accounting/token identity first, then decide whether the public queu broadcast should be reduced, converted to local UI state, or moved into a broader server-owned purchase queue redesign.

Agent Index Facts

[
  {"fact":"factory_queue_master_chernarus_patched","source":"Client_BuildUnit.sqf:168 (token), 446-453 (crewless exit)","summary":"DR-33a and DR-33b are resolved in master Chernarus. Token at line 168 is now Format[\"%1_%2\", getPlayerUID player, diag_tickTime] (UID+tickTime); crewless exit at lines 446-453 decrements unitQueu and WFBE_C_QUEUE_<type> before exiting. Vanilla propagation status must be verified separately."},
  {"fact":"factory_queue_partial_branch_fixes","source":"origin/perf/quick-wins Client_BuildUnit.sqf:365-368; origin/release/2026-06-feature-bundle Client_BuildUnit.sqf:366-370","summary":"Perf quick-wins and release Chernarus patch the crewless queue-counter leak but leave the FIFO token unchanged and do not propagate maintained Vanilla."}
]

Continue Reading

Previous: Factory and purchase systems atlas | Next: Performance opportunity sweep

Main map: Home | Fast path: Feature status | Agent file: agent-context.json

Sidebar

Clone this wiki locally