Skip to content

Commit f0811a6

Browse files
authored
Merge pull request #82242 from sparr/dedupe_zone_data_constructors
2 parents 7b8566b + 1eada74 commit f0811a6

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/clzones.h

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ class zone_data
383383

384384
zone_data( const std::string &_name, const zone_type_id &_type, const faction_id &_faction,
385385
bool _invert, const bool _enabled,
386-
const tripoint_abs_ms &_start, const tripoint_abs_ms &_end,
387386
const shared_ptr_fast<zone_options> &_options = nullptr,
388387
bool _is_displayed = false ) {
389388
name = _name;
@@ -392,9 +391,6 @@ class zone_data
392391
invert = _invert;
393392
enabled = _enabled;
394393
is_vehicle = false;
395-
is_personal = false;
396-
start = _start;
397-
end = _end;
398394
is_displayed = _is_displayed;
399395

400396
// ensure that supplied options is of correct class
@@ -405,28 +401,26 @@ class zone_data
405401
}
406402
}
407403

404+
zone_data( const std::string &_name, const zone_type_id &_type, const faction_id &_faction,
405+
bool _invert, const bool _enabled,
406+
const tripoint_abs_ms &_start, const tripoint_abs_ms &_end,
407+
const shared_ptr_fast<zone_options> &_options = nullptr,
408+
bool _is_displayed = false )
409+
: zone_data( _name, _type, _faction, _invert, _enabled, _options, _is_displayed ) {
410+
is_personal = false;
411+
start = _start;
412+
end = _end;
413+
}
414+
408415
zone_data( const std::string &_name, const zone_type_id &_type, const faction_id &_faction,
409416
bool _invert, const bool _enabled,
410417
const tripoint_rel_ms &_start, const tripoint_rel_ms &_end,
411418
const shared_ptr_fast<zone_options> &_options = nullptr,
412-
bool _is_displayed = false ) {
413-
name = _name;
414-
type = _type;
415-
faction = _faction;
416-
invert = _invert;
417-
enabled = _enabled;
418-
is_vehicle = false;
419+
bool _is_displayed = false )
420+
: zone_data( _name, _type, _faction, _invert, _enabled, _options, _is_displayed ) {
419421
is_personal = true;
420422
personal_start = _start;
421423
personal_end = _end;
422-
is_displayed = _is_displayed;
423-
424-
// ensure that supplied options is of correct class
425-
if( _options == nullptr || !zone_options::is_valid( type, *_options ) ) {
426-
options = zone_options::create( type );
427-
} else {
428-
options = _options;
429-
}
430424
}
431425

432426
// returns true if name is changed

0 commit comments

Comments
 (0)