Re: [CODE] Strange occurence

From: Ron Cole (rcole@EZY.NET)
Date: 04/06/98


>void elemental_portal(void)
>{
>  struct obj_data *portal;
>  struct time_info_data time_info;
>  int room;
>
>  room = number(4210, 4299);

Do all of these rooms exist?  Even if they do now, they might not someday.  Also
you need a real room number for obj_to_room and (I assume) send_to_room.  Try
something like this:

   int i = 0;
   while ((room = real_room(number(4210,4200)) == NOWHERE && i < 100)
     i++;
   if (room == NOWHERE) {
      mudlog("Could not find a valid room after 100 tries", BRF,
         LVL_IMMORT, TRUE);
      return;
   }

>  portal = read_object(4216, VIRTUAL);

You are creating objects and only using them once out of 24 hours, move this
inside the time check, and check the result for failure.

>
>  if (time_info.hours == 23) {

     portal = read_object(4216, VIRTUAL);
     if (portal == NOTHING) {
      mudlog("Could not create portal object", BRF,
         LVL_IMMORT, TRUE);
        return;
     }

>    sprintf(buf, "Elemental Portal appearing in room %d.", room);
>    mudlog(buf, BRF, LVL_IMMORT, TRUE);
>    obj_to_room(portal, room);
>    send_to_room("The very fabric of space is ripped apart as a shimmering portal appears.\r\n", room);
>  } else
>    return;
>}

You probably want better error messages, so you know what and where its trying
to do things.

Ron


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