Re: Trouble determining how to express something.

From: Thomas Arp (t_arp@stofanet.dk)
Date: 08/30/02


From: "Mathew Earle Reuther" <graymere@ZIPCON.NET>
>   if ((zone_table[world[EXIT(ch,dir)->to_room].zone].status_mode != 1) &&

You should avoid all uses of magic numbers (in this case 1) in your code.
Also, status_mode could with little effort be made into a bitvector, making
it possible to set more flags than just this open/closed. Ie:

#define ZONE_FLAG_CLOSED (1<<0)
#define ZONE_NO_SUMMON   (1<<1)
#define ZONE_NO_MAGIC    (1<<2)

#define ZONE_FLAGS(zrn) (zone_table[(zrn)].status_mode)
#define ZONE_FLAGGED(zrn, flag) (IS_SET(ZONE_FLAGS(zrn), (flag))

The check above can the be written as
   if (ZONE_FLAGGED(world[EXIT(ch,dir)->to_room].zone, ZONE_FLAG_CLOSED)) &&

To further facilitate this, circle already has some very nice utilities
for handling bitvectors - sprintbits, asciiflag_conv, etc.

Welcor

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT