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.4 by root, Thu Sep 14 22:34:02 2006 UTC vs.
Revision 1.5 by root, Sat Sep 16 22:24:13 2006 UTC

109 * Otherwise, it tries to match the difficulty given with a style 109 * Otherwise, it tries to match the difficulty given with a style
110 * file, named style_name_# where # is an integer 110 * file, named style_name_# where # is an integer
111 */ 111 */
112 112
113/* remove extern, so visible to command_style_map_info function */ 113/* remove extern, so visible to command_style_map_info function */
114mapstruct *styles = NULL; 114maptile *styles = NULL;
115 115
116 116
117mapstruct * 117maptile *
118load_style_map (char *style_name) 118load_style_map (char *style_name)
119{ 119{
120 mapstruct *style_map; 120 maptile *style_map;
121 121
122 /* Given a file. See if its in memory */ 122 /* Given a file. See if its in memory */
123 for (style_map = styles; style_map != NULL; style_map = style_map->next) 123 for (style_map = styles; style_map != NULL; style_map = style_map->next)
124 { 124 {
125 if (!strcmp (style_name, style_map->path)) 125 if (!strcmp (style_name, style_map->path))
127 } 127 }
128 style_map = load_original_map (style_name, MAP_STYLE); 128 style_map = load_original_map (style_name, MAP_STYLE);
129 /* Remove it from global list, put it on our local list */ 129 /* Remove it from global list, put it on our local list */
130 if (style_map) 130 if (style_map)
131 { 131 {
132 mapstruct *tmp; 132 maptile *tmp;
133 133
134 if (style_map == first_map) 134 if (style_map == first_map)
135 first_map = style_map->next; 135 first_map = style_map->next;
136 else 136 else
137 { 137 {
143 styles = style_map; 143 styles = style_map;
144 } 144 }
145 return style_map; 145 return style_map;
146} 146}
147 147
148mapstruct * 148maptile *
149find_style (const char *dirname, const char *stylename, int difficulty) 149find_style (const char *dirname, const char *stylename, int difficulty)
150{ 150{
151 char style_file_path[256]; 151 char style_file_path[256];
152 char style_file_full_path[256]; 152 char style_file_full_path[256];
153 mapstruct *style_map = NULL; 153 maptile *style_map = NULL;
154 struct stat file_stat; 154 struct stat file_stat;
155 int i, only_subdirs = 0; 155 int i, only_subdirs = 0;
156 156
157 /* if stylename exists, set style_file_path to that file. */ 157 /* if stylename exists, set style_file_path to that file. */
158 if (stylename && strlen (stylename) > 0) 158 if (stylename && strlen (stylename) > 0)
253/* picks a random object from a style map. 253/* picks a random object from a style map.
254 * Redone by MSW so it should be faster and not use static 254 * Redone by MSW so it should be faster and not use static
255 * variables to generate tables. 255 * variables to generate tables.
256 */ 256 */
257object * 257object *
258pick_random_object (mapstruct *style) 258pick_random_object (maptile *style)
259{ 259{
260 int x, y, limit = 0; 260 int x, y, limit = 0;
261 object *new_obj; 261 object *new_obj;
262 262
263 /* while returning a null object will result in a crash, that 263 /* while returning a null object will result in a crash, that
282 282
283 283
284void 284void
285free_style_maps (void) 285free_style_maps (void)
286{ 286{
287 mapstruct *next; 287 maptile *next;
288 int style_maps = 0; 288 int style_maps = 0;
289 289
290 /* delete_map will try to free it from the linked list, 290 /* delete_map will try to free it from the linked list,
291 * but won't find it, so we need to do it ourselves 291 * but won't find it, so we need to do it ourselves
292 */ 292 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines