Re: [CODE] Ferry code

From: George Greer (greerga@circlemud.org)
Date: 11/05/02


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.

>    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:

#include <stdio.h>
int main(void) {
  int lal[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  int found = 0, i;

  for (i = 0; i < 10 && !found; i++)
    if (lal[i] == 5) { found = 1; }
  if (found)
    printf("%d found\n", lal[i]);
  return 0;
}


--
George Greer
greerga@circlemud.org

--
   +---------------------------------------------------------------+
   | 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