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.20 by pippijn, Sat Jan 6 14:42:30 2007 UTC vs.
Revision 1.22 by root, Sat Jan 27 02:19:37 2007 UTC

1
2/* 1/*
3 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
4 3 *
5 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
6 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
7 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
8 7 *
9 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version. 11 * (at your option) any later version.
13 12 *
14 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details. 16 * GNU General Public License for more details.
18 17 *
19 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 21 *
23 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
24*/ 23 */
25 24
26#include <global.h> 25#include <global.h>
27#include <random_map.h> 26#include <random_map.h>
28#include <dirent.h> 27#include <dirent.h>
29#include <sys/stat.h> 28#include <sys/stat.h>
149 if (only_subdirs) 148 if (only_subdirs)
150 style_map = 0; 149 style_map = 0;
151 else 150 else
152 { 151 {
153 strcat (style_file_path, "/"); 152 strcat (style_file_path, "/");
154 strcat (style_file_path, namelist[RANDOM () % n]); 153 strcat (style_file_path, namelist[rndm (n)]);
155 style_map = maptile::find_sync (style_file_path); 154 style_map = maptile::find_sync (style_file_path);
156 } 155 }
157 } 156 }
158 else 157 else
159 { /* find the map closest in difficulty */ 158 { /* find the map closest in difficulty */
167 if ((mfile_name - 1) == NULL) 166 if ((mfile_name - 1) == NULL)
168 { /* since there isn't a sequence, */ 167 { /* since there isn't a sequence, */
169 int q; 168 int q;
170 169
171 /*pick one at random to recurse */ 170 /*pick one at random to recurse */
172 style_map = find_style (style_file_path, namelist[RANDOM () % n], difficulty); 171 style_map = find_style (style_file_path, namelist[rndm (n)], difficulty);
173 for (q = 0; q < n; q++) 172 for (q = 0; q < n; q++)
174 free (namelist[q]); 173 free (namelist[q]);
175 free (namelist); 174 free (namelist);
176 return style_map; 175 return style_map;
177 } 176 }
222 * Change the logic on getting the random space - shouldn't make 221 * Change the logic on getting the random space - shouldn't make
223 * any difference, but this seems clearer to me. 222 * any difference, but this seems clearer to me.
224 */ 223 */
225 for (int i = 1000; --i;) 224 for (int i = 1000; --i;)
226 { 225 {
227 object *new_obj = style->at (RANDOM () % style->width, RANDOM () % style->height).bot; 226 object *new_obj = style->at (rndm (style->width), rndm (style->height)).bot;
228 227
229 if (new_obj) 228 if (new_obj)
230 return new_obj->head_ (); 229 return new_obj->head_ ();
231 } 230 }
232 231

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines