1 | /* |
1 | /* |
2 | * static char *rcsid_style_c = |
2 | * static char *rcsid_style_c = |
3 | * "$Id: style.c,v 1.1.1.1 2006/02/03 07:14:23 root Exp $"; |
3 | * "$Id: style.c,v 1.1.1.2 2006/02/22 18:03:16 elmex Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
137 | styles = style_map; |
137 | styles = style_map; |
138 | } |
138 | } |
139 | return style_map; |
139 | return style_map; |
140 | } |
140 | } |
141 | |
141 | |
142 | mapstruct *find_style(char *dirname,char *stylename,int difficulty) { |
142 | mapstruct *find_style(const char *dirname,const char *stylename,int difficulty) { |
143 | char style_file_path[256]; |
143 | char style_file_path[256]; |
144 | char style_file_full_path[256]; |
144 | char style_file_full_path[256]; |
145 | mapstruct *style_map = NULL; |
145 | mapstruct *style_map = NULL; |
146 | struct stat file_stat; |
146 | struct stat file_stat; |
147 | int i, only_subdirs=0; |
147 | int i, only_subdirs=0; |
… | |
… | |
152 | else /* otherwise, just use the dirname. We'll pick a random stylefile.*/ |
152 | else /* otherwise, just use the dirname. We'll pick a random stylefile.*/ |
153 | sprintf(style_file_path,"%s",dirname); |
153 | sprintf(style_file_path,"%s",dirname); |
154 | |
154 | |
155 | /* is what we were given a directory, or a file? */ |
155 | /* is what we were given a directory, or a file? */ |
156 | sprintf(style_file_full_path,"%s/maps%s",settings.datadir,style_file_path); |
156 | sprintf(style_file_full_path,"%s/maps%s",settings.datadir,style_file_path); |
157 | stat(style_file_full_path,&file_stat); |
157 | if (stat(style_file_full_path, &file_stat) == 0 |
158 | |
|
|
159 | if(! (S_ISDIR(file_stat.st_mode))) { |
158 | && !S_ISDIR(file_stat.st_mode)) { |
160 | style_map=load_style_map(style_file_path); |
159 | style_map=load_style_map(style_file_path); |
161 | } |
160 | } |
162 | if(style_map == NULL) /* maybe we were given a directory! */ |
161 | if(style_map == NULL) /* maybe we were given a directory! */ |
163 | { |
162 | { |
164 | char **namelist; |
163 | char **namelist; |