[Code] More Versatile Coding

From: Lord Kyu (Sythrel@Adelphia.net)
Date: 10/15/00


        Looking through the code when I first got it, I noticed a couple of
things that might have been done a little differently to allow for more
versatility with the code.  The example that stands out in this case,
would be the load_into_inventory setting in config.c, which is called in
the act.wizard.c file.  Below is my take of how I would have done the
code.

[Begin Code Here]

// In config.c

- /*
-  * Whether you want items that immortals load to appear on the grounds
or not.
-  * It is most likely best to set this to 'YES' so that something else
doesn't
-  * grab the item before the immortal does, but that also means people
will be
-  * able to carry around things like boards.  That's not necessarily a
bad
-  * thing, but this will be left at a default of 'NO' for historic
reasons.
-  */
- int load_into_inventory = NO;

// In act.wizard.c (external vars)

  extern int circle_restrict;
- extern int load_into_inventory;
  extern int buf_switches, buf_largecount, buf_overflows;

// In act.wizard.c (do_load function)

  act("$n has created $N!", FALSE, ch, 0, mob, TO_ROOM);
  act("You create $N.", FALSE, ch, 0, mob, TO_CHAR);
+ } else if (is_abbrev(buf, "inv")) {
+   if ((r_num = real_object(number)) < 0) {
+     send_to_char("There is no object with that number.\r\n", ch);
+     return;
+   }
+   obj = read_object(r_num, REAL);
+   obj_to_char(obj, ch);
+   act("$n makes a strange magical gesture.", TRUE, ch, 0, 0, TO_ROOM);
+   act("$n has created $p, and places it in $s inventory.", FALSE, ch,
obj, 0, TO_ROOM);
+   act("You create $p, and place it in your inventory.", FALSE, ch,
obj, 0, TO_CHAR);
  } else if (is_abbrev(buf, "obj")) {
    if ((r_num = real_object(number)) < 0) {
      send_to_char("There is no object with that number.\r\n", ch);
      return;
    }
    obj = read_object(r_num, REAL);
-   if (load_into_inventory)
-      obj_to_char(obj, ch);
-    else
-      obj_to_room(obj, ch->in_room);
+   obj_to_room(obj, ch->in_room);
    act("$n makes a strange magical gesture.", TRUE, ch, 0, 0, TO_ROOM);
    act("$n has created $p!", FALSE, ch, obj, 0, TO_ROOM);
    act("You create $p.", FALSE, ch, obj, 0, TO_CHAR);
  } else
-     send_to_char("That'll have to be either 'obj' or 'mob'.\r\n", ch);
+     send_to_char("That'll have to be either 'obj' or 'inv' or
'mob'.\r\n", ch);

--

 Lord Kyu 


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT