27 |
#include "enigma_mapping.h" |
#include "enigma_mapping.h" |
28 |
|
|
29 |
using namespace std; |
using namespace std; |
30 |
|
using namespace OxydLib; |
31 |
using namespace enigma_mapping; |
using namespace enigma_mapping; |
32 |
|
|
33 |
void usage() |
void usage() |
169 |
|
|
170 |
{ |
{ |
171 |
for (int gridTypeInt = GridType_First; |
for (int gridTypeInt = GridType_First; |
172 |
gridTypeInt <= GridType_Last; |
gridTypeInt <= GridType_Last; |
173 |
gridTypeInt++) { |
gridTypeInt++) { |
174 |
GridType gridType = GridType(gridTypeInt); |
GridType gridType = GridType(gridTypeInt); |
175 |
|
|
176 |
for (unsigned int y = 0; y < level.getHeight(); y++) { |
for (unsigned int y = 0; y < level.getHeight(); y++) { |
177 |
for (unsigned int x = 0; x < level.getWidth(); x++) { |
for (unsigned int x = 0; x < level.getWidth(); x++) { |
178 |
unsigned char byteVal = level.getGrid(gridType).get(x, y); |
unsigned char byteVal = level.getGrid(gridType).get(x, y); |
179 |
used[gridType][byteVal].insert(nLevel); |
used[gridType][byteVal].insert(nLevel); |
180 |
} |
} |
181 |
} |
} |
182 |
|
|
183 |
if (gridType == GridType_Surfaces) { |
if (gridType == GridType_Surfaces) { |
184 |
continue; |
continue; |
185 |
} |
} |
186 |
} |
} |
187 |
} |
} |
188 |
|
|
192 |
set<SignalLocation>::const_iterator senderIter = senders.begin(); |
set<SignalLocation>::const_iterator senderIter = senders.begin(); |
193 |
set<SignalLocation>::const_iterator senderEnd = senders.end(); |
set<SignalLocation>::const_iterator senderEnd = senders.end(); |
194 |
for (; senderIter != senderEnd; ++senderIter) { |
for (; senderIter != senderEnd; ++senderIter) { |
195 |
const SignalLocation &sender = *senderIter; |
const SignalLocation &sender = *senderIter; |
196 |
|
|
197 |
unsigned char senderByteVal = |
unsigned char senderByteVal = |
198 |
level.getGrid(sender.getGridType()).get(sender.getX(), |
level.getGrid(sender.getGridType()).get(sender.getX(), |
199 |
sender.getY()); |
sender.getY()); |
200 |
usedAsSender[sender.getGridType()][senderByteVal].insert(nLevel); |
usedAsSender[sender.getGridType()][senderByteVal].insert(nLevel); |
201 |
|
|
202 |
int numRecipients = level.getNumRecipients(sender); |
int numRecipients = level.getNumRecipients(sender); |
203 |
for (int nRecipient = 0; |
for (int nRecipient = 0; |
204 |
nRecipient < numRecipients; |
nRecipient < numRecipients; |
205 |
nRecipient++) { |
nRecipient++) { |
206 |
const SignalLocation &recipient = |
const SignalLocation &recipient = |
207 |
level.getRecipient(sender, nRecipient); |
level.getRecipient(sender, nRecipient); |
208 |
|
|
209 |
unsigned char recipientByteVal = |
unsigned char recipientByteVal = |
210 |
level.getGrid(recipient.getGridType()).get(recipient.getX(), |
level.getGrid(recipient.getGridType()).get(recipient.getX(), |
211 |
recipient.getY()); |
recipient.getY()); |
212 |
usedAsRecipient[recipient.getGridType()][recipientByteVal] |
usedAsRecipient[recipient.getGridType()][recipientByteVal] |
213 |
.insert(nLevel); |
.insert(nLevel); |
214 |
} |
} |
215 |
} |
} |
216 |
} |
} |
217 |
} |
} |
218 |
|
|
219 |
{ |
{ |
220 |
for (int gridTypeInt = GridType_First; |
for (int gridTypeInt = GridType_First; |
221 |
gridTypeInt <= GridType_Last; |
gridTypeInt <= GridType_Last; |
222 |
gridTypeInt++) { |
gridTypeInt++) { |
223 |
GridType gridType = GridType(gridTypeInt); |
GridType gridType = GridType(gridTypeInt); |
224 |
|
|
225 |
switch (gridType) { |
switch (gridType) { |
233 |
printObjectValue(byteValInt, enigmaMapping, gridType); |
printObjectValue(byteValInt, enigmaMapping, gridType); |
234 |
// printf("%02x:", byteValInt); |
// printf("%02x:", byteValInt); |
235 |
|
|
236 |
const set<int> &intSet = used[gridType][byteValInt]; |
const set<int> &intSet = used[gridType][byteValInt]; |
237 |
set<int>::const_iterator iter = intSet.begin(); |
set<int>::const_iterator iter = intSet.begin(); |
238 |
set<int>::const_iterator end = intSet.end(); |
set<int>::const_iterator end = intSet.end(); |
239 |
for (; iter != end; ++iter) { |
for (; iter != end; ++iter) { |
240 |
int nLevel = *iter; |
int nLevel = *iter; |
241 |
printf(" %d", nLevel + 1); |
printf(" %d", nLevel + 1); |
242 |
} |
} |
243 |
|
|
244 |
printf("\n"); |
printf("\n"); |
245 |
} |
} |
246 |
|
|
247 |
printf("\n"); |
printf("\n"); |
250 |
|
|
251 |
{ |
{ |
252 |
for (int gridTypeInt = GridType_First; |
for (int gridTypeInt = GridType_First; |
253 |
gridTypeInt <= GridType_Last; |
gridTypeInt <= GridType_Last; |
254 |
gridTypeInt++) { |
gridTypeInt++) { |
255 |
GridType gridType = GridType(gridTypeInt); |
GridType gridType = GridType(gridTypeInt); |
256 |
|
|
257 |
if (gridType == GridType_Surfaces) { |
if (gridType == GridType_Surfaces) { |
258 |
continue; |
continue; |
259 |
} |
} |
260 |
|
|
261 |
for (int useType = 1; useType <= 2; useType++) { |
for (int useType = 1; useType <= 2; useType++) { |
262 |
switch (gridType) { |
switch (gridType) { |
263 |
case GridType_Pieces: printf("Pieces ("); break; |
case GridType_Pieces: printf("Pieces ("); break; |
264 |
case GridType_Objects: printf("Objects ("); break; |
case GridType_Objects: printf("Objects ("); break; |
265 |
default: exit(1); |
default: exit(1); |
266 |
} |
} |
267 |
|
|
268 |
switch (useType) { |
switch (useType) { |
269 |
case 1: printf("senders"); break; |
case 1: printf("senders"); break; |
270 |
case 2: printf("recipients"); break; |
case 2: printf("recipients"); break; |
271 |
default: exit(1); |
default: exit(1); |
272 |
} |
} |
273 |
|
|
274 |
printf("):\n"); |
printf("):\n"); |
275 |
|
|
276 |
for (int byteValInt = 0; byteValInt < 256; byteValInt++) { |
for (int byteValInt = 0; byteValInt < 256; byteValInt++) { |
277 |
printObjectValue(byteValInt, enigmaMapping, gridType); |
printObjectValue(byteValInt, enigmaMapping, gridType); |
278 |
// printf("%02x:", byteValInt); |
// printf("%02x:", byteValInt); |
279 |
|
|
280 |
const set<int> &intSet = |
const set<int> &intSet = |
281 |
(useType == 1 ? usedAsSender : usedAsRecipient) |
(useType == 1 ? usedAsSender : usedAsRecipient) |
282 |
[gridType][byteValInt]; |
[gridType][byteValInt]; |
283 |
set<int>::const_iterator iter = intSet.begin(); |
set<int>::const_iterator iter = intSet.begin(); |
284 |
set<int>::const_iterator end = intSet.end(); |
set<int>::const_iterator end = intSet.end(); |
285 |
for (; iter != end; ++iter) { |
for (; iter != end; ++iter) { |
286 |
int nLevel = *iter; |
int nLevel = *iter; |
287 |
printf(" %d", nLevel + 1); |
printf(" %d", nLevel + 1); |
288 |
} |
} |
289 |
|
|
290 |
printf("\n"); |
printf("\n"); |
291 |
} |
} |
292 |
|
|
293 |
printf("\n"); |
printf("\n"); |
294 |
} |
} |
295 |
} |
} |
296 |
} |
} |