Skip to content

Store the support rearm pool sparsely - #7758

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

Store the support rearm pool sparsely#7758
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:refactor/rearm_weapon_pool

Conversation

@Goober5000

@Goober5000 Goober5000 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

support_ship_info::rearm_weapon_pool was a dense per-weapon-class array where -1 = unlimited (the default), 0 = not rearmable, and >0 = remaining stockpile. Convert it to a sparse per-team map:

std::array<SCP_map<int, int>, MAX_TVT_TEAMS> rearm_weapon_pool;
int rearm_pool_default() const; // -1, or 0 under rearm_pool_from_loadout

Mission-file format and save output are unchanged. Also tightens the two weapon-class bounds checks in ship.cpp. This removes another MAX_WEAPON_TYPES sized structure on the way to lifting the weapon class limit.

In draft as it depends on #7757.

@Goober5000 Goober5000 added this to the Release 27.0 milestone Aug 31, 2026
@Goober5000 Goober5000 added the refactor A cleanup/restructure of a feature for speed, simplicity, and/or maintainability label Aug 31, 2026
@Goober5000
Goober5000 force-pushed the refactor/rearm_weapon_pool branch from 1de072a to 22dcf1f Compare August 31, 2026 03:47
@Goober5000
Goober5000 marked this pull request as ready for review August 31, 2026 03:48
@Goober5000
Goober5000 force-pushed the refactor/rearm_weapon_pool branch from 22dcf1f to a946337 Compare August 31, 2026 04:00
`support_ship_info::rearm_weapon_pool` was a dense per-weapon-class array where -1 = unlimited (the default), 0 = not rearmable, and >0 = remaining stockpile.  Convert it to a sparse per-team map:

  `std::array<SCP_map<int, int>, MAX_TVT_TEAMS> rearm_weapon_pool;`
  `int rearm_pool_default() const;  // -1, or 0 under rearm_pool_from_loadout`

Mission-file format and save output are unchanged.  Also tightens the two weapon-class bounds checks in ship.cpp.  This removes another `MAX_WEAPON_TYPES` sized structure on the way to lifting the weapon class limit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Goober5000
Goober5000 force-pushed the refactor/rearm_weapon_pool branch from a946337 to 4e4929d Compare September 2, 2026 03:16

@wookieejedi wookieejedi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated changes now look good, thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants