Crossfire Server, Trunk  1.75.0
mapper.cpp File Reference
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include "global.h"
#include "sproto.h"
#include "image.h"
#include "quest.h"
#include <gd.h>
#include <gdfonts.h>
#include <gdfontl.h>
#include <gdfontg.h>
#include "inja.hpp"
#include <map>
#include <set>
+ Include dependency graph for mapper.cpp:

Go to the source code of this file.

Data Structures

class  pageToRender
 One page to render, with its parameters. More...
 
struct  struct_equipment
 One special item (weapon, shield, ...). More...
 
struct  struct_map_in_quest
 Link between a quest and a map. More...
 
struct  struct_map_in_quest_list
 Utility structure to group map-quest link structure. More...
 
struct  struct_map_info
 Map information. More...
 
struct  struct_map_list
 List of maps. More...
 
struct  struct_npc_info
 Information about a NPC with a custom message. More...
 
struct  struct_quest
 One quest. More...
 
struct  struct_race
 One monster race in the maps. More...
 
struct  struct_race_list
 Collection of races. More...
 
struct  struct_region_info
 Region information. More...
 
struct  struct_slaying_info
 slaying information. More...
 

Macros

#define S_CONNECT   4
 
#define S_CONTAINER   2
 
#define S_DETECTOR   3
 
#define S_DOOR   0
 Connection/slaying information. More...
 
#define S_KEY   1
 
#define S_MAX   5
 
#define SIZE   50
 
#define size_large   sizes[0]
 
#define size_small   sizes[1]
 

Typedefs

typedef std::vector< struct_npc_info * > npc_list
 List of NPCs with a custom message. More...
 

Enumerations

enum  output_format_type { OF_PNG = 0, OF_JPG = 1 }
 Map output formats. More...
 
enum  SearchType {
  SearchType::Region = 1, SearchType::Map, SearchType::Item, SearchType::Monster,
  SearchType::Quest, SearchType::Count
}
 Search values, for the JS search engine. More...
 

Functions

static void add_map (struct_map_info *info, struct_map_list *list)
 Adds a map to specified array, if it isn't already. More...
 
static void add_map_to_quest (struct_map_info *map, const char *name, const char *description)
 Links a map to a quest. More...
 
static void add_map_to_region (struct_map_info *map, region *reg)
 Links a map to a region. More...
 
static void add_map_to_slaying (struct_slaying_info *info, int item, struct_map_info *map)
 Adds the specified map to the slaying information if not already present. More...
 
static void add_monster (object *monster, struct_map_info *map)
 Adds a monster to the monster list. More...
 
static void add_npc_to_map (npc_list *list, const object *npc)
 Add the specified NPC to the list. More...
 
static void add_one_item (object *item, struct_map_info *map)
 Adds an item to the list of special items. More...
 
static void add_race_to_list (struct_race *race, struct_race_list *list, int check)
 Appends a race to a race list. More...
 
static void add_region_link (mapstruct *source, mapstruct *dest)
 Creates a link between two maps if they are on different regions. More...
 
static void add_slaying (struct_map_info *map, object *item)
 Adds the item's information to the map. More...
 
void add_template_to_render (const std::string &template_name, const std::string &output_name, const std::string &param)
 Push the specified template, with optional param, on the list of files to process. More...
 
static void add_to_struct_map_in_quest_list (struct_map_in_quest_list *list, struct_map_in_quest *item)
 
static void append_map_list (struct_map_list &dest, struct_map_list &src)
 Append the contents of src to dest. More...
 
static void check_equipment (object *item, struct_map_info *map)
 Checks if item and its inventory are worthy to be listed. More...
 
static void check_slaying_inventory (struct_map_info *map, object *item)
 Recursively checks if the object should be considered for slaying information. More...
 
static int compare_map_info (const struct_map_info *left, const struct_map_info *right)
 Compares struct_map_info according to the map name or the path if equal. More...
 
static void create_destination (void)
 Ensures destination directory exists. More...
 
static nlohmann::json create_map_in_quest_array (struct_map_in_quest_list &list)
 Return an array of map-in-quest items. More...
 
static struct_map_infocreate_map_info (void)
 Returns an initialised struct_map_info. More...
 
static nlohmann::json create_map_object (struct_map_info *map, const std::string &key)
 Return a JSON map object. More...
 
static nlohmann::json create_maps_array (struct_map_list &maps)
 Return an array of map identifiers. More...
 
static nlohmann::json create_npc_array (npc_list &list)
 Return an array of NPC information. More...
 
static struct_npc_infocreate_npc_info (const object *npc)
 Create the struct_npc_info from the specified NPC. More...
 
static nlohmann::json create_quest_object (struct_quest *quest, const std::string &key)
 Return a JSON quest object. More...
 
static nlohmann::json create_race_array (struct_race_list &list)
 Return an array of monster information. More...
 
static nlohmann::json create_region_array (const std::set< region * > &regions)
 Return an array of region identifiers. More...
 
static struct_map_infocreate_tiled_map (void)
 Create a new tiled map and link it to the tiled map list. More...
 
static void define_quest (const char *name, struct_map_info *mainmap, const char *description)
 Sets the main map for a quest. More...
 
void do_auto_apply (mapstruct *m)
 
static void do_exit_map (mapstruct *map)
 Proceses exit / road / blocking information for specified map into the global infomap map. More...
 
static void do_help (const char *program)
 Prints usage information, and exit. More...
 
static void do_parameters (int argc, char **argv)
 Handles command-line parameters. More...
 
static void do_tiled_map_picture (struct_map_info *map)
 Generates the large and small pictures for a tiled map. More...
 
static void dump_unused_maps (void)
 Writes the list of unused maps, maps found in the directories but not linked from the other maps. More...
 
static struct_equipmentensure_unique (struct_equipment *item)
 Searches the item list for an identical item, except maps. More...
 
static void fill_json (nlohmann::json &json)
 Add all global variables to the data available to templates. More...
 
static void fill_reverse_maps (struct_map_list &list)
 Fill the reverse_maps array with the provided list. More...
 
static struct_map_infofind_map_by_key (const std::string &key)
 Get the map with the specified key, nullptr if not found. More...
 
static void find_maps (const char *from)
 Recursively find all all maps in a directory. More...
 
static struct_questfind_quest_info (const char *name)
 Gets the information for a quest if it exists. More...
 
static regionfind_region_by_key (const std::string &key)
 Get the region with the specified key, nullptr if not found. More...
 
static void fix_exits_for_map (struct_map_info *current, struct_map_list *from, int is_from)
 Changes for the list all maps to the tiled map they are part of, if applicable. More...
 
static void fix_exits_to_tiled_maps (void)
 Changes all exits to maps in a tiled map to point directly to the tiled map. More...
 
static void fix_map_names (void)
 Ensures all maps have a name (if there was a limit to map processing, some maps will have a NULL name which causes issues). More...
 
static void fix_tiled_map (void)
 Ensures all tiled maps have a name, a region, a filename and a path. More...
 
static void fix_tiled_map_monsters (void)
 Makes all monsters point to tiled maps instead of map when appliable, and merge map monster to tiled map. More...
 
static void free_equipment (struct_equipment *equip)
 Frees a struct_equipment. More...
 
static nlohmann::json generate_page_and_link (inja::Arguments &args)
 Create a link to a page, generating it if needed. More...
 
static nlohmann::json generate_picture_link (inja::Arguments &args)
 Return the link to the picture of the specified item. More...
 
static void generate_picture_path (const char *path, size_t pic_size, char *out, size_t len)
 
static int get_elevation_color (int elevation, gdImagePtr elevationmap)
 Gets the color for an elevation. More...
 
static struct_equipmentget_equipment (void)
 Gets an empty struct_equipment. More...
 
static struct_map_infoget_map_info (const char *path)
 Gets or creates if required the info structure for a map. More...
 
static struct_questget_quest_info (const char *name)
 Gets the information for a quest, create the field if needed. More...
 
static struct_raceget_race (const char *name)
 Returns the race for specified name. More...
 
static struct_slaying_infoget_slaying_struct (const char *slaying)
 Returns a struct_slaying_info for specified slaying. More...
 
static inja::Template get_template (const std::string &filename)
 
static void init_map_list (struct_map_list *list)
 Initialises a list structure. More...
 
static void init_race_list (struct_race_list *list)
 Blanks a struct_race_list. More...
 
static void init_renderer_env ()
 Initialize env and set various callbacks and options. More...
 
static void init_struct_map_in_quest_list (struct_map_in_quest_list *list)
 
static int is_blocking (object *item)
 Checks if item blocks movement or not. More...
 
static int is_road (object *item)
 Checks if object is considered a road or not. More...
 
static int is_slaying (object *item)
 Is the slaying field relevant for this item? More...
 
static int is_special_equipment (object *item)
 
static void list_map (const char *path)
 Marks specified path as processed. More...
 
int main (int argc, char **argv)
 
static void merge_tiled_maps (struct_map_info *map, struct_map_info *tiled_map)
 Merge two tiled maps groups. More...
 
static std::string path_from_current (const std::string &path)
 Compute the relative path from the specified file to the current file. More...
 
static void process_map (struct_map_info *info)
 Processes a map. More...
 
static void process_map_lore (struct_map_info *map)
 Extracts from the map's lore quest information if found. More...
 
static void quest_callback (const quest_definition *quest, void *)
 
static void relative_path (const char *from, const char *to, char *result)
 Computes the shortest path from one file to another. More...
 
static const char * remove_trailing_slash (const char *path)
 
static void save_picture (FILE *file, gdImagePtr pic)
 Saves a map to a file, based on jpg/png settings. More...
 
static bool sort_equipment (const struct_equipment *l, const struct_equipment *r)
 Sort 2 struct_equipment. More...
 
static int sort_map_info (const void *left, const void *right)
 Sorts the struct_map_info according to the map name or the path if equal. More...
 
static int sort_race (const void *a, const void *b)
 Sort 2 struct_race. More...
 
static int sort_region (const void *left, const void *right)
 Sorts an array of struct_region_info by region name. More...
 
static int sort_slaying (const void *left, const void *right)
 Helper function to sort an array of struct_slaying_info. More...
 
static int sort_struct_map_in_quest (const void *left, const void *right)
 Sorts 2 struct_map_in_quest, on the map's name or path. More...
 
static int sort_struct_quest (const void *left, const void *right)
 Sorts 2 struct_quest, on the map's name or path. More...
 
static std::vector< std::string > split (const std::string &field, const std::string &by)
 
static std::string templates_root ("templates/")
 Directory to get templates from, with a leading /. More...
 
static int tiled_map_need_pic (struct_map_info *map)
 
static void write_pictures_from_real_size (const char *path, gdImagePtr real, int width, int height)
 
static void write_tiled_map_page (struct_map_info *map)
 Writes the page for a tiled map group. More...
 
static void write_tiled_maps (void)
 Outputs all tiled map pages. More...
 
static void write_world_info (void)
 Writes the exit information world map. More...
 
static void write_world_map (void)
 Generates a big world map. More...
 
static const char * yesno (int value)
 Helper to write yes/no. More...
 

Variables

static nlohmann::json all_data
 All JSON data available to templates. More...
 
static bool build_search_file = false
 If set, will build the 'search_data.js' file. More...
 
static int cached_pics = 0
 Non recreated pics. More...
 
static int color_blocking
 Block all movement. More...
 
static int color_linked_exit
 Exit leading to another map. More...
 
static int color_road
 Road or equivalent. More...
 
static int color_slowing
 Slows movement. More...
 
static int color_unlinked_exit
 Color for exits without a path set. More...
 
static int created_pics = 0
 Picture statistics. More...
 
static bool detail_quests = false
 Whether to show all quests details or not. More...
 
static bool display_rendered_template = false
 Whether to display the template to be rendered or not. More...
 
static bool do_regions_link = false
 
static int ** elevation_info
 All elevation spots in the "world_" maps. More...
 
static int elevation_max
 Lowest elevation found. More...
 
static int elevation_min
 Maximal elevation found. More...
 
static std::shared_ptr< inja::Environment > env
 Rendering environment. More...
 
static int force_pics = 0
 To force picture regeneration even if map didn't change. More...
 
static std::vector< char * > found_maps
 Maps found in directories. More...
 
static std::vector< gdImagePtr > gdfaces
 
static int generate_pics = 1
 Whether to generate the picture or not. More...
 
static const char * ignore_name []
 File names to ignore for map search. More...
 
static const char * ignore_path []
 Directories to ignore for map search. More...
 
static gdImagePtr infomap
 World map with exits / roads / blocking / ... More...
 
static int jpeg_quality = -1
 Quality for jpg pictures. More...
 
static bool list_system_quests = false
 Whether to show 'system' quests or not. More...
 
static int list_unused_maps = 0
 If set, program will list maps found in directory but not linked from the first maps. More...
 
static int map_limit = -1
 Maximum number of maps to browse, -1 for all. More...
 
static struct_map_list maps_list
 Maps to process or found. More...
 
static const int num_sizes = sizeof(sizes)/sizeof(int)
 
static const char * output_extensions []
 Extensions depending on output format. More...
 
static enum output_format_type output_format = OF_PNG
 Selected output format. More...
 
static std::vector< pageToRenderpages
 List of pages to render. More...
 
static std::vector< std::string > path_stack
 Path, relative to output root, of pages being generated. More...
 
static int pics_allocated
 Number of created pictures for GD. More...
 
static struct_quest ** quests = NULL
 All quests in the game. More...
 
static int quests_allocated = 0
 Allocated items in quests. More...
 
static int quests_count = 0
 Count of quests. More...
 
static struct_race_list races
 Monsters found in maps. More...
 
static int rawmaps = 0
 Whether to generate raw pics or instancied ones. More...
 
static size_t region_allocated = 0
 Allocated size of regions. More...
 
static size_t region_count = 0
 Count of regions. More...
 
static std::map< region *, std::set< region * > > region_links
 
static struct struct_region_info ** regions = NULL
 Found regions. More...
 
static std::set< std::string > rendered_templates
 List of generated files, to not generate multiple times. More...
 
static std::set< std::string > reset_groups
 All defined reset groups. More...
 
static std::map< struct_map_info *, std::string > reverse_maps
 Link between a map and its unique identifier. More...
 
static std::map< region *, std::string > reverse_regions
 Link between a region and its unique identifier. More...
 
static char root [500]
 Path to store generated files. More...
 
static std::string SearchName [int(SearchType::Count)]
 Search names for types, for the JS search engine. More...
 
static int show_maps = 0
 If set, will generate much information on map loaded. More...
 
static int sizes [] = {32, 16, 8, 4, 2}
 
static size_t slaying_allocated = 0
 Allocated size of slaying_info. More...
 
static size_t slaying_count = 0
 Count of items in slaying_info. More...
 
static struct_slaying_info ** slaying_info = NULL
 Found slaying fields. More...
 
static std::vector< struct_equipment * > special_equipment
 Special equipment list. More...
 
static std::vector< quest_definition * > system_quests
 
static inja::TemplateStorage templateCache
 
static std::vector< std::string > templates
 List of template files to start processing from. More...
 
static struct_map_list tiled_map_list
 Pseudo-maps grouping other maps. More...
 
static int tileset = 0
 Tileset to use to generate pics. More...
 
static int warn_no_path = 0
 Whether to warn of exits without a path. More...
 
static int world_exit_info = 1
 If set, will generate a world map of exits. More...
 
static int world_map = 1
 If set, will generate a world map. More...
 

Detailed Description

Main file for Crossfire Mapper.

Todo:
  • split this file in multiple ones for easier maintenance
  • add missing documentation on variables / functions
  • add command line argument for large / small picture size
  • add maximum width/height for small picture
  • add slaying information to maps themselves
  • shop catalog
  • treasure list use

Definition in file mapper.cpp.

Macro Definition Documentation

◆ S_CONNECT

#define S_CONNECT   4

Definition at line 441 of file mapper.cpp.

◆ S_CONTAINER

#define S_CONTAINER   2

Definition at line 439 of file mapper.cpp.

◆ S_DETECTOR

#define S_DETECTOR   3

Definition at line 440 of file mapper.cpp.

◆ S_DOOR

#define S_DOOR   0

Connection/slaying information.

Definition at line 437 of file mapper.cpp.

◆ S_KEY

#define S_KEY   1

Definition at line 438 of file mapper.cpp.

◆ S_MAX

#define S_MAX   5

Definition at line 442 of file mapper.cpp.

◆ SIZE

#define SIZE   50

◆ size_large

#define size_large   sizes[0]

Definition at line 364 of file mapper.cpp.

◆ size_small

#define size_small   sizes[1]

Definition at line 365 of file mapper.cpp.

Typedef Documentation

◆ npc_list

typedef std::vector<struct_npc_info *> npc_list

List of NPCs with a custom message.

Definition at line 216 of file mapper.cpp.

Enumeration Type Documentation

◆ output_format_type

Map output formats.

Enumerator
OF_PNG 

PNG, default value.

OF_JPG 

JPG.

Definition at line 381 of file mapper.cpp.

◆ SearchType

enum SearchType
strong

Search values, for the JS search engine.

Enumerator
Region 
Map 
Item 
Monster 
Quest 
Count 

Definition at line 295 of file mapper.cpp.

Function Documentation

◆ add_map()

static void add_map ( struct_map_info info,
struct_map_list list 
)
static

Adds a map to specified array, if it isn't already.

Parameters
infomap to add.
listlist to add to.
Note
will allocate memory and update variables when required.

Definition at line 1218 of file mapper.cpp.

References list.

Referenced by add_map_to_region(), add_map_to_slaying(), add_monster(), add_one_item(), append_map_list(), create_tiled_map(), do_parameters(), fix_exits_for_map(), fix_exits_to_tiled_maps(), fix_tiled_map_monsters(), get_map_info(), merge_tiled_maps(), and process_map().

+ Here is the caller graph for this function:

◆ add_map_to_quest()

static void add_map_to_quest ( struct_map_info map,
const char *  name,
const char *  description 
)
static

Links a map to a quest.

Parameters
mapmap to link.
namequest name.
descriptionassociated link description. Must not be NULL.

Definition at line 1014 of file mapper.cpp.

References add_to_struct_map_in_quest_list(), description, struct_map_in_quest::description, get_quest_info(), struct_map_in_quest::map, struct_quest::maps, name, struct_map_in_quest::quest, and struct_map_info::quests.

Referenced by process_map_lore().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_map_to_region()

static void add_map_to_region ( struct_map_info map,
region reg 
)
static

Links a map to a region.

Will not readd the map if already linked.

Parameters
mapmap name.
regregion to link the map to.

Definition at line 1359 of file mapper.cpp.

References add_map(), struct_region_info::is_world, maps_list, struct_map_info::path, struct_region_info::reg, region_allocated, region_count, regions, struct_region_info::sum, struct_region_info::sum_x, and struct_region_info::sum_y.

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_map_to_slaying()

static void add_map_to_slaying ( struct_slaying_info info,
int  item,
struct_map_info map 
)
static

Adds the specified map to the slaying information if not already present.

Parameters
infostructure to add to.
itemone of the S_xxx values specifying what type of slaying this is.
mapmap to add.

Definition at line 1470 of file mapper.cpp.

References add_map(), and struct_slaying_info::maps.

Referenced by add_slaying().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_monster()

static void add_monster ( object monster,
struct_map_info map 
)
static

Adds a monster to the monster list.

Parameters
monstermonster to add. Can be any part.
mapmap to add the monster to.

Definition at line 677 of file mapper.cpp.

References add_map(), add_race_to_list(), get_race(), MAX, struct_map_info::max_monster, MIN, struct_map_info::min_monster, monster, struct_map_info::monsters, and struct_race::origin.

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_npc_to_map()

static void add_npc_to_map ( npc_list list,
const object npc 
)
static

Add the specified NPC to the list.

Parameters
listwhere to add the NPC.
npcNPC to add. Must have a name and message.

Definition at line 1202 of file mapper.cpp.

References create_npc_info(), and list.

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_one_item()

◆ add_race_to_list()

static void add_race_to_list ( struct_race race,
struct_race_list list,
int  check 
)
static

Appends a race to a race list.

Parameters
racerace to add.
listlist to add to.
checkif 0, don't check if race is already on the list ; else don't make duplicated entries.

Definition at line 335 of file mapper.cpp.

References list.

Referenced by add_monster(), fix_tiled_map_monsters(), and get_race().

+ Here is the caller graph for this function:

◆ add_region_link()

static void add_region_link ( mapstruct source,
mapstruct dest 
)
static

Creates a link between two maps if they are on different regions.

Parameters
sourcemap from.
destmap to.

Definition at line 1407 of file mapper.cpp.

References d, get_region_by_map(), and region_links.

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_slaying()

static void add_slaying ( struct_map_info map,
object item 
)
static

Adds the item's information to the map.

Parameters
mapmap containing the item.
itemitem which slaying field we're considering.

Definition at line 1482 of file mapper.cpp.

References add_map_to_slaying(), CONTAINER, DETECTOR, get_slaying_struct(), LOCKED_DOOR, S_CONNECT, S_CONTAINER, S_DETECTOR, S_DOOR, S_KEY, object::slaying, SPECIAL_KEY, and object::type.

Referenced by check_slaying_inventory(), and process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_template_to_render()

void add_template_to_render ( const std::string &  template_name,
const std::string &  output_name,
const std::string &  param 
)

Push the specified template, with optional param, on the list of files to process.

Parameters
template_nametemplate name to use.
output_nameoutput file name.
paramadditional parameter to the template.

Definition at line 2719 of file mapper.cpp.

References pageToRender::output_name, pages, pageToRender::param, rendered_templates, and pageToRender::template_name.

Referenced by generate_page_and_link(), and main().

+ Here is the caller graph for this function:

◆ add_to_struct_map_in_quest_list()

static void add_to_struct_map_in_quest_list ( struct_map_in_quest_list list,
struct_map_in_quest item 
)
static

Definition at line 955 of file mapper.cpp.

References list.

Referenced by add_map_to_quest().

+ Here is the caller graph for this function:

◆ append_map_list()

static void append_map_list ( struct_map_list dest,
struct_map_list src 
)
static

Append the contents of src to dest.

Parameters
destwhere to put items.
srcwhat to append to dest, unchanged.

Definition at line 2395 of file mapper.cpp.

References add_map(), struct_map_list::count, and struct_map_list::maps.

Referenced by fill_json().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_equipment()

static void check_equipment ( object item,
struct_map_info map 
)
static

Checks if item and its inventory are worthy to be listed.

Parameters
itemitem to check.
mapmap the item is on.

Definition at line 631 of file mapper.cpp.

References add_one_item(), FOR_INV_FINISH, FOR_INV_PREPARE, and is_special_equipment().

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_slaying_inventory()

static void check_slaying_inventory ( struct_map_info map,
object item 
)
static

Recursively checks if the object should be considered for slaying information.

Parameters
mapmap containing the items.
itemitem to consider. Must not be NULL.

Definition at line 1510 of file mapper.cpp.

References add_slaying(), FOR_INV_FINISH, FOR_INV_PREPARE, and is_slaying().

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_map_info()

static int compare_map_info ( const struct_map_info left,
const struct_map_info right 
)
static

Compares struct_map_info according to the map name or the path if equal.

Parameters
leftfirst item.
rightsecond item.
Returns
comparison on name, and if equal then on whole path.

Definition at line 873 of file mapper.cpp.

References c, struct_map_info::name, struct_map_info::path, strcasecmp(), and struct_map_info::tiled_group.

Referenced by sort_map_info().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_destination()

static void create_destination ( void  )
static

Ensures destination directory exists.

Definition at line 3113 of file mapper.cpp.

References make_path_to_file(), and root.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_map_in_quest_array()

static nlohmann::json create_map_in_quest_array ( struct_map_in_quest_list list)
static

Return an array of map-in-quest items.

Parameters
listitems to return the JSON of.
Returns
array.

Definition at line 2309 of file mapper.cpp.

References list, m, and reverse_maps.

Referenced by create_map_object(), and create_quest_object().

+ Here is the caller graph for this function:

◆ create_map_info()

static struct_map_info* create_map_info ( void  )
static

◆ create_map_object()

static nlohmann::json create_map_object ( struct_map_info map,
const std::string &  key 
)
static

Return a JSON map object.

Parameters
mapmap to return the JSON of.
keymap unique identifier.
Returns
JSON object.

Definition at line 2337 of file mapper.cpp.

References struct_map_info::cfregion, create_map_in_quest_array(), create_maps_array(), create_npc_array(), create_race_array(), struct_map_info::exits_from, struct_map_info::exits_to, struct_map_info::level, struct_map_info::lore, struct_map_info::monsters, struct_map_info::name, struct_map_info::npcs, struct_map_info::path, struct_map_info::quests, struct_map_info::readable, remove_trailing_slash(), struct_map_info::reset_group, and reverse_regions.

Referenced by fill_json().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_maps_array()

static nlohmann::json create_maps_array ( struct_map_list maps)
static

Return an array of map identifiers.

Parameters
mapsitems to return the JSON of.
Returns
array.

Definition at line 2257 of file mapper.cpp.

References m, maps, and reverse_maps.

Referenced by create_map_object(), and fill_json().

+ Here is the caller graph for this function:

◆ create_npc_array()

static nlohmann::json create_npc_array ( npc_list list)
static

Return an array of NPC information.

Parameters
listitems to return the JSON of.
Returns
array.

Definition at line 2273 of file mapper.cpp.

References list.

Referenced by create_map_object().

+ Here is the caller graph for this function:

◆ create_npc_info()

static struct_npc_info* create_npc_info ( const object npc)
static

Create the struct_npc_info from the specified NPC.

It must have a name and message.

Parameters
npcNPC to gather info for.
Returns
structure with info.

Definition at line 1184 of file mapper.cpp.

References struct_npc_info::message, object::msg, struct_npc_info::name, object::name, struct_npc_info::x, object::x, struct_npc_info::y, and object::y.

Referenced by add_npc_to_map().

+ Here is the caller graph for this function:

◆ create_quest_object()

static nlohmann::json create_quest_object ( struct_quest quest,
const std::string &  key 
)
static

Return a JSON quest object.

Parameters
questquest to return the JSON of.
keyquest unique key.
Returns
JSON object.

Definition at line 2361 of file mapper.cpp.

References create_map_in_quest_array(), struct_quest::description, struct_quest::mainmap, struct_quest::maps, struct_quest::name, struct_quest::number, and reverse_maps.

Referenced by fill_json().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_race_array()

static nlohmann::json create_race_array ( struct_race_list list)
static

Return an array of monster information.

Parameters
listitems to return the JSON of.
Returns
array.

Definition at line 2292 of file mapper.cpp.

References list.

Referenced by create_map_object().

+ Here is the caller graph for this function:

◆ create_region_array()

static nlohmann::json create_region_array ( const std::set< region * > &  regions)
static

Return an array of region identifiers.

Parameters
regionsregions to process.
Returns
JSON object.

Definition at line 2405 of file mapper.cpp.

References regions, and reverse_regions.

Referenced by fill_json().

+ Here is the caller graph for this function:

◆ create_tiled_map()

static struct_map_info* create_tiled_map ( void  )
static

Create a new tiled map and link it to the tiled map list.

Returns
new tiled map.

Definition at line 1261 of file mapper.cpp.

References add_map(), create_map_info(), and tiled_map_list.

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ define_quest()

static void define_quest ( const char *  name,
struct_map_info mainmap,
const char *  description 
)
static

Sets the main map for a quest.

Parameters
namequest name.
mainmapmain map to associate.
descriptionquest description. Must not be NULL.

Definition at line 1080 of file mapper.cpp.

References description, struct_quest::description, get_quest_info(), struct_quest::mainmap, name, struct_quest::name, and struct_map_info::path.

Referenced by process_map_lore().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_auto_apply()

◆ do_exit_map()

static void do_exit_map ( mapstruct map)
static

Proceses exit / road / blocking information for specified map into the global infomap map.

If map isn't a world map, won't do anything.

Parameters
mapmap to write info for.

Definition at line 777 of file mapper.cpp.

References color_blocking, color_linked_exit, color_road, color_slowing, color_unlinked_exit, elevation_info, elevation_max, elevation_min, EXIT, FOR_MAP_FINISH, FOR_MAP_PREPARE, HEAD, infomap, is_blocking(), is_road(), MAP_HEIGHT, MAP_WIDTH, MAX, MIN, object::move_slow, mapstruct::path, object::slaying, TELEPORTER, and object::type.

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_help()

static void do_help ( const char *  program)
static

Prints usage information, and exit.

Parameters
programprogram path.

Definition at line 2992 of file mapper.cpp.

Referenced by do_parameters().

+ Here is the caller graph for this function:

◆ do_parameters()

static void do_parameters ( int  argc,
char **  argv 
)
static

Handles command-line parameters.

Parameters
argcnumber of parameters, including program name.
argvarguments, including program name.

Definition at line 3029 of file mapper.cpp.

References add_map(), build_search_file, detail_quests, display_rendered_template, do_help(), do_regions_link, force_pics, generate_pics, get_map_info(), jpeg_quality, list_system_quests, list_unused_maps, map_limit, maps_list, OF_JPG, output_format, rawmaps, root, show_maps, templates, templates_root(), tileset, warn_no_path, world_exit_info, and world_map.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_tiled_map_picture()

static void do_tiled_map_picture ( struct_map_info map)
static

Generates the large and small pictures for a tiled map.

This uses the large/small pictures made during process_map(), so having a map limit could lead to maps not found and invalid results.

Parameters
maptiled map to make the picture of.
Todo:
add a field to struct_map_info to remember if pic was updated or not, and update the tiled map only if one map has changed / the pic doesn't exist.

Definition at line 2087 of file mapper.cpp.

References struct_map_list::count, generate_pics, generate_picture_path(), struct_map_info::height, struct_map_list::maps, struct_map_info::name, OF_PNG, output_format, struct_map_info::path, struct_map_info::processed, size_large, tiled_map_need_pic(), struct_map_info::tiled_maps, struct_map_info::tiled_x_from, struct_map_info::tiled_y_from, struct_map_info::tiles, struct_map_info::width, and write_pictures_from_real_size().

Referenced by write_tiled_map_page().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dump_unused_maps()

static void dump_unused_maps ( void  )
static

Writes the list of unused maps, maps found in the directories but not linked from the other maps.

Definition at line 2909 of file mapper.cpp.

References dump(), found_maps, and root.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensure_unique()

static struct_equipment* ensure_unique ( struct_equipment item)
static

Searches the item list for an identical item, except maps.

Parameters
itemitem to search. The variable may be freed, so must not be used after calling this function.
Returns
item guaranteed to be unique in the item list.

Definition at line 533 of file mapper.cpp.

References free_equipment(), and special_equipment.

Referenced by add_one_item().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fill_json()

◆ fill_reverse_maps()

static void fill_reverse_maps ( struct_map_list list)
static

Fill the reverse_maps array with the provided list.

Parameters
listmaps to put.

Definition at line 2376 of file mapper.cpp.

References buf, list, reverse_maps, sort_map_info(), and sort_race().

Referenced by fill_json().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_map_by_key()

static struct_map_info* find_map_by_key ( const std::string &  key)
static

Get the map with the specified key, nullptr if not found.

Parameters
keykey of the map to find.
Returns
map, nullptr if not found.

Definition at line 2233 of file mapper.cpp.

References c, is_valid_types_gen::found, and reverse_maps.

Referenced by generate_page_and_link(), and generate_picture_link().

+ Here is the caller graph for this function:

◆ find_maps()

static void find_maps ( const char *  from)
static

Recursively find all all maps in a directory.

Parameters
frompath to search from, without trailing /.

Definition at line 2869 of file mapper.cpp.

References closedir(), Settings::datadir, found_maps, HUGE_BUF, ignore_name, ignore_path, Settings::mapdir, opendir(), readdir(), and settings.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_quest_info()

static struct_quest* find_quest_info ( const char *  name)
static

Gets the information for a quest if it exists.

Parameters
namequest's name.
Returns
quest information, NULL if no match.

Definition at line 968 of file mapper.cpp.

References name, quests, and quests_count.

Referenced by fill_json(), and get_quest_info().

+ Here is the caller graph for this function:

◆ find_region_by_key()

static region* find_region_by_key ( const std::string &  key)
static

Get the region with the specified key, nullptr if not found.

Parameters
keykey of the region to find.
Returns
region, nullptr if not found.

Definition at line 2245 of file mapper.cpp.

References c, is_valid_types_gen::found, and reverse_regions.

Referenced by generate_page_and_link().

+ Here is the caller graph for this function:

◆ fix_exits_for_map()

static void fix_exits_for_map ( struct_map_info current,
struct_map_list from,
int  is_from 
)
static

Changes for the list all maps to the tiled map they are part of, if applicable.

Parameters
currentmap currently being processed.
fromlist that contains the exits to/from map to be fixed.
is_fromif non zero, from is exit_from field, else it is an exit_to.

Definition at line 1983 of file mapper.cpp.

References add_map(), struct_map_list::count, struct_map_info::exits_from, struct_map_info::exits_to, struct_map_list::maps, and struct_map_info::tiled_group.

Referenced by fix_exits_to_tiled_maps().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fix_exits_to_tiled_maps()

static void fix_exits_to_tiled_maps ( void  )
static

Changes all exits to maps in a tiled map to point directly to the tiled map.

Same for region lists.

Definition at line 2002 of file mapper.cpp.

References add_map(), struct_map_list::count, struct_map_info::exits_from, struct_map_info::exits_to, fix_exits_for_map(), struct_map_list::maps, maps_list, struct_region_info::maps_list, region_count, regions, and struct_map_info::tiled_group.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fix_map_names()

static void fix_map_names ( void  )
static

Ensures all maps have a name (if there was a limit to map processing, some maps will have a NULL name which causes issues).

Definition at line 1896 of file mapper.cpp.

References struct_map_list::count, struct_map_info::filename, struct_map_list::maps, maps_list, and struct_map_info::name.

Referenced by main().

+ Here is the caller graph for this function:

◆ fix_tiled_map()

static void fix_tiled_map ( void  )
static

Ensures all tiled maps have a name, a region, a filename and a path.

Will try to find a suitable name and region from the maps in the group.

Todo:
use a better filename, try to get the start of the map filenames.

Definition at line 1914 of file mapper.cpp.

References struct_map_info::cfregion, struct_map_list::count, struct_map_info::filename, struct_map_list::maps, name, struct_map_info::name, region::name, struct_map_info::path, tiled_map_list, and struct_map_info::tiled_maps.

Referenced by main().

+ Here is the caller graph for this function:

◆ fix_tiled_map_monsters()

static void fix_tiled_map_monsters ( void  )
static

Makes all monsters point to tiled maps instead of map when appliable, and merge map monster to tiled map.

Definition at line 2030 of file mapper.cpp.

References add_map(), add_race_to_list(), struct_race_list::count, struct_map_list::count, struct_map_list::maps, maps_list, struct_map_info::monsters, struct_race::origin, struct_race_list::races, races, and struct_map_info::tiled_group.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_equipment()

static void free_equipment ( struct_equipment equip)
static

Frees a struct_equipment.

Parameters
equipitem to free.

Definition at line 499 of file mapper.cpp.

References struct_equipment::diff, and struct_equipment::name.

Referenced by add_one_item(), and ensure_unique().

+ Here is the caller graph for this function:

◆ generate_page_and_link()

static nlohmann::json generate_page_and_link ( inja::Arguments &  args)
static

Create a link to a page, generating it if needed.

Parameters
argslink arguments.
Returns
link to the page.

Definition at line 2654 of file mapper.cpp.

References add_template_to_render(), find_map_by_key(), find_region_by_key(), and path_from_current().

Referenced by init_renderer_env().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generate_picture_link()

static nlohmann::json generate_picture_link ( inja::Arguments &  args)
static

Return the link to the picture of the specified item.

Parameters
argsfunction arguments.
Returns
link, empty string if invalid.

Definition at line 2685 of file mapper.cpp.

References find_map_by_key(), output_extensions, output_format, and path_from_current().

Referenced by init_renderer_env().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generate_picture_path()

static void generate_picture_path ( const char *  path,
size_t  pic_size,
char *  out,
size_t  len 
)
static

Definition at line 1518 of file mapper.cpp.

References output_extensions, output_format, and root.

Referenced by do_tiled_map_picture(), process_map(), tiled_map_need_pic(), and write_pictures_from_real_size().

+ Here is the caller graph for this function:

◆ get_elevation_color()

static int get_elevation_color ( int  elevation,
gdImagePtr  elevationmap 
)
static

Gets the color for an elevation.

Parameters
elevationelevation to get color for.
elevationmappicture that will get the color.
Returns
color.

Definition at line 762 of file mapper.cpp.

References elevation_max, and elevation_min.

Referenced by write_world_info().

+ Here is the caller graph for this function:

◆ get_equipment()

static struct_equipment* get_equipment ( void  )
static

Gets an empty struct_equipment.

Returns
new item.

Definition at line 486 of file mapper.cpp.

References init_map_list(), and struct_equipment::origin.

Referenced by add_one_item().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_map_info()

static struct_map_info* get_map_info ( const char *  path)
static

Gets or creates if required the info structure for a map.

Parameters
pathmap to consider.
Returns
associated structure.

Definition at line 1311 of file mapper.cpp.

References add_map(), struct_map_list::count, create_map_info(), struct_map_info::filename, struct_map_list::maps, maps_list, and struct_map_info::path.

Referenced by do_parameters(), main(), and process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_quest_info()

static struct_quest* get_quest_info ( const char *  name)
static

Gets the information for a quest, create the field if needed.

Parameters
namequest's name.
Returns
information, never NULL.

Definition at line 985 of file mapper.cpp.

References find_quest_info(), init_struct_map_in_quest_list(), struct_quest::maps, name, struct_quest::name, struct_quest::number, quests, quests_allocated, and quests_count.

Referenced by add_map_to_quest(), and define_quest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_race()

static struct_race* get_race ( const char *  name)
static

Returns the race for specified name.

Parameters
namemonster's name.
Returns
race structure.

Definition at line 648 of file mapper.cpp.

References add_race_to_list(), struct_race_list::count, struct_race::count, init_map_list(), name, struct_race::name, struct_race::origin, struct_race_list::races, and races.

Referenced by add_monster().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_slaying_struct()

static struct_slaying_info* get_slaying_struct ( const char *  slaying)
static

Returns a struct_slaying_info for specified slaying.

Creates a new one if required.

Parameters
slayingvalue to get the structure of.
Returns
structure for slaying. Never NULL.

Definition at line 1439 of file mapper.cpp.

References init_map_list(), struct_slaying_info::maps, S_MAX, struct_slaying_info::slaying, slaying_allocated, slaying_count, and slaying_info.

Referenced by add_slaying().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_template()

static inja::Template get_template ( const std::string &  filename)
static

Definition at line 2417 of file mapper.cpp.

References env, and templateCache.

Referenced by fill_json(), and main().

+ Here is the caller graph for this function:

◆ init_map_list()

static void init_map_list ( struct_map_list list)
static

Initialises a list structure.

Parameters
listlist to blank.

Definition at line 459 of file mapper.cpp.

References list.

Referenced by create_map_info(), fill_json(), get_equipment(), get_race(), get_slaying_struct(), and main().

+ Here is the caller graph for this function:

◆ init_race_list()

static void init_race_list ( struct_race_list list)
static

Blanks a struct_race_list.

Parameters
listlist to blank.

Definition at line 319 of file mapper.cpp.

References list.

Referenced by create_map_info(), and main().

+ Here is the caller graph for this function:

◆ init_renderer_env()

static void init_renderer_env ( )
static

Initialize env and set various callbacks and options.

Definition at line 2751 of file mapper.cpp.

References buf, env, is_valid_types_gen::found, generate_page_and_link(), generate_picture_link(), path_stack, root, and templates_root().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_struct_map_in_quest_list()

static void init_struct_map_in_quest_list ( struct_map_in_quest_list list)
static

Definition at line 949 of file mapper.cpp.

References list.

Referenced by create_map_info(), and get_quest_info().

+ Here is the caller graph for this function:

◆ is_blocking()

static int is_blocking ( object item)
static

Checks if item blocks movement or not.

Parameters
itemobject to test.
Returns
1 if item blocks all movement, 0 else.

Definition at line 748 of file mapper.cpp.

References MOVE_ALL, and object::move_block.

Referenced by do_exit_map().

+ Here is the caller graph for this function:

◆ is_road()

static int is_road ( object item)
static

Checks if object is considered a road or not.

Parameters
itemobject to check.
Returns
1 if object is a road, 0 else.

Definition at line 712 of file mapper.cpp.

References object::arch, FLAG_IS_FLOOR, archetype::name, and QUERY_FLAG.

Referenced by do_exit_map().

+ Here is the caller graph for this function:

◆ is_slaying()

static int is_slaying ( object item)
static

Is the slaying field relevant for this item?

Parameters
itemitem to check.
Returns
1 if relevant, 0 else.

Definition at line 1426 of file mapper.cpp.

References CHECK_INV, CONTAINER, LOCKED_DOOR, SPECIAL_KEY, and object::type.

Referenced by check_slaying_inventory(), and process_map().

+ Here is the caller graph for this function:

◆ is_special_equipment()

static int is_special_equipment ( object item)
static

Definition at line 467 of file mapper.cpp.

References AMULET, object::arch, archetype::clone, FLAG_NO_PICK, IS_ARMOR, IS_ARROW, IS_SHIELD, IS_WEAPON, MOVE_ALL, object::move_block, object::name, QUERY_FLAG, RING, ROD, object::title, object::type, and WAND.

Referenced by check_equipment().

+ Here is the caller graph for this function:

◆ list_map()

static void list_map ( const char *  path)
static

Marks specified path as processed.

Parameters
pathmap to remove.

Definition at line 1338 of file mapper.cpp.

References found_maps.

Referenced by process_map().

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 3133 of file mapper.cpp.

References add_template_to_render(), all_data, all_regions, cached_pics, color_blocking, color_linked_exit, color_road, color_slowing, color_unlinked_exit, struct_race_list::count, struct_map_list::count, create_destination(), created_pics, Settings::debug, detail_quests, display_rendered_template, do_parameters(), do_regions_link, dump_unused_maps(), elevation_info, elevation_max, elevation_min, env, region::fallback, fill_json(), find_faceset(), find_maps(), first_map_path, fix_exits_to_tiled_maps(), fix_map_names(), fix_tiled_map(), fix_tiled_map_monsters(), force_pics, found_maps, gdfaces, generate_pics, get_faces_count(), get_map_info(), get_region_struct(), get_template(), infomap, init_globals(), init_gods(), init_library(), init_map_list(), init_race_list(), init_readable(), init_renderer_env(), is_valid_faceset(), jpeg_quality, list_system_quests, list_unused_maps, llevError, region::longname, map_limit, struct_map_list::maps, maps_list, region::name, OF_JPG, output_extensions, output_format, pages, path_stack, pics_allocated, process_map(), quest_callback(), quest_for_each(), quests, quests_count, struct_race_list::races, races, rawmaps, region_count, regions, root, settings, show_maps, slaying_count, slaying_info, sort_equipment(), sort_map_info(), sort_race(), sort_region(), sort_slaying(), sort_struct_quest(), special_equipment, strdup_local, system_quests, templates, templates_root(), tiled_map_list, tileset, time, warn_no_path, world_exit_info, world_map, write_tiled_maps(), write_world_info(), write_world_map(), and yesno().

+ Here is the call graph for this function:

◆ merge_tiled_maps()

static void merge_tiled_maps ( struct_map_info map,
struct_map_info tiled_map 
)
static

Merge two tiled maps groups.

This can happen if based on processing we do one map with tiled maps, another with tiled maps, and later figure out the tiles are actually linked.

Parameters
mapthe map that being processed has a tiling to a map in another group. Its group will be the final merging group.
tiled_mapthe map tiled to another group. Its group will disappear.

Definition at line 1277 of file mapper.cpp.

References add_map(), struct_map_list::count, struct_map_list::maps, struct_map_info::tiled_group, tiled_map_list, and struct_map_info::tiled_maps.

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ path_from_current()

static std::string path_from_current ( const std::string &  path)
static

Compute the relative path from the specified file to the current file.

Parameters
pathpath to get from.
Returns
relative path to the current page.

Definition at line 2637 of file mapper.cpp.

References path_stack, and relative_path().

Referenced by generate_page_and_link(), and generate_picture_link().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process_map()

static void process_map ( struct_map_info info)
static

Processes a map.

Generates the map pictures (big and small), and exit information.

Parameters
infomap to process.

Definition at line 1550 of file mapper.cpp.

References add_map(), add_map_to_region(), add_monster(), add_npc_to_map(), add_region_link(), add_slaying(), add_string(), BOOK, cached_pics, struct_map_info::cfregion, check_equipment(), check_slaying_inventory(), archetype::clone, create_pathname(), create_tiled_map(), created_pics, face_info::data, face_info::datalen, delete_map(), do_auto_apply(), do_exit_map(), do_regions_link, EXIT, EXIT_PATH, struct_map_info::exits_from, struct_map_info::exits_to, face_sets::faces, struct_map_info::filename, find_archetype(), find_faceset(), FLAG_FRIENDLY, FLAG_MONSTER, FLAG_UNAGGRESSIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, force_pics, gdfaces, generate_pics, generate_picture_path(), get_face_fallback(), get_map_info(), get_region_by_map(), struct_map_info::height, mapstruct::in_memory, is_slaying(), struct_map_info::level, list_map(), list_unused_maps, struct_map_info::lore, m, MAP_HEIGHT, MAP_IN_MEMORY, MAP_WIDTH, MAX_BUF, merge_tiled_maps(), object::msg, struct_map_info::name, struct_map_info::npcs, num_sizes, object_get_multi_size(), struct_map_info::path, path_combine_and_normalize(), struct_map_info::pic_was_done, pics_allocated, PLAYER_CHANGER, process_map_lore(), QUERY_FLAG, rawmaps, struct_map_info::readable, ready_map_name(), struct_map_info::reset_group, reset_groups, mapstruct::reset_time, show_maps, SIGN, size_large, stats, TELEPORTER, struct_map_info::tiled_group, struct_map_info::tiled_maps, struct_map_info::tiles, tileset, warn_no_path, struct_map_info::width, and write_pictures_from_real_size().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process_map_lore()

static void process_map_lore ( struct_map_info map)
static

Extracts from the map's lore quest information if found.

May modify map->lore.

Parameters
mapmap to process.

Definition at line 1099 of file mapper.cpp.

References add_map_to_quest(), define_quest(), description, struct_map_info::lore, and name.

Referenced by process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quest_callback()

static void quest_callback ( const quest_definition quest,
void *   
)
static

Definition at line 2216 of file mapper.cpp.

References list_system_quests, quest_definition::quest_is_system, and system_quests.

Referenced by main().

+ Here is the caller graph for this function:

◆ relative_path()

static void relative_path ( const char *  from,
const char *  to,
char *  result 
)
static

Computes the shortest path from one file to another.

Parameters
fromorigin.
todestination.
resultstring that will contain the calculated path. Must be large enough, no test done.
Warning
from and to must be absolute paths (starting with /).

Definition at line 834 of file mapper.cpp.

References to.

Referenced by path_from_current().

+ Here is the caller graph for this function:

◆ remove_trailing_slash()

static const char* remove_trailing_slash ( const char *  path)
static

Definition at line 2326 of file mapper.cpp.

Referenced by create_map_object().

+ Here is the caller graph for this function:

◆ save_picture()

static void save_picture ( FILE *  file,
gdImagePtr  pic 
)
static

Saves a map to a file, based on jpg/png settings.

Parameters
fileopened file to which to save.
picpicture to save.

Definition at line 1393 of file mapper.cpp.

References jpeg_quality, OF_PNG, and output_format.

Referenced by write_pictures_from_real_size(), write_world_info(), and write_world_map().

+ Here is the caller graph for this function:

◆ sort_equipment()

static bool sort_equipment ( const struct_equipment l,
const struct_equipment r 
)
static

Sort 2 struct_equipment.

Parameters
l
ritems to compare.
Returns
true if l is before r, false else

Definition at line 513 of file mapper.cpp.

References struct_equipment::calc_power, struct_equipment::diff, struct_equipment::name, struct_equipment::power, and strcasecmp().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sort_map_info()

static int sort_map_info ( const void *  left,
const void *  right 
)
static

Sorts the struct_map_info according to the map name or the path if equal.

Parameters
leftfirst item.
rightsecond item.
Returns
comparison on name, and if equal then on whole path.

Definition at line 903 of file mapper.cpp.

References compare_map_info().

