home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / tinymud2.zip / DUMP.C < prev    next >
C/C++ Source or Header  |  1990-09-02  |  3KB  |  147 lines

  1. #include "copyright.h"
  2.  
  3. #include <stdio.h>
  4.  
  5. #include "db.h"
  6.  
  7. #ifndef COMPRESS
  8. #define uncompress(x) (x)
  9. #else
  10. const char *uncompress(const char *s);
  11. #endif /* COMPRESS */
  12.  
  13. const char *unparse_object(dbref player, dbref loc);
  14.  
  15. /* in a dump, you can see everything */
  16. int can_link_to(dbref who, object_flag_type what, dbref where)
  17. {
  18.     return 1;
  19. }
  20.  
  21. int controls(dbref who, dbref what)
  22. {
  23.     return 1;
  24. }
  25.  
  26. void main(int argc, char **argv)
  27. {
  28.     struct object *o;
  29.     dbref owner;
  30.     dbref thing;
  31.  
  32.     if(argc < 1) {
  33.     fprintf(stderr, "Usage: %s [owner]\n", *argv);
  34.     exit(1);
  35.     }
  36.     
  37.     if(argc >= 2) {
  38.     owner = atol(argv[1]);
  39.     } else {
  40.     owner = NOTHING;
  41.     }
  42.  
  43.     if(db_read(stdin) < 0) {
  44.     fprintf(stderr, "%s: bad input\n", argv[0]);
  45.     exit(5);
  46.     }
  47.  
  48.     for(o = db; o < db+db_top; o++) {
  49.     /* don't show exits separately */
  50.     if((o->flags & TYPE_MASK) == TYPE_EXIT) continue;
  51.  
  52.     /* don't show it if it isn't owned by the right player */
  53.     if(owner != NOTHING && o->owner != owner) continue;
  54.  
  55.     printf("#%d: %s [%s] at %s Pennies: %d Type: ",
  56.            o - db, o->name, db[o->owner].name,
  57.            unparse_object(owner, o->location),
  58.            o->pennies);
  59.     switch(o->flags & TYPE_MASK) {
  60.       case TYPE_ROOM:
  61.         printf("Room");
  62.         break;
  63.       case TYPE_EXIT:
  64.         printf("Exit");
  65.         break;
  66.       case TYPE_THING:
  67.         printf("Thing");
  68.         break;
  69.       case TYPE_PLAYER:
  70.         printf("Player");
  71.         break;
  72.       default:
  73.         printf("***UNKNOWN TYPE***");
  74.         break;
  75.     }
  76.  
  77.     /* handle flags */
  78.     putchar(' ');
  79.     if(o->flags & ~TYPE_MASK) {
  80.         printf("Flags: ");
  81.         if(o->flags & LINK_OK) printf("LINK_OK ");
  82.         if(o->flags & DARK) printf("DARK ");
  83.         if(o->flags & STICKY) printf("STICKY ");
  84.         if(o->flags & WIZARD) printf("WIZARD ");
  85.         if(o->flags & TEMPLE) printf("TEMPLE ");
  86. #ifdef RESTRICTED_BUILDING
  87.         if(o->flags & BUILDER) printf("BUILDER ");
  88. #endif /* RESTRICTED_BUILDING */
  89.     }
  90.     putchar('\n');
  91.            
  92.     if(o->key != TRUE_BOOLEXP) printf("KEY: %s\n",
  93.                       unparse_boolexp(owner, o->key));
  94.     if(o->description) {
  95.         puts("Description:");
  96.         puts(uncompress(o->description));
  97.     }
  98.     if(o->succ_message) {
  99.         puts("Success Message:");
  100.         puts(uncompress(o->succ_message));
  101.     }
  102.     if(o->fail_message) {
  103.         puts("Fail Message:");
  104.         puts(uncompress(o->fail_message));
  105.     }
  106.     if(o->ofail) {
  107.         puts("Other Fail Message:");
  108.         puts(uncompress(o->ofail));
  109.     }
  110.     if(o->osuccess) {
  111.         puts("Other Success Message:");
  112.         puts(uncompress(o->osuccess));
  113.     }
  114.     if(o->contents != NOTHING) {
  115.         puts("Contents:");
  116.         DOLIST(thing, o->contents) {
  117.         /* dump thing description */
  118.         putchar(' ');
  119.         puts(unparse_object(owner, thing));
  120.         }
  121.     }
  122.     if(o->exits != NOTHING) {
  123.         if((o->flags & TYPE_MASK) == TYPE_ROOM) {
  124.         puts("Exits:");
  125.         DOLIST(thing, o->exits) {
  126.             printf(" %s", unparse_object(owner, thing));
  127.             if(db[thing].key != TRUE_BOOLEXP) {
  128.             printf(" KEY: %s",
  129.                    unparse_boolexp(owner, db[thing].key));
  130.             }
  131.             if(db[thing].location != NOTHING) {
  132.             printf(" => %s\n",
  133.                    unparse_object(owner, db[thing].location));
  134.             } else {
  135.             puts(" ***OPEN***");
  136.             }
  137.         }
  138.         } else {
  139.         printf("Home: %s\n", unparse_object(owner, o->exits));
  140.         }
  141.     }
  142.     putchar('\n');
  143.     }
  144.  
  145.     exit(0);
  146. }
  147.