On Fri, 5 Jun 1998, John Evans wrote:
>I spotted the GET_ROOM_VNUM() macro while hand patching in bp12->bpl13
>(AAAHHHH!!!!!) and decided that a GET_ROOM_NAME() macro would fit nicely.
>There are probably some others that could be made, but I'm too tired to
>think of them at the moment.
I'll eventually add more to cover most array handling cases.
>Anyway, perhaps add this to bpl14?
>
>#define GET_ROOM_NAME(rnum) \
> ((rnum) >= 0 && (rnum) <= top_of_world ? \
> world[(rnum)].name : "NoWhere")
I like the more instrusive:
#define GET_ROOM_NAME(rnum) (*(((rnum) < 0 || (rnum) > top_of_world) ?\
(log("SYSERR: Out of range world index %d at %s:%d.", (rnum), \
__FILE__, __LINE__), &world[0].name) : &world[(rnum)].name))
(Not sure if balanced ()'s there.)
That allows:
GET_ROOM_NAME(rnum) = str_dup("string");
and
fprintf(file, "%s\n", GET_ROOM_NAME(rnum));
Although the macro above might be (rightfully) called 'scary'...
--
George Greer, greerga@circlemud.org | Genius may have its limitations, but
http://patches.van.ml.org/ | stupidity is not thus handicapped.
http://www.van.ml.org/CircleMUD/ | -- Elbert Hubbard
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST