Go to the documentation of this file.
156 #include <sys/stat.h>
157 #include <sys/types.h>
289 for (test = 0; test <
list->count; test++) {
290 if (
list->races[test] == race)
295 if (
list->allocated ==
list->count) {
296 list->allocated += 50;
312 static int sizes[] = {32, 16, 8, 4, 2};
314 #define size_large sizes[0]
315 #define size_small sizes[1]
388 #define S_CONTAINER 2
417 if (
item->name ==
item->arch->clone.name &&
item->title ==
item->arch->clone.title)
466 if (
l->power !=
r->power)
467 return l->power <
r->power;
468 if (
l->calc_power !=
r->calc_power)
469 return l->calc_power <
r->calc_power;
485 [&] (
const auto *e) { return !sort_equipment(e, item) && !sort_equipment(item, e); });
517 namepl =
item->name_pl;
520 if (
item->artifact != NULL) {
556 item->name_pl = namepl;
559 if (add->
diff == NULL || strcmp(add->
diff,
"") == 0) {
629 if (monster->
head && monster != monster->
head)
664 const char *roads[] = {
670 const char *partial[] = {
674 for (test = 0; partial[test] != NULL; test++) {
675 if (strstr(
item->arch->name, partial[test]) != NULL)
682 for (test = 0; roads[test] != NULL; test++) {
683 if (strcmp(
item->arch->name, roads[test]) == 0)
713 return gdImageColorResolve(elevationmap, 200*elevation/
elevation_max, 0, 0);
715 return gdImageColorResolve(elevationmap, 0, 0, 200*elevation/
elevation_min);
730 if (sscanf(
map->path,
"/world/world_%d_%d", &
x, &
y) != 2)
743 int elevation =
item->elevation;
744 if (elevation != 0) {
789 fslash = strchr(from+1,
'/');
795 rslash = strchr(to+1,
'/');
796 while (fslash && rslash && (fslash-from == rslash-to) && strncmp(from, to, fslash-from+1) == 0) {
799 fslash = strchr(fslash+1,
'/');
800 rslash = strchr(rslash+1,
'/');
805 fslash = strchr(fslash+1,
'/');
905 if (
list->count ==
list->allocated) {
906 list->allocated += 10;
1033 printf(
"warning, multiple quest definition for %s, found in %s and %s.\n",
quest->name,
quest->mainmap ?
quest->mainmap->path :
"(unknown map)", mainmap->
path);
1036 quest->description = strdup(description);
1037 while (strlen(
quest->description) &&
quest->description[strlen(
quest->description)-1] ==
'\n')
1038 quest->description[strlen(
quest->description)-1] =
'\0';
1039 quest->mainmap = mainmap;
1049 char *start, *end, *
next;
1051 char description[500];
1053 start = strstr(
map->lore,
"@def");
1055 description[0] =
'\0';
1057 end = strstr(start,
"\n");
1059 strncpy(
name, start+5, end-start-5);
1060 name[end-start-5] =
'\0';
1062 end = strstr(
next,
"@end");
1064 strncpy(description,
next, end-
next);
1065 description[end-
next] =
'\0';
1067 memmove(start, end+4, strlen(
map->lore)-(end-start+3));
1071 strcpy(description,
next);
1076 strcpy(
name, start);
1082 start = end ? strstr(end,
"@def") : NULL;
1085 start = strstr(
map->lore,
"@quest");
1087 description[0] =
'\0';
1089 end = strstr(start,
"\n");
1091 strncpy(
name, start+7, end-start-7);
1092 name[end-start-7] =
'\0';
1094 end = strstr(
next,
"@end");
1096 strncpy(description,
next, end-
next);
1097 description[end-
next] =
'\0';
1099 memmove(start, end+4, strlen(
map->lore)-(end-start+3));
1103 strcpy(description,
next);
1108 strcpy(
name, start);
1114 start = end ? strstr(end,
"@quest") : NULL;
1136 info->
name = strdup(
npc->name ?
npc->name :
"(null name)");
1174 if (
list->count ==
list->allocated) {
1175 list->allocated += 50;
1234 add_map(change, &
map->tiled_group->tiled_maps);
1247 printf(
"tiled_map not in tiled_map_list!");
1271 tmp = strrchr((
char *)
path,
'/');
1289 if (strcmp(
path, *
map) == 0) {
1295 printf(
"Map processed but not found in directory reading? %s\n",
path);
1313 if (
regions[test]->reg == reg)
1326 if (sscanf(
map->path,
"/world/world_%d_%d", &
x, &
y) == 2) {
1344 gdImagePng(pic,
file);
1399 add->
slaying = strdup(slaying);
1476 FILE *
out = fopen(picpath,
"wb+");
1480 for (
size_t i = 1; i <
num_sizes; i++) {
1482 gdImagePtr small = gdImageCreateTrueColor(width*
sizes[i], height*
sizes[i]);
1484 out = fopen(picpath,
"wb+");
1487 gdImageDestroy(small);
1502 gdImagePtr pic =
nullptr;
1504 struct stat statspic;
1505 char exit_path[500];
1515 printf(
" processing map %s\n", info->
path);
1519 printf(
"couldn't load map %s\n", info->
path);
1528 info->
level =
m->difficulty;
1530 info->
lore = strdup(
m->maplore);
1533 if (
m->reset_group) {
1538 isworld = (sscanf(info->
path,
"/world/world_%d_%d", &
x, &
y) == 2);
1541 info->
name = strdup(
m->name);
1556 stat(tmppath, &stats);
1557 if (stat(picpath[0], &statspic) || (statspic.st_mtime < stats.st_mtime))
1570 for (
x = 0;
x < 4;
x++)
1571 if (
m->tile_path[
x] != NULL) {
1574 if (stat(tmppath, &stats)) {
1575 printf(
" map %s doesn't exist in map %s, for tile %d.\n", exit_path, info->
path,
x);
1586 if (link && link !=
m) {
1631 if (!
item->slaying) {
1634 printf(
" exit without any path at %d, %d on %s\n",
item->x,
item->y, info->
path);
1637 if (strcmp(
item->slaying,
"/!"))
1641 printf(
" random map without message in %s at %d, %d\n", info->
path,
item->x,
item->y);
1644 start = strstr(
item->msg,
"\nfinal_map ");
1645 if (!start && strncmp(
item->msg,
"final_map", strlen(
"final_map")) == 0)
1649 char *end = strchr((
char *)start+1,
'\n');
1651 start += strlen(
"final_map")+2;
1652 strncpy(ep, start, end-start);
1660 if (stat(tmppath, &stats)) {
1661 printf(
" map %s doesn't exist in map %s, at %d, %d.\n", ep, info->
path,
item->x,
item->y);
1670 if (link && link !=
m) {
1700 if (
item->invisible)
1721 if (
gdfaces[
item->face->number] != NULL && ((!
item->head && !
item->more) || (
item->arch->clone.x+hx == 0 &&
item->arch->clone.y+hy == 0))) {
1730 gdImageDestroy(pic);
1748 char mapleft[10], maptop[10], mapright[10], mapbottom[10], mappath[5000];
1758 printf(
"Generating world map in world.html...");
1761 pic = gdImageCreateTrueColor(
SIZE*30,
SIZE*30);
1764 strcat(
file,
"/world.html");
1769 for (
y = 0;
y < 30;
y++) {
1770 for (
x = 0;
x < 30;
x++) {
1771 snprintf(
name,
sizeof(
name),
"world_%d_%d", wx, wy);
1772 snprintf(mapleft,
sizeof(mapleft),
"%d",
SIZE*
x);
1773 snprintf(maptop,
sizeof(maptop),
"%d",
SIZE*
y);
1774 snprintf(mapright,
sizeof(mapright),
"%d",
SIZE*(
x+1)-1);
1775 snprintf(mapbottom,
sizeof(mapbottom),
"%d",
SIZE*(
y+1)-1);
1779 out = fopen(mappath,
"rb");
1781 printf(
"\n warning: large pic not found for world_%d_%d", wx, wy);
1786 small = gdImageCreateFromPng(
out);
1788 small = gdImageCreateFromJpeg(
out);
1791 printf(
"\n warning: pic not found for world_%d_%d", wx, wy);
1795 gdImageCopyResized(pic, small,
SIZE*
x,
SIZE*
y, 0, 0,
SIZE,
SIZE, small->sx, small->sy);
1796 gdImageDestroy(small);
1805 out = fopen(mappath,
"wb+");
1810 small = gdImageCreateTrueColor(
SIZE*30,
SIZE*30);
1811 font = gdFontGetGiant();
1812 color = gdImageColorAllocateAlpha(pic, 255, 0, 0, 20);
1829 out = fopen(mappath,
"wb+");
1832 gdImageDestroy(small);
1835 out = fopen(mappath,
"wb+");
1838 gdImageDestroy(pic);
1850 printf(
"map without path!\n");
1871 printf(
"empty tiled map group!");
1875 snprintf(
name,
sizeof(
name),
"tiled_map_group_%zu",
map);
1889 printf(
"*** warning: tiled maps %s and %s not in same region (%s and %s).\n",
1912 slash = strrchr(
name,
'/');
1983 for (
size_t race = 0; race <
races.
count; race++) {
2011 for (
size_t size = 0; size <
num_sizes; size++) {
2013 if (stat(picpath, &stats))
2017 for (test = 0; test <
map->tiled_maps.count; test++) {
2018 if (
map->tiled_maps.maps[test]->pic_was_done)
2037 int xmin = 0, xmax = 0, ymin = 0, ymax = 0,
count, last;
2040 gdImagePtr large, load;
2047 printf(
" Generating composite map for %s...",
map->name);
2051 printf(
" already uptodate.\n");
2057 printf(
"Tiled map without tiled maps?\n");
2060 map->tiled_maps.maps[0]->processed = 1;
2061 map->tiled_maps.maps[0]->tiled_x_from = 0;
2062 map->tiled_maps.maps[0]->tiled_y_from = 0;
2067 for (tiled = 0; tiled <
map->tiled_maps.count; tiled++) {
2074 if ((
current->tiles[0]) && (
current->tiles[0]->processed == 0)) {
2075 current->tiles[0]->processed = 1;
2079 if ((
current->tiles[1]) && (
current->tiles[1]->processed == 0)) {
2080 current->tiles[1]->processed = 1;
2084 if ((
current->tiles[2]) && (
current->tiles[2]->processed == 0)) {
2085 current->tiles[2]->processed = 1;
2089 if ((
current->tiles[3]) && (
current->tiles[3]->processed == 0)) {
2090 current->tiles[3]->processed = 1;
2096 if (last ==
count) {
2097 printf(
"do_tiled_map_picture: didn't process any map in %s (%d left)??\n",
map->path, last);
2102 for (tiled = 0; tiled <
map->tiled_maps.count; tiled++) {
2103 if (
map->tiled_maps.maps[tiled]->tiled_x_from < xmin)
2104 xmin =
map->tiled_maps.maps[tiled]->tiled_x_from;
2105 if (
map->tiled_maps.maps[tiled]->tiled_y_from < ymin)
2106 ymin =
map->tiled_maps.maps[tiled]->tiled_y_from;
2107 if (
map->tiled_maps.maps[tiled]->tiled_x_from+
map->tiled_maps.maps[tiled]->width > xmax)
2108 xmax =
map->tiled_maps.maps[tiled]->tiled_x_from+
map->tiled_maps.maps[tiled]->width;
2109 if (
map->tiled_maps.maps[tiled]->tiled_y_from+
map->tiled_maps.maps[tiled]->height > ymax)
2110 ymax =
map->tiled_maps.maps[tiled]->tiled_y_from+
map->tiled_maps.maps[tiled]->height;
2115 for (tiled = 0; tiled <
map->tiled_maps.count; tiled++) {
2118 out = fopen(picpath,
"rb");
2120 printf(
"\n do_tiled_map_picture: warning: pic file %s not found for %s (errno=%d)\n", picpath,
map->tiled_maps.maps[tiled]->path, errno);
2124 load = gdImageCreateFromPng(
out);
2126 load = gdImageCreateFromJpeg(
out);
2129 printf(
"\n do_tiled_map_picture: warning: pic not found for %s\n",
map->tiled_maps.maps[tiled]->path);
2132 gdImageCopy(large, load,
size_large*(
map->tiled_maps.maps[tiled]->tiled_x_from-xmin),
size_large*(
map->tiled_maps.maps[tiled]->tiled_y_from-ymin), 0, 0, load->sx, load->sy);
2133 gdImageDestroy(load);
2138 gdImageDestroy(large);
2155 printf(
"Writing tiled map information...\n");
2171 static std::shared_ptr<inja::Environment>
env;
2185 return found->first;
2197 return found->first;
2208 for (
size_t m = 0;
m <
maps.count;
m++) {
2224 for (
size_t n = 0; n <
list.size(); n++) {
2227 {
"name",
npc->name },
2230 {
"message",
npc->message },
2243 for (
size_t n = 0; n <
list.count; n++) {
2244 auto race =
list.races[n];
2246 {
"name", race->name },
2247 {
"count", race->count },
2260 for (
size_t m = 0;
m <
list.count;
m++) {
2262 if (!
q->map || !
q->description)
2266 {
"description",
q->description },
2267 {
"quest",
q->quest->name },
2268 {
"number",
q->quest->number },
2284 {
"name",
map->name },
2285 {
"path",
map->path },
2287 {
"level",
map->level },
2288 {
"reset_group",
map->reset_group ?
map->reset_group :
"" },
2289 {
"lore",
map->lore &&
map->lore[0] ?
map->lore :
"" },
2308 {
"number",
quest->number },
2310 {
"description",
quest->description ?
quest->description :
"" },
2324 if (cur->tiled_group)
2326 snprintf(
buf,
sizeof(
buf),
"map_%04lu",
map);
2368 bool need_unknown_region =
false;
2379 snprintf(
buf,
sizeof(
buf),
"reg_%04lu", reg);
2398 auto cur =
map.first;
2399 if (cur->tiled_group)
2401 if (cur->cfregion ==
nullptr)
2402 need_unknown_region =
true;
2406 if (need_unknown_region) {
2408 {
"_key",
"reg_ffff" },
2409 {
"name",
"unknown" },
2410 {
"longname",
"unknown" },
2411 {
"description",
"unknown" },
2425 json[
"items"][idx] = {
2426 {
"name", eq->name },
2427 {
"power", eq->power },
2428 {
"calc_power", eq->calc_power },
2429 {
"diff", eq->
diff },
2439 {
"name", race->name },
2440 {
"count", race->count },
2449 {
"code",
quest->quest_code },
2450 {
"title",
quest->quest_title },
2451 {
"description",
quest->quest_description ?
quest->quest_description :
"" },
2452 {
"replayable",
quest->quest_restart },
2458 std::sort(
quest->steps.begin(),
quest->steps.end(), [] (
auto left,
auto right) { return left->step < right->step; });
2459 for (
size_t s = 0; s <
quest->steps.size(); s++) {
2460 j[
"steps"].push_back({
2461 {
"description",
quest->steps[s]->step_description ?
quest->steps[s]->step_description :
"" },
2462 {
"is_completion",
quest->steps[s]->is_completion_step ? true :
false },
2468 for (
size_t m = 0;
m < qim->maps.count;
m++) {
2471 j[
"maps"].push_back({
2472 {
"description", qim->maps.list[
m]->description },
2473 {
"map",
map->second },
2485 {
"slaying", info->slaying },
2506 void add_template_to_render(
const std::string &template_name,
const std::string &output_name,
const std::string ¶m);
2531 auto template_name =
args.at(0)->get<std::string>();
2532 auto output_name(template_name);
2533 auto param = (
args.size() > 1 ?
args.at(1)->get<std::string>() :
"");
2535 if (!param.empty()) {
2536 output_name = param +
"_" + output_name;
2537 if (param.substr(0, 4) ==
"map_") {
2539 if (
map !=
nullptr) {
2540 output_name = std::string(
map->path + 1) +
".html";
2543 if (param.substr(0, 4) ==
"reg_") {
2545 if (reg !=
nullptr) {
2546 output_name = std::string(reg->name) +
".html";
2561 auto what =
args.at(0)->get<std::string>();
2562 if (what.substr(0, 4) ==
"map_") {
2567 if (
args.size() > 1) {
2568 size =
args.at(1)->get<
int>() - 1;
2595 auto on(output_name);
2603 r.template_name = template_name;
2609 static std::vector<std::string>
split(
const std::string &field,
const std::string &by) {
2610 std::vector<std::string>
result;
2611 size_t start = 0,
found;
2612 while ((
found = field.find(by, start)) != std::string::npos) {
2613 result.push_back(field.substr(start,
found - start));
2616 result.push_back(field.substr(start));
2630 std::string
str =
args.at(0)->get<std::string>();
2631 size_t start =
args.at(1)->get<size_t>();
2632 size_t len =
args.size() > 2 ?
args.at(2)->get<
size_t>() : std::string::npos;
2633 return str.substr(start, len);
2638 int val =
args.at(0)->get<int>(), digits =
args.at(1)->get<
int>();
2639 snprintf(
buf,
sizeof(
buf),
"%0*d", digits, val);
2640 return std::string(
buf);
2643 std::string
r(
root);
2649 return std::string(rel);
2652 const auto &src =
args.at(0);
2653 auto field =
args.at(1)->get<std::string>();
2655 auto found = std::find_if(src->begin(), src->end(), [&field, &
value] (
auto item) {
2656 return item[field] == *value;
2658 if (
found == src->end()) {
2665 const auto &src =
args.at(0);
2666 auto field =
args.at(1)->get<std::string>();
2668 if (
filter->is_array()) {
2669 std::copy_if(src->begin(), src->end(), std::back_inserter(ret), [&] (
auto &
item) {
2670 auto val = item[field];
2671 return std::find_if(filter->begin(), filter->end(), [&] (auto li) { return val == li; }) !=
filter->end();
2674 std::copy_if(src->begin(), src->end(), std::back_inserter(ret), [&] (
auto &
item) {
2675 return filter->get<std::string>() == item[field];
2681 const auto &src =
args.at(0);
2682 std::vector<nlohmann::json> ret;
2683 for (
auto i : *src) {
2686 auto fields =
split(
args.at(1)->get<std::string>(),
",");
2687 bool invert =
args.size() > 2 ?
args.at(2)->get<
bool>() :
false;
2688 bool ignore_case =
args.size() > 3 ?
args.at(3)->get<
bool>() :
true;
2689 std::sort(ret.begin(), ret.end(), [&] (
auto left,
auto right) {
2690 for (auto field : fields) {
2691 nlohmann::json l = left[field], r = right[field];
2692 if (ignore_case && l.is_string() && r.is_string()) {
2693 std::string ls(l.get<std::string>()), rs(r.get<std::string>());
2694 std::transform(ls.begin(), ls.end(), ls.begin(), [](unsigned char c){ return std::tolower(c); });
2695 std::transform(rs.begin(), rs.end(), rs.begin(), [](unsigned char c){ return std::tolower(c); });
2699 return invert ? (rs < ls) : (ls < rs);
2704 return invert ? (r < l) : (l < r);
2711 env->set_trim_blocks(
true);
2712 env->set_lstrip_blocks(
true);
2742 struct dirent *
file;
2743 struct stat statbuf;
2748 for (ignore = 0;
ignore_path[ignore] != NULL; ignore++) {
2759 for (ignore = 0;
ignore_name[ignore] != NULL; ignore++) {
2766 snprintf(full,
sizeof(full),
"%s/%s",
path,
file->d_name);
2768 status = stat(full, &statbuf);
2769 snprintf(full,
sizeof(full),
"%s/%s", from,
file->d_name);
2770 if ((
status != -1) && (S_ISDIR(statbuf.st_mode))) {
2785 snprintf(
path,
sizeof(
path),
"%s/%s",
root,
"maps.unused");
2788 printf(
"Unable to open file maps.unused!\n");
2795 printf(
"%ld unused maps.\n",
found_maps.size());
2803 gdImagePtr elevationmap;
2809 printf(
"Saving exit/blocking/road information...");
2819 puts(
"Error: Could not save elevation world map due to not finding any minimum or maximum elevation.");
2823 elevationmap = gdImageCreateTrueColor(30*50, 30*50);;
2825 for (
x = 0;
x < 30*50;
x++) {
2826 for (
y = 0;
y < 30*50;
y++) {
2831 printf(
"Saving elevation world map...");
2837 gdImageDestroy(elevationmap);
2838 elevationmap = NULL;
2865 printf(
"Crossfire Mapper will generate pictures of maps, and create indexes for all maps and regions.\n\n");
2866 printf(
"Syntax: %s\n\n", program);
2867 printf(
"Optional arguments:\n");
2868 printf(
" -nopics don't generate pictures.\n");
2869 printf(
" -root=<path> destination path. Default 'html'.\n");
2870 printf(
" -limit=<number> stop processing after this number of maps, -1 to do all maps (default).\n");
2871 printf(
" -showmaps outputs the name of maps as they are processed.\n");
2872 printf(
" -jpg[=quality] generate jpg pictures, instead of default png. Quality should be 0-95, -1 for automatic.\n");
2873 printf(
" -forcepics force to regenerate pics, even if pics's date is after map's.\n");
2874 printf(
" -addmap=<map> adds a map to process. Path is relative to map's directory root.\n");
2875 printf(
" -rawmaps generates maps pics without items on random (shop, treasure) tiles.\n");
2876 printf(
" -warnnopath inform when an exit has no path set.\n");
2877 printf(
" -listunusedmaps finds all unused maps in the maps directory.\n");
2878 printf(
" -noworldmap don't write the world map in world.png.\n");
2879 printf(
" -noregionslink don't generate regions relation file.\n");
2880 printf(
" -regionslink generate regions relation file.\n");
2881 printf(
" -noexitmap don't generate map of exits.\n");
2882 printf(
" -exitmap generate map of exits.\n");
2883 printf(
" -tileset=<number> use specified tileset to generate the pictures. Default 0 (standard).\n");
2884 printf(
" -details-quests list all quests steps. Default no.\n");
2885 printf(
" -list-system-quests include 'system' quests in quest list. Default no.\n");
2886 printf(
" -templates-dir=[dir] set the directory to get templates from. Default 'templates/'.\n");
2887 printf(
" -add-template=[file] add a template to process. May be specified multiple times. If empty, 'index.html' is used.\n");
2888 printf(
" -list-template-to-process display the name of the template about to be rendered. Useful for debugging.");
2907 while (arg < argc) {
2908 if (strcmp(argv[arg],
"-nopics") == 0)
2910 else if (strncmp(argv[arg],
"-root=", 6) == 0)
2911 strncpy(
root, argv[arg]+6, 500);
2912 else if (strncmp(argv[arg],
"-limit=", 7) == 0)
2914 else if (strcmp(argv[arg],
"-showmaps") == 0)
2916 else if (strcmp(argv[arg],
"-jpg") == 0) {
2918 if (argv[arg][4] ==
'=') {
2924 else if (strcmp(argv[arg],
"-forcepics") == 0)
2926 else if (strncmp(argv[arg],
"-addmap=", 8) == 0) {
2927 if (*(argv[arg]+8) ==
'/')
2928 strncpy(
path, argv[arg]+8, 500);
2930 snprintf(
path, 500,
"/%s", argv[arg]+8);
2933 else if (strcmp(argv[arg],
"-rawmaps") == 0)
2935 else if (strcmp(argv[arg],
"-warnnopath") == 0)
2937 else if (strcmp(argv[arg],
"-listunusedmaps") == 0)
2939 else if (strcmp(argv[arg],
"-noworldmap") == 0)
2941 else if (strcmp(argv[arg],
"-noregionslink") == 0)
2943 else if (strcmp(argv[arg],
"-regionslink") == 0)
2945 else if (strcmp(argv[arg],
"-noexitmap") == 0)
2947 else if (strcmp(argv[arg],
"-exitmap") == 0)
2949 else if (strncmp(argv[arg],
"-tileset=", 9) == 0) {
2952 }
else if (strcmp(argv[arg],
"-detail-quests") == 0) {
2954 }
else if (strcmp(argv[arg],
"-list-system-quests") == 0) {
2956 }
else if (strncmp(argv[arg],
"-templates-dir=", 15) == 0) {
2958 }
else if (strncmp(argv[arg],
"-add-template=", 14) == 0) {
2960 }
else if (strcmp(argv[arg],
"-list-template-to-process") == 0) {
2967 strcpy(
root,
"html");
2986 strcpy(dummy,
root);
2987 strcat(dummy,
"/a");
3000 return (
value ?
"yes" :
"no");
3007 return find->second;
3026 printf(
"Initializing Crossfire data...\n");
3044 printf(
"\n\n done.\n\n");
3047 printf(
"Erreor: invalid tileset %d!\n",
tileset);
3061 strcpy(
max,
"(none)");
3062 printf(
"Crossfire map browser generator\n");
3063 printf(
"-------------------------------\n\n");
3064 printf(
"Parameters:\n");
3065 printf(
" path to write files: %s\n",
root);
3066 printf(
" maximum number of maps to process: %s\n",
max);
3083 printf(
" templates to process: ");
3084 const char *sep =
"";
3086 printf(
"%s%s", sep, f.c_str());
3094 printf(
"listing all maps...");
3096 printf(
"done, %ld maps found.\n",
found_maps.size());
3100 infomap = gdImageCreateTrueColor(30*50, 30*50);
3107 for (i = 0; i < 50*30; i++)
3112 printf(
"browsing maps...\n");
3122 printf(
" --- map limit reached, stopping ---\n");
3149 std::sort(
system_quests.begin(),
system_quests.end(), [] (
const auto &left,
const auto &right) { return strcmp(left->quest_code, right->quest_code) < 0; });
3156 if (!
file.empty()) {
3161 const auto fullStart = time(
nullptr);
3162 printf(
"rendering pages...");
3167 while (!
pages.empty()) {
3168 auto p =
pages.back();
3170 if (p.param.empty())
3174 const auto start = time(
nullptr);
3176 printf(
" rendering page %s (%s)... ", p.template_name.c_str(), p.param.c_str());
3183 const auto elapsed = time(
nullptr) - start;
3185 printf(
"took %ld seconds\n", elapsed);
3189 const auto elapsed = time(
nullptr) - fullStart;
3190 printf(
" done, took %ld seconds\n", elapsed);
3209 while ((invtmp->stats.hp--) > 0)
3211 invtmp->randomitems = NULL;
3215 && invtmp->type !=
SPELL
3216 && invtmp->type !=
CLASS
3222 invtmp->randomitems = NULL;
3242 tmp->randomitems = NULL;
3248 while ((
tmp->stats.hp--) > 0)
3250 tmp->randomitems = NULL;
3274 tmp->randomitems = NULL;
3287 #ifndef DOXYGEN_SHOULD_SKIP_THIS
3293 void draw_ext_info(
int,
int,
const object *, uint8_t, uint8_t,
const char *txt) {
3294 fprintf(
logfile,
"%s\n", txt);
3300 va_start(ap, format);
3301 vfprintf(
logfile, format, ap);
3306 fprintf(
logfile,
"ext_info_map: %s\n", str1);
3376 while ((
op->stats.hp--) > 0)
static struct_race * get_race(const char *name)
struct struct_map_info * tiles[4]
void move_firewall(object *)
static void write_tiled_map_page(struct_map_info *map)
static void fix_tiled_map_monsters(void)
void do_auto_apply(mapstruct *m)
static void add_map(struct_map_info *info, struct_map_list *list)
#define HAS_RANDOM_ITEMS(op)
#define FREE_OBJ_NO_DESTROY_CALLBACK
static const char * ignore_name[]
static struct_quest * get_quest_info(const char *name)
static region * find_region_by_key(const std::string &key)
static void process_map_lore(struct_map_info *map)
const artifact * find_artifact(const object *op, const char *name)
region * get_region_struct(void)
static std::unordered_map< std::string, mapzone * > maps
static int compare_map_info(const struct_map_info *left, const struct_map_info *right)
static std::string path_from_current(const std::string &path)
void quest_for_each(quest_op op, void *user)
void LOG(LogLevel logLevel, const char *format,...)
static nlohmann::json generate_picture_link(inja::Arguments &args)
struct struct_map_info * tiled_group
static const int num_sizes
static void add_slaying(struct_map_info *map, object *item)
mapstruct * ready_map_name(const char *name, int flags)
static void write_tiled_maps(void)
char first_map_path[MAX_BUF]
#define QUERY_FLAG(xyz, p)
struct_map_in_quest_list maps
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
static nlohmann::json create_quest_object(struct_quest *quest, const std::string &key)
static struct_map_info * create_map_info(void)
basic_json<> json
default JSON class
void esrv_del_item(player *, object *)
static void write_pictures_from_real_size(const char *path, gdImagePtr real, int width, int height)
static std::map< region *, std::set< region * > > region_links
int get_face_fallback(int faceset, uint16_t imageno)
static event_registration c
static enum output_format_type output_format
StringBuffer * stringbuffer_new(void)
static nlohmann::json create_npc_array(npc_list &list)
static struct_map_info * get_map_info(const char *path)
static void fix_exits_to_tiled_maps(void)
static std::map< struct_map_info *, std::string > reverse_maps
static int dump(const std::set< std::string > &items, const char *name)
static std::vector< gdImagePtr > gdfaces
static size_t slaying_allocated
void give_artifact_abilities(object *op, const object *artifact)
static struct_equipment * get_equipment(void)
static int is_special_equipment(object *item)
static size_t region_allocated
static nlohmann::json generate_page_and_link(inja::Arguments &args)
object * generate_treasure(treasurelist *t, int difficulty)
face_sets * find_faceset(int id)
static nlohmann::json create_map_in_quest_array(struct_map_in_quest_list &list)
static const char * yesno(int value)
static void fix_map_names(void)
struct_map_list maps[S_MAX]
static struct_map_list maps_list
static int color_unlinked_exit
static std::vector< pageToRender > pages
static int list_unused_maps
void draw_ext_info_format(int, int, const object *, uint8_t, uint8_t, const char *format,...)
void esrv_send_item(object *, object *)
void push_back(basic_json &&val)
add an object to an array
static nlohmann::json create_region_array(const std::set< region * > ®ions)
void clean_tmp_files(void)
static void add_npc_to_map(npc_list *list, const object *npc)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
object * object_insert_in_ob(object *op, object *where)
void apply_auto_fix(mapstruct *)
void account_char_save(Account_Chars *)
static int world_exit_info
static int sort_struct_quest(const void *left, const void *right)
struct struct_quest * quest
#define FLAG_IS_A_TEMPLATE
static void init_renderer_env()
static event_registration m
char * stringbuffer_finish(StringBuffer *sb)
void object_free_drop_inventory(object *ob)
DIR * opendir(const char *)
static inja::TemplateStorage templateCache
static struct struct_region_info ** regions
struct_map_list exits_from
static bool detail_quests
static struct_equipment * ensure_unique(struct_equipment *item)
static struct_slaying_info * get_slaying_struct(const char *slaying)
static void generate_picture_path(const char *path, size_t pic_size, char *out, size_t len)
void set_darkness_map(mapstruct *)
static void define_quest(const char *name, struct_map_info *mainmap, const char *description)
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
static void add_to_struct_map_in_quest_list(struct_map_in_quest_list *list, struct_map_in_quest *item)
static void do_tiled_map_picture(struct_map_info *map)
static struct_slaying_info ** slaying_info
sstring add_string(const char *str)
static struct_race_list races
std::vector< struct_npc_info * > npc_list
void object_get_multi_size(const object *ob, int *sx, int *sy, int *hx, int *hy)
int main(int argc, char **argv)
static const char * output_extensions[]
static nlohmann::json create_maps_array(struct_map_list &maps)
static std::vector< quest_definition * > system_quests
static int get_elevation_color(int elevation, gdImagePtr elevationmap)
static std::set< std::string > reset_groups
static void quest_callback(const quest_definition *quest, void *)
struct dirent * readdir(DIR *)
static int is_slaying(object *item)
static nlohmann::json create_race_array(struct_race_list &list)
Account_Chars * account_char_load(const char *)
void dragon_ability_gain(object *, int, int)
array_t * array
array (stored with pointer to save storage)
void object_update_speed(object *op)
struct_map_in_quest_list quests
static void write_world_map(void)
static void add_map_to_quest(struct_map_info *map, const char *name, const char *description)
static struct_npc_info * create_npc_info(const object *npc)
void esrv_update_item(int, object *, object *)
void object_free(object *ob, int flags)
static int is_blocking(object *item)
static void do_exit_map(mapstruct *map)
static void create_destination(void)
struct struct_race ** races
#define FLAG_UNAGGRESSIVE
static void check_slaying_inventory(struct_map_info *map, object *item)
static void append_map_list(struct_map_list &dest, struct_map_list &src)
static void init_struct_map_in_quest_list(struct_map_in_quest_list *list)
void delete_map(mapstruct *m)
struct struct_map_info ** maps
static void fill_json(nlohmann::json &json)
static void add_map_to_region(struct_map_info *map, region *reg)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
static bool list_system_quests
static nlohmann::json create_map_object(struct_map_info *map, const std::string &key)
struct_map_info * mainmap
static std::shared_ptr< inja::Environment > env
static int sort_map_info(const void *left, const void *right)
static void fill_reverse_maps(struct_map_list &list)
int is_valid_faceset(int fsn)
static int sort_slaying(const void *left, const void *right)
static struct_map_list tiled_map_list
static void add_race_to_list(struct_race *race, struct_race_list *list, int check)
static void check_equipment(object *item, struct_map_info *map)
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
static std::vector< std::string > path_stack
static void merge_tiled_maps(struct_map_info *map, struct_map_info *tiled_map)
static void list_map(const char *path)
static std::set< std::string > rendered_templates
int apply_auto(object *op)
static void init_map_list(struct_map_list *list)
std::vector< region * > all_regions
static void add_region_link(mapstruct *source, mapstruct *dest)
static void free_equipment(struct_equipment *equip)
void esrv_update_spells(player *)
static void add_map_to_slaying(struct_slaying_info *info, int item, struct_map_info *map)
std::map< std::string, Template > TemplateStorage
void account_char_free(Account_Chars *)
struct_map_list maps_list
std::vector< const json * > Arguments
char * create_pathname(const char *name, char *buf, size_t size)
const typedef char * sstring
a class to store JSON values
static void save_picture(FILE *file, gdImagePtr pic)
static bool display_rendered_template
static std::string templates_root("templates/")
struct_race_list monsters
archetype * find_archetype(const char *name)
static int ** elevation_info
static int color_blocking
static inja::Template get_template(const std::string &filename)
struct_map_list tiled_maps
void ext_info_map(int, const mapstruct *, uint8_t, uint8_t, const char *str1)
static size_t region_count
void command_help(object *, const char *)
static void do_parameters(int argc, char **argv)
#define CLEAR_FLAG(xyz, p)
static nlohmann::json all_data
static void add_monster(object *monster, struct_map_info *map)
struct struct_map_in_quest ** list
std::string template_name
void get_ob_diff(StringBuffer *sb, const object *op, const object *op2)
static int sort_race(const void *a, const void *b)
static bool do_regions_link
object * arch_to_object(archetype *at)
void object_give_identified_properties(object *op)
static void init_race_list(struct_race_list *list)
static void process_map(struct_map_info *info)
static int quests_allocated
int strcasecmp(const char *s1, const char *s2)
object * find_skill_by_number(object *, int)
void account_logout(const char *)
static std::map< region *, std::string > reverse_regions
region * get_region_by_map(mapstruct *m)
static struct_map_info * create_tiled_map(void)
static std::vector< std::string > templates
static const char * ignore_path[]
static size_t slaying_count
SockList * player_get_delayed_buffer(player *)
void add_template_to_render(const std::string &template_name, const std::string &output_name, const std::string ¶m)
void object_remove(object *op)
static gdImagePtr infomap
static int sort_struct_map_in_quest(const void *left, const void *right)
static void relative_path(const char *from, const char *to, char *result)
static void dump_unused_maps(void)
void rod_adjust(object *)
static int sort_region(const void *left, const void *right)
static std::vector< struct_equipment * > special_equipment
void make_path_to_file(const char *filename)
#define FREE_OBJ_FREE_INVENTORY
static void fix_exits_for_map(struct_map_info *current, struct_map_list *from, int is_from)
void draw_ext_info(int, int, const object *, uint8_t, uint8_t, const char *txt)
static std::vector< std::string > split(const std::string &field, const std::string &by)
static void do_help(const char *program)
IteratorType erase(IteratorType pos)
remove element given an iterator
int calc_item_power(const object *op)
static void write_world_info(void)
static int tiled_map_need_pic(struct_map_info *map)
static struct_quest ** quests
static void fix_tiled_map(void)
static int pics_allocated
static std::vector< char * > found_maps
#define FOR_INV_PREPARE(op_, it_)
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
player * find_player_partial_name(const char *)
static struct_map_info * find_map_by_key(const std::string &key)
static struct_quest * find_quest_info(const char *name)
static void find_maps(const char *from)
static int is_road(object *item)
static int color_linked_exit
static bool sort_equipment(const struct_equipment *l, const struct_equipment *r)
static void add_one_item(object *item, struct_map_info *map)
object * identify(object *op)