copy constructor and swap() must copy status

Fix calref#710
This commit is contained in:
2025-04-05 16:53:05 -05:00
parent d89d149d5b
commit df0e3cd723
3 changed files with 12 additions and 0 deletions

View File

@@ -53,4 +53,13 @@ void iLiving::void_sanctuary() {
status[eStatus::INVISIBLE] = 0;
}
iLiving::iLiving() {}
iLiving::iLiving(const iLiving& other)
: status(other.status)
, ap(other.ap)
, direction(other.direction)
, marked_damage(other.marked_damage)
{}
void(* iLiving::print_result)(std::string) = nullptr;

View File

@@ -54,6 +54,8 @@ public:
virtual int get_level() const = 0;
virtual location get_loc() const = 0;
iLiving();
iLiving(const iLiving& other);
virtual ~iLiving() = default;
static void(* print_result)(std::string);

View File

@@ -1209,6 +1209,7 @@ void swap(cPlayer& lhs, cPlayer& rhs) {
using std::swap;
// Don't swap the party reference!
swap(lhs.main_status, rhs.main_status);
swap(lhs.status, rhs.status);
swap(lhs.name, rhs.name);
swap(lhs.skills, rhs.skills);
swap(lhs.max_health, rhs.max_health);