Skip to content

Commit

Permalink
refactor: Move temperature data to bodypart (#5557)
Browse files Browse the repository at this point in the history
* Move temperature data to bodypart

* Replace use of move ctor with operator= in Character

* Default bp temperature

* Convert temperature when loading old saves
  • Loading branch information
Coolthulhu authored Oct 19, 2024
1 parent 7fc34a4 commit 3469dd0
Show file tree
Hide file tree
Showing 15 changed files with 342 additions and 328 deletions.
6 changes: 6 additions & 0 deletions src/bodypart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ void bodypart::serialize( JsonOut &json ) const
json.member( "hp_max", hp_max );
json.member( "damage_bandaged", damage_bandaged );
json.member( "damage_disinfected", damage_disinfected );
json.member( "temp_cur", temp_cur );
json.member( "temp_conv", temp_conv );
json.member( "frostbite_timer", frostbite_timer );
json.end_object();
}

Expand All @@ -600,6 +603,9 @@ void bodypart::deserialize( JsonIn &jsin )
jo.read( "hp_max", hp_max, true );
jo.read( "damage_bandaged", damage_bandaged, true );
jo.read( "damage_disinfected", damage_disinfected, true );
jo.read( "temp_cur", temp_cur, true );
jo.read( "temp_conv", temp_conv, false );
jo.read( "frostbite_timer", frostbite_timer, true );
}

void bodypart::set_location( location<item> *loc )
Expand Down
26 changes: 26 additions & 0 deletions src/bodypart.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ class bodypart
int damage_bandaged = 0;
int damage_disinfected = 0;

// @todo BODYTEMP_NORM
int temp_cur = 5000;
int temp_conv = 5000;
int frostbite_timer = 0;

public:
// TODO: private
wield_status wielding;
Expand Down Expand Up @@ -223,6 +228,27 @@ class bodypart
void mod_damage_bandaged( int mod );
void mod_damage_disinfected( int mod );

int get_temp_cur() const {
return temp_cur;
}
void set_temp_cur( int set ) {
temp_cur = set;
}

int get_temp_conv() const {
return temp_conv;
}
void set_temp_conv( int set ) {
temp_conv = set;
}

int get_frostbite_timer() const {
return frostbite_timer;
}
void set_frostbite_timer( int set ) {
frostbite_timer = set;
}

void serialize( JsonOut &json ) const;
void deserialize( JsonIn &jsin );

Expand Down
Loading

0 comments on commit 3469dd0

Please sign in to comment.