diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index 452cdd6374..e62c4af156 100644 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -5821,7 +5821,7 @@ void ship::clear() target_shields_delta = 0.0f; target_weapon_energy_delta = 0.0f; - weapons = ship_weapon(); + weapons.clear(); // ---------- special weapons init that isn't setting things to 0 for (i = 0; i < MAX_SHIP_PRIMARY_BANKS; i++) @@ -5993,7 +5993,7 @@ void ship::clear() autoaim_fov = 0.0f; } -ship_weapon::ship_weapon() +void ship_weapon::clear() { flags.reset(); @@ -6076,6 +6076,10 @@ ship_weapon::ship_weapon() last_fired_weapon_signature = -1; } +ship_weapon::ship_weapon() { + clear(); +} + // NOTE: Now that the clear() member function exists, this function only sets the stuff associated with the object and ship class. void ship_set(int ship_index, int objnum, int ship_type) { diff --git a/code/ship/ship.h b/code/ship/ship.h index bae34b1c7e..c60a67b078 100644 --- a/code/ship/ship.h +++ b/code/ship/ship.h @@ -158,7 +158,15 @@ public: size_t primary_bank_pattern_index[MAX_SHIP_PRIMARY_BANKS]; size_t secondary_bank_pattern_index[MAX_SHIP_SECONDARY_BANKS]; + /** + * @brief Constructor. Calls clear() + */ ship_weapon(); + + /** + * @brief Inits ship_weapon + */ + void clear(); }; //**************************************************************