Use NSDMI for zero-initialized Mission members
Prefer non-static data member initializers over leaving the member undefined in the constructor and relying on the caller to zero the member afterward.
This commit is contained in:
parent
da39846514
commit
397d582031
|
@ -152,30 +152,17 @@ struct Mission : Mission_path
|
|||
std::unique_ptr<d_fname[]> secret_level_names;
|
||||
int builtin_hogsize; // the size of the hogfile for a builtin mission, and 0 for an add-on mission
|
||||
ntstring<MISSION_NAME_LEN> mission_name;
|
||||
d_fname briefing_text_filename; // name of briefing file
|
||||
d_fname ending_text_filename; // name of ending file
|
||||
d_fname briefing_text_filename{}; // name of briefing file
|
||||
d_fname ending_text_filename{}; // name of ending file
|
||||
anarchy_only_level anarchy_only_flag; // if true, mission is only for anarchy
|
||||
ubyte last_level;
|
||||
sbyte last_secret_level;
|
||||
ubyte n_secret_levels;
|
||||
uint8_t last_level{};
|
||||
int8_t last_secret_level{};
|
||||
uint8_t n_secret_levels{};
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
descent_version_type descent_version; // descent 1 or descent 2?
|
||||
std::unique_ptr<d_fname> alternate_ham_file;
|
||||
std::unique_ptr<LoadedMovieWithResolution> extra_robot_movie;
|
||||
#endif
|
||||
/* Explicitly default move constructor and move operator=
|
||||
*
|
||||
* Without this, gcc (tested gcc-4.9, gcc-5) tries to use
|
||||
* a synthetic operator=(const Mission &) to implement `instance =
|
||||
* {};`, which fails because Mission contains std::unique_ptr, a
|
||||
* movable but noncopyable type.
|
||||
*
|
||||
* With the explicit default, gcc uses operator=(Mission &&), which
|
||||
* works.
|
||||
*
|
||||
* Explicitly delete copy constructor and copy operator= for
|
||||
* thoroughness.
|
||||
*/
|
||||
Mission(Mission &&) = default;
|
||||
Mission &operator=(Mission &&) = default;
|
||||
Mission(const Mission &) = delete;
|
||||
|
|
|
@ -914,19 +914,6 @@ static const char *load_mission(const mle *const mission)
|
|||
Current_mission->descent_version = mission->descent_version;
|
||||
#endif
|
||||
Current_mission->anarchy_only_flag = mission->anarchy_only_flag;
|
||||
Current_mission->n_secret_levels = 0;
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
Current_mission->alternate_ham_file = NULL;
|
||||
#endif
|
||||
|
||||
//init vars
|
||||
Current_mission->last_level = 0;
|
||||
Current_mission->last_secret_level = 0;
|
||||
Current_mission->briefing_text_filename = {};
|
||||
Current_mission->ending_text_filename = {};
|
||||
Current_mission->secret_level_table.reset();
|
||||
Current_mission->level_names.reset();
|
||||
Current_mission->secret_level_names.reset();
|
||||
|
||||
// for Descent 1 missions, load descent.hog
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
|
|
Loading…
Reference in a new issue