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.17 by root, Sun Dec 31 19:02:24 2006 UTC vs.
Revision 1.19 by root, Thu Jan 4 16:19:32 2007 UTC

95} 95}
96 96
97maptile * 97maptile *
98find_style (const char *dirname, const char *stylename, int difficulty) 98find_style (const char *dirname, const char *stylename, int difficulty)
99{ 99{
100 char style_file_path[256]; 100 char style_file_path[1024];
101 char style_file_full_path[256]; 101 char style_file_full_path[1024];
102 maptile *style_map = NULL; 102 maptile *style_map = NULL;
103 struct stat file_stat; 103 struct stat file_stat;
104 int i, only_subdirs = 0; 104 int i, only_subdirs = 0;
105 105
106 /* if stylename exists, set style_file_path to that file. */ 106 /* if stylename exists, set style_file_path to that file. */
111 111
112 /* is what we were given a directory, or a file? */ 112 /* is what we were given a directory, or a file? */
113 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);
114 114
115 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))
116 style_map = maptile::load_map_sync (style_file_path); 116 style_map = maptile::find_sync (style_file_path);
117 117
118 if (!style_map) /* maybe we were given a directory! */ 118 if (!style_map) /* maybe we were given a directory! */
119 { 119 {
120 char **namelist; 120 char **namelist;
121 int n; 121 int n;
149 style_map = 0; 149 style_map = 0;
150 else 150 else
151 { 151 {
152 strcat (style_file_path, "/"); 152 strcat (style_file_path, "/");
153 strcat (style_file_path, namelist[RANDOM () % n]); 153 strcat (style_file_path, namelist[RANDOM () % n]);
154 style_map = maptile::load_map_sync (style_file_path); 154 style_map = maptile::find_sync (style_file_path);
155 } 155 }
156 } 156 }
157 else 157 else
158 { /* find the map closest in difficulty */ 158 { /* find the map closest in difficulty */
159 int min_dist = 32000, min_index = -1; 159 int min_dist = 32000, min_index = -1;
187 187
188 /* presumably now we've found the "best" match for the 188 /* presumably now we've found the "best" match for the
189 difficulty. */ 189 difficulty. */
190 strcat (style_file_path, "/"); 190 strcat (style_file_path, "/");
191 strcat (style_file_path, namelist[min_index]); 191 strcat (style_file_path, namelist[min_index]);
192 style_map = maptile::load_map_sync (style_file_path); 192 style_map = maptile::find_sync (style_file_path);
193 } 193 }
194 194
195 for (i = 0; i < n; i++) 195 for (i = 0; i < n; i++)
196 free (namelist[i]); 196 free (namelist[i]);
197 197
198 free (namelist); 198 free (namelist);
199 } 199 }
200 200
201 if (style_map) 201 if (style_map)
202 {
203 style_map->load_sync ();
202 style_map->deactivate (); 204 style_map->deactivate ();
205 }
203 206
204 return style_map; 207 return style_map;
205 208
206} 209}
207 210

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines