Re: [CODE] Ferry code

From: Thomas Arp (t_arp@stofanet.dk)
Date: 11/05/02


From: "George Greer" <greerga@CIRCLEMUD.ORG>
> On Wed, 6 Nov 2002, Thomas Arp wrote:
>
> >May I suggest a small macro to make this easier to read:
> >
> >#define FERRY ferrys[onferrynum]
>
> Use a pointer, such as:
>
>   struct ferry_data_thingie *ferry;
>   ...
>   ferry = &ferrys[onferrynum];
>   if (time_info.hours == ferry->f_time_leave_from_room) {
>
> A #define would make sense if different values could be used in place of
> 'onferrynum', but in this case that's what you're trying to get rid of.
>
I thought onferrynum was some kind of iterator, thus the define.

> >    for (tobj = world[from_room].contents;
> >         tobj && !found; tobj = tobj->next_content)
> >      if (GET_OBJ_VNUM(tobj)==FERRY_VNUM)
> >        found = TRUE;
> >    if (found)
> >      extract_obj(tobj);
>
> You're extracting the wrong object.  Hint:
>
<snip>
Oh yes, I should have thought of that :(

Ok, I guess this is a better solution:


    for (tobj = world[from_room].contents;
         tobj; tobj = tobj->next_content)
      if (GET_OBJ_VNUM(tobj)==FERRY_VNUM)
        break;

    if (tobj)
      extract_obj(tobj);

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