-
Notifications
You must be signed in to change notification settings - Fork 10
/
objser.h
62 lines (56 loc) · 1.37 KB
/
objser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef OBJSER_H
#define OBJSER_H
#include "room.h"
// Serialization functions for Object are defined here so
// that room.h can be included properly.
// For serialization
template <class archive>
void Object::save(archive &ar, const unsigned int version) const
{
ar & oid();
ar & (_ocan ? _ocan->oid() : std::string());
ar & flags;
ar & (_oroom ? _oroom->rid() : std::string());
ar & _ofval;
ar & _osize;
ar & _ocapac;
ar & _omatch;
ar & _ostrength;
std::list<std::string> conts;
std::transform(contents.begin(), contents.end(), std::back_inserter(conts), [](ObjectP o) { return o->oid(); });
ar & conts;
ar & _odesc1;
ar & desc;
}
template <class archive>
void Object::load(archive &ar, const unsigned int version)
{
std::string temp;
ar & temp;
_ASSERT(synonyms.empty());
synonyms.push_back(temp);
ar & temp;
if (!temp.empty())
{
_ocan = sfind_obj(temp);
}
ar & flags;
ar & temp;
if (!temp.empty())
_oroom = sfind_room(temp);
ar & _ofval;
ar & _osize;
ar & _ocapac;
ar & _omatch;
ar & _ostrength;
std::list<std::string> conts;
ar & conts;
ar & _odesc1;
ar & desc;
contents.clear();
std::transform(conts.begin(), conts.end(), std::back_inserter(contents), [](const std::string &s)
{
return sfind_obj(s);
});
}
#endif