Crossfire Server, Branches 1.12
R18729
|
#include <global.h>
#include <random_map.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../include/autoconf.h"
Go to the source code of this file.
Functions | |
mapstruct * | find_style (const char *dirname, const char *stylename, int difficulty) |
void | free_style_maps (void) |
int | load_dir (const char *dir, char ***namelist, int skip_dirs) |
mapstruct * | load_style_map (char *style_name) |
object * | pick_random_object (mapstruct *style) |
static int | pointer_strcmp (const void *p1, const void *p2) |
Variables | |
mapstruct * | styles = NULL |
Those functions deal with style for random maps.
Definition in file style.c.
mapstruct* find_style | ( | const char * | dirname, |
const char * | stylename, | ||
int | difficulty | ||
) |
Loads and returns the map requested. Dirname, for example, is "/styles/wallstyles", stylename, is, for example, "castle", difficulty is -1 when difficulty is irrelevant to the style. If dirname is given, but stylename isn't, and difficult is -1, it returns a random style map. Otherwise, it tries to match the difficulty given with a style file, named style_name_# where # is an integer
dirname | where to look. |
stylename | style to use, can be NULL. |
difficulty | style difficulty. |
Definition at line 177 of file style.c.
References Settings::datadir, load_dir(), load_style_map(), S_ISDIR, settings, and snprintf().
Referenced by make_map_floor(), make_map_walls(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), place_specials_in_map(), place_treasure(), put_decor(), and put_doors().
void free_style_maps | ( | void | ) |
Frees cached style maps.
Definition at line 300 of file style.c.
References delete_map(), llevDebug, LOG(), and mapdef::next.
Referenced by cleanup().
int load_dir | ( | const char * | dir, |
char *** | namelist, | ||
int | skip_dirs | ||
) |
This is our own version of scandir/select_regular_files/sort. To support having subdirectories in styles, we need to know if in fact the directory we read is a subdirectory. However, we can't get that through the normal dirent entry. So instead, we do our own where we do have the full directory path so can do stat calls to see if in fact it is a directory. dir is the name of the director to scan. namelist is the array of file names returned. IT needs to be freed by the caller. skip_dirs controls our behavioru - if nonzero, we don't skip any subdirectories - if zero, we store those away, since there are cases where we want to choose a random directory.
dir | directory to list. | |
[out] | namelist | list of files found. |
skip_dirs | if non 0, don't list directories. |
Definition at line 83 of file style.c.
References closedir(), dirent::d_name, NAME_MAX, opendir(), pointer_strcmp(), readdir(), S_ISDIR, snprintf(), and strdup_local().
Referenced by find_style().
mapstruct* load_style_map | ( | char * | style_name | ) |
Loads specified map (or take it from cache list).
style_name | map to load. |
Definition at line 131 of file style.c.
References first_map, load_original_map(), MAP_STYLE, mapdef::next, mapdef::path, and styles.
Referenced by find_style().
Picks a random object from a style map. Redone by MSW so it should be faster and not use static variables to generate tables.
style | map to pick from. |
Definition at line 275 of file style.c.
References GET_MAP_OB, obj::head, MAP_HEIGHT, and MAP_WIDTH.
Referenced by make_map_floor(), make_map_walls(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), put_decor(), and put_doors().
|
static |
Char comparison for sorting purposes.
p1 | |
p2 | pointers to compare. |
Definition at line 53 of file style.c.
Referenced by load_dir().
mapstruct* styles = NULL |
Loaded styles maps cache, to avoid having to load all the time.
Definition at line 122 of file style.c.
Referenced by command_style_map_info(), and load_style_map().