-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathblueprint_furniture.cpp
113 lines (95 loc) · 2.67 KB
/
blueprint_furniture.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "blueprint.h"
room_base::furniture_t::furniture_t() :
has_placeholder(false),
placeholder(),
type(layout_type::none),
construction(construction_type::NONE),
dig(tile_dig_designation::Default),
pos(0, 0, 0),
has_target(false),
target(),
has_users(0),
ignore(false),
makeroom(false),
internal(false),
stairs_special(false),
comment()
{
}
bool room_base::furniture_t::apply(Json::Value data, std::string & error, bool allow_placeholders)
{
std::ostringstream scratch;
if (allow_placeholders && data.isMember("placeholder") && !apply_index(has_placeholder, placeholder, data, "placeholder", error))
{
return false;
}
if (data.isMember("type") && !apply_enum(type, data, "type", error))
{
return false;
}
if (data.isMember("construction") && !apply_enum(construction, data, "construction", error))
{
return false;
}
if (data.isMember("dig") && !apply_enum(dig, data, "dig", error))
{
return false;
}
if (data.isMember("x") && !apply_int(pos.x, data, "x", error))
{
return false;
}
if (data.isMember("y") && !apply_int(pos.y, data, "y", error))
{
return false;
}
if (data.isMember("z") && !apply_int(pos.z, data, "z", error))
{
return false;
}
if (data.isMember("target") && !apply_index(has_target, target, data, "target", error))
{
return false;
}
if (data.isMember("has_users") && !apply_int(has_users, data, "has_users", error))
{
return false;
}
if (data.isMember("ignore") && !apply_bool(ignore, data, "ignore", error))
{
return false;
}
if (data.isMember("makeroom") && !apply_bool(makeroom, data, "makeroom", error))
{
return false;
}
if (data.isMember("internal") && !apply_bool(internal, data, "internal", error))
{
return false;
}
if (data.isMember("stairs_special") && !apply_bool(stairs_special, data, "stairs_special", error))
{
return false;
}
if (data.isMember("comment") && !apply_variable_string(comment, data, "comment", error, true))
{
return false;
}
return apply_unhandled_properties(data, "furniture", error);
}
void room_base::furniture_t::shift(room_base::layoutindex_t layout_start, room_base::roomindex_t)
{
if (has_target)
{
target += layout_start;
}
}
bool room_base::furniture_t::check_indexes(room_base::layoutindex_t layout_limit, room_base::roomindex_t, std::string & error) const
{
if (has_target && target >= layout_limit)
{
error = "invalid target";
return false;
}
return true;
}