View Single Post
  #14  
Old 11-22-2002, 11:58 PM
neotokyo
Hill Giant
 
Join Date: Oct 2002
Posts: 118
Default

Quote:
Originally Posted by kathgar
Code:
Door * GetDoorByDoorID(const *zone_name,uint32 door_id)
{/*god I hate editing code this way*/
         Door* door = NULL;
         for(uint32 i=0; i<max_door_type;i++)
         {
                  door = GetDoorDBID(i);
                  if(door)
                  {
                        if(door->db_id==door_id && strcasecmp(door->zone_name, zone_name)==0)
                               return door;
                  }
         } 
         return NULL;//if we don't find it
}
we have a winner )

the problem was:
Code:
Door* door = GetDoorDBID(i);

since the for-loop doesnt leave the scope, the variable door is intialized using GetDoorDBID(i) (which in this case i == 0), and then never again touched. so all you do is that you run the loop thru from i=0 to i=max_door_type, but with always the same door.


take care,
neo
Reply With Quote