Difference for random_maps/style.c from version 1.19 to 1.20


version 1.19 version 1.20
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_style_c =   * static char *rcsid_style_c =
  *   "$Id: style.c,v 1.19 2002/07/15 04:25:40 mwedel Exp $";   *   "$Id: style.c,v 1.20 2004/06/11 06:12:57 mwedel Exp $";
  */   */
   
 /*  /*
Line 269
 
Line 269
  * variables to generate tables.   * variables to generate tables.
  */   */
 object *pick_random_object(mapstruct *style) {  object *pick_random_object(mapstruct *style) {
     int x,y, i;      int x,y, limit=0;
     object *new_obj;      object *new_obj;
   
     /* If someone makes a style map that is empty, this will loop forever,      /* while returning a null object will result in a crash, that
      * but the callers will crash if we return a null object, so either       * is actually preferable to an infinite loop.  That is because
      * way is not good.       * most servers will automatically restart in case of crash.
        * Change the logic on getting the random space - shouldn't make
        * any difference, but this seems clearer to me.
      */       */
     do {      do {
  i = RANDOM () % (MAP_WIDTH(style) * MAP_HEIGHT(style));   limit++;
    x = RANDOM() % MAP_WIDTH(style);
  x = i / MAP_HEIGHT(style);   y = RANDOM() % MAP_HEIGHT(style);
  y = i % MAP_HEIGHT(style);  
  new_obj = get_map_ob(style,x,y);   new_obj = get_map_ob(style,x,y);
     } while (new_obj == NULL);      } while (new_obj == NULL && limit<1000);
     if (new_obj->head) return new_obj->head;      if (new_obj->head) return new_obj->head;
     else return new_obj;      else return new_obj;
 }  }


Legend:
line(s) removed in v.1.19 
line(s) changed
 line(s) added in v.1.20

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:58