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);
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)
1718 if (
gdfaces[
item->face->number] != NULL && ((!
item->head && !
item->more) || (
item->arch->clone.x+hx == 0 &&
item->arch->clone.y+hy == 0))) {
1727 gdImageDestroy(pic);
1745 char mapleft[10], maptop[10], mapright[10], mapbottom[10], mappath[5000];
1755 printf(
"Generating world map in world.html...");
1758 pic = gdImageCreateTrueColor(
SIZE*30,
SIZE*30);
1761 strcat(
file,
"/world.html");
1766 for (
y = 0;
y < 30;
y++) {
1767 for (
x = 0;
x < 30;
x++) {
1768 snprintf(
name,
sizeof(
name),
"world_%d_%d", wx, wy);
1769 snprintf(mapleft,
sizeof(mapleft),
"%d",
SIZE*
x);
1770 snprintf(maptop,
sizeof(maptop),
"%d",
SIZE*
y);
1771 snprintf(mapright,
sizeof(mapright),
"%d",
SIZE*(
x+1)-1);
1772 snprintf(mapbottom,
sizeof(mapbottom),
"%d",
SIZE*(
y+1)-1);
1776 out = fopen(mappath,
"rb");
1778 printf(
"\n warning: large pic not found for world_%d_%d", wx, wy);
1783 small = gdImageCreateFromPng(
out);
1785 small = gdImageCreateFromJpeg(
out);
1788 printf(
"\n warning: pic not found for world_%d_%d", wx, wy);
1792 gdImageCopyResized(pic, small,
SIZE*
x,
SIZE*
y, 0, 0,
SIZE,
SIZE, small->sx, small->sy);
1793 gdImageDestroy(small);
1802 out = fopen(mappath,
"wb+");
1807 small = gdImageCreateTrueColor(
SIZE*30,
SIZE*30);
1808 font = gdFontGetGiant();
1809 color = gdImageColorAllocateAlpha(pic, 255, 0, 0, 20);
1826 out = fopen(mappath,
"wb+");
1829 gdImageDestroy(small);
1832 out = fopen(mappath,
"wb+");
1835 gdImageDestroy(pic);
1847 printf(
"map without path!\n");
1868 printf(
"empty tiled map group!");
1872 snprintf(
name,
sizeof(
name),
"tiled_map_group_%zu",
map);
1886 printf(
"*** warning: tiled maps %s and %s not in same region (%s and %s).\n",
1909 slash = strrchr(
name,
'/');
1980 for (
size_t race = 0; race <
races.
count; race++) {
2008 for (
size_t size = 0; size <
num_sizes; size++) {
2010 if (stat(picpath, &stats))
2014 for (test = 0; test <
map->tiled_maps.count; test++) {
2015 if (
map->tiled_maps.maps[test]->pic_was_done)
2034 int xmin = 0, xmax = 0, ymin = 0, ymax = 0,
count, last;
2037 gdImagePtr large, load;
2044 printf(
" Generating composite map for %s...",
map->name);
2048 printf(
" already uptodate.\n");
2054 printf(
"Tiled map without tiled maps?\n");
2057 map->tiled_maps.maps[0]->processed = 1;
2058 map->tiled_maps.maps[0]->tiled_x_from = 0;
2059 map->tiled_maps.maps[0]->tiled_y_from = 0;
2064 for (tiled = 0; tiled <
map->tiled_maps.count; tiled++) {
2071 if ((
current->tiles[0]) && (
current->tiles[0]->processed == 0)) {
2072 current->tiles[0]->processed = 1;
2076 if ((
current->tiles[1]) && (
current->tiles[1]->processed == 0)) {
2077 current->tiles[1]->processed = 1;
2081 if ((
current->tiles[2]) && (
current->tiles[2]->processed == 0)) {
2082 current->tiles[2]->processed = 1;
2086 if ((
current->tiles[3]) && (
current->tiles[3]->processed == 0)) {
2087 current->tiles[3]->processed = 1;
2093 if (last ==
count) {
2094 printf(
"do_tiled_map_picture: didn't process any map in %s (%d left)??\n",
map->path, last);
2099 for (tiled = 0; tiled <
map->tiled_maps.count; tiled++) {
2100 if (
map->tiled_maps.maps[tiled]->tiled_x_from < xmin)
2101 xmin =
map->tiled_maps.maps[tiled]->tiled_x_from;
2102 if (
map->tiled_maps.maps[tiled]->tiled_y_from < ymin)
2103 ymin =
map->tiled_maps.maps[tiled]->tiled_y_from;
2104 if (
map->tiled_maps.maps[tiled]->tiled_x_from+
map->tiled_maps.maps[tiled]->width > xmax)
2105 xmax =
map->tiled_maps.maps[tiled]->tiled_x_from+
map->tiled_maps.maps[tiled]->width;
2106 if (
map->tiled_maps.maps[tiled]->tiled_y_from+
map->tiled_maps.maps[tiled]->height > ymax)
2107 ymax =
map->tiled_maps.maps[tiled]->tiled_y_from+
map->tiled_maps.maps[tiled]->height;
2112 for (tiled = 0; tiled <
map->tiled_maps.count; tiled++) {
2115 out = fopen(picpath,
"rb");
2117 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);
2121 load = gdImageCreateFromPng(
out);
2123 load = gdImageCreateFromJpeg(
out);
2126 printf(
"\n do_tiled_map_picture: warning: pic not found for %s\n",
map->tiled_maps.maps[tiled]->path);
2129 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);
2130 gdImageDestroy(load);
2135 gdImageDestroy(large);
2152 printf(
"Writing tiled map information...\n");
2168 static std::shared_ptr<inja::Environment>
env;
2182 return found->first;
2194 return found->first;
2205 for (
size_t m = 0;
m <
maps.count;
m++) {
2221 for (
size_t n = 0; n <
list.size(); n++) {
2224 {
"name",
npc->name },
2227 {
"message",
npc->message },
2240 for (
size_t n = 0; n <
list.count; n++) {
2241 auto race =
list.races[n];
2243 {
"name", race->name },
2244 {
"count", race->count },
2257 for (
size_t m = 0;
m <
list.count;
m++) {
2259 if (!
q->map || !
q->description)
2263 {
"description",
q->description },
2264 {
"quest",
q->quest->name },
2265 {
"number",
q->quest->number },
2281 {
"name",
map->name },
2282 {
"path",
map->path },
2284 {
"level",
map->level },
2285 {
"reset_group",
map->reset_group ?
map->reset_group :
"" },
2286 {
"lore",
map->lore &&
map->lore[0] ?
map->lore :
"" },
2305 {
"number",
quest->number },
2307 {
"description",
quest->description ?
quest->description :
"" },
2321 if (cur->tiled_group)
2323 snprintf(
buf,
sizeof(
buf),
"map_%04lu",
map);
2365 bool need_unknown_region =
false;
2376 snprintf(
buf,
sizeof(
buf),
"reg_%04lu", reg);
2395 auto cur =
map.first;
2396 if (cur->tiled_group)
2398 if (cur->cfregion ==
nullptr)
2399 need_unknown_region =
true;
2403 if (need_unknown_region) {
2405 {
"_key",
"reg_ffff" },
2406 {
"name",
"unknown" },
2407 {
"longname",
"unknown" },
2408 {
"description",
"unknown" },
2422 json[
"items"][idx] = {
2423 {
"name", eq->name },
2424 {
"power", eq->power },
2425 {
"calc_power", eq->calc_power },
2426 {
"diff", eq->
diff },
2436 {
"name", race->name },
2437 {
"count", race->count },
2446 {
"code",
quest->quest_code },
2447 {
"title",
quest->quest_title },
2448 {
"description",
quest->quest_description ?
quest->quest_description :
"" },
2449 {
"replayable",
quest->quest_restart },
2455 std::sort(
quest->steps.begin(),
quest->steps.end(), [] (
auto left,
auto right) { return left->step < right->step; });
2456 for (
size_t s = 0; s <
quest->steps.size(); s++) {
2457 j[
"steps"].push_back({
2458 {
"description",
quest->steps[s]->step_description ?
quest->steps[s]->step_description :
"" },
2459 {
"is_completion",
quest->steps[s]->is_completion_step ? true :
false },
2465 for (
size_t m = 0;
m < qim->maps.count;
m++) {
2468 j[
"maps"].push_back({
2469 {
"description", qim->maps.list[
m]->description },
2470 {
"map",
map->second },
2482 {
"slaying", info->slaying },
2503 void add_template_to_render(
const std::string &template_name,
const std::string &output_name,
const std::string ¶m);
2528 auto template_name =
args.at(0)->get<std::string>();
2529 auto output_name(template_name);
2530 auto param = (
args.size() > 1 ?
args.at(1)->get<std::string>() :
"");
2532 if (!param.empty()) {
2533 output_name = param +
"_" + output_name;
2534 if (param.substr(0, 4) ==
"map_") {
2536 if (
map !=
nullptr) {
2537 output_name = std::string(
map->path + 1) +
".html";
2540 if (param.substr(0, 4) ==
"reg_") {
2542 if (reg !=
nullptr) {
2543 output_name = std::string(reg->name) +
".html";
2558 auto what =
args.at(0)->get<std::string>();
2559 if (what.substr(0, 4) ==
"map_") {
2564 if (
args.size() > 1) {
2565 size =
args.at(1)->get<
int>() - 1;
2592 auto on(output_name);
2600 r.template_name = template_name;
2606 static std::vector<std::string>
split(
const std::string &field,
const std::string &by) {
2607 std::vector<std::string>
result;
2608 size_t start = 0,
found;
2609 while ((
found = field.find(by, start)) != std::string::npos) {
2610 result.push_back(field.substr(start,
found - start));
2613 result.push_back(field.substr(start));
2627 std::string
str =
args.at(0)->get<std::string>();
2628 size_t start =
args.at(1)->get<size_t>();
2629 size_t len =
args.size() > 2 ?
args.at(2)->get<
size_t>() : std::string::npos;
2630 return str.substr(start, len);
2635 int val =
args.at(0)->get<int>(), digits =
args.at(1)->get<
int>();
2636 snprintf(
buf,
sizeof(
buf),
"%0*d", digits, val);
2637 return std::string(
buf);
2640 std::string
r(
root);
2646 return std::string(rel);
2649 const auto &src =
args.at(0);
2650 auto field =
args.at(1)->get<std::string>();
2652 auto found = std::find_if(src->begin(), src->end(), [&field, &
value] (
auto item) {
2653 return item[field] == *value;
2655 if (
found == src->end()) {
2662 const auto &src =
args.at(0);
2663 auto field =
args.at(1)->get<std::string>();
2665 if (
filter->is_array()) {
2666 std::copy_if(src->begin(), src->end(), std::back_inserter(ret), [&] (
auto &
item) {
2667 auto val = item[field];
2668 return std::find_if(filter->begin(), filter->end(), [&] (auto li) { return val == li; }) !=
filter->end();
2671 std::copy_if(src->begin(), src->end(), std::back_inserter(ret), [&] (
auto &
item) {
2672 return filter->get<std::string>() == item[field];
2678 const auto &src =
args.at(0);
2679 std::vector<nlohmann::json> ret;
2680 for (
auto i : *src) {
2683 auto fields =
split(
args.at(1)->get<std::string>(),
",");
2684 bool invert =
args.size() > 2 ?
args.at(2)->get<
bool>() :
false;
2685 bool ignore_case =
args.size() > 3 ?
args.at(3)->get<
bool>() :
true;
2686 std::sort(ret.begin(), ret.end(), [&] (
auto left,
auto right) {
2687 for (auto field : fields) {
2688 nlohmann::json l = left[field], r = right[field];
2689 if (ignore_case && l.is_string() && r.is_string()) {
2690 std::string ls(l.get<std::string>()), rs(r.get<std::string>());
2691 std::transform(ls.begin(), ls.end(), ls.begin(), [](unsigned char c){ return std::tolower(c); });
2692 std::transform(rs.begin(), rs.end(), rs.begin(), [](unsigned char c){ return std::tolower(c); });
2696 return invert ? (rs < ls) : (ls < rs);
2701 return invert ? (r < l) : (l < r);
2708 env->set_trim_blocks(
true);
2709 env->set_lstrip_blocks(
true);
2739 struct dirent *
file;
2740 struct stat statbuf;
2745 for (ignore = 0;
ignore_path[ignore] != NULL; ignore++) {
2756 for (ignore = 0;
ignore_name[ignore] != NULL; ignore++) {
2763 snprintf(full,
sizeof(full),
"%s/%s",
path,
file->d_name);
2765 status = stat(full, &statbuf);
2766 snprintf(full,
sizeof(full),
"%s/%s", from,
file->d_name);
2767 if ((
status != -1) && (S_ISDIR(statbuf.st_mode))) {
2782 snprintf(
path,
sizeof(
path),
"%s/%s",
root,
"maps.unused");
2785 printf(
"Unable to open file maps.unused!\n");
2792 printf(
"%ld unused maps.\n",
found_maps.size());
2800 gdImagePtr elevationmap;
2806 printf(
"Saving exit/blocking/road information...");
2816 puts(
"Error: Could not save elevation world map due to not finding any minimum or maximum elevation.");
2820 elevationmap = gdImageCreateTrueColor(30*50, 30*50);;
2822 for (
x = 0;
x < 30*50;
x++) {
2823 for (
y = 0;
y < 30*50;
y++) {
2828 printf(
"Saving elevation world map...");
2834 gdImageDestroy(elevationmap);
2835 elevationmap = NULL;
2862 printf(
"Crossfire Mapper will generate pictures of maps, and create indexes for all maps and regions.\n\n");
2863 printf(
"Syntax: %s\n\n", program);
2864 printf(
"Optional arguments:\n");
2865 printf(
" -nopics don't generate pictures.\n");
2866 printf(
" -root=<path> destination path. Default 'html'.\n");
2867 printf(
" -limit=<number> stop processing after this number of maps, -1 to do all maps (default).\n");
2868 printf(
" -showmaps outputs the name of maps as they are processed.\n");
2869 printf(
" -jpg[=quality] generate jpg pictures, instead of default png. Quality should be 0-95, -1 for automatic.\n");
2870 printf(
" -forcepics force to regenerate pics, even if pics's date is after map's.\n");
2871 printf(
" -addmap=<map> adds a map to process. Path is relative to map's directory root.\n");
2872 printf(
" -rawmaps generates maps pics without items on random (shop, treasure) tiles.\n");
2873 printf(
" -warnnopath inform when an exit has no path set.\n");
2874 printf(
" -listunusedmaps finds all unused maps in the maps directory.\n");
2875 printf(
" -noworldmap don't write the world map in world.png.\n");
2876 printf(
" -noregionslink don't generate regions relation file.\n");
2877 printf(
" -regionslink generate regions relation file.\n");
2878 printf(
" -noexitmap don't generate map of exits.\n");
2879 printf(
" -exitmap generate map of exits.\n");
2880 printf(
" -tileset=<number> use specified tileset to generate the pictures. Default 0 (standard).\n");
2881 printf(
" -details-quests list all quests steps. Default no.\n");
2882 printf(
" -list-system-quests include 'system' quests in quest list. Default no.\n");
2883 printf(
" -templates-dir=[dir] set the directory to get templates from. Default 'templates/'.\n");
2884 printf(
" -add-template=[file] add a template to process. May be specified multiple times. If empty, 'index.html' is used.\n");
2885 printf(
" -list-template-to-process display the name of the template about to be rendered. Useful for debugging.");
2904 while (arg < argc) {
2905 if (strcmp(argv[arg],
"-nopics") == 0)
2907 else if (strncmp(argv[arg],
"-root=", 6) == 0)
2908 strncpy(
root, argv[arg]+6, 500);
2909 else if (strncmp(argv[arg],
"-limit=", 7) == 0)
2911 else if (strcmp(argv[arg],
"-showmaps") == 0)
2913 else if (strcmp(argv[arg],
"-jpg") == 0) {
2915 if (argv[arg][4] ==
'=') {
2921 else if (strcmp(argv[arg],
"-forcepics") == 0)
2923 else if (strncmp(argv[arg],
"-addmap=", 8) == 0) {
2924 if (*(argv[arg]+8) ==
'/')
2925 strncpy(
path, argv[arg]+8, 500);
2927 snprintf(
path, 500,
"/%s", argv[arg]+8);
2930 else if (strcmp(argv[arg],
"-rawmaps") == 0)
2932 else if (strcmp(argv[arg],
"-warnnopath") == 0)
2934 else if (strcmp(argv[arg],
"-listunusedmaps") == 0)
2936 else if (strcmp(argv[arg],
"-noworldmap") == 0)
2938 else if (strcmp(argv[arg],
"-noregionslink") == 0)
2940 else if (strcmp(argv[arg],
"-regionslink") == 0)
2942 else if (strcmp(argv[arg],
"-noexitmap") == 0)
2944 else if (strcmp(argv[arg],
"-exitmap") == 0)
2946 else if (strncmp(argv[arg],
"-tileset=", 9) == 0) {
2949 }
else if (strcmp(argv[arg],
"-detail-quests") == 0) {
2951 }
else if (strcmp(argv[arg],
"-list-system-quests") == 0) {
2953 }
else if (strncmp(argv[arg],
"-templates-dir=", 15) == 0) {
2955 }
else if (strncmp(argv[arg],
"-add-template=", 14) == 0) {
2957 }
else if (strcmp(argv[arg],
"-list-template-to-process") == 0) {
2964 strcpy(
root,
"html");
2983 strcpy(dummy,
root);
2984 strcat(dummy,
"/a");
2997 return (
value ?
"yes" :
"no");
3004 return find->second;
3023 printf(
"Initializing Crossfire data...\n");
3041 printf(
"\n\n done.\n\n");
3044 printf(
"Erreor: invalid tileset %d!\n",
tileset);
3058 strcpy(
max,
"(none)");
3059 printf(
"Crossfire map browser generator\n");
3060 printf(
"-------------------------------\n\n");
3061 printf(
"Parameters:\n");
3062 printf(
" path to write files: %s\n",
root);
3063 printf(
" maximum number of maps to process: %s\n",
max);
3080 printf(
" templates to process: ");
3081 const char *sep =
"";
3083 printf(
"%s%s", sep, f.c_str());
3091 printf(
"listing all maps...");
3093 printf(
"done, %ld maps found.\n",
found_maps.size());
3097 infomap = gdImageCreateTrueColor(30*50, 30*50);
3104 for (i = 0; i < 50*30; i++)
3109 printf(
"browsing maps...\n");
3119 printf(
" --- map limit reached, stopping ---\n");
3146 std::sort(
system_quests.begin(),
system_quests.end(), [] (
const auto &left,
const auto &right) { return strcmp(left->quest_code, right->quest_code) < 0; });
3153 if (!
file.empty()) {
3158 const auto fullStart = time(
nullptr);
3159 printf(
"rendering pages...");
3164 while (!
pages.empty()) {
3165 auto p =
pages.back();
3167 if (p.param.empty())
3171 const auto start = time(
nullptr);
3173 printf(
" rendering page %s (%s)... ", p.template_name.c_str(), p.param.c_str());
3180 const auto elapsed = time(
nullptr) - start;
3182 printf(
"took %ld seconds\n", elapsed);
3186 const auto elapsed = time(
nullptr) - fullStart;
3187 printf(
" done, took %ld seconds\n", elapsed);
3206 while ((invtmp->stats.hp--) > 0)
3208 invtmp->randomitems = NULL;
3212 && invtmp->type !=
SPELL
3213 && invtmp->type !=
CLASS
3219 invtmp->randomitems = NULL;
3239 tmp->randomitems = NULL;
3245 while ((
tmp->stats.hp--) > 0)
3247 tmp->randomitems = NULL;
3271 tmp->randomitems = NULL;
3284 #ifndef DOXYGEN_SHOULD_SKIP_THIS
3290 void draw_ext_info(
int,
int,
const object *, uint8_t, uint8_t,
const char *txt) {
3291 fprintf(
logfile,
"%s\n", txt);
3297 va_start(ap, format);
3298 vfprintf(
logfile, format, ap);
3303 fprintf(
logfile,
"ext_info_map: %s\n", str1);
3373 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 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)
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
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
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
object * generate_treasure(treasurelist *t, int difficulty)
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 gdImagePtr * gdfaces
static int pics_allocated
static std::vector< char * > found_maps
#define FOR_INV_PREPARE(op_, it_)
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)