Include division tree in @scan and scan()
authorAri Johnson <ari@theari.com>
Thu, 6 Jun 2013 15:38:36 +0000 (11:38 -0400)
committerAri Johnson <ari@theari.com>
Thu, 6 Jun 2013 15:53:27 +0000 (11:53 -0400)
hdrs/game.h
src/SWITCHES
src/cmds.c
src/command.c
src/game.c

index abf45a365b5e017a0870e395b6dfa850b4cca763..39e519fe2a5e10d2c8274f4cd761d000a2c6fb1a 100644 (file)
@@ -11,6 +11,7 @@
 #define CHECK_HERE                 0x80
 #define CHECK_ZONE                 0x100
 #define CHECK_GLOBAL               0x200
+#define CHECK_DIVISION             0x400
 
 /* hash table stuff */
 extern void init_func_hashtab(void);   /* eval.c */
index 38d83ca864c0f380edf719802b395ed909b0de66..cc95773342b93ab0bbefc2c597576b44a612cc3e 100644 (file)
@@ -37,6 +37,7 @@ DELIMIT
 DESCRIBE
 DESTROY
 DISABLE
+DIVISION
 DOWN
 DSTATS
 EMIT
index eac532d36c0e3d66ed660c5e86601883e7b66504..f57fb7fbaadeeab45ec80b3b5e0d67d906a2c1cb 100644 (file)
@@ -816,11 +816,14 @@ COMMAND (cmd_scan) {
     do_scan(player, arg_left, CHECK_INVENTORY | CHECK_SELF);
   else if (SW_ISSET(sw, SWITCH_ZONE))
     do_scan(player, arg_left, CHECK_ZONE);
+  else if (SW_ISSET(sw, SWITCH_DIVISION))
+    do_scan(player, arg_left, CHECK_DIVISION);
   else if (SW_ISSET(sw, SWITCH_GLOBALS))
     do_scan(player, arg_left, CHECK_GLOBAL);
   else
     do_scan(player, arg_left, CHECK_INVENTORY | CHECK_NEIGHBORS |
-           CHECK_SELF | CHECK_HERE | CHECK_ZONE | CHECK_GLOBAL);
+           CHECK_SELF | CHECK_HERE | CHECK_ZONE | CHECK_DIVISION |
+           CHECK_GLOBAL);
 }
 
 COMMAND (cmd_search) {
index d71f3a5d1e5739a70200b734e177e6084f738f57..cca892d62e9e29f0c0fb6a33402dd4dea1b02c8b 100644 (file)
@@ -250,7 +250,7 @@ COMLIST commands[] = {
 #ifdef RPMODE_SYS
   {"@CRPLOG", "QUIET RESET COMBAT", cmd_rplog, CMD_T_ANY, "POWER^COMBAT"},
 #endif
-  {"@SCAN", "ROOM SELF ZONE GLOBALS", cmd_scan,
+  {"@SCAN", "ROOM SELF ZONE DIVISION GLOBALS", cmd_scan,
    CMD_T_ANY | CMD_T_NOGAGGED, NULL},
   {"@SD", "LOGOUT", cmd_su, CMD_T_ANY, NULL},
   {"@SEARCH", NULL, cmd_search,
index 7df66d81e8d85867e78bdb2954f3ab90b7b4e7e3..19b6b206e7e30d3914ced238d1d0709c0b0d4c75 100644 (file)
@@ -1712,6 +1712,18 @@ scan_list(dbref player, char *command)
     }
   }
   ptr = atrname;
+  if (GoodObject(Division(player))) {
+    /* try division tree */
+    for (thing = Division(player); GoodObject(thing);
+        thing = Division(thing)) {
+      if (ScanFind(player, thing)) {
+        *ptr = '\0';
+        safe_str(atrname, tbuf, &tp);
+        ptr = atrname;
+      }
+    }
+  }
+  ptr = atrname;
   if ((Location(player) != MASTER_ROOM)
       && (Zone(Location(player)) != MASTER_ROOM)
       && (Zone(player) != MASTER_ROOM)) {
@@ -1851,6 +1863,20 @@ do_scan(dbref player, char *command, int flag)
     }
   }
   ptr = atrname;
+  if ((flag & CHECK_DIVISION) && GoodObject(Division(player))) {
+    /* try division tree */
+    notify(player, T("Matches on objects in the division tree:"));
+    for (thing = Division(player); GoodObject(thing);
+        thing = Division(thing)) {
+      if (ScanFind(player, thing)) {
+        *ptr = '\0';
+       notify_format(player, "%s  [%d:%s]",
+                     unparse_object(player, thing), num, atrname);
+       ptr = atrname;
+      }
+    }
+  }
+  ptr = atrname;
   if ((flag & CHECK_GLOBAL)
       && (Location(player) != MASTER_ROOM)
       && (Zone(Location(player)) != MASTER_ROOM)