CleverRaven/Cataclysm-DDA — pull request #8968 by BevapDin (2014-09-13 13:44:51+00:00)
Title: Make a common store and load infrastructure for creatures and derived classes

Currently the classes monster, npc and player each store the Creature members in their own serialize/deserialize functions. But not even all of the data is stored, the monster ignores most of the Creature members, the npc class ignores most of the player members.

This PR implements a hierarchical store/load, so each class has one store/load function that stores/loads only the members of that class. Those functions are protected as they are not to be used without the proper wrapping.

The main interface to json is JsonSerializer/JsonDeserializer. This is implemented for monster, player and npc like this:
```
// Interface to json - see json.h - JsonSerializer
void some_class::serialize(JsonOut &jsout) const
{
jsout.start_object();
store( jsout );
jsout.end_object();
}
// Interface to json - see json.h - JsonDeserializer
void some_class::deserialize(JsonIn &jsin)
{
JsonObject &data = jsin.get_object();
load( data );
}
```

It's *not* implemented in the Creature/Character classes. There is no instance of those classes alone, only as part of other objects (player, npc, monster), so there is no need to serialize a pure Creature object.

Instead all classes that inherit (direct or indirect) have the functions load/store:
```
void some_other_class::store(JsonOut &jsout) const
{
parent_class::store( jsout );
jsout.member( "my_member_name", my_member_name );
}
void some_other_class::load(JsonObject &data)
{
parent_class::load( data );
data.read( "my_member_name", my_member_name );
}
```
Each calls the same function of the parent class (except Creature, it has no parent class). This results in a single json object for each C++ object which mirrors the C++ class.

Adding member to the Creature class and adding them to the load/store functions makes them loaded and stored for each class that inherits from Creature.

This also allows to add more classes to system without duplicating loading/storing the members of the parent classes.

----

Currently there is one exception: `player::serialize`/`player::deserialize` stores and loads player specific data that is not supposed to go into the npc object.

----

I also made the copy constructors and the assignment operators of the Creature and derived classes compiler generated. None of those classes has any special member that needs special code to copy it. Letting the compiler generate those functions makes sure that no member is forgotten.