Files
Goober5000andClaude Opus 4.7 a168f5a9c0 Store the support rearm pool sparsely (#7758)
`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) <[email protected]>
2026-09-08 10:50:22 -04:00

54 lines
1.6 KiB
C++

#pragma once
class CSupportRearmDlg : public CDialog {
public:
CSupportRearmDlg(CWnd* pParent = nullptr);
enum {
IDD = IDD_SUPPORT_REARM_OPTIONS
};
BOOL OnInitDialog() override;
void DoDataExchange(CDataExchange* pDX) override;
void OnOK() override;
protected:
afx_msg void OnSelchangeWeaponList();
afx_msg void OnSetPoolAmount();
afx_msg void OnSetPoolUnlimited();
afx_msg void OnSetPoolZero();
afx_msg void OnSetAllPoolAmount();
afx_msg void OnSetAllPoolUnlimited();
afx_msg void OnSetAllPoolZero();
afx_msg void OnSelchangePoolTeam();
afx_msg void OnOptionChanged();
afx_msg void OnRearmPoolFromLoadoutChanged();
afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
DECLARE_MESSAGE_MAP()
private:
void update_control_states();
void populate_team_list();
void populate_weapon_list();
void update_weapon_amount_display();
int get_selected_weapon_class() const;
void set_selected_weapon_amount(int amount);
void set_all_weapon_amount(int amount);
void set_weapon_pool_entry(int weapon_class, int amount);
CString format_weapon_pool_entry(int weapon_class) const;
int rearm_pool_default() const { return m_rearm_pool_from_loadout ? 0 : -1; }
BOOL m_disallow_support_ships;
BOOL m_limit_rearm_to_pool;
BOOL m_support_repairs_hull;
BOOL m_disallow_support_rearm;
BOOL m_allow_weapon_precedence;
BOOL m_rearm_pool_from_loadout;
float m_max_hull_repair_val;
float m_max_subsys_repair_val;
int m_weapon_pool_amount;
int m_rearm_pool_team;
// weapon class -> amount; absent = rearm_pool_default(), mirroring the mission struct
std::array<SCP_map<int, int>, MAX_TVT_TEAMS> m_rearm_weapon_pool;
};