Odd Loop

cyhawk <[email protected]>
Newsgroups gmane.games.devel.mud.rom
Message-ID <[email protected]>
hey everyone, Ok im creating my maps as a roguelike style, anyhow, im 
having a problem with the display for the map.
Basicly, if its like say, a 10x10 map, it displays perfectly, but if i 
change the room settings to say 12x20 or 70x30 It ends up in a loop, im 
rather confused with this perhaps the collective knowledge can come up 
with an answer.

The code is..
void do_thri_look(CHAR_DATA * ch, char *argument)
{
          char buf[MSL];
          int temp_x          = 0;
          int temp_y          = 0;
          int max_x           = ch->in_room->map_max_x;
          int max_y           = ch->in_room->map_max_y;
          int temp_sector     = 0;
         
         
          while (temp_x != max_x)
          {
                    while (temp_y != (max_x + 1))
                    {
                             
                              temp_sector = find_sector_number(temp_x, 
temp_y, ch);
                             
                              if (ch->x == temp_x && ch->y == temp_y)
                                        sprintf(buf, "{RX{x");
                              else if (temp_y == max_y)
                                        sprintf(buf, "%s%s{x\n\r",
                                                
exits_table[temp_sector].sector_color,
                                                
exits_table[temp_sector].sector_char);
                              else
                                        sprintf(buf, "%s%s{x",
                                                
exits_table[temp_sector].sector_color,
                                                
exits_table[temp_sector].sector_char);
                             
                              send_to_char(buf, ch);
                             
                              if (temp_y == max_y)
                              {
                                        temp_y = 0;
                                        temp_x++;
                                        break;
                              }
                              temp_y++;
                    }
        }
}

temp_sector returns the value of the room's X/Y cord (the number for 
displaying the charater) and the exits_table (bad name i know, i ripped 
it out of my Defunct Socketmud) contains a table with every sector, 
their charater, color, cant_move message, full name etc)

int find_sector_number(int x, int y,  CHAR_DATA * ch)
{
          int sector;
         
          sector = ch->in_room->map[x][y];        
         
          return sector;
}

i *think* the problem is due to the buffer crashing out maybe?
I've tried forcing the look command to display only say max_x = 10/max_x 
= 10 and it works, but if i force it to another value it also ends up 
looping.

Any Ideas? Thanks =)

-Thri
-- 
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.