Skip to content

Gear Template Profile Filter

rayswaynl edited this page Jun 28, 2026 · 17 revisions

Gear Template Profile Filter

This page documents two profile-template persistence bugs in the buy-gear system: the save filter's undefined upgrade variable, and the load/import guard that accepts six-field rows before reading backpack data. It is a focused implementation note for the rows in Feature status and the gear atlas.

All mission paths are relative to Missions/[55-2hc]warfarev2_073v48co.chernarus/.

Current Flow

flowchart TD
    InitClient["Client/Init/Init_Client.sqf"] --> CompileGear["Compile gear UI helpers"]
    InitClient --> ProfileGate["OA version gate compiles SaveTemplateProfile"]
    ProfileVars["Client/Init/Init_ProfileVariables.sqf"] --> ProfileGear["Client/Init/Init_ProfileGear.sqf"]
    ProfileGear --> MissionTemplates["WFBE_%SIDE_Template in missionNamespace"]
    BuyGear["GUI_BuyGearMenu.sqf"] --> AddTemplate["Client_UI_Gear_AddTemplate.sqf"]
    AddTemplate --> MissionTemplates
    BuyGear --> SaveNeeded["_need_save when template changes"]
    SaveNeeded --> SaveProfile["Client_UI_Gear_SaveTemplateProfile.sqf"]
    SaveProfile --> ProfileNamespace["profileNamespace WFBE_PERSISTENT_%SIDE_GEAR_TEMPLATE"]
Loading

Source Evidence

Source Evidence
Client/Init/Init_Client.sqf:165-175 Compiles gear UI helpers including add/delete/fill/template functions.
Client/Init/Init_Client.sqf:224-227 Under the OA version gate, compiles WFBE_CL_FNC_UI_Gear_SaveTemplateProfile and runs profile variable loading.
Client/Init/Init_ProfileVariables.sqf:37-42 Reads WFBE_PERSISTENT_%SIDE_GEAR_TEMPLATE from profileNamespace and validates through Init_ProfileGear.sqf.
Client/Init/Init_ProfileGear.sqf:17,25 Accepts stored rows with count _x >= 6, then reads _x select 6 as backpack data.
Client/Init/Init_ProfileGear.sqf:25-136 Re-validates stored profile templates for shape, side membership, price and max upgrade before replacing mission templates.
Client/Functions/Client_UI_Gear_AddTemplate.sqf:15,37,83,110,136-148 Builds _u_upgrade as the maximum required upgrade in the new template, then appends the template and sets _need_save = true.
Client/GUI/GUI_BuyGearMenu.sqf:524 Spawns WFBE_CL_FNC_UI_Gear_SaveTemplateProfile after the dialog closes when _need_save is true.
Client/Functions/Client_UI_Gear_SaveTemplateProfile.sqf:17-19 Privates and sets _template_upgrade = _x select 3.
Current docs/source Client/Functions/Client_UI_Gear_SaveTemplateProfile.sqf:33,52,75 Still uses undefined _u_upgrade in the three per-item upgrade checks. Current stable/B74.1 origin/master@f8a76de34 / origin/claude/b74.1-aicom@f8a76de34, current B74.2 origin/claude/b74.2-aicom@21b62b04, B69 origin/claude/b69@8d465fce and adjacent B74 origin/claude/b74-aicom-spend@b23f557f fix this in both maintained roots at :34,57,82 by comparing (_get select 3) against both upgrade lanes.
Client/Functions/Client_UI_Gear_SaveTemplateProfile.sqf:94-95 Writes the filtered array to profileNamespace and calls saveProfileNamespace.
Client/Functions/Client_UI_Gear_FillTemplates.sqf:15-22 The visible template list only adds templates whose stored upgrade level is at or below current WFBE_UP_GEAR.

Current Branch Matrix

Root / branch Save filter Profile import guard Practical meaning
Current docs/source Chernarus docs/developer-wiki-index@4b9591314c96 Source-unchanged from 72b5f0de98f9 and the 2026-06-21 43c3ba05 proof for checked template paths; Client_UI_Gear_SaveTemplateProfile.sqf:33,52,75 still reference undefined _u_upgrade. Init_ProfileGear.sqf:17 accepts count _x >= 6, then :25 reads _x select 6. Patch-ready in the docs/source target.
Maintained Vanilla Takistan docs/developer-wiki-index@4b9591314c96 Same save-filter _u_upgrade references. Same six-field guard before index-6 read. Propagate deliberately after Chernarus source fix.
Current stable/B74.1 origin/master@f8a76de34 / origin/claude/b74.1-aicom@f8a76de34, current B74.2 origin/claude/b74.2-aicom@21b62b04, B69 origin/claude/b69@8d465fce and adjacent B74 origin/claude/b74-aicom-spend@b23f557f Save-filter _u_upgrade bug fixed in both maintained roots (task 44): Client_UI_Gear_SaveTemplateProfile.sqf:34,57,82 use (_get select 3) directly. Only comments mention the old _u_upgrade shape. Checked diffs 0139a3468609..origin/master, origin/master..origin/claude/b74.2-aicom, d472da6a..origin/claude/b74.2-aicom and B69..B74 are empty for the maintained-root template paths. Same six-field guard/index-6 read at Init_ProfileGear.sqf:17,25 in both maintained roots. Source-present for the save-filter fix; B74.1/B74.2 do not rescue import-bound or template-policy work.
Current Miksuu master@b8389e748243, origin/perf/quick-wins@0076040f8a5e, historical release commit a96fdda28087, historical EASA QoL commit a66d46912e2a and old upstream miksuu/Gear_template_error@5b056013 Old save-filter _u_upgrade references remain at Client_UI_Gear_SaveTemplateProfile.sqf:33,52,75. Miksuu master/perf/release/EASA QoL carry the old shape in both maintained roots; miksuu/Gear_template_error carries it in source Chernarus and has no maintained Vanilla template payload. Same six-field guard before index-6 read on refs with the checked profile helper. No old-ref rescue exists. miksuu/Gear_template_error only adds a Chernarus GUI_BuyGearMenu.sqf nil guard around template selection; live origin exposes no release/*, profile or template rescue head and only has Trello buy-menu gear-display / EASA category branches with no checked template-path delta.

Creation Gate Branch Matrix

Refreshed 2026-06-24 for docs checkout 4b9591314c96 (source-unchanged from 72b5f0de98f9 and the 2026-06-21 43c3ba05 proof for checked template paths), current stable/B74.1 origin/master@f8a76de34 / origin/claude/b74.1-aicom@f8a76de34, previous B74.2 origin/claude/b74.2-aicom@d472da6a, current B74.2 origin/claude/b74.2-aicom@21b62b04, current B69 origin/claude/b69@8d465fce, adjacent B74 origin/claude/b74-aicom-spend@b23f557f, current upstream Miksuu master@b8389e748243, origin/perf/quick-wins@0076040f8a5e, historical release commit a96fdda28087, historical EASA QoL commit a66d46912e2a and old upstream miksuu/Gear_template_error@5b056013. Checked d472da6a..21b62b04, origin/master..origin/claude/b74.2-aicom and B69..B74 template-path deltas are empty. Current origin exposes only Trello buy-menu gear-display and EASA category heads for this family on 2026-06-24, and neither has a checked template-path delta.

Scope Add-template gate Fill/save contrast Practical meaning
Docs/source Chernarus + maintained Vanilla Client_UI_Gear_AddTemplate.sqf:15,37,83,110 computes _u_upgrade, then :136 accepts a new template when _u_upgrade <= WFBE_UP_BARRACKS or _u_upgrade <= WFBE_UP_GEAR. Client_UI_Gear_FillTemplates.sqf:17 displays templates only when stored upgrade <= WFBE_UP_GEAR; Client_UI_Gear_SaveTemplateProfile.sqf:33,52,75 still tries to filter with undefined _u_upgrade. Owner-decision consistency debt: choose whether templates are unlocked by either Barracks/Gear lane or Gear-only display should be changed.
Current stable/B74.1 origin/master@f8a76de34, current B74.2 origin/claude/b74.2-aicom@21b62b04, B69 origin/claude/b69@8d465fce and adjacent B74 origin/claude/b74-aicom-spend@b23f557f Same OR gate in both maintained roots. Same Gear-only fill in both maintained roots; save-filter _u_upgrade is fixed at Client_UI_Gear_SaveTemplateProfile.sqf:34,57,82, but the import guard remains old-shape. d472da6a..21b62b04 is empty for checked template paths. Stable/B74.1/B74.2/B69/B74 rescue the local save-filter bug, not the creation/display policy or import-bound issue.
Current upstream Miksuu master@b8389e748243 Same OR gate in both maintained roots. Same Gear-only fill and undefined save-filter shape in both maintained roots. No upstream rescue found.
origin/perf/quick-wins@0076040f8a5e Same OR gate in both maintained roots. Same Gear-only fill and undefined save-filter shape in both maintained roots. Perf branch does not touch gear-template semantics.
Historical release commit a96fdda28087 Same OR gate in both maintained roots. Same Gear-only fill and undefined save-filter shape in both maintained roots. Historical release evidence only until a live release head is restored or rechecked.
Historical EASA QoL commit a66d46912e2a and old upstream miksuu/Gear_template_error@5b056013 Same OR gate where the checked template helper exists. Historical EASA QoL keeps Gear-only fill and undefined save-filter shape in both maintained roots; miksuu/Gear_template_error keeps the same old Chernarus template helper shape and changes only GUI_BuyGearMenu.sqf. Neither branch changes profile-template semantics.

Bug Shape

Client_UI_Gear_SaveTemplateProfile.sqf intends to filter templates so only side-valid and currently unlocked items are saved to the player's profile. The function has a correctly named _template_upgrade value, but the original three per-item upgrade checks referenced _u_upgrade instead (pre-fix shape):

if ((_get select 3) > _upgrade_barracks && _u_upgrade > _upgrade_gear) then {_can_save = false};

_u_upgrade exists in Client_UI_Gear_AddTemplate.sqf, where it is the computed max upgrade for a newly created template. It does not exist in Client_UI_Gear_SaveTemplateProfile.sqf. This bug is still present on the current docs/source branch, Miksuu, perf, historical release, historical EASA QoL and old upstream miksuu/Gear_template_error refs. It is already fixed on current stable/B74.1 origin/master@f8a76de34, current B74.2 origin/claude/b74.2-aicom@21b62b04, B69 origin/claude/b69@8d465fce and adjacent B74 origin/claude/b74-aicom-spend@b23f557f in both maintained roots: all three loops (weapon, magazine, backpack-content) now use (_get select 3) on both sides of the AND, matching the corrected form shown in the Patch Options section below. The B74.2 head advance from d472da6a to 21b62b04 did not touch the checked template paths.

Separate creation-gate nuance: Client_UI_Gear_AddTemplate.sqf:135-136 accepts a new template when the computed requirement is below either current Barracks upgrade or current Gear upgrade:

if (_u_upgrade <= (_upgrades select WFBE_UP_BARRACKS) || _u_upgrade <= (_upgrades select WFBE_UP_GEAR)) then {

That may be intentional because some infantry equipment gates are Barracks-led while others are Gear-led. It still needs owner confirmation before profile/template cleanup: Client_UI_Gear_FillTemplates.sqf:15-22 later hides visible templates above current WFBE_UP_GEAR only. On old-shape refs, Client_UI_Gear_SaveTemplateProfile.sqf also has the undefined _u_upgrade filter bug; on current stable/B69/B74 that save filter is fixed but still follows the same broad Barracks-or-Gear policy. If the intended rule is "unlocked by either relevant tech lane," keep the OR and document which item classes use which lane. If the intended rule is "both infantry tech and gear tech must support it," change AddTemplate, FillTemplates and SaveTemplateProfile together.

Practical impact:

  • On docs/source and old-shape refs, the save pass can hit an undefined-variable script error when a template item's upgrade exceeds the current barracks upgrade and the expression evaluates the second operand.
  • On docs/source and old-shape refs, saved-template upgrade filtering cannot be trusted as written because the intended second comparison reads the wrong variable.
  • Init_ProfileGear.sqf still validates profile templates on load, so this is mainly a persistence/filter correctness bug, not proof that the live buy-gear UI lets locked gear equip by itself.
  • Client_UI_Gear_FillTemplates.sqf intentionally hides templates above the current gear upgrade instead of showing them as locked. This can make valid saved templates look missing until the side upgrades gear again.
  • The broader gear/EASA/service authority issue remains separate: purchases and effects are still client-authoritative legacy flows, covered by Server authority migration map and Gear/loadout/EASA atlas.

Patch Options

Option Shape Tradeoff
Use item upgrade directly Replace _u_upgrade > _upgrade_gear with (_get select 3) > _upgrade_gear in all three checks. Most local and easiest to reason about: reject each item if its own upgrade exceeds both barracks and gear.
Use template max upgrade Replace _u_upgrade with _template_upgrade. Matches the already-read template field, but rejects based on the template max when checking each item. This is close to AddTemplate behavior.
Recompute local max Initialize _u_upgrade = _template_upgrade or recompute max before per-item checks. More churn than needed unless the owner wants to normalize stale profile data during save.

Recommended first patch for docs/source or old-shape refs:

if ((_get select 3) > _upgrade_barracks && (_get select 3) > _upgrade_gear) then {_can_save = false};

Apply that replacement at the weapon, magazine and backpack-content checks. Keep Init_ProfileGear.sqf load validation unchanged unless a smoke test proves it filters too aggressively or too loosely.

Import Bounds Paired Fix

Client/Init/Init_ProfileGear.sqf has a separate profile-load compatibility bug. It accepts any stored template row with at least six fields, then reads field 6 as backpack data:

if (count _x >= 6) then {
    ...
    _magazines = _x select 5;
    _backpack = _x select 6;

Arrays are zero-indexed, so a six-field legacy row has valid indexes 0..5; reading index 6 is one past the end. Maintained Vanilla Takistan carries the same :17/:25 shape. Patch this in the same profile-template pass as the save filter, but keep the behavior choice explicit:

Option Shape Tradeoff
Require current seven-field rows Change the guard to if (count _x >= 7) then { ... }. Smallest correctness patch; drops old six-field rows instead of trying to repair them.
Preserve legacy six-field rows If count _x == 6, inject _backpack = [] or normalize the row before validation. More compatible for old profiles, but needs smoke for both old and current row shapes.

Validation for this paired fix:

  1. Init_ProfileGear.sqf never reads _x select 6 unless the row has at least seven fields, or it intentionally supplies an empty backpack default for six-field rows.
  2. Current seven-field templates still load and recalculate price/upgrade fields.
  3. Old six-field profile rows either fail closed without an RPT out-of-range error or load with an explicit empty backpack default.
  4. Maintained Vanilla receives the same profile-load fix after propagation.

Validation Plan

Source checks:

  1. Client_UI_Gear_SaveTemplateProfile.sqf has no live _u_upgrade comparison, except comments documenting the old shape if retained.
  2. The function still writes WFBE_PERSISTENT_%SIDE_GEAR_TEMPLATE.
  3. Client_UI_Gear_AddTemplate.sqf still computes and stores template max upgrade in field 3.
  4. Init_ProfileGear.sqf still recalculates stored profile price and max upgrade on load.
  5. Init_ProfileGear.sqf no longer accepts six-field rows and then reads index 6 without a compatibility default.
  6. AddTemplate, FillTemplates and SaveTemplateProfile all use the same intended Barracks/Gear lane rule after the owner decision.

Arma smoke:

  1. Create a gear template with currently allowed gear; close the menu and confirm it persists after restart/rejoin.
  2. Try to save a template containing gear above both barracks and gear upgrade levels; confirm it is not written and no RPT undefined-variable error appears.
  3. Upgrade barracks/gear and confirm the same template becomes saveable when the relevant level is unlocked.
  4. Confirm templates still disappear from the visible list when Client_UI_Gear_FillTemplates.sqf filters them above current WFBE_UP_GEAR.
  5. Decide whether hidden higher-upgrade templates should remain invisible or appear as locked rows so players understand they were not deleted.

Generated mission:

  • Patch source Chernarus first.
  • Propagate Vanilla Takistan with Tools/LoadoutManager from a checkout whose ancestor folder is literally named a2waspwarfare.
  • Do not hand-edit divergent/stubbed Modded_Missions unless the owner picks a maintenance model.

Agent Notes

  • This is a correctness and persistence bug in profile-template filtering.
  • The import-bound issue is a paired profile persistence bug, not proof that live gear purchase authority is hardened or broken in a new way.
  • It is not the same as full gear purchase authority. Do not claim public-server gear hardening after this patch.
  • Keep this page paired with Gear/loadout/EASA atlas, Client UI systems atlas and Feature status.
  • Branch check 2026-06-24 keeps the split from the 2026-06-21 proof and refreshes current B74.2 evidence: docs/source checkout 4b9591314c96 is source-unchanged from 72b5f0de98f9 and 43c3ba05 for checked template paths and still keeps undefined _u_upgrade plus the six-field import guard in both maintained roots. Current stable/B74.1 origin/master@f8a76de34, current B74.2 origin/claude/b74.2-aicom@21b62b04, B69 origin/claude/b69@8d465fce and adjacent B74 origin/claude/b74-aicom-spend@b23f557f fix the save-filter comparisons at Client_UI_Gear_SaveTemplateProfile.sqf:34,57,82 but still keep the six-field import guard and Barracks-or-Gear creation versus Gear-only display policy. Checked d472da6a..21b62b04, origin/master..origin/claude/b74.2-aicom and B69..B74 template deltas are empty. Current Miksuu master@b8389e748243, perf 0076040f8a5e, historical release a96fdda28087, historical EASA QoL a66d46912e2a and old upstream miksuu/Gear_template_error@5b056013 keep the old save-filter shape where the helper exists; miksuu/Gear_template_error is adjacent Chernarus-only buy-gear selection-guard evidence, not profile-template persistence closure.

Continue Reading

Previous: Gear/loadout/EASA atlas | Next: UI IDD collision repair

Main map: Home | Agent file: agent-feature-status.jsonl | Backlog: agent-hardening-backlog.jsonl

Sidebar

Clone this wiki locally