Go to the documentation of this file.
153 #include <sys/stat.h>
154 #include <sys/types.h>
291 for (test = 0; test <
list->count; test++) {
292 if (
list->races[test] == race)
297 if (
list->allocated ==
list->count) {
298 list->allocated += 50;
314 static int sizes[] = {32, 16, 8, 4, 2};
316 #define size_large sizes[0]
317 #define size_small sizes[1]
392 #define S_CONTAINER 2
421 if (
item->name ==
item->arch->clone.name &&
item->title ==
item->arch->clone.title)
515 namepl =
item->name_pl;
518 if (
item->artifact != NULL) {
554 item->name_pl = namepl;
557 if (add->
diff == NULL || strcmp(add->
diff,
"") == 0) {
598 int c =
l->power-
r->power;
645 if (monster->
head && monster != monster->
head)
680 const char *roads[] = {
686 const char *partial[] = {
690 for (test = 0; partial[test] != NULL; test++) {
691 if (strstr(
item->arch->name, partial[test]) != NULL)
698 for (test = 0; roads[test] != NULL; test++) {
699 if (strcmp(
item->arch->name, roads[test]) == 0)
729 return gdImageColorResolve(elevationmap, 200*elevation/
elevation_max, 0, 0);
731 return gdImageColorResolve(elevationmap, 0, 0, 200*elevation/
elevation_min);
747 if (sscanf(
map->path,
"/world/world_%d_%d", &
x, &
y) != 2)
774 int32_t elevation = atoi(selevation);
797 return (strcmp(*(
const char **)
a, *(
const char **)
b));
818 fslash = strchr(from+1,
'/');
824 rslash = strchr(to+1,
'/');
825 while (fslash && rslash && (fslash-from == rslash-to) && strncmp(from, to, fslash-from+1) == 0) {
828 fslash = strchr(fslash+1,
'/');
829 rslash = strchr(rslash+1,
'/');
834 fslash = strchr(fslash+1,
'/');
929 if (
list->count ==
list->allocated) {
930 list->allocated += 10;
1057 printf(
"warning, multiple quest definition for %s, found in %s and %s.\n",
quest->name,
quest->mainmap ?
quest->mainmap->path :
"(unknown map)", mainmap->
path);
1060 quest->description = strdup(description);
1061 while (strlen(
quest->description) &&
quest->description[strlen(
quest->description)-1] ==
'\n')
1062 quest->description[strlen(
quest->description)-1] =
'\0';
1063 quest->mainmap = mainmap;
1073 char *start, *end, *
next;
1075 char description[500];
1077 start = strstr(
map->lore,
"@def");
1079 description[0] =
'\0';
1081 end = strstr(start,
"\n");
1083 strncpy(
name, start+5, end-start-5);
1084 name[end-start-5] =
'\0';
1086 end = strstr(
next,
"@end");
1088 strncpy(description,
next, end-
next);
1089 description[end-
next] =
'\0';
1091 memcpy(start, end+4, strlen(
map->lore)-(end-start+3));
1095 strcpy(description,
next);
1100 strcpy(
name, start);
1106 start = end ? strstr(end,
"@def") : NULL;
1109 start = strstr(
map->lore,
"@quest");
1111 description[0] =
'\0';
1113 end = strstr(start,
"\n");
1115 strncpy(
name, start+7, end-start-7);
1116 name[end-start-7] =
'\0';
1118 end = strstr(
next,
"@end");
1120 strncpy(description,
next, end-
next);
1121 description[end-
next] =
'\0';
1123 memcpy(start, end+4, strlen(
map->lore)-(end-start+3));
1127 strcpy(description,
next);
1132 strcpy(
name, start);
1138 start = end ? strstr(end,
"@quest") : NULL;
1156 list->allocated = 0;
1171 info->
name = strdup(
npc->name);
1187 if (
list->count ==
list->allocated) {
1188 list->allocated += 50;
1215 if (
list->count ==
list->allocated) {
1216 list->allocated += 50;
1275 add_map(change, &
map->tiled_group->tiled_maps);
1288 printf(
"tiled_map not in tiled_map_list!");
1312 tmp = strrchr((
char *)
path,
'/');
1338 printf(
"Map processed but not found in directory reading? %s\n",
path);
1356 if (
regions[test]->reg == reg)
1369 if (sscanf(
map->path,
"/world/world_%d_%d", &
x, &
y) == 2) {
1387 gdImagePng(pic,
file);
1442 add->
slaying = strdup(slaying);
1519 FILE *
out = fopen(picpath,
"wb+");
1523 for (
size_t i = 1; i <
num_sizes; i++) {
1525 gdImagePtr small = gdImageCreateTrueColor(width*
sizes[i], height*
sizes[i]);
1527 out = fopen(picpath,
"wb+");
1530 gdImageDestroy(small);
1545 gdImagePtr pic =
nullptr;
1547 struct stat statspic;
1548 char exit_path[500];
1558 printf(
" processing map %s\n", info->
path);
1562 printf(
"couldn't load map %s\n", info->
path);
1571 info->
level =
m->difficulty;
1573 info->
lore = strdup(
m->maplore);
1577 isworld = (sscanf(info->
path,
"/world/world_%d_%d", &
x, &
y) == 2);
1580 info->
name = strdup(
m->name);
1595 stat(tmppath, &stats);
1596 if (stat(picpath[0], &statspic) || (statspic.st_mtime < stats.st_mtime))
1609 for (
x = 0;
x < 4;
x++)
1610 if (
m->tile_path[
x] != NULL) {
1613 if (stat(tmppath, &stats)) {
1614 printf(
" map %s doesn't exist in map %s, for tile %d.\n", exit_path, info->
path,
x);
1625 if (link && link !=
m) {
1670 if (!
item->slaying) {
1673 printf(
" exit without any path at %d, %d on %s\n",
item->x,
item->y, info->
path);
1676 if (strcmp(
item->slaying,
"/!"))
1680 printf(
" random map without message in %s at %d, %d\n", info->
path,
item->x,
item->y);
1683 start = strstr(
item->msg,
"\nfinal_map ");
1684 if (!start && strncmp(
item->msg,
"final_map", strlen(
"final_map")) == 0)
1688 char *end = strchr((
char *)start+1,
'\n');
1690 start += strlen(
"final_map")+2;
1691 strncpy(ep, start, end-start);
1699 if (stat(tmppath, &stats)) {
1700 printf(
" map %s doesn't exist in map %s, at %d, %d.\n", ep, info->
path,
item->x,
item->y);
1709 if (link && link !=
m) {
1739 if (
item->invisible)
1757 if (
gdfaces[
item->face->number] != NULL && ((!
item->head && !
item->more) || (
item->arch->clone.x+hx == 0 &&
item->arch->clone.y+hy == 0))) {
1766 gdImageDestroy(pic);
1784 char mapleft[10], maptop[10], mapright[10], mapbottom[10], mappath[5000];
1794 printf(
"Generating world map in world.html...");
1797 pic = gdImageCreateTrueColor(
SIZE*30,
SIZE*30);
1800 strcat(
file,
"/world.html");
1805 for (
y = 0;
y < 30;
y++) {
1806 for (
x = 0;
x < 30;
x++) {
1807 snprintf(
name,
sizeof(
name),
"world_%d_%d", wx, wy);
1808 snprintf(mapleft,
sizeof(mapleft),
"%d",
SIZE*
x);
1809 snprintf(maptop,
sizeof(maptop),
"%d",
SIZE*
y);
1810 snprintf(mapright,
sizeof(mapright),
"%d",
SIZE*(
x+1)-1);
1811 snprintf(mapbottom,
sizeof(mapbottom),
"%d",
SIZE*(
y+1)-1);
1815 out = fopen(mappath,
"rb");
1817 printf(
"\n warning: large pic not found for world_%d_%d", wx, wy);
1822 small = gdImageCreateFromPng(
out);
1824 small = gdImageCreateFromJpeg(
out);
1827 printf(
"\n warning: pic not found for world_%d_%d", wx, wy);
1831 gdImageCopyResized(pic, small,
SIZE*
x,
SIZE*
y, 0, 0,
SIZE,
SIZE, small->sx, small->sy);
1832 gdImageDestroy(small);
1841 out = fopen(mappath,
"wb+");
1846 small = gdImageCreateTrueColor(
SIZE*30,
SIZE*30);
1847 font = gdFontGetGiant();
1848 color = gdImageColorAllocateAlpha(pic, 255, 0, 0, 20);
1865 out = fopen(mappath,
"wb+");
1868 gdImageDestroy(small);
1871 out = fopen(mappath,
"wb+");
1874 gdImageDestroy(pic);
1886 printf(
"map without path!\n");
1907 printf(
"empty tiled map group!");
1911 snprintf(
name,
sizeof(
name),
"tiled_map_group_%zu",
map);
1925 printf(
"*** warning: tiled maps %s and %s not in same region (%s and %s).\n",
1948 slash = strrchr(
name,
'/');
2019 for (
size_t race = 0; race <
races.
count; race++) {
2047 for (
size_t size = 0; size <
num_sizes; size++) {
2049 if (stat(picpath, &stats))
2053 for (test = 0; test <
map->tiled_maps.count; test++) {
2054 if (
map->tiled_maps.maps[test]->pic_was_done)
2073 int xmin = 0, xmax = 0, ymin = 0, ymax = 0,
count, last;
2076 gdImagePtr large, load;
2083 printf(
" Generating composite map for %s...",
map->name);
2087 printf(
" already uptodate.\n");
2093 printf(
"Tiled map without tiled maps?\n");
2096 map->tiled_maps.maps[0]->processed = 1;
2097 map->tiled_maps.maps[0]->tiled_x_from = 0;
2098 map->tiled_maps.maps[0]->tiled_y_from = 0;
2103 for (tiled = 0; tiled <
map->tiled_maps.count; tiled++) {
2110 if ((
current->tiles[0]) && (
current->tiles[0]->processed == 0)) {
2111 current->tiles[0]->processed = 1;
2115 if ((
current->tiles[1]) && (
current->tiles[1]->processed == 0)) {
2116 current->tiles[1]->processed = 1;
2120 if ((
current->tiles[2]) && (
current->tiles[2]->processed == 0)) {
2121 current->tiles[2]->processed = 1;
2125 if ((
current->tiles[3]) && (
current->tiles[3]->processed == 0)) {
2126 current->tiles[3]->processed = 1;
2132 if (last ==
count) {
2133 printf(
"do_tiled_map_picture: didn't process any map in %s (%d left)??\n",
map->path, last);
2138 for (tiled = 0; tiled <
map->tiled_maps.count; tiled++) {
2139 if (
map->tiled_maps.maps[tiled]->tiled_x_from < xmin)
2140 xmin =
map->tiled_maps.maps[tiled]->tiled_x_from;
2141 if (
map->tiled_maps.maps[tiled]->tiled_y_from < ymin)
2142 ymin =
map->tiled_maps.maps[tiled]->tiled_y_from;
2143 if (
map->tiled_maps.maps[tiled]->tiled_x_from+
map->tiled_maps.maps[tiled]->width > xmax)
2144 xmax =
map->tiled_maps.maps[tiled]->tiled_x_from+
map->tiled_maps.maps[tiled]->width;
2145 if (
map->tiled_maps.maps[tiled]->tiled_y_from+
map->tiled_maps.maps[tiled]->height > ymax)
2146 ymax =
map->tiled_maps.maps[tiled]->tiled_y_from+
map->tiled_maps.maps[tiled]->height;
2151 for (tiled = 0; tiled <
map->tiled_maps.count; tiled++) {
2154 out = fopen(picpath,
"rb");
2156 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);
2160 load = gdImageCreateFromPng(
out);
2162 load = gdImageCreateFromJpeg(
out);
2165 printf(
"\n do_tiled_map_picture: warning: pic not found for %s\n",
map->tiled_maps.maps[tiled]->path);
2168 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);
2169 gdImageDestroy(load);
2174 gdImageDestroy(large);
2191 printf(
"Writing tiled map information...\n");
2216 static std::shared_ptr<inja::Environment>
env;
2230 return found->first;
2242 return found->first;
2253 for (
size_t m = 0;
m <
maps.count;
m++) {
2269 for (
size_t n = 0; n <
list.count; n++) {
2272 {
"name",
npc->name },
2275 {
"message",
npc->message },
2288 for (
size_t n = 0; n <
list.count; n++) {
2289 auto race =
list.races[n];
2291 {
"name", race->name },
2292 {
"count", race->count },
2305 for (
size_t m = 0;
m <
list.count;
m++) {
2307 if (!
q->map || !
q->description)
2311 {
"description",
q->description },
2312 {
"quest",
q->quest->name },
2313 {
"number",
q->quest->number },
2329 {
"name",
map->name },
2330 {
"path",
map->path },
2332 {
"level",
map->level },
2333 {
"lore",
map->lore &&
map->lore[0] ?
map->lore :
"" },
2352 {
"number",
quest->number },
2354 {
"description",
quest->description ?
quest->description :
"" },
2368 if (cur->tiled_group)
2370 snprintf(
buf,
sizeof(
buf),
"map_%04lu",
map);
2412 bool need_unknown_region =
false;
2423 snprintf(
buf,
sizeof(
buf),
"reg_%04lu", reg);
2442 auto cur =
map.first;
2443 if (cur->tiled_group)
2445 if (cur->cfregion ==
nullptr)
2446 need_unknown_region =
true;
2450 if (need_unknown_region) {
2452 {
"_key",
"reg_ffff" },
2453 {
"name",
"unknown" },
2454 {
"longname",
"unknown" },
2455 {
"description",
"unknown" },
2464 json[
"items"][idx] = {
2465 {
"name", eq->name },
2466 {
"power", eq->power },
2467 {
"calc_power", eq->calc_power },
2468 {
"diff", eq->
diff },
2478 {
"name", race->name },
2479 {
"count", race->count },
2488 {
"code",
quest->quest_code },
2489 {
"title",
quest->quest_title },
2490 {
"description",
quest->quest_description ?
quest->quest_description :
"" },
2491 {
"replayable",
quest->quest_restart },
2498 size_t steps_count = 0;
2501 steps[steps_count++] = step;
2505 for (
size_t s = 0; s < steps_count; s++) {
2506 j[
"steps"].push_back({
2514 for (
size_t m = 0;
m < qim->maps.count;
m++) {
2517 j[
"maps"].push_back({
2518 {
"description", qim->maps.list[
m]->description },
2519 {
"map",
map->second },
2531 {
"slaying", info->slaying },
2552 void add_template_to_render(
const std::string &template_name,
const std::string &output_name,
const std::string ¶m);
2577 auto template_name =
args.at(0)->get<std::string>();
2578 auto output_name(template_name);
2579 auto param = (
args.size() > 1 ?
args.at(1)->get<std::string>() :
"");
2581 if (!param.empty()) {
2582 output_name = param +
"_" + output_name;
2583 if (param.substr(0, 4) ==
"map_") {
2585 if (
map !=
nullptr) {
2586 output_name = std::string(
map->path + 1) +
".html";
2589 if (param.substr(0, 4) ==
"reg_") {
2591 if (reg !=
nullptr) {
2592 output_name = std::string(reg->name) +
".html";
2607 auto what =
args.at(0)->get<std::string>();
2608 if (what.substr(0, 4) ==
"map_") {
2613 if (
args.size() > 1) {
2614 size =
args.at(1)->get<
int>() - 1;
2641 auto on(output_name);
2649 r.template_name = template_name;
2655 static std::vector<std::string>
split(
const std::string &field,
const std::string &by) {
2656 std::vector<std::string>
result;
2657 size_t start = 0,
found;
2658 while ((
found = field.find(by, start)) != std::string::npos) {
2659 result.push_back(field.substr(start,
found - start));
2662 result.push_back(field.substr(start));
2676 std::string
str =
args.at(0)->get<std::string>();
2677 size_t start =
args.at(1)->get<size_t>();
2678 size_t len =
args.size() > 2 ?
args.at(2)->get<
size_t>() : std::string::npos;
2679 return str.substr(start, len);
2684 int val =
args.at(0)->get<int>(), digits =
args.at(1)->get<
int>();
2685 snprintf(
buf,
sizeof(
buf),
"%0*d", digits, val);
2686 return std::string(
buf);
2689 std::string
r(
root);
2695 return std::string(rel);
2698 const auto &src =
args.at(0);
2699 auto field =
args.at(1)->get<std::string>();
2701 auto found = std::find_if(src->begin(), src->end(), [&field, &
value] (
auto item) {
2702 return item[field] == *value;
2704 if (
found == src->end()) {
2710 const auto &src =
args.at(0);
2711 auto field =
args.at(1)->get<std::string>();
2714 std::copy_if(src->begin(), src->end(), std::back_inserter(ret), [&] (
auto &
item) {
2715 auto val = item[field];
2716 return std::find_if(list->begin(), list->end(), [&] (auto li) { return val == li; }) !=
list->end();
2721 const auto &src =
args.at(0);
2722 std::vector<nlohmann::json> ret;
2723 for (
auto i : *src) {
2726 auto fields =
split(
args.at(1)->get<std::string>(),
",");
2727 bool invert =
args.size() > 2 ?
args.at(2)->get<
bool>() :
false;
2728 bool ignore_case =
args.size() > 3 ?
args.at(3)->get<
bool>() :
true;
2729 std::sort(ret.begin(), ret.end(), [&] (
auto left,
auto right) {
2730 for (auto field : fields) {
2731 nlohmann::json l = left[field], r = right[field];
2732 if (ignore_case && l.is_string() && r.is_string()) {
2733 std::string ls(l.get<std::string>()), rs(r.get<std::string>());
2734 std::transform(ls.begin(), ls.end(), ls.begin(), [](unsigned char c){ return std::tolower(c); });
2735 std::transform(rs.begin(), rs.end(), rs.begin(), [](unsigned char c){ return std::tolower(c); });
2739 return invert ? (rs < ls) : (ls < rs);
2744 return invert ? (r < l) : (l < r);
2751 env->set_trim_blocks(
true);
2752 env->set_lstrip_blocks(
true);
2782 struct stat statbuf;
2784 char path[1024], full[1024];
2787 for (ignore = 0;
ignore_path[ignore] != NULL; ignore++) {
2798 for (ignore = 0;
ignore_name[ignore] != NULL; ignore++) {
2805 snprintf(full,
sizeof(full),
"%s/%s",
path,
file->d_name);
2807 status = stat(full, &statbuf);
2808 if ((
status != -1) && (S_ISDIR(statbuf.st_mode))) {
2809 snprintf(full,
sizeof(full),
"%s/%s", from,
file->d_name);
2817 snprintf(full,
sizeof(full),
"%s/%s", from,
file->d_name);
2830 snprintf(
path,
sizeof(
path),
"%s/%s",
root,
"maps.unused");
2833 printf(
"Unable to open file maps.unused!\n");
2844 printf(
"%d unused maps.\n",
found);
2852 gdImagePtr elevationmap;
2857 printf(
"Saving exit/blocking/road information...");
2867 puts(
"Error: Could not save elevation world map due to not finding any minimum or maximum elevation.");
2871 elevationmap = gdImageCreateTrueColor(30*50, 30*50);;
2873 for (
x = 0;
x < 30*50;
x++) {
2874 for (
y = 0;
y < 30*50;
y++) {
2879 printf(
"Saving elevation world map...");
2885 gdImageDestroy(elevationmap);
2886 elevationmap = NULL;
2913 printf(
"Crossfire Mapper will generate pictures of maps, and create indexes for all maps and regions.\n\n");
2914 printf(
"Syntax: %s\n\n", program);
2915 printf(
"Optional arguments:\n");
2916 printf(
" -nopics don't generate pictures.\n");
2917 printf(
" -root=<path> destination path. Default 'html'.\n");
2918 printf(
" -limit=<number> stop processing after this number of maps, -1 to do all maps (default).\n");
2919 printf(
" -showmaps outputs the name of maps as they are processed.\n");
2920 printf(
" -jpg[=quality] generate jpg pictures, instead of default png. Quality should be 0-95, -1 for automatic.\n");
2921 printf(
" -forcepics force to regenerate pics, even if pics's date is after map's.\n");
2922 printf(
" -addmap=<map> adds a map to process. Path is relative to map's directory root.\n");
2923 printf(
" -rawmaps generates maps pics without items on random (shop, treasure) tiles.\n");
2924 printf(
" -warnnopath inform when an exit has no path set.\n");
2925 printf(
" -listunusedmaps finds all unused maps in the maps directory.\n");
2926 printf(
" -noworldmap don't write the world map in world.png.\n");
2927 printf(
" -noregionslink don't generate regions relation file.\n");
2928 printf(
" -regionslink generate regions relation file.\n");
2929 printf(
" -noexitmap don't generate map of exits.\n");
2930 printf(
" -exitmap generate map of exits.\n");
2931 printf(
" -tileset=<number> use specified tileset to generate the pictures. Default 0 (standard).\n");
2932 printf(
" -details-quests list all quests steps. Default no.\n");
2933 printf(
" -list-system-quests include 'system' quests in quest list. Default no.\n");
2934 printf(
" -templates-dir=[dir] set the directory to get templates from. Default 'templates/'.\n");
2935 printf(
" -add-template=[file] add a template to process. May be specified multiple times. If empty, 'index.html' is used.\n");
2936 printf(
" -list-template-to-process display the name of the template about to be rendered. Useful for debugging.");
2955 while (arg < argc) {
2956 if (strcmp(argv[arg],
"-nopics") == 0)
2958 else if (strncmp(argv[arg],
"-root=", 6) == 0)
2959 strncpy(
root, argv[arg]+6, 500);
2960 else if (strncmp(argv[arg],
"-limit=", 7) == 0)
2962 else if (strcmp(argv[arg],
"-showmaps") == 0)
2964 else if (strcmp(argv[arg],
"-jpg") == 0) {
2966 if (argv[arg][4] ==
'=') {
2972 else if (strcmp(argv[arg],
"-forcepics") == 0)
2974 else if (strncmp(argv[arg],
"-addmap=", 8) == 0) {
2975 if (*(argv[arg]+8) ==
'/')
2976 strncpy(
path, argv[arg]+8, 500);
2978 snprintf(
path, 500,
"/%s", argv[arg]+8);
2981 else if (strcmp(argv[arg],
"-rawmaps") == 0)
2983 else if (strcmp(argv[arg],
"-warnnopath") == 0)
2985 else if (strcmp(argv[arg],
"-listunusedmaps") == 0)
2987 else if (strcmp(argv[arg],
"-noworldmap") == 0)
2989 else if (strcmp(argv[arg],
"-noregionslink") == 0)
2991 else if (strcmp(argv[arg],
"-regionslink") == 0)
2993 else if (strcmp(argv[arg],
"-noexitmap") == 0)
2995 else if (strcmp(argv[arg],
"-exitmap") == 0)
2997 else if (strncmp(argv[arg],
"-tileset=", 9) == 0) {
3000 }
else if (strcmp(argv[arg],
"-detail-quests") == 0) {
3002 }
else if (strcmp(argv[arg],
"-list-system-quests") == 0) {
3004 }
else if (strncmp(argv[arg],
"-templates-dir=", 15) == 0) {
3006 }
else if (strncmp(argv[arg],
"-add-template=", 14) == 0) {
3008 }
else if (strcmp(argv[arg],
"-list-template-to-process") == 0) {
3015 strcpy(
root,
"html");
3034 strcpy(dummy,
root);
3035 strcat(dummy,
"/a");
3048 return (
value ?
"yes" :
"no");
3055 return find->second;
3074 printf(
"Initializing Crossfire data...\n");
3093 printf(
"\n\n done.\n\n");
3096 printf(
"Erreor: invalid tileset %d!\n",
tileset);
3110 strcpy(
max,
"(none)");
3111 printf(
"Crossfire map browser generator\n");
3112 printf(
"-------------------------------\n\n");
3113 printf(
"Parameters:\n");
3114 printf(
" path to write files: %s\n",
root);
3115 printf(
" maximum number of maps to process: %s\n",
max);
3132 printf(
" templates to process: ");
3133 const char *sep =
"";
3135 printf(
"%s%s", sep, f.c_str());
3143 printf(
"listing all maps...");
3150 infomap = gdImageCreateTrueColor(30*50, 30*50);
3157 for (i = 0; i < 50*30; i++)
3162 printf(
"browsing maps...\n");
3172 printf(
" --- map limit reached, stopping ---\n");
3206 if (!
file.empty()) {
3211 const auto fullStart = time(
nullptr);
3212 printf(
"rendering pages...");
3217 while (!
pages.empty()) {
3218 auto p =
pages.back();
3220 if (p.param.empty())
3224 const auto start = time(
nullptr);
3226 printf(
" rendering page %s (%s)... ", p.template_name.c_str(), p.param.c_str());
3233 const auto elapsed = time(
nullptr) - start;
3235 printf(
"took %ld seconds\n", elapsed);
3239 const auto elapsed = time(
nullptr) - fullStart;
3240 printf(
" done, took %ld seconds\n", elapsed);
3259 while ((invtmp->stats.hp--) > 0)
3261 invtmp->randomitems = NULL;
3265 && invtmp->type !=
SPELL
3266 && invtmp->type !=
CLASS
3272 invtmp->randomitems = NULL;
3292 tmp->randomitems = NULL;
3298 while ((
tmp->stats.hp--) > 0)
3300 tmp->randomitems = NULL;
3324 tmp->randomitems = NULL;
3337 #ifndef DOXYGEN_SHOULD_SKIP_THIS
3343 void draw_ext_info(
int,
int,
const object *, uint8_t, uint8_t,
const char *txt) {
3344 fprintf(
logfile,
"%s\n", txt);
3350 va_start(ap, format);
3351 vfprintf(
logfile, format, ap);
3356 fprintf(
logfile,
"ext_info_map: %s\n", str1);
3426 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)
mapstruct * ready_map_name(const char *name, int flags)
void do_auto_apply(mapstruct *m)
static void add_map(struct_map_info *info, struct_map_list *list)
#define HAS_RANDOM_ITEMS(op)
struct artifactstruct artifact
struct struct_map_in_quest struct_map_in_quest
#define FREE_OBJ_NO_DESTROY_CALLBACK
void object_free(object *ob, int flags)
static const char * ignore_name[]
struct struct_npc_info struct_npc_info
static struct_quest * get_quest_info(const char *name)
static region * find_region_by_key(const std::string &key)
void object_remove(object *op)
StringBuffer * stringbuffer_new(void)
static int found_maps_allocated
static void process_map_lore(struct_map_info *map)
void give_artifact_abilities(object *op, const object *artifact)
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)
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)
static void write_tiled_maps(void)
#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
struct struct_npc_list struct_npc_list
int calc_item_power(const object *op)
static event_registration c
static enum output_format_type output_format
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)
void get_ob_diff(StringBuffer *sb, const object *op, const object *op2)
static size_t slaying_allocated
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
char * create_pathname(const char *name, char *buf, size_t size)
static std::vector< pageToRender > pages
static int list_unused_maps
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
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 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
EXTERN char first_map_path[MAX_BUF]
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
int is_valid_faceset(int fsn)
void make_path_to_file(const char *filename)
void apply_auto_fix(mapstruct *)
void account_char_save(Account_Chars *)
const artifact * find_artifact(const object *op, const char *name)
static int world_exit_info
static int sort_struct_quest(const void *left, const void *right)
struct struct_quest * quest
const char * object_get_value(const object *op, const char *const key)
#define FLAG_IS_A_TEMPLATE
object * identify(object *op)
static void init_renderer_env()
static event_registration m
struct struct_race struct_race
DIR * opendir(const char *)
struct quest_step_definition * next
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_equipment ** special_equipment
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)
static void add_npc_to_map(struct_npc_list *list, const object *npc)
struct struct_map_info struct_map_info
void set_darkness_map(mapstruct *)
static size_t system_quests_count
static void define_quest(const char *name, struct_map_info *mainmap, const char *description)
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
static struct_race_list races
int main(int argc, char **argv)
static const char * output_extensions[]
static nlohmann::json create_maps_array(struct_map_list &maps)
static int get_elevation_color(int elevation, gdImagePtr elevationmap)
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)
static const quest_definition * system_quests[500]
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)
struct struct_quest struct_quest
char * stringbuffer_finish(StringBuffer *sb)
void esrv_update_item(int, object *, object *)
static int is_blocking(object *item)
static void do_exit_map(mapstruct *map)
static void create_destination(void)
struct struct_race ** races
const typedef char * sstring
#define FLAG_UNAGGRESSIVE
static void check_slaying_inventory(struct_map_info *map, object *item)
void object_give_identified_properties(object *op)
static int sort_system_quest_step(const void *a, const void *b)
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)
struct struct_map_info ** maps
void delete_map(mapstruct *m)
static void fill_json(nlohmann::json &json)
static void add_map_to_region(struct_map_info *map, region *reg)
static int found_maps_count
struct struct_equipment struct_equipment
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
void object_get_multi_size(const object *ob, int *sx, int *sy, int *hx, int *hy)
static int sort_map_info(const void *left, const void *right)
static void fill_reverse_maps(struct_map_list &list)
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 size_t equipment_count
struct struct_race_list struct_race_list
static void check_equipment(object *item, struct_map_info *map)
static int sort_system_quest(const void *a, const void *b)
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
static int sortbyname(const void *a, const void *b)
static std::vector< std::string > path_stack
static nlohmann::json create_npc_array(struct_npc_list &list)
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)
static void add_region_link(mapstruct *source, mapstruct *dest)
struct struct_region_info struct_region_info
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
static void init_npc_list(struct_npc_list *list)
void LOG(LogLevel logLevel, const char *format,...)
int get_face_fallback(int faceset, uint16_t imageno)
std::vector< const json * > Arguments
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
object * object_insert_in_ob(object *op, object *where)
std::string template_name
void object_update_speed(object *op)
static int sort_race(const void *a, const void *b)
static bool do_regions_link
object * arch_to_object(archetype *at)
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)
static char ** found_maps
object * find_skill_by_number(object *, int)
static std::map< region *, std::string > reverse_regions
region * get_region_by_map(mapstruct *m)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
static struct_map_info * create_tiled_map(void)
void object_free_drop_inventory(object *ob)
static std::vector< std::string > templates
static const char * ignore_path[]
static int sort_equipment(const void *a, const void *b)
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)
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)
object * generate_treasure(treasurelist *t, int difficulty)
#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
static void write_world_info(void)
static int tiled_map_need_pic(struct_map_info *map)
static size_t equipment_allocated
static struct_quest ** quests
static void fix_tiled_map(void)
EXTERN region * first_region
static gdImagePtr * gdfaces
static int pics_allocated
#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 void add_one_item(object *item, struct_map_info *map)