ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/style.C
(Generate patch)

Comparing deliantra/server/random_maps/style.C (file contents):
Revision 1.16 by root, Sun Dec 31 18:13:27 2006 UTC vs.
Revision 1.17 by root, Sun Dec 31 19:02:24 2006 UTC

1
1/* 2/*
2 CrossFire, A Multiplayer game for X-windows 3 CrossFire, A Multiplayer game for X-windows
3 4
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
112 sprintf (style_file_full_path, "%s/maps%s", settings.datadir, style_file_path); 113 sprintf (style_file_full_path, "%s/maps%s", settings.datadir, style_file_path);
113 114
114 if (stat (style_file_full_path, &file_stat) == 0 && !S_ISDIR (file_stat.st_mode)) 115 if (stat (style_file_full_path, &file_stat) == 0 && !S_ISDIR (file_stat.st_mode))
115 style_map = maptile::load_map_sync (style_file_path); 116 style_map = maptile::load_map_sync (style_file_path);
116 117
117 if (!style_map) /* maybe we were given a directory! */ 118 if (!style_map) /* maybe we were given a directory! */
118 { 119 {
119 char **namelist; 120 char **namelist;
120 int n; 121 int n;
121 char style_dir_full_path[256]; 122 char style_dir_full_path[256];
122 123
215 * is actually preferable to an infinite loop. That is because 216 * is actually preferable to an infinite loop. That is because
216 * most servers will automatically restart in case of crash. 217 * most servers will automatically restart in case of crash.
217 * Change the logic on getting the random space - shouldn't make 218 * Change the logic on getting the random space - shouldn't make
218 * any difference, but this seems clearer to me. 219 * any difference, but this seems clearer to me.
219 */ 220 */
220 for (int i = 1000; --i; ) 221 for (int i = 1000; --i;)
221 { 222 {
222 object *new_obj = style->at (RANDOM () % style->width, RANDOM () % style->height).bot; 223 object *new_obj = style->at (RANDOM () % style->width, RANDOM () % style->height).bot;
223 224
224 if (new_obj) 225 if (new_obj)
225 return new_obj->head_ (); 226 return new_obj->head_ ();
226 } 227 }
227 228
228 // instead of crashing in the unlikely case, try to return *something* 229 // instead of crashing in the unlikely case, try to return *something*
229 return get_archetype ("blocked"); 230 return get_archetype ("blocked");
230} 231}
231

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines