… | |
… | |
374 | * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. |
374 | * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. |
375 | * Some error messages. |
375 | * Some error messages. |
376 | * The result of the dump is stored in the static global errmsg array. |
376 | * The result of the dump is stored in the static global errmsg array. |
377 | */ |
377 | */ |
378 | |
378 | |
379 | void |
379 | char * |
380 | dump_object2 (object *op) |
|
|
381 | { |
|
|
382 | errmsg[0] = 0; |
|
|
383 | return; |
|
|
384 | //TODO//D#d# |
|
|
385 | #if 0 |
|
|
386 | char *cp; |
|
|
387 | |
|
|
388 | /* object *tmp;*/ |
|
|
389 | |
|
|
390 | if (op->arch != NULL) |
|
|
391 | { |
|
|
392 | strcat (errmsg, "arch "); |
|
|
393 | strcat (errmsg, op->arch->name ? op->arch->name : "(null)"); |
|
|
394 | strcat (errmsg, "\n"); |
|
|
395 | if ((cp = get_ob_diff (op, &empty_archetype->clone)) != NULL) |
|
|
396 | strcat (errmsg, cp); |
|
|
397 | # if 0 |
|
|
398 | /* Don't dump player diffs - they are too long, mostly meaningless, and |
|
|
399 | * will overflow the buffer. |
|
|
400 | * Changed so that we don't dump inventory either. This may |
|
|
401 | * also overflow the buffer. |
|
|
402 | */ |
|
|
403 | if (op->type != PLAYER && (cp = get_ob_diff (op, &empty_archetype->clone)) != NULL) |
|
|
404 | strcat (errmsg, cp); |
|
|
405 | for (tmp = op->inv; tmp; tmp = tmp->below) |
|
|
406 | dump_object2 (tmp); |
|
|
407 | # endif |
|
|
408 | strcat (errmsg, "end\n"); |
|
|
409 | } |
|
|
410 | else |
|
|
411 | { |
|
|
412 | strcat (errmsg, "Object "); |
|
|
413 | if (op->name == NULL) |
|
|
414 | strcat (errmsg, "(null)"); |
|
|
415 | else |
|
|
416 | strcat (errmsg, op->name); |
|
|
417 | strcat (errmsg, "\n"); |
|
|
418 | # if 0 |
|
|
419 | if ((cp = get_ob_diff (op, &empty_archetype->clone)) != NULL) |
|
|
420 | strcat (errmsg, cp); |
|
|
421 | for (tmp = op->inv; tmp; tmp = tmp->below) |
|
|
422 | dump_object2 (tmp); |
|
|
423 | # endif |
|
|
424 | strcat (errmsg, "end\n"); |
|
|
425 | } |
|
|
426 | #endif |
|
|
427 | } |
|
|
428 | |
|
|
429 | /* |
|
|
430 | * Dumps an object. Returns output in the static global errmsg array. |
|
|
431 | */ |
|
|
432 | |
|
|
433 | void |
|
|
434 | dump_object (object *op) |
380 | dump_object (object *op) |
435 | { |
381 | { |
436 | if (op == NULL) |
382 | if (!op) |
437 | { |
383 | return strdup ("[NULLOBJ]"); |
438 | strcpy (errmsg, "[NULL pointer]"); |
|
|
439 | return; |
|
|
440 | } |
|
|
441 | errmsg[0] = '\0'; |
|
|
442 | dump_object2 (op); |
|
|
443 | } |
|
|
444 | |
384 | |
445 | void |
385 | object_freezer freezer; |
446 | dump_all_objects (void) |
386 | save_object (freezer, op, 3); |
447 | { |
387 | return freezer.as_string (); |
448 | object *op; |
|
|
449 | |
|
|
450 | for (op = object::first; op != NULL; op = op->next) |
|
|
451 | { |
|
|
452 | dump_object (op); |
|
|
453 | fprintf (logfile, "Object %s\n", errmsg); |
|
|
454 | } |
|
|
455 | } |
388 | } |
456 | |
389 | |
457 | /* |
390 | /* |
458 | * get_nearest_part(multi-object, object 2) returns the part of the |
391 | * get_nearest_part(multi-object, object 2) returns the part of the |
459 | * multi-object 1 which is closest to the second object. |
392 | * multi-object 1 which is closest to the second object. |
… | |
… | |
1176 | * use translated coordinates in case some oddness with map tiling is |
1109 | * use translated coordinates in case some oddness with map tiling is |
1177 | * evident |
1110 | * evident |
1178 | */ |
1111 | */ |
1179 | if (GET_MAP_OB (m, x, y) != op) |
1112 | if (GET_MAP_OB (m, x, y) != op) |
1180 | { |
1113 | { |
1181 | dump_object (op); |
1114 | char *dump = dump_object (op); |
1182 | LOG (llevError, |
1115 | LOG (llevError, |
1183 | "remove_ob: GET_MAP_OB does not return object to be removed even though it appears to be on the bottom?\n%s\n", errmsg); |
1116 | "remove_ob: GET_MAP_OB does not return object to be removed even though it appears to be on the bottom?\n%s\n", dump); |
|
|
1117 | free (dump); |
1184 | dump_object (GET_MAP_OB (m, x, y)); |
1118 | dump = dump_object (GET_MAP_OB (m, x, y)); |
1185 | LOG (llevError, "%s\n", errmsg); |
1119 | LOG (llevError, "%s\n", dump); |
|
|
1120 | free (dump); |
1186 | } |
1121 | } |
1187 | |
1122 | |
1188 | SET_MAP_OB (m, x, y, op->above); /* goes on above it. */ |
1123 | SET_MAP_OB (m, x, y, op->above); /* goes on above it. */ |
1189 | } |
1124 | } |
1190 | |
1125 | |
… | |
… | |
1345 | return NULL; |
1280 | return NULL; |
1346 | } |
1281 | } |
1347 | |
1282 | |
1348 | if (m == NULL) |
1283 | if (m == NULL) |
1349 | { |
1284 | { |
1350 | dump_object (op); |
1285 | char *dump = dump_object (op); |
1351 | LOG (llevError, "Trying to insert in null-map!\n%s\n", errmsg); |
1286 | LOG (llevError, "Trying to insert in null-map!\n%s\n", dump); |
|
|
1287 | free (dump); |
1352 | return op; |
1288 | return op; |
1353 | } |
1289 | } |
1354 | |
1290 | |
1355 | if (out_of_map (m, op->x, op->y)) |
1291 | if (out_of_map (m, op->x, op->y)) |
1356 | { |
1292 | { |
1357 | dump_object (op); |
1293 | char *dump = dump_object (op); |
1358 | LOG (llevError, "Trying to insert object outside the map.\n%s\n", errmsg); |
1294 | LOG (llevError, "Trying to insert object outside the map.\n%s\n", dump); |
1359 | #ifdef MANY_CORES |
1295 | #ifdef MANY_CORES |
1360 | /* Better to catch this here, as otherwise the next use of this object |
1296 | /* Better to catch this here, as otherwise the next use of this object |
1361 | * is likely to cause a crash. Better to find out where it is getting |
1297 | * is likely to cause a crash. Better to find out where it is getting |
1362 | * improperly inserted. |
1298 | * improperly inserted. |
1363 | */ |
1299 | */ |
1364 | abort (); |
1300 | abort (); |
1365 | #endif |
1301 | #endif |
|
|
1302 | free (dump); |
1366 | return op; |
1303 | return op; |
1367 | } |
1304 | } |
1368 | |
1305 | |
1369 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1306 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1370 | { |
1307 | { |
1371 | dump_object (op); |
1308 | char *dump = dump_object (op); |
1372 | LOG (llevError, "Trying to insert (map) inserted object.\n%s\n", errmsg); |
1309 | LOG (llevError, "Trying to insert (map) inserted object.\n%s\n", dump); |
|
|
1310 | free (dump); |
1373 | return op; |
1311 | return op; |
1374 | } |
1312 | } |
1375 | |
1313 | |
1376 | if (op->more != NULL) |
1314 | if (op->more != NULL) |
1377 | { |
1315 | { |
… | |
… | |
1814 | tmp, * |
1752 | tmp, * |
1815 | otmp; |
1753 | otmp; |
1816 | |
1754 | |
1817 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1755 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1818 | { |
1756 | { |
1819 | dump_object (op); |
1757 | char *dump = dump_object (op); |
1820 | LOG (llevError, "Trying to insert (ob) inserted object.\n%s\n", errmsg); |
1758 | LOG (llevError, "Trying to insert (ob) inserted object.\n%s\n", dump); |
|
|
1759 | free (dump); |
1821 | return op; |
1760 | return op; |
1822 | } |
1761 | } |
1823 | |
1762 | |
1824 | if (where == NULL) |
1763 | if (where == NULL) |
1825 | { |
1764 | { |
1826 | dump_object (op); |
1765 | char *dump = dump_object (op); |
1827 | LOG (llevError, "Trying to put object in NULL.\n%s\n", errmsg); |
1766 | LOG (llevError, "Trying to put object in NULL.\n%s\n", dump); |
|
|
1767 | free (dump); |
1828 | return op; |
1768 | return op; |
1829 | } |
1769 | } |
1830 | |
1770 | |
1831 | if (where->head) |
1771 | if (where->head) |
1832 | { |
1772 | { |