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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
#include "validator.h"
#include <iostream>
#include "proto/human.pb.h"
#include "structs.h"
#include "util/identifiers.h"
namespace com::fourisland::lingo2_archipelago {
namespace {
void ValidateRoom(const RoomIdentifier& room_identifier,
const RoomInfo& room_info) {
if (room_info.definitions.empty()) {
std::cout << "Room " << room_identifier.ShortDebugString()
<< " has no definition, but was referenced:" << std::endl;
for (const DoorIdentifier& door_identifier :
room_info.doors_referenced_by) {
std::cout << " DOOR " << door_identifier.ShortDebugString()
<< std::endl;
}
for (const PanelIdentifier& panel_identifier :
room_info.panels_referenced_by) {
std::cout << " PANEL " << panel_identifier.ShortDebugString()
<< std::endl;
}
for (const HumanConnection& connection :
room_info.connections_referenced_by) {
std::cout << " CONNECTION " << connection.ShortDebugString()
<< std::endl;
}
} else if (room_info.definitions.size() > 1) {
std::cout << "Room " << room_identifier.ShortDebugString()
<< " was defined multiple times." << std::endl;
}
}
void ValidateDoor(const DoorIdentifier& door_identifier,
const DoorInfo& door_info) {
if (door_info.definitions.empty()) {
std::cout << "Door " << door_identifier.ShortDebugString()
<< " has no definition, but was referenced:" << std::endl;
for (const DoorIdentifier& other_door_identifier :
door_info.doors_referenced_by) {
std::cout << " DOOR " << other_door_identifier.ShortDebugString()
<< std::endl;
}
for (const PanelIdentifier& panel_identifier :
door_info.panels_referenced_by) {
std::cout << " PANEL " << panel_identifier.ShortDebugString()
<< std::endl;
}
for (const PaintingIdentifier& painting_identifier :
door_info.paintings_referenced_by) {
std::cout << " PAINTING " << painting_identifier.ShortDebugString()
<< std::endl;
}
for (const PortIdentifier& port_identifier :
door_info.ports_referenced_by) {
std::cout << " PORT " << port_identifier.ShortDebugString()
<< std::endl;
}
for (const HumanConnection& connection :
door_info.connections_referenced_by) {
std::cout << " CONNECTION " << connection.ShortDebugString()
<< std::endl;
}
} else if (door_info.definitions.size() > 1) {
std::cout << "Door " << door_identifier.ShortDebugString()
<< " was defined multiple times." << std::endl;
}
if (door_info.malformed_identifiers.HasAny()) {
std::cout << "Door " << door_identifier.ShortDebugString()
<< " has malformed identifiers:" << std::endl;
for (const PaintingIdentifier& painting_identifier :
door_info.malformed_identifiers.paintings) {
std::cout << " PAINTING " << painting_identifier.ShortDebugString()
<< std::endl;
}
for (const PanelIdentifier& panel_identifier :
door_info.malformed_identifiers.panels) {
std::cout << " PANEL " << panel_identifier.ShortDebugString()
<< std::endl;
}
for (const KeyholderIdentifier& keyholder_identifier :
door_info.malformed_identifiers.keyholders) {
std::cout << " KEYHOLDER " << keyholder_identifier.ShortDebugString()
<< std::endl;
}
}
}
void ValidatePort(const PortIdentifier& port_identifier,
const PortInfo& port_info) {
if (port_info.definitions.empty()) {
std::cout << "Port " << port_identifier.ShortDebugString()
<< " has no definition, but was referenced:" << std::endl;
for (const HumanConnection& connection :
port_info.connections_referenced_by) {
std::cout << " CONNECTION " << connection.ShortDebugString()
<< std::endl;
}
} else if (port_info.definitions.size() > 1) {
std::cout << "Port " << port_identifier.ShortDebugString()
<< " was defined multiple times." << std::endl;
}
}
void ValidatePainting(const PaintingIdentifier& painting_identifier,
const PaintingInfo& painting_info) {
if (painting_info.definitions.empty()) {
std::cout << "Painting " << painting_identifier.ShortDebugString()
<< " has no definition, but was referenced:" << std::endl;
for (const DoorIdentifier& door_identifier :
painting_info.doors_referenced_by) {
std::cout << " DOOR " << door_identifier.ShortDebugString()
<< std::endl;
}
for (const HumanConnection& connection :
painting_info.connections_referenced_by) {
std::cout << " CONNECTION " << connection.ShortDebugString()
<< std::endl;
}
} else if (painting_info.definitions.size() > 1) {
std::cout << "Painting " << painting_identifier.ShortDebugString()
<< " was defined multiple times." << std::endl;
}
}
void ValidatePanel(const PanelIdentifier& panel_identifier,
const PanelInfo& panel_info) {
if (panel_info.definitions.empty()) {
std::cout << "Panel " << panel_identifier.ShortDebugString()
<< " has no definition, but was referenced:" << std::endl;
for (const DoorIdentifier& door_identifier :
panel_info.doors_referenced_by) {
std::cout << " DOOR " << door_identifier.ShortDebugString()
<< std::endl;
}
for (const HumanConnection& connection :
panel_info.connections_referenced_by) {
std::cout << " CONNECTION " << connection.ShortDebugString()
<< std::endl;
}
} else if (panel_info.definitions.size() > 1) {
std::cout << "Panel " << panel_identifier.ShortDebugString()
<< " was defined multiple times." << std::endl;
}
for (const auto& [answer, proxy_info] : panel_info.proxies) {
if (proxy_info.definitions.empty()) {
std::cout << "Panel " << panel_identifier.ShortDebugString()
<< " with answer \"" << answer
<< "\" has no definition, but was referenced:" << std::endl;
for (const DoorIdentifier& door_identifier :
proxy_info.doors_referenced_by) {
std::cout << " DOOR " << door_identifier.ShortDebugString()
<< std::endl;
}
for (const HumanConnection& connection :
proxy_info.connections_referenced_by) {
std::cout << " CONNECTION " << connection.ShortDebugString()
<< std::endl;
}
} else if (proxy_info.definitions.size() > 1) {
std::cout << "Panel " << panel_identifier.ShortDebugString()
<< " with answer \"" << answer
<< "\" was defined multiple times." << std::endl;
}
}
}
void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier,
const KeyholderInfo& keyholder_info) {
if (keyholder_info.definitions.empty()) {
std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
<< " has no definition, but was referenced:" << std::endl;
for (const DoorIdentifier& door_identifier :
keyholder_info.doors_referenced_by) {
std::cout << " DOOR " << door_identifier.ShortDebugString()
<< std::endl;
}
} else if (keyholder_info.definitions.size() > 1) {
std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
<< " was defined multiple times." << std::endl;
}
}
void ValidateLetter(const LetterIdentifier& letter_identifier,
const LetterInfo& letter_info) {
std::string letter_name = std::string(1, std::get<0>(letter_identifier)) +
(std::get<1>(letter_identifier) ? "2" : "1");
if (letter_info.defined_in.size() > 1) {
std::cout << "Letter " << letter_name
<< " was defined in multiple places:" << std::endl;
for (const RoomIdentifier& room_identifier : letter_info.defined_in) {
std::cout << " " << room_identifier.ShortDebugString() << std::endl;
}
}
}
} // namespace
void ValidateCollectedInfo(const CollectedInfo& info) {
for (const auto& [room_identifier, room_info] : info.rooms) {
ValidateRoom(room_identifier, room_info);
}
for (const auto& [door_identifier, door_info] : info.doors) {
ValidateDoor(door_identifier, door_info);
}
for (const auto& [port_identifier, port_info] : info.ports) {
ValidatePort(port_identifier, port_info);
}
for (const auto& [painting_identifier, painting_info] : info.paintings) {
ValidatePainting(painting_identifier, painting_info);
}
for (const auto& [panel_identifier, panel_info] : info.panels) {
ValidatePanel(panel_identifier, panel_info);
}
for (const auto& [keyholder_identifier, keyholder_info] : info.keyholders) {
ValidateKeyholder(keyholder_identifier, keyholder_info);
}
for (const auto& [letter_identifier, letter_info] : info.letters) {
ValidateLetter(letter_identifier, letter_info);
}
}
} // namespace com::fourisland::lingo2_archipelago
|