Referenced by fill_json(), fill_reverse_maps(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sort_race()

static int sort_race ( const void *  a,
const void *  b 
)
static

Sort 2 struct_race.

Parameters
a
bitems to compare.
Returns
-1, 0 or 1.

Definition at line 699 of file mapper.cpp.

References a(), struct_race::name, and strcasecmp().

Referenced by fill_reverse_maps(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sort_region()

static int sort_region ( const void *  left,
const void *  right 
)
static

Sorts an array of struct_region_info by region name.

Parameters
leftfirst region.
rightsecond region.
Returns
result of strcmp() for names.

Definition at line 919 of file mapper.cpp.

Referenced by main().

+ Here is the caller graph for this function:

◆ sort_slaying()

static int sort_slaying ( const void *  left,
const void *  right 
)
static

Helper function to sort an array of struct_slaying_info.

Parameters
leftfirst item.
rightsecond item.
Returns
sort order.

Definition at line 2979 of file mapper.cpp.

References struct_slaying_info::slaying, and strcasecmp().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sort_struct_map_in_quest()

static int sort_struct_map_in_quest ( const void *  left,
const void *  right 
)
static

Sorts 2 struct_map_in_quest, on the map's name or path.

Parameters
left
rightitems to compare.
Returns
-1, 0 or 1.

Definition at line 1036 of file mapper.cpp.

References c, struct_map_in_quest::map, struct_map_info::name, struct_map_info::path, strcasecmp(), and struct_map_info::tiled_group.

Referenced by fill_json().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sort_struct_quest()

static int sort_struct_quest ( const void *  left,
const void *  right 
)
static

Sorts 2 struct_quest, on the map's name or path.

Parameters
left
rightitems to compare.
Returns
-1, 0 or 1.

Definition at line 1064 of file mapper.cpp.

References struct_quest::name, and strcasecmp().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ split()

static std::vector<std::string> split ( const std::string &  field,
const std::string &  by 
)
static

Definition at line 2734 of file mapper.cpp.

References is_valid_types_gen::found.

Referenced by assets_pack(), cfapi_object_split(), Crossfire_Object_Split(), PngLoader::load(), load_bells(), and load_citylife().

+ Here is the caller graph for this function:

◆ templates_root()

static std::string templates_root ( "templates/"  )
static

Directory to get templates from, with a leading /.

Referenced by do_parameters(), init_renderer_env(), and main().

+ Here is the caller graph for this function:

◆ tiled_map_need_pic()

static int tiled_map_need_pic ( struct_map_info map)
static

Definition at line 2057 of file mapper.cpp.

References struct_map_list::count, generate_picture_path(), struct_map_list::maps, num_sizes, struct_map_info::path, struct_map_info::pic_was_done, stats, and struct_map_info::tiled_maps.

Referenced by do_tiled_map_picture().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_pictures_from_real_size()

static void write_pictures_from_real_size ( const char *  path,
gdImagePtr  real,
int  width,
int  height 
)
static

Definition at line 1522 of file mapper.cpp.

References generate_picture_path(), make_path_to_file(), MAX_BUF, num_sizes, save_picture(), size_large, and sizes.

Referenced by do_tiled_map_picture(), and process_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_tiled_map_page()

static void write_tiled_map_page ( struct_map_info map)
static

Writes the page for a tiled map group.

Todo:
: do a real page, with the various levels, maps and such.

Definition at line 2195 of file mapper.cpp.

References do_tiled_map_picture().

Referenced by write_tiled_maps().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_tiled_maps()

static void write_tiled_maps ( void  )
static

Outputs all tiled map pages.

Definition at line 2205 of file mapper.cpp.

References struct_map_list::count, struct_map_list::maps, tiled_map_list, and write_tiled_map_page().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_world_info()

static void write_world_info ( void  )
static

Writes the exit information world map.

Definition at line 2927 of file mapper.cpp.

References elevation_info, elevation_max, elevation_min, get_elevation_color(), infomap, output_extensions, output_format, root, save_picture(), and world_exit_info.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_world_map()

static void write_world_map ( void  )
static

Generates a big world map.

Definition at line 1793 of file mapper.cpp.

References infomap, name, OF_PNG, output_extensions, output_format, region_allocated, regions, root, save_picture(), SIZE, struct_region_info::sum, struct_region_info::sum_x, struct_region_info::sum_y, and world_map.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ yesno()

static const char* yesno ( int  value)
static

Helper to write yes/no.

Parameters
valuevalue to print.
Returns
"no" if value == 0, "yes" else.

Definition at line 3129 of file mapper.cpp.

Referenced by main().

+ Here is the caller graph for this function:

Variable Documentation

◆ all_data

nlohmann::json all_data
static

All JSON data available to templates.

Definition at line 2223 of file mapper.cpp.

Referenced by main().

◆ build_search_file

bool build_search_file = false
static

If set, will build the 'search_data.js' file.

Definition at line 374 of file mapper.cpp.

Referenced by do_parameters(), and fill_json().

◆ cached_pics

int cached_pics = 0
static

Non recreated pics.

Definition at line 378 of file mapper.cpp.

Referenced by main(), and process_map().

◆ color_blocking

int color_blocking
static

Block all movement.

Definition at line 424 of file mapper.cpp.

Referenced by do_exit_map(), and main().

◆ color_linked_exit

int color_linked_exit
static

Exit leading to another map.

Definition at line 422 of file mapper.cpp.

Referenced by do_exit_map(), and main().

◆ color_road

int color_road
static

Road or equivalent.

Definition at line 423 of file mapper.cpp.

Referenced by do_exit_map(), and main().

◆ color_slowing

int color_slowing
static

Slows movement.

Definition at line 425 of file mapper.cpp.

Referenced by do_exit_map(), and main().

◆ color_unlinked_exit

int color_unlinked_exit
static

Color for exits without a path set.

Definition at line 421 of file mapper.cpp.

Referenced by do_exit_map(), and main().

◆ created_pics

int created_pics = 0
static

Picture statistics.

Total created pics.

Definition at line 377 of file mapper.cpp.

Referenced by main(), and process_map().

◆ detail_quests

bool detail_quests = false
static

Whether to show all quests details or not.

Definition at line 371 of file mapper.cpp.

Referenced by do_parameters(), fill_json(), and main().

◆ display_rendered_template

bool display_rendered_template = false
static

Whether to display the template to be rendered or not.

Definition at line 373 of file mapper.cpp.

Referenced by do_parameters(), and main().

◆ do_regions_link

bool do_regions_link = false
static

Definition at line 432 of file mapper.cpp.

Referenced by do_parameters(), main(), and process_map().

◆ elevation_info

int** elevation_info
static

All elevation spots in the "world_" maps.

Definition at line 427 of file mapper.cpp.

Referenced by do_exit_map(), main(), and write_world_info().

◆ elevation_max

int elevation_max
static

Lowest elevation found.

Definition at line 429 of file mapper.cpp.

Referenced by do_exit_map(), get_elevation_color(), main(), and write_world_info().

◆ elevation_min

int elevation_min
static

Maximal elevation found.

Definition at line 428 of file mapper.cpp.

Referenced by do_exit_map(), get_elevation_color(), main(), and write_world_info().

◆ env

◆ force_pics

int force_pics = 0
static

To force picture regeneration even if map didn't change.

Definition at line 361 of file mapper.cpp.

Referenced by do_parameters(), main(), and process_map().

◆ found_maps

std::vector<char *> found_maps
static

Maps found in directories.

Definition at line 417 of file mapper.cpp.

Referenced by dump_unused_maps(), find_maps(), list_map(), and main().

◆ gdfaces

std::vector<gdImagePtr> gdfaces
static

Definition at line 206 of file mapper.cpp.

Referenced by main(), and process_map().

◆ generate_pics

int generate_pics = 1
static

Whether to generate the picture or not.

Definition at line 360 of file mapper.cpp.

Referenced by do_parameters(), do_tiled_map_picture(), main(), and process_map().

◆ ignore_name

const char* ignore_name[]
static
Initial value:
= {
".",
"..",
".git",
".svn",
"README",
NULL }

File names to ignore for map search.

Definition at line 2855 of file mapper.cpp.

Referenced by find_maps().

◆ ignore_path

const char* ignore_path[]
static
Initial value:
= {
"/Info",
"/editor",
"/python",
"/styles",
"/templates",
"/test",
"/unlinked",
NULL }

Directories to ignore for map search.

Definition at line 2844 of file mapper.cpp.

Referenced by find_maps().

◆ infomap

gdImagePtr infomap
static

World map with exits / roads / blocking / ...

Definition at line 420 of file mapper.cpp.

Referenced by do_exit_map(), main(), write_world_info(), and write_world_map().

◆ jpeg_quality

int jpeg_quality = -1
static

Quality for jpg pictures.

Definition at line 396 of file mapper.cpp.

Referenced by do_parameters(), main(), and save_picture().

◆ list_system_quests

bool list_system_quests = false
static

Whether to show 'system' quests or not.

Definition at line 372 of file mapper.cpp.

Referenced by do_parameters(), main(), and quest_callback().

◆ list_unused_maps

int list_unused_maps = 0
static

If set, program will list maps found in directory but not linked from the first maps.

Definition at line 416 of file mapper.cpp.

Referenced by do_parameters(), main(), and process_map().

◆ map_limit

int map_limit = -1
static

Maximum number of maps to browse, -1 for all.

Definition at line 366 of file mapper.cpp.

Referenced by do_parameters(), and main().

◆ maps_list

struct_map_list maps_list
static

◆ num_sizes

const int num_sizes = sizeof(sizes)/sizeof(int)
static

Definition at line 363 of file mapper.cpp.

Referenced by process_map(), tiled_map_need_pic(), and write_pictures_from_real_size().

◆ output_extensions

const char* output_extensions[]
static
Initial value:
= {
".png",
".jpg"
}

Extensions depending on output format.

Definition at line 387 of file mapper.cpp.

Referenced by generate_picture_link(), generate_picture_path(), main(), write_world_info(), and write_world_map().

◆ output_format

enum output_format_type output_format = OF_PNG
static

◆ pages

std::vector<pageToRender> pages
static

List of pages to render.

Definition at line 2711 of file mapper.cpp.

Referenced by add_template_to_render(), and main().

◆ path_stack

std::vector<std::string> path_stack
static

Path, relative to output root, of pages being generated.

Definition at line 2628 of file mapper.cpp.

Referenced by init_renderer_env(), main(), and path_from_current().

◆ pics_allocated

int pics_allocated
static

Number of created pictures for GD.

Definition at line 357 of file mapper.cpp.

Referenced by main(), and process_map().

◆ quests

struct_quest** quests = NULL
static

All quests in the game.

Definition at line 943 of file mapper.cpp.

Referenced by fill_json(), find_quest_info(), get_quest_info(), and main().

◆ quests_allocated

int quests_allocated = 0
static

Allocated items in quests.

Definition at line 947 of file mapper.cpp.

Referenced by get_quest_info().

◆ quests_count

int quests_count = 0
static

Count of quests.

Definition at line 945 of file mapper.cpp.

Referenced by fill_json(), find_quest_info(), get_quest_info(), main(), and quest_display().

◆ races

struct_race_list races
static

Monsters found in maps.

Definition at line 290 of file mapper.cpp.

Referenced by fill_json(), fix_tiled_map_monsters(), get_race(), and main().

◆ rawmaps

int rawmaps = 0
static

Whether to generate raw pics or instancied ones.

Definition at line 399 of file mapper.cpp.

Referenced by do_parameters(), main(), and process_map().

◆ region_allocated

size_t region_allocated = 0
static

Allocated size of regions.

Definition at line 414 of file mapper.cpp.

Referenced by add_map_to_region(), and write_world_map().

◆ region_count

size_t region_count = 0
static

Count of regions.

Definition at line 413 of file mapper.cpp.

Referenced by add_map_to_region(), fill_json(), fix_exits_to_tiled_maps(), and main().

◆ region_links

std::map<region *, std::set<region *> > region_links
static

Definition at line 434 of file mapper.cpp.

Referenced by add_region_link(), and fill_json().

◆ regions

struct struct_region_info** regions = NULL
static

Found regions.

Definition at line 412 of file mapper.cpp.

Referenced by add_map_to_region(), create_region_array(), fill_json(), fix_exits_to_tiled_maps(), main(), and write_world_map().

◆ rendered_templates

std::set<std::string> rendered_templates
static

List of generated files, to not generate multiple times.

Definition at line 2224 of file mapper.cpp.

Referenced by add_template_to_render().

◆ reset_groups

std::set<std::string> reset_groups
static

All defined reset groups.

Definition at line 292 of file mapper.cpp.

Referenced by fill_json(), and process_map().

◆ reverse_maps

std::map<struct_map_info *, std::string> reverse_maps
static

Link between a map and its unique identifier.

Definition at line 2225 of file mapper.cpp.

Referenced by create_map_in_quest_array(), create_maps_array(), create_quest_object(), fill_json(), fill_reverse_maps(), and find_map_by_key().

◆ reverse_regions

std::map<region *, std::string> reverse_regions
static

Link between a region and its unique identifier.

Definition at line 2226 of file mapper.cpp.

Referenced by create_map_object(), create_region_array(), fill_json(), and find_region_by_key().

◆ root

char root[500]
static

Path to store generated files.

Relative or absolute, shouldn't end with a /

Definition at line 354 of file mapper.cpp.

Referenced by create_destination(), do_parameters(), dump_unused_maps(), fill_json(), generate_picture_path(), init_renderer_env(), main(), write_world_info(), and write_world_map().

◆ SearchName

std::string SearchName[int(SearchType::Count)]
static
Initial value:
= {
"(invalid)",
"region",
"map",
"item",
"monster",
"quest",
}

Search names for types, for the JS search engine.

Definition at line 305 of file mapper.cpp.

Referenced by fill_json().

◆ show_maps

int show_maps = 0
static

If set, will generate much information on map loaded.

Definition at line 367 of file mapper.cpp.

Referenced by do_parameters(), main(), and process_map().

◆ sizes

int sizes[] = {32, 16, 8, 4, 2}
static

Definition at line 362 of file mapper.cpp.

Referenced by write_pictures_from_real_size().

◆ slaying_allocated

size_t slaying_allocated = 0
static

Allocated size of slaying_info.

Definition at line 452 of file mapper.cpp.

Referenced by get_slaying_struct().

◆ slaying_count

size_t slaying_count = 0
static

Count of items in slaying_info.

Definition at line 451 of file mapper.cpp.

Referenced by fill_json(), get_slaying_struct(), and main().

◆ slaying_info

struct_slaying_info** slaying_info = NULL
static

Found slaying fields.

Definition at line 450 of file mapper.cpp.

Referenced by fill_json(), get_slaying_struct(), and main().

◆ special_equipment

std::vector<struct_equipment *> special_equipment
static

Special equipment list.

Definition at line 280 of file mapper.cpp.

Referenced by ensure_unique(), fill_json(), and main().

◆ system_quests

std::vector<quest_definition *> system_quests
static

Definition at line 2214 of file mapper.cpp.

Referenced by fill_json(), main(), and quest_callback().

◆ templateCache

inja::TemplateStorage templateCache
static

Definition at line 2416 of file mapper.cpp.

Referenced by get_template().

◆ templates

std::vector<std::string> templates
static

List of template files to start processing from.

Definition at line 2746 of file mapper.cpp.

Referenced by do_parameters(), and main().

◆ tiled_map_list

struct_map_list tiled_map_list
static

Pseudo-maps grouping other maps.

Definition at line 269 of file mapper.cpp.

Referenced by create_tiled_map(), fill_json(), fix_tiled_map(), main(), merge_tiled_maps(), and write_tiled_maps().

◆ tileset

int tileset = 0
static

Tileset to use to generate pics.

Definition at line 370 of file mapper.cpp.

Referenced by do_parameters(), main(), and process_map().

◆ warn_no_path

int warn_no_path = 0
static

Whether to warn of exits without a path.

Definition at line 402 of file mapper.cpp.

Referenced by do_parameters(), main(), and process_map().

◆ world_exit_info

int world_exit_info = 1
static

If set, will generate a world map of exits.

Definition at line 369 of file mapper.cpp.

Referenced by do_parameters(), main(), and write_world_info().

◆ world_map

int world_map = 1
static

If set, will generate a world map.

Definition at line 368 of file mapper.cpp.

Referenced by do_parameters(), main(), and write_world_map().