346 for (test = 0; test < list->
count; test++) {
347 if (list->
races[test] == race)
485 #define S_CONTAINER 2
564 comp = special_equipment[check];
621 if (add->
diff == NULL || strcmp(add->
diff,
"") == 0) {
648 for (inv = item->
inv; inv; inv = inv->
below) {
683 for (test = 0; test < races.
count; test++) {
684 if (strcmp(races.
races[test]->
name, name) == 0) {
686 return races.
races[test];
691 item->
name = strdup(name);
711 if (monster->
head && monster != monster->
head)
746 const char *roads[] = {
752 const char *partial[] = {
756 for (test = 0; partial[test] != NULL; test++) {
757 if (strstr(item->
arch->
name, partial[test]) != NULL)
764 for (test = 0; roads[test] != NULL; test++) {
765 if (strcmp(item->
arch->
name, roads[test]) == 0)
795 return gdImageColorResolve(elevationmap, 200*elevation/
elevation_max, 0, 0);
797 return gdImageColorResolve(elevationmap, 0, 0, 200*elevation/
elevation_min);
812 if (sscanf(map->
path,
"/world/world_%d_%d", &x, &y) != 2)
818 for (tx = 0; tx <
MAP_WIDTH(map); tx++) {
822 test = item->
head ? item->
head : item;
863 return (strcmp(*(
const char **)a, *(
const char **)b));
879 source = realloc(source, strlen(source)+strlen(add)+1);
899 if (stat(name, &info)) {
900 printf(
"Couldn't stat template %s!\n", name);
904 (*buffer) = calloc(1, info.st_size+1);
906 printf(
"Template %s calloc failed!\n", name);
910 if (info.st_size == 0) {
915 file = fopen(name,
"rb");
917 printf(
"Couldn't open template %s!\n", name);
921 if (fread(*buffer, info.st_size, 1, file) != 1) {
922 printf(
"Couldn't read template %s!\n", name);
947 static char *
do_template(
const char *
template,
const char **vars,
const char **values) {
949 const char *sharp =
template;
953 char *current_result;
956 while ((sharp = strchr(sharp,
'#')) != NULL) {
961 return strdup(
template);
963 printf(
"Malformed template, mismatched #!\n");
964 return strdup(
template);
967 while (vars[var] != NULL) {
968 if (strlen(values[var]) > maxlen)
969 maxlen = strlen(values[var]);
972 result = calloc(1, strlen(
template)+maxlen*(count/2)+1);
975 current_result = result;
978 while ((sharp = strchr(sharp,
'#')) != NULL) {
979 end = strchr(sharp+1,
'#');
980 strncpy(current_result,
template, sharp-
template);
981 if (end == sharp+1) {
982 strcat(current_result,
"#");
985 current_result = current_result+strlen(current_result);
987 while (vars[var] != NULL && (strncmp(vars[var], sharp+1, end-sharp-1) || (strlen(vars[var]) != end-sharp-1)))
990 if (vars[var] == NULL)
991 printf(
"Wrong tag: %s\n", sharp);
993 strcpy(current_result, values[var]);
995 current_result = current_result+strlen(current_result);
999 strcat(current_result,
template);
1021 fslash = strchr(from+1,
'/');
1023 strcpy(result, to+1);
1027 rslash = strchr(to+1,
'/');
1028 while (fslash && rslash && (fslash-from == rslash-to) && strncmp(from, to, fslash-from+1) == 0) {
1031 fslash = strchr(fslash+1,
'/');
1032 rslash = strchr(rslash+1,
'/');
1036 strcat(result,
"../");
1037 fslash = strchr(fslash+1,
'/');
1039 if (strlen(result) && result[strlen(result)-1] ==
'/' && *to ==
'/')
1040 result[strlen(result)-1] =
'\0';
1055 const char *l = *(
const char **)left;
1056 const char *r = *(
const char **)right;
1057 const char *sl = strrchr(l,
'/');
1058 const char *sr = strrchr(r,
'/');
1199 if (strcmp(quests[test]->name, name) == 0)
1200 return quests[test];
1208 add->
name = strdup(name);
1282 printf(
"warning, multiple quest definition for %s, found in %s and %s.\n", quest->
name, quest->
mainmap ? quest->
mainmap->
path :
"(unknown map)", mainmap->
path);
1298 char *start, *end, *next;
1300 char description[500];
1302 start = strstr(map->
lore,
"@def");
1304 description[0] =
'\0';
1306 end = strstr(start,
"\n");
1308 strncpy(name, start+5, end-start-5);
1309 name[end-start-5] =
'\0';
1311 end = strstr(next,
"@end");
1313 strncpy(description, next, end-next);
1314 description[end-next] =
'\0';
1316 memcpy(start, end+4, strlen(map->
lore)-(end-start+3));
1320 strcpy(description, next);
1325 strcpy(name, start);
1331 start = end ? strstr(end,
"@def") : NULL;
1334 start = strstr(map->
lore,
"@quest");
1336 description[0] =
'\0';
1338 end = strstr(start,
"\n");
1340 strncpy(name, start+7, end-start-7);
1341 name[end-start-7] =
'\0';
1343 end = strstr(next,
"@end");
1345 strncpy(description, next, end-next);
1346 description[end-next] =
'\0';
1348 memcpy(start, end+4, strlen(map->
lore)-(end-start+3));
1352 strcpy(description, next);
1357 strcpy(name, start);
1363 start = end ? strstr(end,
"@quest") : NULL;
1375 char mainmappath[500];
1377 const char *map_vars[] = {
"MAPPATH",
"MAPNAME",
"MAPTEXT", NULL };
1378 const char *map_vals[] = { mappath, NULL, NULL, NULL };
1379 const char *quest_vars[] = {
"QUESTNAME",
"QUESTTEXT",
"QUESTMAPS",
"QUESTID",
"MAINMAPPATH",
"MAINMAPNAME", NULL };
1380 const char *quest_vals[] = { NULL, NULL, NULL, questid, mainmappath, NULL, NULL };
1381 const char *idx_vars[] = {
"QUESTS", NULL };
1382 const char *idx_vals[] = { NULL, NULL };
1383 char *text_map = NULL;
1384 char *text_quest = NULL;
1385 char *text_idx = NULL;
1387 printf(
"Writing quest index...");
1391 for (map = 0; map < quests[quest]->
maps.
count; map++) {
1392 snprintf(mappath,
sizeof(mappath),
"%s.html", quests[quest]->maps.list[map]->map->path+1);
1398 text_map = strdup(
"");
1400 quest_vals[0] = quests[quest]->
name;
1402 quest_vals[2] = text_map;
1403 snprintf(questid,
sizeof(questid),
"quest_%d", quests[quest]->number);
1404 if (quests[quest]->mainmap) {
1405 snprintf(mainmappath,
sizeof(mainmappath),
"%s.html", quests[quest]->mainmap->path+1);
1408 snprintf(mainmappath,
sizeof(mainmappath),
"#");
1417 text_quest = strdup(
"No quest.");
1419 idx_vals[0] = text_quest;
1424 out = fopen(path,
"w+");
1425 fprintf(out, text_idx);
1501 for (map = 0; map < list->
count; map++)
1502 if (list->
maps[map] == info)
1526 for (map = 0; map < list->
count; map++) {
1527 if (list->
maps[map] == find) {
1528 list->
maps[map] = replace_by;
1532 printf(
"replace_map: couldn't find map %s.\n", find->
path);
1565 add_map(add, &tiled_map_list);
1592 for (g = 0; g < tiled_map_list.
count; g++) {
1593 if (tiled_map_list.
maps[g] == group) {
1594 if (g < tiled_map_list.
count-1)
1595 tiled_map_list.
maps[g] = tiled_map_list.
maps[tiled_map_list.
count-1];
1596 tiled_map_list.
count--;
1601 printf(
"tiled_map not in tiled_map_list!");
1619 for (map = 0; map < maps_list.
count; map++) {
1620 if (strcmp(maps_list.
maps[map]->
path, path) == 0)
1621 return maps_list.
maps[map];
1625 add->
path = strdup(path);
1626 tmp = strrchr(path,
'/');
1652 printf(
"Map processed but not found in directory reading? %s\n", path);
1670 if (regions[test]->reg == reg)
1673 if (test == region_count) {
1680 regions[test]->
reg = reg;
1682 add_map(map, ®ions[test]->maps_list);
1683 if (sscanf(map->
path,
"/world/world_%d_%d", &x, &y) == 2) {
1684 regions[test]->
sum_x += (x-100);
1685 regions[test]->
sum_y += (y-100);
1686 regions[test]->
sum++;
1701 gdImagePng(pic, file);
1726 snprintf(entry,
sizeof(entry),
"%s -> %s [ label = \"%s\" ]\n", s->
name, d->
name, linkname);
1740 regions_link_count++;
1769 if (!strcmp(slaying_info[l]->slaying, slaying))
1770 return slaying_info[l];
1778 add->
slaying = strdup(slaying);
1779 for (l = 0; l <
S_MAX; l++)
1839 for (inv = item->
inv; inv; inv = inv->
below) {
1862 struct stat statspic;
1863 char exit_path[500];
1873 printf(
" processing map %s\n", info->
path);
1877 printf(
"couldn't load map %s\n", info->
path);
1892 isworld = (sscanf(info->
path,
"/world/world_%d_%d", &x, &y) == 2);
1909 stat(tmppath, &stats);
1910 if (stat(picpath, &statspic) || (statspic.st_mtime < stats.st_mtime))
1912 else if (stat(smallpicpath, &statspic) || (statspic.st_mtime < stats.st_mtime))
1925 for (x = 0; x < 4; x++)
1929 if (stat(tmppath, &stats)) {
1930 printf(
" map %s doesn't exist in map %s, for tile %d.\n", exit_path, info->
path, x);
1941 if (link && link != m) {
1952 info->
tiles[x] = link;
1989 printf(
" exit without any path at %d, %d on %s\n", item->
x, item->
y, info->
path);
1992 if (strcmp(item->
slaying,
"/!"))
1996 printf(
" random map without message in %s at %d, %d\n", info->
path, item->
x, item->
y);
1999 start = strstr(item->
msg,
"\nfinal_map ");
2000 if (!start && strncmp(item->
msg,
"final_map", strlen(
"final_map")) == 0)
2004 char *end = strchr(start+1,
'\n');
2006 start += strlen(
"final_map")+2;
2007 strncpy(ep, start, end-start);
2015 if (stat(tmppath, &stats)) {
2016 printf(
" map %s doesn't exist in map %s, at %d, %d.\n", ep, info->
path, item->
x, item->
y);
2025 if (link && link != m) {
2080 out = fopen(picpath,
"wb+");
2087 out = fopen(smallpicpath,
"wb+");
2090 gdImageDestroy(small);
2092 gdImageDestroy(pic);
2123 const char *template_page,
const char *template_letter,
2124 const char *template_map,
const char **vars,
2125 const char **values) {
2132 char lettercount[50];
2134 const char **idx_vars;
2135 const char **idx_values;
2138 char index_path[500];
2139 char *mapstext = NULL;
2141 int basevalues, realcount = 0;
2148 for (basevalues = 0; vars[basevalues] != NULL; basevalues++)
2153 idx_vars = malloc(
sizeof(
char *)*(basevalues+
VARSADD));
2154 idx_vars[0] =
"MAPCOUNT";
2155 memcpy(&idx_vars[1], vars,
sizeof(
char *)*basevalues);
2156 idx_vars[basevalues+
VARSADD-1] = NULL;
2158 idx_values = malloc(
sizeof(
char *)*(basevalues+
VARSADD-1));
2159 memcpy(&idx_values[1], values,
sizeof(
char *)*basevalues);
2163 idx_values[0] = count;
2167 idx_vars[basevalues+1] =
"MAPNAME";
2168 idx_vars[basevalues+2] =
"MAPPATH";
2169 idx_vars[basevalues+3] =
"MAPHTML";
2170 idx_vars[basevalues+4] = NULL;
2175 str_letter[0] =
'\0';
2176 str_letter[1] =
'\0';
2178 strcpy(index_path,
"/");
2179 strcat(index_path, dest);
2182 for (map = 0; map < maps_list->
count; map++) {
2184 if (mapstext != NULL) {
2185 idx_vars[basevalues+1] =
"MAPS";
2186 idx_vars[basevalues+2] =
"LETTER";
2187 idx_vars[basevalues+3] =
"LETTERCOUNT";
2188 idx_vars[basevalues+4] = NULL;
2189 idx_values[basevalues+1] = mapstext;
2190 idx_values[basevalues+2] = str_letter;
2191 snprintf(lettercount,
sizeof(lettercount),
"%d", byletter);
2192 idx_values[basevalues+3] = lettercount;
2196 idx_values[basevalues+2] = NULL;
2199 str_letter[0] = last_letter;
2210 idx_vars[basevalues+1] =
"MAPNAME";
2211 idx_vars[basevalues+2] =
"MAPPATH";
2212 idx_vars[basevalues+3] =
"MAPHTML";
2213 idx_values[basevalues+1] = last_group ? last_group->
name : (maps_list->
maps[map]->
name ? maps_list->
maps[map]->
name : maps_list->
maps[map]->
path);
2215 strcpy(maphtml, mappath);
2216 strcat(maphtml,
".html");
2217 idx_values[basevalues+2] = mappath;
2218 idx_values[basevalues+3] = maphtml;
2222 if (last_letter !=
'\0') {
2223 idx_vars[basevalues+1] =
"MAPS";
2224 idx_vars[basevalues+2] =
"LETTER";
2225 idx_vars[basevalues+3] =
"LETTERCOUNT";
2226 idx_vars[basevalues+4] = NULL;
2227 idx_values[basevalues+1] = mapstext;
2228 idx_values[basevalues+2] = str_letter;
2229 snprintf(lettercount,
sizeof(lettercount),
"%d", byletter);
2230 idx_values[basevalues+3] = lettercount;
2234 idx_values[basevalues+2] = NULL;
2237 snprintf(count,
sizeof(count),
"%d", realcount);
2238 idx_values[basevalues+1] = string;
2239 idx_vars[basevalues+1] =
"LETTERS";
2240 idx_vars[basevalues+2] = NULL;
2241 tmp =
do_template(template_page, idx_vars, idx_values);
2261 const char *vars[] = {
"REGIONNAME",
"REGIONHTML",
"REGIONLONGNAME",
"REGIONDESC", NULL };
2262 const char *values[] = { reg->
reg->
name, html, NULL, NULL };
2264 printf(
"Generating map index for region %s...", reg->
reg->
name);
2270 strcat(html,
".html");
2277 strcat(html,
".html");
2278 index = fopen(html,
"w+");
2279 fprintf(index,
string);
2303 char index_path[500];
2307 printf(
"Generating global map index in maps.html...");
2311 strcpy(index_path,
root);
2312 strcat(index_path,
"/maps.html");
2313 index = fopen(index_path,
"w+");
2314 fprintf(index, tmp);
2331 const char *vars[] = {
"REGIONCOUNT",
"REGIONFILE",
"REGIONNAME", NULL };
2332 const char *values[] = { count, file, NULL };
2335 printf(
"Generating regions index in regions.html...");
2341 region = regions[reg];
2346 vars[1] =
"REGIONS";
2353 strcat(file,
"/regions.html");
2354 out = fopen(file,
"w+");
2355 fprintf(out,
final);
2374 char mapleft[10], maptop[10], mapright[10], mapbottom[10];
2375 const char *vars[] = { NULL, NULL,
"MAPLEFT",
"MAPTOP",
"MAPRIGHT",
"MAPBOTTOM", NULL };
2376 const char *values[] = { NULL, NULL, mapleft, maptop, mapright, mapbottom, NULL };
2378 char mappath[500], mapraw[500], mapregion[500];
2387 printf(
"Generating world map in world.html...");
2390 pic = gdImageCreateTrueColor(
SIZE*30,
SIZE*30);
2393 strcat(file,
"/world.html");
2398 for (y = 0; y < 30; y++) {
2399 for (x = 0; x < 30; x++) {
2401 vars[0] =
"MAPNAME";
2402 vars[1] =
"MAPPATH";
2403 values[1] = mappath,
2404 snprintf(name,
sizeof(name),
"world_%d_%d", wx, wy);
2405 snprintf(mappath,
sizeof(mappath),
"world/%s.html", name);
2408 snprintf(mapright,
sizeof(mapright),
"%d",
SIZE*(x+1)-1);
2409 snprintf(mapbottom,
sizeof(mapbottom),
"%d",
SIZE*(y+1)-1);
2415 out = fopen(mappath,
"rb");
2417 printf(
"\n warning: large pic not found for world_%d_%d", wx, wy);
2421 if (output_format ==
OF_PNG)
2422 small = gdImageCreateFromPng(out);
2424 small = gdImageCreateFromJpeg(out);
2427 printf(
"\n warning: pic not found for world_%d_%d", wx, wy);
2431 gdImageCopyResized(pic, small,
SIZE*x,
SIZE*y, 0, 0,
SIZE,
SIZE, small->sx, small->sy);
2432 gdImageDestroy(small);
2451 values[1] = mappath;
2452 vars[1] =
"WORLDMAP";
2454 vars[2] =
"WORLDRAW";
2455 values[3] = mapregion;
2456 vars[3] =
"WORLDREGIONS";
2460 out = fopen(file,
"w+");
2461 fprintf(out, total);
2466 out = fopen(mappath,
"wb+");
2471 small = gdImageCreateTrueColor(
SIZE*30,
SIZE*30);
2472 font = gdFontGetGiant();
2473 color = gdImageColorAllocateAlpha(pic, 255, 0, 0, 20);
2475 if (!regions[region]->is_world || regions[region]->sum == 0)
2480 gdImageString(small, font, x, y, regions[region]->reg->name, color);
2481 gdImageString(pic, font, x, y, regions[region]->reg->name, color);
2484 x = regions[
region]->
sum_x*50/regions[
region]->
sum+50/2-strlen(regions[region]->reg->name)*font->w/2;
2486 gdImageString(
infomap, font, x, y, regions[region]->reg->name, color);
2490 out = fopen(mappath,
"wb+");
2493 gdImageDestroy(small);
2496 out = fopen(mappath,
"wb+");
2499 gdImageDestroy(pic);
2521 char mapsmallpic[500];
2522 char indexpath[500];
2523 char regionpath[500];
2524 char regionname[500];
2525 char regionindexpath[500];
2526 char worldmappath[500];
2527 char exit_path[500];
2528 char maplevel[5], minmonster[5], maxmonster[5];
2530 char questpath[500], questtemp[500];
2531 const char *quest_vars[] = {
"NAME",
"PATH",
"TEXT", NULL };
2532 const char *quest_vals[] = { NULL, questpath, NULL, NULL };
2533 const char *q_vars[] = {
"QUESTS", NULL };
2534 const char *q_vals[] = { NULL, NULL };
2535 const char *m_vars[] = {
"NAME", NULL };
2536 const char *m_vals[] = { NULL, NULL };
2537 const char *vars[] = {
"NAME",
"MAPPATH",
"MAPNAME",
"MAPPIC",
"MAPSMALLPIC",
"MAPEXITFROM",
"INDEXPATH",
"REGIONPATH",
"REGIONNAME",
"REGIONINDEXPATH",
"WORLDMAPPATH",
"MAPLORE",
"MAPEXITTO",
"MAPLEVEL",
"QUESTS",
"MONSTERS",
"MINMONSTER",
"MAXMONSTER", NULL, NULL, NULL };
2538 const char *values[] = { map->
path, htmlpath, map->
name, mappic, mapsmallpic,
"", indexpath, regionpath, regionname, regionindexpath, worldmappath,
"",
"", maplevel, NULL,
"", minmonster, maxmonster, NULL, NULL, NULL };
2541 while (vars[vars_count])
2553 strcpy(exit_path,
"/");
2555 strcat(exit_path,
".html");
2559 snprintf(regionname,
sizeof(regionname),
"(map was not processed)");
2571 if (map->
lore && map->
lore[0] !=
'\0') {
2572 values[11] = map->
lore;
2577 values[11] = maplore;
2580 char *one_exit = NULL;
2584 vars[vars_count] =
"EXITNAME";
2585 vars[vars_count+1] =
"EXITFILE";
2591 strcat(relative,
".html");
2592 values[vars_count+1] = relative;
2595 vars[vars_count] =
"EXIT";
2596 vars[vars_count+1] = NULL;
2597 values[vars_count] = one_exit;
2604 values[5] = exits_text;
2607 char *one_exit = NULL;
2611 vars[vars_count] =
"EXITNAME";
2612 vars[vars_count+1] =
"EXITFILE";
2618 strcat(relative,
".html");
2619 values[vars_count+1] = relative;
2622 vars[vars_count] =
"EXIT";
2623 vars[vars_count+1] = NULL;
2624 values[vars_count] = one_exit;
2630 values[12] = exits_to;
2667 values[15] = monsters;
2669 vars[vars_count] = NULL;
2670 out = fopen(htmlpath,
"w+");
2686 for (map = 0; map < maps_list.
count; map++) {
2690 printf(
"map without path!\n");
2709 for (map = 0; map < tiled_map_list.
count; map++) {
2711 printf(
"empty tiled map group!");
2715 snprintf(name,
sizeof(name),
"tiled_map_group_%d", map);
2729 printf(
"*** warning: tiled maps %s and %s not in same region (%s and %s).\n",
2744 printf(
"*** warning: tiled map without any name. First map path %s\n", tiled_map_list.
maps[map]->
tiled_maps.
maps[0]->
path);
2748 tiled_map_list.
maps[map]->
name = strdup(test);
2752 slash = strrchr(name,
'/');
2757 strncat(name, tiled_map_list.
maps[map]->
filename,
sizeof(name));
2758 tiled_map_list.
maps[map]->
path = strdup(name);
2776 max = from->
count-1;
2777 for (map = max; map >= 0; map--) {
2795 for (map = 0; map < maps_list.
count; map++) {
2802 for (map = max; map >= 0; map--) {
2809 add_map(group, ®ions[region]->maps_list);
2823 for (race = 0; race < races.
count; race++) {
2825 for (map = max; map >= 0; map--) {
2837 for (map = 0; map < maps_list.
count; map++) {
2850 printf(
"Writing map pages...");
2852 for (map = 0; map < maps_list.
count; map++)
2865 if (stat(picpath, &stats))
2869 if (stat(picpath, &stats))
2892 int xmin = 0, xmax = 0, ymin = 0, ymax = 0, tiled, count, last;
2901 printf(
" Generating composite map for %s...", map->
name);
2905 printf(
" already uptodate.\n");
2911 printf(
"Tiled map without tiled maps?\n");
2950 if (last == count) {
2951 printf(
"do_tiled_map_picture: didn't process any map in %s (%d left)??\n", map->
path, last);
2967 large = gdImageCreateTrueColor(32*(xmax-xmin), 32*(ymax-ymin));
2973 out = fopen(picpath,
"rb");
2975 printf(
"\n do_tiled_map_picture: warning: pic file not found for %s (errno=%d)\n", map->
tiled_maps.
maps[tiled]->
path, errno);
2978 if (output_format ==
OF_PNG)
2979 load = gdImageCreateFromPng(out);
2981 load = gdImageCreateFromJpeg(out);
2984 printf(
"\n do_tiled_map_picture: warning: pic not found for %s\n", map->
tiled_maps.
maps[tiled]->
path);
2988 gdImageDestroy(load);
2991 out = fopen(picpath,
"rb");
2992 if (output_format ==
OF_PNG)
2993 load = gdImageCreateFromPng(out);
2995 load = gdImageCreateFromJpeg(out);
2998 printf(
"\n do_tiled_map_picture: warning: small pic not found for %s\n", map->
tiled_maps.
maps[tiled]->
path);
3002 gdImageDestroy(load);
3006 out = fopen(picpath,
"wb+");
3011 out = fopen(picpath,
"wb+");
3015 gdImageDestroy(small);
3016 gdImageDestroy(large);
3035 printf(
"Writing tiled map information...\n");
3037 for (map = 0; map < tiled_map_list.
count; map++)
3049 char *letters = NULL;
3055 const char *val_vars[] = {
"LEVEL",
"MAPS", NULL };
3056 const char *val_values[] = { strlevel, NULL, NULL };
3057 const char *map_vars[] = {
"MAPNAME",
"MAPPATH", NULL };
3058 const char *map_values[] = { NULL, mappath, NULL };
3059 const char *idx_vars[] = {
"COUNT",
"LEVELS", NULL };
3060 const char *idx_values[] = { strcount, NULL, NULL };
3065 printf(
"Writing map index by level...");
3067 snprintf(name,
sizeof(name),
"%s/index_by_level.html",
root);
3071 for (map = 0; map < maps_list.
count; map++) {
3072 process = maps_list.
maps[map];
3073 if (maps_list.
maps[map]->
level != lastlevel) {
3075 snprintf(strlevel,
sizeof(strlevel),
"%d", lastlevel);
3076 val_values[1] = maps;
3081 lastlevel = process->
level;
3085 if (last_tiled && last_tiled == process->
tiled_group)
3091 last_tiled = process;
3095 map_values[0] = process->
name;
3096 snprintf(mappath,
sizeof(mappath),
"%s.html", process->
path+1);
3100 snprintf(strlevel,
sizeof(strlevel),
"%d", lastlevel);
3101 val_values[1] = maps;
3106 snprintf(strcount,
sizeof(strcount),
"%d", levelcount);
3107 idx_values[1] = letters;
3111 out = fopen(name,
"w+");
3112 fprintf(out, level);
3127 printf(
"Generating special equipment list..");
3133 out = fopen(name,
"w+");
3135 fprintf(out,
"<html><head><title>Item list</title></head></body><h1>Special items found in maps</h1>\n");
3136 fprintf(out,
"<table border=\"1\"><tr><th>Name</th><th>Map(s)</th><th>Item power</th><th>Calc item power</th><th>Description</th></tr>\n");
3139 fprintf(out,
"<tr><td>%s</td><td><ul>", special_equipment[item]->name);
3141 for (map = 0; map < special_equipment[item]->
origin.
count; map++)
3142 fprintf(out,
"<li>%s</li>\n", special_equipment[item]->origin.maps[map]->path);
3144 fprintf(out,
"</ul></td><td>%d</td><td>%d</td><td><pre>%s</pre></td></tr>\n", special_equipment[item]->power, special_equipment[item]->calc_power, special_equipment[item]->diff);
3146 fprintf(out,
"</body></html>\n");
3160 printf(
"Generating monster list...");
3165 snprintf(name,
sizeof(name),
"%s/monsters.html",
root);
3166 out = fopen(name,
"w+");
3168 fprintf(out,
"<html><head><title>Monster list</title></head></body><h1>Monsters found in maps</h1>\n");
3169 fprintf(out,
"<table border=\"1\"><tr><th>Name</th><th>Count</th><th>Map(s)</th></tr>\n");
3171 for (item = 0; item < races.
count; item++) {
3179 fprintf(out,
"</ul></td></tr>\n");
3181 fprintf(out,
"</body></html>\n");
3214 struct stat statbuf;
3216 char path[1024], full[1024];
3219 for (ignore = 0;
ignore_path[ignore] != NULL; ignore++) {
3230 for (ignore = 0;
ignore_name[ignore] != NULL; ignore++) {
3239 status = stat(full, &statbuf);
3240 if ((status != -1) && (
S_ISDIR(statbuf.st_mode))) {
3260 int index, found = 0;
3262 snprintf(path,
sizeof(path),
"%s/%s",
root,
"maps.unused");
3263 dump = fopen(path,
"w+");
3265 printf(
"Unable to open file maps.unused!\n");
3276 printf(
"%d unused maps.\n", found);
3284 gdImagePtr elevationmap;
3289 printf(
"Saving exit/blocking/road information...");
3291 file = fopen(path,
"wb+");
3299 puts(
"Error: Could not save elevation world map due to not finding any minimum or maximum elevation.");
3303 elevationmap = gdImageCreateTrueColor(30*50, 30*50);;
3305 for (x = 0; x < 30*50; x++) {
3306 for (y = 0; y < 30*50; y++) {
3311 printf(
"Saving elevation world map...");
3313 file = fopen(path,
"wb+");
3317 gdImageDestroy(elevationmap);
3318 elevationmap = NULL;
3330 printf(
"Writing regions link file...");
3331 snprintf(path,
sizeof(path),
"%s/%s",
root,
"region_links.dot");
3332 file = fopen(path,
"wb+");
3333 fprintf(file,
"digraph {\n");
3336 fprintf(file,
"}\n");
3372 fprintf(file, without);
3378 fprintf(file, with);
3379 fprintf(file,
"<ul>\n");
3380 for (map = 0; map < info->
maps[item].
count; map++) {
3381 fprintf(file,
"\t<li>");
3383 fprintf(file,
"</li>\n");
3385 fprintf(file,
"</ul>\n");
3414 printf(
"Writing slaying info file...");
3418 snprintf(path,
sizeof(path),
"%s/%s",
root,
"slaying_info.html");
3419 file = fopen(path,
"wb+");
3421 fprintf(file,
"<html>\n<head>\n<title>Slaying information</title>\n</head>\n<body>\n");
3422 fprintf(file,
"<p>This is a list of various slaying fields on keys, containers, doors, detectors.</p>");
3425 info = slaying_info[lock];
3426 fprintf(file,
"<h1>%s</h1>\n", info->
slaying);
3429 fprintf(file,
"No door, container or detector matching this slaying.<br />\n");
3438 fprintf(file,
"</body>\n</html>\n");
3452 printf(
"Writing NPC info file...");
3456 snprintf(path,
sizeof(path),
"%s/%s",
root,
"npc_info.html");
3457 file = fopen(path,
"wb+");
3459 fprintf(file,
"<html>\n<head>\n<title>NPCs who have a special message</title>\n</head>\n<body>\n");
3460 fprintf(file,
"<p>This is a list of NPCs having a special message.</p>");
3461 fprintf(file,
"<ul>\n");
3463 for (map = 0; map < maps_list.
count; map++) {
3466 fprintf(file,
"<li>%s</li>\n<ul>", maps_list.
maps[map]->
path);
3467 for (npc = 0; npc < maps_list.
maps[map]->
npcs.
count; npc++) {
3470 fprintf(file,
"</ul>\n</li>\n");
3473 fprintf(file,
"</ul>\n");
3474 fprintf(file,
"</body>\n</html>\n");
3487 printf(
"Crossfire Mapper will generate pictures of maps, and create indexes for all maps and regions.\n\n");
3488 printf(
"Syntax: %s\n\n", program);
3489 printf(
"Optional arguments:\n");
3490 printf(
" -nopics don't generate pictures.\n");
3491 printf(
" -noindex don't generate global map index.\n");
3492 printf(
" -root=<path> destination path. Default 'html'.\n");
3493 printf(
" -limit=<number> stop processing after this number of maps, -1 to do all maps (default).\n");
3494 printf(
" -showmaps outputs the name of maps as they are processed.\n");
3495 printf(
" -jpg[=quality] generate jpg pictures, instead of default png. Quality should be 0-95, -1 for automatic.\n");
3496 printf(
" -forcepics force to regenerate pics, even if pics's date is after map's.\n");
3497 printf(
" -addmap=<map> adds a map to process. Path is relative to map's directory root.\n");
3498 printf(
" -rawmaps generates maps pics without items on random (shop, treasure) tiles.\n");
3499 printf(
" -warnnopath inform when an exit has no path set.\n");
3500 printf(
" -listunusedmaps finds all unused maps in the maps directory.\n");
3501 printf(
" -noworldmap don't write the world map in world.png.\n");
3502 printf(
" -noregionslink don't generate regions relation file.\n");
3503 printf(
" -regionslink generate regions relation file.\n");
3504 printf(
" -noexitmap don't generate map of exits.\n");
3505 printf(
" -exitmap generate map of exits.\n");
3506 printf(
" -tileset=<number> use specified tileset to generate the pictures. Default 0 (standard).\n");
3525 while (arg < argc) {
3526 if (strcmp(argv[arg],
"-nopics") == 0)
3528 else if (strcmp(argv[arg],
"-noindex") == 0)
3530 else if (strncmp(argv[arg],
"-root=", 6) == 0)
3531 strncpy(
root, argv[arg]+6, 500);
3532 else if (strncmp(argv[arg],
"-limit=", 7) == 0)
3534 else if (strcmp(argv[arg],
"-showmaps") == 0)
3536 else if (strcmp(argv[arg],
"-jpg") == 0) {
3538 if (argv[arg][4] ==
'=') {
3544 else if (strcmp(argv[arg],
"-forcepics") == 0)
3546 else if (strncmp(argv[arg],
"-addmap=", 8) == 0) {
3547 if (*(argv[arg]+8) ==
'/')
3548 strncpy(path, argv[arg]+8, 500);
3550 snprintf(path, 500,
"/%s", argv[arg]+8);
3553 else if (strcmp(argv[arg],
"-rawmaps") == 0)
3555 else if (strcmp(argv[arg],
"-warnnopath") == 0)
3557 else if (strcmp(argv[arg],
"-listunusedmaps") == 0)
3559 else if (strcmp(argv[arg],
"-noworldmap") == 0)
3561 else if (strcmp(argv[arg],
"-noregionslink") == 0)
3563 else if (strcmp(argv[arg],
"-regionslink") == 0)
3565 else if (strcmp(argv[arg],
"-noexitmap") == 0)
3567 else if (strcmp(argv[arg],
"-exitmap") == 0)
3569 else if (strncmp(argv[arg],
"-tileset=", 9) == 0) {
3577 strcpy(
root,
"html");
3590 strcpy(dummy,
root);
3591 strcat(dummy,
"/a");
3604 return (value ?
"yes" :
"no");
3608 int current_map = 0, i;
3619 printf(
"Initializing Crossfire data...\n");
3638 dummy->
longname =
add_string(
"This dummy region contains all maps without a region set.");
3639 dummy->
longname =
add_string(
"This dummy region contains all maps without a region set.");
3643 printf(
"\n\n done.\n\n");
3646 printf(
"Erreor: invalid tileset %d!\n",
tileset);
3698 strcpy(max,
"(none)");
3699 printf(
"Crossfire map browser generator\n");
3700 printf(
"-------------------------------\n\n");
3701 printf(
"Parameters:\n");
3702 printf(
" path to write files: %s\n",
root);
3703 printf(
" maximum number of maps to process: %s\n", max);
3707 if (output_format ==
OF_JPG)
3721 printf(
"listing all maps...");
3728 infomap = gdImageCreateTrueColor(30*50, 30*50);
3735 for (i = 0; i < 50*30; i++)
3740 printf(
"browsing maps...\n");
3744 while (current_map < maps_list.
count) {
3746 if (current_map%100 == 0) {
3750 printf(
" --- map limit reached, stopping ---\n");
3755 printf(
" finished map parsing, %d maps processed, %d map pictures created, %d map pictures were uptodate. Total %d faces used.\n", current_map,
created_pics,
cached_pics,
pics_allocated);
3789 object *tmp, *above = NULL;
3797 for (tmp =
GET_MAP_OB(m, x, y); tmp != NULL; tmp = above) {
3801 object *invtmp, *invnext;
3803 for (invtmp = tmp->
inv; invtmp != NULL; invtmp = invnext) {
3804 invnext = invtmp->
below;
3809 while ((invtmp->
stats.
hp--) > 0)
3853 object *head = tmp->
head != NULL ? tmp->
head : tmp;
3887 #ifndef DOXYGEN_SHOULD_SKIP_THIS
3894 fprintf(
logfile,
"%s\n", txt);
3900 va_start(ap, old_format);
3901 vfprintf(
logfile, old_format, ap);
3906 fprintf(
logfile,
"ext_info_map: %s\n", str2);
3946 int execute_event(
object *op,
int eventcode,
object *activator,
object *third,
const char *message,
int fix) {
3955 object *tmp = NULL, *tmp2;
3993 for (tmp = op->
inv; tmp; tmp = tmp2) {
struct struct_npc_info struct_npc_info
struct_map_in_quest_list quests
struct struct_equipment struct_equipment
object * find_skill_by_number(object *who, int skillno)
static void free_equipment(struct_equipment *equip)
static void find_maps(const char *from)
static int region_allocated
static int tiled_map_need_pic(struct_map_info *map)
static char * map_exit_to_template
static char * level_map_template
archetype * find_archetype(const char *name)
static void init_map_list(struct_map_list *list)
static char * map_no_exit_to_template
static char * region_template
static void process_map_lore(struct_map_info *map)
static char * region_letter_template
static int generate_index
static char * world_map_template
void esrv_update_spells(player *pl)
static int sort_mapname(const void *left, const void *right)
static char * map_lore_template
static char ** regions_link
struct struct_map_in_quest ** list
static struct_equipment ** special_equipment
void make_path_to_file(const char *filename)
static int compare_map_info(const struct_map_info *left, const struct_map_info *right)
struct_race_list monsters
static void write_tiled_maps(void)
static void add_map_to_region(struct_map_info *map, region *reg)
struct_map_list maps[S_MAX]
struct_map_list tiled_maps
static char * cat_template(char *source, char *add)
static int equipment_allocated
static void add_slaying(struct_map_info *map, object *item)
static struct_equipment * ensure_unique(struct_equipment *item)
char * create_pathname(const char *name, char *buf, size_t size)
static char * map_with_exit_template
StringBuffer * stringbuffer_new(void)
mapstruct * ready_map_name(const char *name, int flags)
static void write_maps_index(void)
static char * do_template(const char *template, const char **vars, const char **values)
void dragon_ability_gain(object *ob, int x, int y)
static char * map_with_quests_template
struct treasureliststruct * randomitems
static void write_maps_by_level(void)
static struct_slaying_info ** slaying_info
void set_darkness_map(mapstruct *m)
struct_map_info * mainmap
void monster_check_apply(object *ob, object *obt)
struct_map_in_quest_list maps
static void list_map(const char *path)
region * get_region_by_map(mapstruct *m)
static char * map_no_quest_template
static void init_npc_list(struct_npc_list *list)
void init_archetypes(void)
static gdImagePtr infomap
DIR * opendir(const char *)
static void merge_tiled_maps(struct_map_info *map, int tile, struct_map_info *tiled_map)
static const char * output_extensions[]
int is_valid_faceset(int fsn)
static void save_picture(FILE *file, gdImagePtr pic)
static char * map_no_lore_template
static const char * yesno(int value)
static void do_help(const char *program)
static void relative_path(const char *from, const char *to, char *result)
static void do_parameters(int argc, char **argv)
static int sort_slaying(const void *left, const void *right)
static int color_unlinked_exit
static void write_npc_list(void)
void get_multi_size(object *ob, int *sx, int *sy, int *hx, int *hy)
static struct struct_region_info ** regions
static void write_quests_page(void)
struct struct_race_list struct_race_list
static void fix_tiled_map_monsters(void)
static void process_map(struct_map_info *info)
static struct_race_list races
static int is_special_equipment(object *item)
static int regions_link_count
int main(int argc, char **argv)
struct struct_quest * quest
static void dump_unused_maps(void)
static int slaying_allocated
static char * quest_map_template
static void init_race_list(struct_race_list *list)
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
static int color_linked_exit
static void define_quest(const char *name, struct_map_info *mainmap, const char *description)
const char * get_region_longname(const region *r)
static void add_map_to_quest(struct_map_info *map, const char *name, const char *description)
static int sort_map_info(const void *left, const void *right)
void esrv_update_item(int flags, object *pl, object *op)
static int sort_struct_map_in_quest(const void *left, const void *right)
static void add_to_struct_map_in_quest_list(struct_map_in_quest_list *list, struct_map_in_quest *item)
void remove_ob(object *op)
static void write_map_page(struct_map_info *map)
void clean_tmp_files(void)
static void fix_exits_to_tiled_maps(void)
static char * map_monster_after_template
static int list_unused_maps
static char * level_value_template
static void write_slaying_info(void)
static char * index_template
static struct_map_info * create_map_info(void)
static struct_map_list maps_list
static char * index_letter
static int pics_allocated
static int is_road(object *item)
static void write_one_slaying_info(FILE *file, struct_slaying_info *info, int item, const char *with, const char *without)
#define FLAG_UNAGGRESSIVE
struct struct_quest struct_quest
static struct_slaying_info * get_slaying_struct(const char *slaying)
static char * index_region_template
struct struct_map_info * tiled_group
static char * map_monster_before_template
region * get_region_struct(void)
void emergency_save(int x)
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
void identify(object *op)
struct struct_map_info * tiles[4]
static char * map_monster_between_template
static void do_tiled_map_picture(struct_map_info *map)
static char * map_monster_one_template
static void write_equipment_index(void)
static void add_npc_to_map(struct_map_info *map, const object *npc)
static int ** elevation_info
void ext_info_map(int color, const mapstruct *map, uint8 type, uint8 subtype, const char *str1, const char *str2)
static char * index_region_region_template
#define FLAG_IS_A_TEMPLATE
static char * level_template
struct struct_npc_list struct_npc_list
static void replace_map(struct_map_info *find, struct_map_info *replace_by, struct_map_list *list)
static gdImagePtr * gdfaces
static enum output_format_type output_format
static void check_slaying_inventory(struct_map_info *map, object *item)
static void add_one_item(object *item, struct_map_info *map)
static char * world_template
static void fix_map_names(void)
int auto_apply(object *op)
void read_client_images(void)
char d_name[_MAX_FNAME+1]
void trap_adjust(object *ob, int x)
static void add_monster(object *monster, struct_map_info *map)
void esrv_del_item(player *pl, int tag)
#define QUERY_FLAG(xyz, p)
#define CLEAR_FLAG(xyz, p)
static int sortbyname(const void *a, const void *b)
int execute_global_event(int eventcode,...)
static char * index_quest_template
static void add_map_to_slaying(struct_slaying_info *info, int item, struct_map_info *map)
static int regions_link_allocated
static void add_region_link(mapstruct *source, mapstruct *dest, const char *linkname)
object * insert_ob_in_ob(object *op, object *where)
static void create_destination(void)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
static int sort_race(const void *a, const void *b)
static int sort_region(const void *left, const void *right)
static char * map_exit_template
object * insert_ob_in_map(object *op, mapstruct *m, object *originator, int flag)
struct struct_map_in_quest struct_map_in_quest
static void write_all_regions(void)
void move_firewall(object *ob)
static void write_slaying_map_name(FILE *file, struct_map_info *map)
void esrv_send_item(object *ob, object *obx)
static char * map_template
struct_map_list maps_list
static const flag_definition flags[]
static char * region_map_template
static int sort_equipment(const void *a, const void *b)
static char * map_no_monster_template
int snprintf(char *dest, int max, const char *format,...)
void get_ob_diff(StringBuffer *sb, object *op, object *op2)
static void write_regions_link(void)
struct struct_region_info struct_region_info
face_sets facesets[MAX_FACE_SETS]
struct struct_race ** races
static void init_struct_map_in_quest_list(struct_map_in_quest_list *list)
static int do_regions_link
static void write_world_info(void)
static int equipment_count
static void check_equipment(object *item, struct_map_info *map)
void draw_ext_info(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *txt, const char *txt2)
static void write_all_maps(void)
struct dirent * readdir(DIR *)
void delete_map(mapstruct *m)
int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
static const char * ignore_path[]
EXTERN char first_map_path[MAX_BUF]
static void fix_tiled_map(void)
static int get_elevation_color(int elevation, gdImagePtr elevationmap)
void update_ob_speed(object *op)
static void do_exit_map(mapstruct *map)
sstring add_string(const char *str)
static struct_map_list tiled_map_list
static char * do_map_index(const char *dest, struct_map_list *maps_list, const char *template_page, const char *template_letter, const char *template_map, const char **vars, const char **values)
static struct_equipment * get_equipment(void)
#define GET_MAP_OB(M, X, Y)
int strcasecmp(const char *s1, const char *s2)
static void read_template(const char *name, char **buffer)
static char * world_row_template
static char * map_one_quest_template
void fix_auto_apply(mapstruct *m)
struct struct_race struct_race
static struct_race * get_race(const char *name)
static int world_exit_info
EXTERN region * first_region
static struct_map_info * create_tiled_map(void)
static int color_blocking
struct struct_map_info ** maps
static char * map_no_exit_template
static char * map_with_exit_to_template
int calc_item_power(const object *op, int flag)
int get_face_fallback(int faceset, int imageno)
static int sort_map_info_by_level(const void *left, const void *right)
object * generate_treasure(treasurelist *t, int difficulty)
static int found_maps_count
void free_object(object *ob)
static void write_world_map(void)
static char ** found_maps
static struct_map_info * get_map_info(const char *path)
static void add_race_to_list(struct_race *race, struct_race_list *list, int check)
static void write_race_index(void)
void do_auto_apply(mapstruct *m)
static void write_region_page(struct_region_info *reg)
static struct_npc_info * create_npc_info(const object *npc)
struct_map_list exits_from
static int is_blocking(object *item)
static void fix_exits_for_map(struct_map_info *current, struct_map_list *from, int is_from)
static void write_tiled_map_page(struct_map_info *map)
static struct_quest ** quests
static char * quest_template
static void add_map(struct_map_info *info, struct_map_list *list)
char * stringbuffer_finish(StringBuffer *sb)
static int is_slaying(object *item)
#define HAS_RANDOM_ITEMS(op)
const char * get_region_msg(const region *r)
static struct_quest * get_quest_info(const char *name)
void init_artifacts(void)
static int quests_allocated
static void write_region_index(void)
struct struct_map_info struct_map_info
static const char * ignore_name[]
static int found_maps_allocated