Skip to content

Commit

Permalink
Fix save/load of avatar-specific variables
Browse files Browse the repository at this point in the history
 - Move avatar-specific savegame code to `avatar::store()` and `avatar::load()`.
   (This code was left behind when migrating from player.)
 - Make several variables in player protected to allow access from `avatar::store()` and
   `avatar::load()`.  This is just a temporary fix until these variables are migrated
   to the avatar class.
 - Do some reorganization of savegame_json.cpp to make it easier to understand the
   hierarchy of functions.
  • Loading branch information
ifreund authored and kevingranade committed May 23, 2019
1 parent 093c7ea commit ed96404
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 164 deletions.
22 changes: 22 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1873,8 +1873,12 @@ class player : public Character
private:
friend class debug_menu::mission_debug;

protected:
// TODO: move this to avatar
// Items the player has identified.
std::unordered_set<std::string> items_identified;
private:

/** Check if an area-of-effect technique has valid targets */
bool valid_aoe_technique( Creature &t, const ma_technique &technique );
bool valid_aoe_technique( Creature &t, const ma_technique &technique,
Expand Down Expand Up @@ -1940,7 +1944,10 @@ class player : public Character

int pkill;

protected:
// TODO: move this to avatar
std::string move_mode;
private:

std::vector<tripoint> auto_move_route;
player_activity destination_activity;
Expand All @@ -1953,14 +1960,23 @@ class player : public Character
time_point cached_time;
tripoint cached_position;

protected:
// TODO: move this to avatar
object_type grab_type;
private:

struct weighted_int_list<std::string> melee_miss_reasons;

protected:
// TODO: move this to avatar
pimpl<player_morale> morale;
private:

int id; // A unique ID number, assigned by the game class private so it cannot be overwritten and cause save game corruptions.
//NPCs also use this ID value. Values should never be reused.

protected:
// TODO: move these to avatar
/**
* Missions that the player has accepted and that are not finished (one
* way or the other).
Expand All @@ -1978,10 +1994,13 @@ class player : public Character
* The currently active mission, or null if no mission is currently in progress.
*/
mission *active_mission;
private:

/** smart pointer to targeting data stored for aiming the player's weapon across turns. */
std::shared_ptr<targeting_data> tdata;

protected:
// TODO: move these to avatar
/** Current deficiency/excess quantity for each vitamin */
std::map<vitamin_id, int> vitamin_levels;

Expand All @@ -1990,10 +2009,13 @@ class player : public Character

/** Stamp of skills. @ref learned_recipes are valid only with this set of skills. */
mutable decltype( _skills ) valid_autolearn_skills;
private:

/** Amount of time the player has spent in each overmap tile. */
std::unordered_map<point, time_duration> overmap_time;

protected:
// TODO: move these to avatar
map_memory player_map_memory;
bool show_map_memory;
};
Expand Down
Loading

0 comments on commit ed96404

Please sign in to comment.