Code:
typedef enum {head, left_arm, right_arm, centre_torso, left_torso, right_torso, left_leg, right_leg} body_location;
struct installed_part {
int item_id;
int damage;
body_location location;
int start_slot_number;
// possibly include the stop_slot_number, but you can determine this by looking up the item_id
};
typedef std::vector<installed_part> mech_parts;
struct item_details;
// contains item details, like what kind of item, its size, and possibly a reference to
// another table (ie, rather than having all parts carry all of the weapon details, have an
// optional weapon_id int in this structure)
typedef std::map<item_id, item_detail*> mech_part_registry;
// maps item_ids to item_datail*s.
struct global_mech_spec_data;
// contains all the things, like mech_part_registry, or mech_weapon_registry,
// that are needed to understand what id's mean. Could be
// a global variable, but globals are evil.
bool verify_valid_mech_part_layout(const mech_parts& parts, global_mech_spec_data const& global_data);
// makes sure the parts don't overlap
// returns false if the constructor of the mech cheated
// returns true if the mech can be layed out like that.
struct mech_armor;
// a struct describing the state of a mech's armor.
struct mech_base_specs;
// a struct describing the non-part specific parts of a mech's design:
// engine size, total weight, options like quad, etc.
struct total_mech;
// contains mech_base_specs, mech_armor and mech_parts
bool verify_mech(const total_mech& mech, global_mech_spec_data const& global_data);
// returns true if and only if the mech is a valid mech.
// Checks weight restrictions, slot alloitments, etc.
That would work. No wasted empty arrays. Doing crit hits would be somewhat annoying.
Quad mech support would require extra parameters to verify_valid_mech_part_layout.