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.23 by root, Wed Feb 14 01:33:24 2007 UTC vs.
Revision 1.24 by root, Sat Feb 17 23:32:11 2007 UTC

201 style_map->load_sync (); 201 style_map->load_sync ();
202 style_map->deactivate (); 202 style_map->deactivate ();
203 } 203 }
204 204
205 return style_map; 205 return style_map;
206
207} 206}
208
209/* picks a random object from a style map.
210 * Redone by MSW so it should be faster and not use static
211 * variables to generate tables.
212 */
213object *
214pick_random_object (maptile *style)
215{
216 /* while returning a null object will result in a crash, that
217 * is actually preferable to an infinite loop. That is because
218 * most servers will automatically restart in case of crash.
219 * Change the logic on getting the random space - shouldn't make
220 * any difference, but this seems clearer to me.
221 */
222 for (int i = 1000; --i;)
223 {
224 object *new_obj = style->at (rndm (style->width), rndm (style->height)).bot;
225
226 if (new_obj)
227 return new_obj->head_ ();
228 }
229
230 // instead of crashing in the unlikely case, try to return *something*
231 return get_archetype ("blocked");
232}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines