Skip to content

refactor loadout pools for vectorized ship and weapon classes - #7679

Open
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:refactor/loadout_pools
Open

refactor loadout pools for vectorized ship and weapon classes#7679
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:refactor/loadout_pools

Conversation

@Goober5000

@Goober5000 Goober5000 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Convert ship/weapon loadout pools from naive per-class arrays to ordered maps that list loadout entries. Each entry represents a ship/weapon class and its count. An absent entry means the class is not in this mission's loadout. Since these are ordered maps, iteration of the map keys occurs in the same sequence as iteration of Ship_info or Weapon_info.

Includes several bugfixes:

  • csg_read_loadout now clears both pools before reading. Previously the pools were only zeroed in mission_campaign_init
  • restore_wss_data: non-transmitted classes are now absent rather than memset to 0
  • a copy-paste bug where the weapon pool entries were bounds-checked against MAX_SHIP_CLASSES
  • wss_maybe_restore_loadout: the pool write-back now preserves loadout membership instead of writing a count for every class
  • ss_dump_to_list/ss_swap_list_slot: returning a slot ship whose class is not in the pool now makes it available instead of silently losing it. Unreachable in retail but reachable via script
  • off-by-one errors in the Lua Ship_Pool/Weapon_Pool indexers

Another step toward dynamic ship limits. Depends on #7672; in draft until that is merged.

@Goober5000 Goober5000 added refactor A cleanup/restructure of a feature for speed, simplicity, and/or maintainability Requested by Active Mod A feature request that has been requested by a mod that is actively in development. labels Aug 2, 2026
Convert ship/weapon loadout pools from naive per-class arrays to ordered maps that list loadout entries.  Each entry represents a ship/weapon class and its count.  An absent entry means the class is not in this mission's loadout.  Since these are ordered maps, iteration of the map keys occurs in the same sequence as iteration of `Ship_info` or `Weapon_info`.

Includes several bugfixes:
- `csg_read_loadout` now clears both pools before reading.  Previously the pools were only zeroed in `mission_campaign_init`
- `restore_wss_data`: non-transmitted classes are now absent rather than memset to 0
- a copy-paste bug where the weapon pool entries were bounds-checked against MAX_SHIP_CLASSES
- `wss_maybe_restore_loadout`: the pool write-back now preserves loadout membership instead of writing a count for every class
- `ss_dump_to_list`/`ss_swap_list_slot`: returning a slot ship whose class is not in the pool now makes it available instead of silently losing it.  Unreachable in retail but reachable via script
- off-by-one errors in the Lua `Ship_Pool`/`Weapon_Pool` indexers

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Goober5000
Goober5000 force-pushed the refactor/loadout_pools branch from 3d7131d to 77186c7 Compare August 3, 2026 05:28
@Goober5000
Goober5000 marked this pull request as ready for review August 3, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor A cleanup/restructure of a feature for speed, simplicity, and/or maintainability Requested by Active Mod A feature request that has been requested by a mod that is actively in development.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant