From 4153aa80a94de6a13399780542808f1cf9fc84e9 Mon Sep 17 00:00:00 2001 From: z64555 Date: Tue, 31 Jan 2017 12:04:32 -0600 Subject: [PATCH] Harmony to 1163's malady * Looks like a shallow copy wasn't enough, so this fix creates ship_weapons::clear() which is called by ship_weapons's constructor and by ship::clear(). --- code/ship/ship.cpp | 8 ++++++-- code/ship/ship.h | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) 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(); }; //**************************************************************