[CODE] help with whirlpool

From: Derek L. Karnes (dkarnes@mystech.com)
Date: 12/18/96


Ladies and gentlemen:

Been messing with this one off and on for a while, and I think the
problem is a flying pointer somewhere outside the function that 
corrupts the number. 
What I'm trying to accomplish is a simple teleport to a room within a
given zone (46, in this case) Neither one of these works.. am I missing
something simple, or do you think it is memory as I supposed above?
Using gdb and printing to_room after it has been assigned usually gives
me a number upward of 100000 (i.e garbage).



Attempt 1:
----------
SPECIAL(whirlpool)
{
  int room;
  struct char_data *vict;
  int spec_occured = FALSE, to_room = 0, i = 0;
  struct char_data *mobile = (struct char_data *) me;         

  if (!ch) return FALSE;
  room = ch->in_room;
  for (vict = world[room].people; vict; vict = vict->next_in_room)
    if (GET_LEVEL(vict) < LVL_IMMORT && vict !=mobile){
      char_from_room(ch);
    
      for (i = 0; i <= top_of_zone_table; i++)
        if (zone_table[i].number == 46)
          break;
      if (i >= 0 && i <= top_of_zone_table)
        {
          do
            {
              to_room = number(0, top_of_world);
              /* start hack that doesn't fix the problem anyway */
              /* dunno why, but i gets corrupted in 
               * number()?, so reset it */
              for (i = 0; i <= top_of_zone_table; i++)
                if (zone_table[i].number == 46)
                  break;
              /* end hack that doesn't fix the problem anyway */
            }  
          while( (IS_SET(world[to_room].room_flags,ROOM_PRIVATE))
                 ||(IS_SET(world[to_room].room_flags,ROOM_GODROOM))
                 ||(IS_SET(world[to_room].room_flags,ROOM_DEATH))
                 ||(IS_SET(world[to_room].room_flags,ROOM_NOMOB))
                 ||(world[to_room].zone != zone_table[i].number) );
        } 
      char_to_room(ch, to_room);
      send_to_char("A ravaging whirlpool sucks you under!\n\r", ch);
      send_to_char("You finally surface, sputtering...\n\r", ch);
      do_look(ch, NULL, 0, 0);
      spec_occured = TRUE;
    }
  return(spec_occured); 
}
----------

Attempt 2:
----------
SPECIAL(whirlpool)
{
  int room;
  struct char_data *vict;
  int spec_occured = FALSE, to_room = 0;
  struct char_data *mobile = (struct char_data *) me;         

  if (!ch) 
        return FALSE;
  room = ch->in_room;
  for (vict = world[room].people; vict; vict = vict->next_in_room)
    if (GET_LEVEL(vict) < LVL_IMMORT && vict !=mobile){
      char_from_room(ch);
      do
        {
         to_room = number(real_room(4600), real_room(4699));
        }  
       while( (IS_SET(world[to_room].room_flags,ROOM_PRIVATE))
                 ||(IS_SET(world[to_room].room_flags,ROOM_GODROOM))
                 ||(IS_SET(world[to_room].room_flags,ROOM_DEATH))
                 ||(IS_SET(world[to_room].room_flags,ROOM_NOMOB)));
      char_to_room(ch, to_room);
      send_to_char("A ravaging whirlpool sucks you under!\n\r", ch);
      send_to_char("You finally surface, sputtering...\n\r", ch);
      do_look(ch, NULL, 0, 0);
      spec_occured = TRUE;
    }
  return(spec_occured); 
}


----------

Any light you can shed would be appreciated.
-D
--

--    dkarnes@mystech.com
--    Serapis, Imp of Dark Pawns
--    Back up this weekend if all goes well :)
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST