Crossfire Server, Trunk
mapper.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire map browser generator.
3  *
4  * Author: Nicolas Weeger <nicolas.weeger@laposte.net>, (C) 2006-2021.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 
147 #include <ctype.h>
148 #include <errno.h>
149 #include <stdio.h>
150 #include <stdlib.h>
151 #include <string.h>
152 #include <strings.h>
153 #include <sys/stat.h>
154 #include <sys/types.h>
155 #include <time.h>
156 
157 extern "C" {
158 #include "global.h"
159 #include "sproto.h"
160 #include "image.h"
161 #include "quest.h"
162 
163 #include <gd.h>
164 #include <gdfonts.h>
165 #include <gdfontl.h>
166 #include <gdfontg.h>
167 }
168 
169 #include "inja.hpp"
170 #include <map>
171 #include <set>
172 
173 static gdImagePtr *gdfaces;
174 
176 typedef struct struct_npc_info {
177  const char *name;
178  const char *message;
179  int x, y;
181 
183 typedef struct struct_npc_list {
185  size_t count;
186  size_t allocated;
188 
190 typedef struct struct_race_list {
191  struct struct_race **races;
192  size_t count;
193  size_t allocated;
195 
197 typedef struct {
199  size_t count;
200  size_t allocated;
202 
204 typedef struct {
206  size_t count;
207  size_t allocated;
209 
211 typedef struct struct_map_info {
212  char *path;
213  char *name;
214  char *filename;
215  char *lore;
221 
223 
225 
228 
230  int height, width;
232  struct struct_map_info *tiles[4];
234 
237 
240 
242 typedef struct struct_equipment {
243  char *name;
244  int power;
246  char *diff;
249 
252 static size_t equipment_count = 0;
254 static size_t equipment_allocated = 0;
258 typedef struct struct_race {
259  char *name;
260  int count;
262 } struct_race;
263 
272  list->races = NULL;
273  list->count = 0;
274  list->allocated = 0;
275 }
276 
288  if (check) {
289  size_t test;
290 
291  for (test = 0; test < list->count; test++) {
292  if (list->races[test] == race)
293  return;
294  }
295  }
296 
297  if (list->allocated == list->count) {
298  list->allocated += 50;
299  list->races = (struct_race **)realloc(list->races, sizeof(struct_race *)*list->allocated);
300  }
301  list->races[list->count] = race;
302  list->count++;
303 }
304 
306 static char root[500];
307 
309 static int pics_allocated;
310 
311 /* Options */
312 static int generate_pics = 1;
313 static int force_pics = 0;
314 static int sizes[] = {32, 16, 8, 4, 2};
315 static const int num_sizes = sizeof(sizes)/sizeof(int);
316 #define size_large sizes[0]
317 #define size_small sizes[1]
318 static int map_limit = -1;
319 static int show_maps = 0;
320 static int world_map = 1;
321 static int world_exit_info = 1;
322 static int tileset = 0;
323 static bool detail_quests = false;
324 static bool list_system_quests = false;
325 static bool display_rendered_template = false;
328 static int created_pics = 0;
329 static int cached_pics = 0;
333  OF_PNG = 0,
334  OF_JPG = 1
335 };
336 
338 static const char *output_extensions[] = {
339  ".png",
340  ".jpg"
341 };
342 
345 
347 static int jpeg_quality = -1;
348 
350 static int rawmaps = 0;
351 
353 static int warn_no_path = 0;
354 
356 typedef struct struct_region_info {
359  int sum_x, sum_y, sum;
360  int is_world;
362 
363 static struct struct_region_info **regions = NULL;
364 static size_t region_count = 0;
365 static size_t region_allocated = 0;
367 static int list_unused_maps = 0;
368 static char **found_maps = NULL;
369 static int found_maps_count = 0;
370 static int found_maps_allocated = 0;
372 /* Path/exit info */
373 static gdImagePtr infomap;
375 static int color_linked_exit;
376 static int color_road;
377 static int color_blocking;
378 static int color_slowing;
380 static int **elevation_info;
381 static int elevation_min;
382 static int elevation_max;
384 /* Whether to compute links between regions or not (expensive). */
385 static bool do_regions_link = false;
386 /* Links between regions, key is source, value are destinations. */
387 static std::map<region *, std::set<region *>> region_links;
388 
390 #define S_DOOR 0
391 #define S_KEY 1
392 #define S_CONTAINER 2
393 #define S_DETECTOR 3
394 #define S_CONNECT 4
395 #define S_MAX 5
396 
398 typedef struct {
399  char *slaying;
402 
404 static size_t slaying_count = 0;
405 static size_t slaying_allocated = 0;
413  list->maps = NULL;
414  list->count = 0;
415  list->allocated = 0;
416 }
417 
418 static void add_map(struct_map_info *info, struct_map_list *list);
419 
420 static int is_special_equipment(object *item) {
421  if (item->name == item->arch->clone.name && item->title == item->arch->clone.title)
422  return 0;
424  return 0;
425  if (item->move_block == MOVE_ALL)
426  return 0;
427 
428  if (IS_SHIELD(item) || IS_WEAPON(item) || IS_ARMOR(item) || IS_ARROW(item) || (item->type == ROD) || (item->type == WAND) || (item->type == RING) || (item->type == AMULET))
429  return 1;
430 
431  return 0;
432 }
433 
440  struct_equipment *add = (struct_equipment *)calloc(1, sizeof(struct_equipment));
441 
442  init_map_list(&add->origin);
443  return add;
444 }
445 
452 static void free_equipment(struct_equipment *equip) {
453  free(equip->diff);
454  free(equip->name);
455  free(equip);
456 }
457 
467  struct_equipment *comp;
468 
469  for (size_t check = 0; check < equipment_count; check++) {
470  comp = special_equipment[check];
471 
472  if (strcmp(comp->name, item->name))
473  continue;
474  if (comp->power != item->power)
475  continue;
476  if (comp->calc_power != item->calc_power)
477  continue;
478  if (strcmp(comp->diff, item->diff))
479  continue;
480 
482  return comp;
483  }
484 
486  equipment_allocated += 50;
488  }
490  equipment_count++;
491 
492  return item;
493 }
494 
504 static void add_one_item(object *item, struct_map_info *map) {
507  int x, y;
508  sstring name, namepl;
509  uint32_t nrof;
510  object *base;
511 
512  x = item->x;
513  y = item->y;
514  name = item->name;
515  namepl = item->name_pl;
516  nrof = item->nrof;
517 
518  if (item->artifact != NULL) {
519  const artifact *artifact;
520 
521  artifact = find_artifact(item, item->artifact);
522  if (artifact == NULL) {
523  LOG(llevError, "could not find artifact %s [%d] to save data\n", item->artifact, item->type);
524  base = arch_to_object(item->arch);
525  } else {
526  base = arch_to_object(item->arch);
528  }
529  }
530  else {
531  base = arch_to_object(item->arch);
532  }
533 
534  item->x = base->x;
535  item->y = base->y;
536  item->name = base->name;
537  item->name_pl = base->name_pl;
538  item->nrof = base->nrof;
539 
542  SET_FLAG(base, FLAG_IDENTIFIED);
543  }
545  SET_FLAG(base, FLAG_UNPAID);
546  get_ob_diff(bf, item, base);
548 
549  add->diff = stringbuffer_finish(bf);
550 
551  item->x = x;
552  item->y = y;
553  item->name = name;
554  item->name_pl = namepl;
555  item->nrof = nrof;
556 
557  if (add->diff == NULL || strcmp(add->diff, "") == 0) {
558  free_equipment(add);
559  return;
560  }
561 
562  add->name = strdup(item->name);
563  add->power = item->item_power;
565 
566  add = ensure_unique(add);
567  add_map(map, &add->origin);
568 }
569 
578 static void check_equipment(object *item, struct_map_info *map) {
581 
584  FOR_INV_FINISH();
585 }
586 
595 static int sort_equipment(const void *a, const void *b) {
596  const struct_equipment *l = *(const struct_equipment **)a;
597  const struct_equipment *r = *(const struct_equipment **)b;
598  int c = l->power-r->power;
599 
600  if (c)
601  return c;
602  return strcasecmp(l->name, r->name);
603 }
604 
613 static struct_race *get_race(const char *name) {
614  size_t test;
615  struct_race *item;
616 
617  for (test = 0; test < races.count; test++) {
618  if (strcmp(races.races[test]->name, name) == 0) {
619  races.races[test]->count++;
620  return races.races[test];
621  }
622  }
623 
624  item = (struct_race *)calloc(1, sizeof(struct_race));
625  item->name = strdup(name);
626  item->count = 1;
627  init_map_list(&item->origin);
628 
630 
631  return item;
632 }
633 
642 static void add_monster(object *monster, struct_map_info *map) {
643  struct_race *race;
644 
645  if (monster->head && monster != monster->head)
646  return;
647 
648  map->min_monster = MIN(monster->level, map->min_monster);
649  map->max_monster = MAX(monster->level, map->max_monster);
650 
651  race = get_race(monster->name);
652  add_map(map, &race->origin);
653  add_race_to_list(race, &map->monsters, 1);
654 }
655 
664 static int sort_race(const void *a, const void *b) {
665  const struct_race *l = *(const struct_race **)a;
666  const struct_race *r = *(const struct_race **)b;
667  return strcasecmp(l->name, r->name);
668 }
669 
677 static int is_road(object *item) {
678  int test;
679  /* Archetypes used as roads. */
680  const char *roads[] = {
681  "cobblestones",
682  "flagstone",
683  "ice_stone",
684  "snow",
685  NULL };
686  const char *partial[] = {
687  "dirtroad_",
688  NULL };
689 
690  for (test = 0; partial[test] != NULL; test++) {
691  if (strstr(item->arch->name, partial[test]) != NULL)
692  return 1;
693  }
694 
696  return 0;
697 
698  for (test = 0; roads[test] != NULL; test++) {
699  if (strcmp(item->arch->name, roads[test]) == 0)
700  return 1;
701  }
702 
703  return 0;
704 }
705 
713 static int is_blocking(object *item) {
714  return item->move_block == MOVE_ALL ? 1 : 0;
715 }
716 
727 static int get_elevation_color(int elevation, gdImagePtr elevationmap) {
728  if (elevation > 0)
729  return gdImageColorResolve(elevationmap, 200*elevation/elevation_max, 0, 0);
730  else
731  return gdImageColorResolve(elevationmap, 0, 0, 200*elevation/elevation_min);
732 }
733 
742 static void do_exit_map(mapstruct *map) {
743  int tx, ty, x, y;
744  object *test;
745  sstring selevation;
746 
747  if (sscanf(map->path, "/world/world_%d_%d", &x, &y) != 2)
748  return;
749 
750  x -= 100;
751  y -= 100;
752 
753  for (tx = 0; tx < MAP_WIDTH(map); tx++) {
754  for (ty = 0; ty < MAP_HEIGHT(map); ty++) {
755  FOR_MAP_PREPARE(map, tx, ty, item) {
756  test = HEAD(item);
757 
758  if (test->type == EXIT || test->type == TELEPORTER) {
759  if (!test->slaying)
760  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_unlinked_exit);
761  else
762  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_linked_exit);
763  } else if (is_road(test))
764  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_road);
765  else if (is_blocking(test)) {
766  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_blocking);
767  /* can't get on the spot, so no need to go on. */
768  break;
769  } else if (test->move_slow != 0)
770  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_slowing);
771 
772  selevation = object_get_value(item, "elevation");
773  if (selevation) {
774  int32_t elevation = atoi(selevation);
775  elevation_min = MIN(elevation_min, elevation);
776  elevation_max = MAX(elevation_max, elevation);
777  elevation_info[x*50+tx][y*50+ty] = elevation;
778  }
779  } FOR_MAP_FINISH();
780  }
781  }
782 }
783 
784 void do_auto_apply(mapstruct *m);
785 
796 static int sortbyname(const void *a, const void *b) {
797  return (strcmp(*(const char **)a, *(const char **)b));
798 }
799 
812 static void relative_path(const char *from, const char *to, char *result) {
813  const char *fslash;
814  const char *rslash;
815 
816  result[0] = '\0';
817 
818  fslash = strchr(from+1, '/');
819  if (!fslash) {
820  strcpy(result, to+1);
821  return;
822  }
823 
824  rslash = strchr(to+1, '/');
825  while (fslash && rslash && (fslash-from == rslash-to) && strncmp(from, to, fslash-from+1) == 0) {
826  from = fslash+1;
827  to = rslash+1;
828  fslash = strchr(fslash+1, '/');
829  rslash = strchr(rslash+1, '/');
830  }
831 
832  while (fslash) {
833  strcat(result, "../");
834  fslash = strchr(fslash+1, '/');
835  }
836  if (strlen(result) && result[strlen(result)-1] == '/' && *to == '/')
837  result[strlen(result)-1] = '\0';
838  strcat(result, to);
839 }
840 
851 static int compare_map_info(const struct_map_info *left, const struct_map_info *right) {
852  int c;
853 
854  if (left->tiled_group)
855  left = left->tiled_group;
856  if (right->tiled_group)
857  right = right->tiled_group;
858 
859  c = strcasecmp(left->name, right->name);
860  if (c)
861  return c;
862 
863  return strcasecmp(left->path, right->path);
864 }
865 
876 static int sort_map_info(const void *left, const void *right) {
877  const struct_map_info *l = *(const struct_map_info **)left;
878  const struct_map_info *r = *(const struct_map_info **)right;
879  return compare_map_info(l, r);
880 }
881 
892 static int sort_region(const void *left, const void *right) {
893  return strcmp((*((struct_region_info **)left))->reg->name, (*((struct_region_info **)right))->reg->name);
894 }
895 
896 /************************************
897  Start of quest-related definitions.
898 ************************************/
899 
901 typedef struct struct_map_in_quest {
903  char *description;
904  struct struct_quest *quest;
906 
908 typedef struct struct_quest {
909  char *name;
910  char *description;
911  int number;
914 } struct_quest;
915 
916 static struct_quest **quests = NULL;
918 static int quests_count = 0;
920 static int quests_allocated = 0;
923  list->list = NULL;
924  list->count = 0;
925  list->allocated = 0;
926 }
927 
929  if (list->count == list->allocated) {
930  list->allocated += 10;
931  list->list = (struct_map_in_quest **)realloc(list->list, sizeof(struct_map_in_quest *)*list->allocated);
932  }
933  list->list[list->count++] = item;
934 }
935 
941 static struct_quest *find_quest_info(const char *name) {
942  int test;
943  for (test = 0; test < quests_count; test++) {
944  if (strcmp(quests[test]->name, name) == 0)
945  return quests[test];
946  }
947  return NULL;
948 }
949 
958 static struct_quest *get_quest_info(const char *name) {
960  if (add) {
961  return add;
962  }
963 
965  quests_allocated += 10;
966  quests = (struct_quest **)realloc(quests, sizeof(struct_quest *)*quests_allocated);
967  }
968  add = (struct_quest *)calloc(1, sizeof(struct_quest));
969  add->name = strdup(name);
970  add->number = quests_count;
972  quests[quests_count] = add;
973  quests_count++;
974  return add;
975 }
976 
987 static void add_map_to_quest(struct_map_info *map, const char *name, const char *description) {
988  struct_map_in_quest *add;
990 
991  add = (struct_map_in_quest *)calloc(1, sizeof(struct_map_in_quest));
992  add->map = map;
993  add->quest = quest;
994  add->description = strdup(description);
995  while (strlen(add->description) && add->description[strlen(add->description)-1] == '\n')
996  add->description[strlen(add->description)-1] = '\0';
998  add_to_struct_map_in_quest_list(&map->quests, add);
999 }
1000 
1009 static int sort_struct_map_in_quest(const void *left, const void *right) {
1010  int c;
1011 
1012  const struct_map_in_quest *l = *(const struct_map_in_quest **)left;
1013  const struct_map_in_quest *r = *(const struct_map_in_quest **)right;
1014  const struct_map_info *ml = l->map;
1015  const struct_map_info *mr = r->map;
1016 
1017  if (ml->tiled_group)
1018  ml = ml->tiled_group;
1019  if (mr->tiled_group)
1020  mr = mr->tiled_group;
1021 
1022  c = strcasecmp(ml->name, mr->name);
1023  if (c)
1024  return c;
1025 
1026  return strcasecmp(ml->path, mr->path);
1027 }
1028 
1037 static int sort_struct_quest(const void *left, const void *right) {
1038  const struct_quest *l = *(const struct_quest **)left;
1039  const struct_quest *r = *(const struct_quest **)right;
1040  return strcasecmp(l->name, r->name);
1041 }
1042 
1053 static void define_quest(const char *name, struct_map_info *mainmap, const char *description) {
1055 
1056  if (quest->description || quest->mainmap) {
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);
1058  return;
1059  }
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;
1064 }
1065 
1073  char *start, *end, *next;
1074  char name[500];
1075  char description[500];
1076 
1077  start = strstr(map->lore, "@def");
1078  while (start) {
1079  description[0] = '\0';
1080  /* find name */
1081  end = strstr(start, "\n");
1082  if (end) {
1083  strncpy(name, start+5, end-start-5);
1084  name[end-start-5] = '\0';
1085  next = end+1;
1086  end = strstr(next, "@end");
1087  if (end) {
1088  strncpy(description, next, end-next);
1089  description[end-next] = '\0';
1090  /* need to erase the text. */
1091  memcpy(start, end+4, strlen(map->lore)-(end-start+3));
1092  end = start;
1093  }
1094  else {
1095  strcpy(description, next);
1096  *start = '\0';
1097  end = NULL;
1098  }
1099  } else {
1100  strcpy(name, start);
1101  *start = '\0';
1102  end = NULL;
1103  }
1104 
1105  define_quest(name, map, description);
1106  start = end ? strstr(end, "@def") : NULL;
1107  }
1108 
1109  start = strstr(map->lore, "@quest");
1110  while (start) {
1111  description[0] = '\0';
1112  /* find name */
1113  end = strstr(start, "\n");
1114  if (end) {
1115  strncpy(name, start+7, end-start-7);
1116  name[end-start-7] = '\0';
1117  next = end+1;
1118  end = strstr(next, "@end");
1119  if (end) {
1120  strncpy(description, next, end-next);
1121  description[end-next] = '\0';
1122  /* need to erase the text. */
1123  memcpy(start, end+4, strlen(map->lore)-(end-start+3));
1124  end = start;
1125  }
1126  else {
1127  strcpy(description, next);
1128  *start = '\0';
1129  end = NULL;
1130  }
1131  } else {
1132  strcpy(name, start);
1133  *start = '\0';
1134  end = NULL;
1135  }
1136 
1137  add_map_to_quest(map, name, description);
1138  start = end ? strstr(end, "@quest") : NULL;
1139  }
1140 }
1141 
1142 /************************************
1143  End of quest-related definitions.
1144 ************************************/
1145 
1146 /*********
1147 NPC-related stuff
1148 ********/
1149 
1156  list->allocated = 0;
1157  list->count = 0;
1158  list->npc = NULL;
1159 }
1160 
1168 static struct_npc_info *create_npc_info(const object *npc) {
1169  struct_npc_info *info = (struct_npc_info *)calloc(1, sizeof(struct_npc_info));
1170 
1171  info->name = strdup(npc->name);
1172  info->message = strdup(npc->msg);
1173  info->x = npc->x;
1174  info->y = npc->y;
1175 
1176  return info;
1177 }
1178 
1186 static void add_npc_to_map(struct_npc_list *list, const object *npc) {
1187  if (list->count == list->allocated) {
1188  list->allocated += 50;
1189  list->npc = (struct_npc_info **)realloc(list->npc, list->allocated*sizeof(struct_npc_info *));
1190  }
1191 
1192  list->npc[list->count] = create_npc_info(npc);
1193  list->count++;
1194 }
1195 /* end of NPC stuff */
1196 
1209  size_t map;
1210 
1211  for (map = 0; map < list->count; map++)
1212  if (list->maps[map] == info)
1213  return;
1214 
1215  if (list->count == list->allocated) {
1216  list->allocated += 50;
1217  list->maps = (struct_map_info **)realloc(list->maps, list->allocated*sizeof(struct_map_info *));
1218  }
1219  list->maps[list->count] = info;
1220  list->count++;
1221 }
1222 
1230  struct_map_info *add = (struct_map_info *)calloc(1, sizeof(struct_map_info));
1231 
1232  add->min_monster = 2000;
1233  init_map_list(&add->exits_to);
1234  init_map_list(&add->exits_from);
1235  init_map_list(&add->tiled_maps);
1237  init_race_list(&add->monsters);
1238  init_npc_list(&add->npcs);
1239  init_npc_list(&add->readable);
1240  add->tiled_group = NULL;
1241 
1242  return add;
1243 }
1244 
1253 
1254  add_map(add, &tiled_map_list);
1255  return add;
1256 }
1257 
1268  size_t g;
1269  struct_map_info *group = tiled_map->tiled_group;
1270  struct_map_info *change;
1271 
1272  while (group->tiled_maps.count > 0) {
1273  change = group->tiled_maps.maps[group->tiled_maps.count-1];
1274  change->tiled_group = map->tiled_group;
1275  add_map(change, &map->tiled_group->tiled_maps);
1276  group->tiled_maps.count--;
1277  }
1278 
1279  for (g = 0; g < tiled_map_list.count; g++) {
1280  if (tiled_map_list.maps[g] == group) {
1281  if (g < tiled_map_list.count-1)
1284  free(group);
1285  return;
1286  }
1287  }
1288  printf("tiled_map not in tiled_map_list!");
1289  abort();
1290 
1291 }
1292 
1301 static struct_map_info *get_map_info(const char *path) {
1302  struct_map_info *add;
1303  char *tmp;
1304 
1305  for (size_t map = 0; map < maps_list.count; map++) {
1306  if (strcmp(maps_list.maps[map]->path, path) == 0)
1307  return maps_list.maps[map];
1308  }
1309 
1310  add = create_map_info();
1311  add->path = strdup(path);
1312  tmp = strrchr((char *)path, '/');
1313  if (tmp)
1314  add->filename = strdup(tmp+1);
1315  else
1316  add->filename = strdup(path);
1317 
1318  add_map(add, &maps_list);
1319  return add;
1320 }
1321 
1328 static void list_map(const char *path) {
1329  int index;
1330 
1331  for (index = 0; index < found_maps_count; index++) {
1332  if (found_maps[index] && strcmp(path, found_maps[index]) == 0) {
1333  free(found_maps[index]);
1334  found_maps[index] = NULL;
1335  return;
1336  }
1337  }
1338  printf("Map processed but not found in directory reading? %s\n", path);
1339 }
1340 
1352  size_t test;
1353  int x, y;
1354 
1355  for (test = 0; test < region_count; test++) {
1356  if (regions[test]->reg == reg)
1357  break;
1358  }
1359  if (test == region_count) {
1360  if (test == region_allocated) {
1361  region_allocated++;
1363  regions[test] = (struct_region_info *)calloc(1, sizeof(struct_region_info));
1364  }
1365  region_count++;
1366  regions[test]->reg = reg;
1367  }
1368  add_map(map, &regions[test]->maps_list);
1369  if (sscanf(map->path, "/world/world_%d_%d", &x, &y) == 2) {
1370  regions[test]->sum_x += (x-100);
1371  regions[test]->sum_y += (y-100);
1372  regions[test]->sum++;
1373  regions[test]->is_world = 1;
1374  }
1375 }
1376 
1385 static void save_picture(FILE *file, gdImagePtr pic) {
1386  if (output_format == OF_PNG)
1387  gdImagePng(pic, file);
1388  else
1389  gdImageJpeg(pic, file, jpeg_quality);
1390 }
1391 
1399 static void add_region_link(mapstruct *source, mapstruct *dest) {
1400  region *s, *d;
1401 
1402  s = get_region_by_map(source);
1403  d = get_region_by_map(dest);
1404  if (s == d)
1405  return;
1406 
1407  region_links[s].insert(d);
1408 }
1409 
1418 static int is_slaying(object *item) {
1419  return (item->type == LOCKED_DOOR || item->type == SPECIAL_KEY || item->type == CONTAINER || item->type == CHECK_INV);
1420 }
1421 
1422 
1431 static struct_slaying_info *get_slaying_struct(const char *slaying) {
1432  for (size_t l = 0; l < slaying_count; l++) {
1433  if (!strcmp(slaying_info[l]->slaying, slaying))
1434  return slaying_info[l];
1435  }
1437  slaying_allocated += 10;
1439  }
1440 
1441  struct_slaying_info *add = (struct_slaying_info *)calloc(1, sizeof(struct_slaying_info));
1442  add->slaying = strdup(slaying);
1443  for (size_t l = 0; l < S_MAX; l++)
1444  init_map_list(&add->maps[l]);
1445 
1446  slaying_info[slaying_count] = add;
1447  slaying_count++;
1448 
1449  return add;
1450 }
1451 
1463  add_map(map, &info->maps[item]);
1464 }
1465 
1474 static void add_slaying(struct_map_info *map, object *item) {
1475  struct_slaying_info *info;
1476 
1477  if (!item->slaying)
1478  /* can be undefined */
1479  return;
1480 
1481  info = get_slaying_struct(item->slaying);
1482  if (item->type == LOCKED_DOOR)
1483  add_map_to_slaying(info, S_DOOR, map);
1484  else if (item->type == SPECIAL_KEY)
1485  add_map_to_slaying(info, S_KEY, map);
1486  else if (item->type == CONTAINER)
1488  else if (item->type == DETECTOR)
1490  else
1492 }
1493 
1504  if (is_slaying(inv))
1505  add_slaying(map, inv);
1507  } FOR_INV_FINISH();
1508 }
1509 
1510 static void generate_picture_path(const char *path, size_t pic_size, char *out, size_t len) {
1511  snprintf(out, len, "%s%s.x%zu%s", root, path, pic_size + 1, output_extensions[output_format]);
1512 }
1513 
1514 static void write_pictures_from_real_size(const char *path, gdImagePtr real, int width, int height) {
1515  char picpath[MAX_BUF];
1516 
1517  generate_picture_path(path, 0, picpath, sizeof(picpath));
1518  make_path_to_file(picpath);
1519  FILE *out = fopen(picpath, "wb+");
1520  save_picture(out, real);
1521  fclose(out);
1522 
1523  for (size_t i = 1; i < num_sizes; i++) {
1524  generate_picture_path(path, i, picpath, sizeof(picpath));
1525  gdImagePtr small = gdImageCreateTrueColor(width*sizes[i], height*sizes[i]);
1526  gdImageCopyResampled(small, real, 0, 0, 0, 0, width*sizes[i], height*sizes[i], width*size_large, height*size_large);
1527  out = fopen(picpath, "wb+");
1528  save_picture(out, small);
1529  fclose(out);
1530  gdImageDestroy(small);
1531  }
1532 }
1533 
1542 static void process_map(struct_map_info *info) {
1543  mapstruct *m;
1544  int x, y, isworld;
1545  gdImagePtr pic = nullptr;
1546  struct stat stats;
1547  struct stat statspic;
1548  char exit_path[500];
1549  char tmppath[MAX_BUF];
1550  char picpath[num_sizes][MAX_BUF];
1551  int needpic = 0;
1552  struct_map_info *link;
1553 
1554  if (list_unused_maps)
1555  list_map(info->path);
1556 
1557  if (show_maps)
1558  printf(" processing map %s\n", info->path);
1559 
1560  m = ready_map_name(info->path, 0);
1561  if (!m) {
1562  printf("couldn't load map %s\n", info->path);
1563  return;
1564  }
1565 
1566  do_exit_map(m);
1567 
1568  if (!rawmaps)
1569  do_auto_apply(m);
1570 
1571  info->level = m->difficulty;
1572  if (m->maplore) {
1573  info->lore = strdup(m->maplore);
1574  process_map_lore(info);
1575  }
1576 
1577  isworld = (sscanf(info->path, "/world/world_%d_%d", &x, &y) == 2);
1578 
1579  if (m->name)
1580  info->name = strdup(m->name);
1581  else
1582  info->name = strdup(info->filename);
1583 
1584  info->cfregion = get_region_by_map(m);
1585  add_map_to_region(info, info->cfregion);
1586 
1587  for (int i = 0; i < num_sizes; i++) {
1588  generate_picture_path(info->path, i, picpath[i], sizeof(picpath[i]));
1589  }
1590 
1591  if (force_pics)
1592  needpic = 1;
1593  else if (generate_pics) {
1594  create_pathname(info->path, tmppath, MAX_BUF);
1595  stat(tmppath, &stats);
1596  if (stat(picpath[0], &statspic) || (statspic.st_mtime < stats.st_mtime))
1597  needpic = 1;
1598  }
1599  else
1600  needpic = 0;
1601 
1602  if (needpic) {
1603  pic = gdImageCreateTrueColor(MAP_WIDTH(m)*size_large, MAP_HEIGHT(m)*size_large);
1604  created_pics++;
1605  }
1606  else
1607  cached_pics++;
1608 
1609  for (x = 0; x < 4; x++)
1610  if (m->tile_path[x] != NULL) {
1611  path_combine_and_normalize(m->path, m->tile_path[x], exit_path, sizeof(exit_path));
1612  create_pathname(exit_path, tmppath, MAX_BUF);
1613  if (stat(tmppath, &stats)) {
1614  printf(" map %s doesn't exist in map %s, for tile %d.\n", exit_path, info->path, x);
1615  }
1616 
1617  if (isworld) {
1618  link = get_map_info(exit_path);
1619  add_map(link, &info->exits_from);
1620  add_map(info, &link->exits_to);
1621 
1622  if (do_regions_link) {
1623  mapstruct *link = ready_map_name(exit_path, 0);
1624 
1625  if (link && link != m) {
1626  /* no need to link a map with itself. Also, if the exit points to the same map, we don't
1627  * want to reset it. */
1628  add_region_link(m, link);
1629  link->reset_time = 1;
1630  link->in_memory = MAP_IN_MEMORY;
1631  delete_map(link);
1632  }
1633  }
1634  } else {
1635  link = get_map_info(exit_path);
1636  info->tiles[x] = link;
1637  if (link->tiled_group) {
1638  if (info->tiled_group && link->tiled_group != info->tiled_group) {
1639  merge_tiled_maps(info, link);
1640  continue;
1641  }
1642  if (link->tiled_group == info->tiled_group) {
1643  continue;
1644  }
1645  if (!info->tiled_group) {
1646  add_map(info, &link->tiled_group->tiled_maps);
1647  continue;
1648  }
1649  }
1650 
1651  if (!info->tiled_group) {
1652  info->tiled_group = create_tiled_map();
1653  add_map(info, &info->tiled_group->tiled_maps);
1654  }
1655  link->tiled_group = info->tiled_group;
1656  add_map(link, &info->tiled_group->tiled_maps);
1657  }
1658  }
1659 
1660  info->width = MAP_WIDTH(m);
1661  info->height = MAP_HEIGHT(m);
1662 
1663  for (x = MAP_WIDTH(m)-1; x >= 0; x--)
1664  for (y = MAP_HEIGHT(m)-1; y >= 0; y--) {
1665  FOR_MAP_PREPARE(m, x, y, item) {
1666  if (item->type == EXIT || item->type == TELEPORTER || item->type == PLAYER_CHANGER) {
1667  char ep[500];
1668  const char *start;
1669 
1670  if (!item->slaying) {
1671  ep[0] = '\0';
1672  if (warn_no_path)
1673  printf(" exit without any path at %d, %d on %s\n", item->x, item->y, info->path);
1674  } else {
1675  memset(ep, 0, 500);
1676  if (strcmp(item->slaying, "/!"))
1677  strcpy(ep, EXIT_PATH(item));
1678  else {
1679  if (!item->msg) {
1680  printf(" random map without message in %s at %d, %d\n", info->path, item->x, item->y);
1681  } else {
1682  /* Some maps have a 'exit_on_final_map' flag, ignore it. */
1683  start = strstr(item->msg, "\nfinal_map ");
1684  if (!start && strncmp(item->msg, "final_map", strlen("final_map")) == 0)
1685  /* Message start is final_map, nice */
1686  start = item->msg;
1687  if (start) {
1688  char *end = strchr((char *)start+1, '\n');
1689 
1690  start += strlen("final_map")+2;
1691  strncpy(ep, start, end-start);
1692  }
1693  }
1694  }
1695 
1696  if (strlen(ep)) {
1697  path_combine_and_normalize(m->path, ep, exit_path, 500);
1698  create_pathname(exit_path, tmppath, MAX_BUF);
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);
1701  } else {
1702  link = get_map_info(exit_path);
1703  add_map(link, &info->exits_from);
1704  add_map(info, &link->exits_to);
1705 
1706  if (do_regions_link) {
1707  mapstruct *link = ready_map_name(exit_path, 0);
1708 
1709  if (link && link != m) {
1710  /* no need to link a map with itself. Also, if the exit points to the same map, we don't
1711  * want to reset it. */
1712  add_region_link(m, link);
1713  link->reset_time = 1;
1714  link->in_memory = MAP_IN_MEMORY;
1715  delete_map(link);
1716  }
1717  }
1718  }
1719  }
1720  }
1721  } else if (is_slaying(item))
1722  add_slaying(info, item);
1723 
1724  check_equipment(item, info);
1725 
1727 
1728  if (QUERY_FLAG(item, FLAG_MONSTER)) {
1729  /* need to get the "real" archetype, as the item's archetype can certainly be a temporary one. */
1730  archetype *arch = find_archetype(item->arch->name);
1731 
1732  add_monster(item, info);
1733  if (arch != NULL && (QUERY_FLAG(item, FLAG_UNAGGRESSIVE) || QUERY_FLAG(item, FLAG_FRIENDLY)) && (item->msg != arch->clone.msg) && (item->msg != NULL))
1734  add_npc_to_map(&info->npcs, item);
1735  } else if ((item->type == SIGN || item->type == BOOK) && (item->msg != item->arch->clone.msg) && (item->msg != NULL)) {
1736  add_npc_to_map(&info->readable, item);
1737  }
1738 
1739  if (item->invisible)
1740  continue;
1741 
1742  if (needpic) {
1743  int sx, sy, hx, hy;
1744 
1745  if (gdfaces[item->face->number] == NULL) {
1746  face_sets *fs = find_faceset(get_face_fallback(tileset, item->face->number));
1747 
1748  gdfaces[item->face->number] = gdImageCreateFromPngPtr(fs->faces[item->face->number].datalen, fs->faces[item->face->number].data);
1749  pics_allocated++;
1750  }
1751  if (item->head || item->more) {
1752  object_get_multi_size(item, &sx, &sy, &hx, &hy);
1753  } else {
1754  hx = 0;
1755  hy = 0;
1756  }
1757  if (gdfaces[item->face->number] != NULL && ((!item->head && !item->more) || (item->arch->clone.x+hx == 0 && item->arch->clone.y+hy == 0))) {
1758  gdImageCopy(pic, gdfaces[item->face->number], x*size_large, y*size_large, 0, 0, gdfaces[item->face->number]->sx, gdfaces[item->face->number]->sy);
1759  }
1760  }
1761  } FOR_MAP_FINISH();
1762  }
1763 
1764  if (needpic) {
1766  gdImageDestroy(pic);
1767  info->pic_was_done = 1;
1768  }
1769 
1770  m->reset_time = 1;
1771  m->in_memory = MAP_IN_MEMORY;
1772  delete_map(m);
1773 }
1774 
1778 static void write_world_map(void) {
1779 #define SIZE 50
1780  int x, y;
1781  FILE *out;
1782  int wx, wy;
1783  char file[500];
1784  char mapleft[10], maptop[10], mapright[10], mapbottom[10], mappath[5000];
1785  char name[100];
1786  gdImagePtr pic;
1787  gdImagePtr small;
1788  gdFontPtr font;
1789  int color;
1790 
1791  if (!world_map)
1792  return;
1793 
1794  printf("Generating world map in world.html...");
1795  fflush(stdout);
1796 
1797  pic = gdImageCreateTrueColor(SIZE*30, SIZE*30);
1798 
1799  strcpy(file, root);
1800  strcat(file, "/world.html");
1801 
1802  wx = 100;
1803  wy = 100;
1804 
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);
1812 
1813  snprintf(mappath, sizeof(mappath), "%s/world/%s.x1%s", root, name, output_extensions[output_format]);
1814 
1815  out = fopen(mappath, "rb");
1816  if (!out) {
1817  printf("\n warning: large pic not found for world_%d_%d", wx, wy);
1818  wx++;
1819  continue;
1820  }
1821  if (output_format == OF_PNG)
1822  small = gdImageCreateFromPng(out);
1823  else
1824  small = gdImageCreateFromJpeg(out);
1825  fclose(out);
1826  if (!small) {
1827  printf("\n warning: pic not found for world_%d_%d", wx, wy);
1828  wx++;
1829  continue;
1830  }
1831  gdImageCopyResized(pic, small, SIZE*x, SIZE*y, 0, 0, SIZE, SIZE, small->sx, small->sy);
1832  gdImageDestroy(small);
1833 
1834  wx++;
1835  }
1836  wy++;
1837  wx = 100;
1838  }
1839 
1840  snprintf(mappath, sizeof(mappath), "%s/world_raw%s", root, output_extensions[output_format]);
1841  out = fopen(mappath, "wb+");
1842  save_picture(out, pic);
1843  fclose(out);
1844 
1845  /* Write region names. */
1846  small = gdImageCreateTrueColor(SIZE*30, SIZE*30);
1847  font = gdFontGetGiant();
1848  color = gdImageColorAllocateAlpha(pic, 255, 0, 0, 20);
1849  for (size_t region = 0; region < region_allocated; region++) {
1850  if (!regions[region]->is_world || regions[region]->sum == 0)
1851  continue;
1852 
1853  x = regions[region]->sum_x*SIZE/regions[region]->sum+SIZE/2-strlen(regions[region]->reg->name)*font->w/2;
1854  y = regions[region]->sum_y*SIZE/regions[region]->sum+SIZE/2-font->h/2;
1855  gdImageString(small, font, x, y, (unsigned char *)regions[region]->reg->name, color);
1856  gdImageString(pic, font, x, y, (unsigned char *)regions[region]->reg->name, color);
1857 
1858  /* For exit/road map, size isn't the same. */
1859  x = regions[region]->sum_x*50/regions[region]->sum+50/2-strlen(regions[region]->reg->name)*font->w/2;
1860  y = regions[region]->sum_y*50/regions[region]->sum+50/2-font->h/2;
1861  gdImageString(infomap, font, x, y, (unsigned char *)regions[region]->reg->name, color);
1862  }
1863 
1864  snprintf(mappath, sizeof(mappath), "%s/world_regions%s", root, output_extensions[output_format]);
1865  out = fopen(mappath, "wb+");
1866  save_picture(out, small);
1867  fclose(out);
1868  gdImageDestroy(small);
1869 
1870  snprintf(mappath, sizeof(mappath), "%s/world%s", root, output_extensions[output_format]);
1871  out = fopen(mappath, "wb+");
1872  save_picture(out, pic);
1873  fclose(out);
1874  gdImageDestroy(pic);
1875 
1876  printf(" done.\n");
1877 #undef SIZE
1878 }
1879 
1881 static void fix_map_names(void) {
1882  for (size_t map = 0; map < maps_list.count; map++) {
1883  if (maps_list.maps[map]->name)
1884  continue;
1885  if (!maps_list.maps[map]->filename) {
1886  printf("map without path!\n");
1887  abort();
1888  }
1889  maps_list.maps[map]->name = strdup(maps_list.maps[map]->filename);
1890  }
1891 }
1892 
1899 static void fix_tiled_map(void) {
1900  size_t map, tile;
1901  char name[500];
1902  char *slash, *test;
1903  region *cfregion;
1904 
1905  for (map = 0; map < tiled_map_list.count; map++) {
1906  if (tiled_map_list.maps[map]->tiled_maps.count == 0) {
1907  printf("empty tiled map group!");
1908  abort();
1909  }
1910 
1911  snprintf(name, sizeof(name), "tiled_map_group_%zu", map);
1912  tiled_map_list.maps[map]->filename = strdup(name);
1913 
1914  cfregion = NULL;
1915  test = NULL;
1916 
1917  for (tile = 0; tile < tiled_map_list.maps[map]->tiled_maps.count; tile++) {
1919  /* map not processed, ignore it. */
1920  continue;
1921 
1922  if (!cfregion)
1924  else if (cfregion != tiled_map_list.maps[map]->tiled_maps.maps[tile]->cfregion) {
1925  printf("*** warning: tiled maps %s and %s not in same region (%s and %s).\n",
1928  cfregion = NULL;
1929  }
1930 
1932  /* map has a custom name, use it */
1933  if (!test)
1935  }
1936  }
1937 
1938  if (!test) {
1939  /* this can happen of course if only partial maps were processed, but well... */
1940  printf("*** warning: tiled map without any name. First map path %s\n", tiled_map_list.maps[map]->tiled_maps.maps[0]->path);
1941  test = name;
1942  }
1943 
1944  tiled_map_list.maps[map]->name = strdup(test);
1945  tiled_map_list.maps[map]->cfregion = cfregion;
1946 
1947  strncpy(name, tiled_map_list.maps[map]->tiled_maps.maps[0]->path, sizeof(name));
1948  slash = strrchr(name, '/');
1949  if (!slash)
1950  snprintf(name, sizeof(name), "/");
1951  else
1952  *(slash+1) = '\0';
1953  strncat(name, tiled_map_list.maps[map]->filename, sizeof(name) - strlen(name) - 1);
1954  tiled_map_list.maps[map]->path = strdup(name);
1955  }
1956 }
1957 
1968 static void fix_exits_for_map(struct_map_info *current, struct_map_list *from, int is_from) {
1969  int map, max;
1970  struct_map_info *group;
1971 
1972  max = from->count-1;
1973  for (map = max; map >= 0; map--) {
1974  if (from->maps[map]->tiled_group) {
1975  group = from->maps[map]->tiled_group;
1976  if (map != max)
1977  from->maps[map] = from->maps[max];
1978  from->count--;
1979  max--;
1980  add_map(group, from);
1981  add_map(current->tiled_group ? current->tiled_group : current, is_from ? &group->exits_to : &group->exits_from);
1982  }
1983  }
1984 }
1985 
1987 static void fix_exits_to_tiled_maps(void) {
1988  int map, max;
1989  struct_map_info *group;
1990 
1991  for (map = 0; static_cast<size_t>(map) < maps_list.count; map++) {
1994  }
1995 
1996  for (size_t region = 0; region < region_count; region++) {
1998  for (map = max; map >= 0; map--) {
2001  if (map != max)
2004  max--;
2005  add_map(group, &regions[region]->maps_list);
2006  }
2007  }
2008  }
2009 }
2010 
2015 static void fix_tiled_map_monsters(void) {
2016  int map, max;
2017  struct_map_info *group;
2018 
2019  for (size_t race = 0; race < races.count; race++) {
2020  max = races.races[race]->origin.count-1;
2021  for (map = max; map >= 0; map--) {
2022  if (races.races[race]->origin.maps[map]->tiled_group) {
2023  group = races.races[race]->origin.maps[map]->tiled_group;
2024  if (map != max)
2025  races.races[race]->origin.maps[map] = races.races[race]->origin.maps[max];
2026  races.races[race]->origin.count--;
2027  max--;
2028  add_map(group, &races.races[race]->origin);
2029  }
2030  }
2031  }
2032 
2033  for (map = 0; static_cast<size_t>(map) < maps_list.count; map++) {
2034  if (maps_list.maps[map]->tiled_group) {
2035  for (size_t race = 0; race < maps_list.maps[map]->monsters.count; race++) {
2037  }
2038  }
2039  }
2040 }
2041 
2043  size_t test;
2044  char picpath[500];
2045  struct stat stats;
2046 
2047  for (size_t size = 0; size < num_sizes; size++) {
2048  generate_picture_path(map->path, size, picpath, sizeof(picpath));
2049  if (stat(picpath, &stats))
2050  return 1;
2051  }
2052 
2053  for (test = 0; test < map->tiled_maps.count; test++) {
2054  if (map->tiled_maps.maps[test]->pic_was_done)
2055  return 1;
2056  }
2057 
2058  return 0;
2059 }
2060 
2073  int xmin = 0, xmax = 0, ymin = 0, ymax = 0, count, last;
2074  size_t tiled;
2075  char picpath[500];
2076  gdImagePtr large, load;
2077  FILE *out;
2079 
2080  if (!generate_pics)
2081  return;
2082 
2083  printf(" Generating composite map for %s...", map->name);
2084  fflush(stdout);
2085 
2086  if (!tiled_map_need_pic(map)) {
2087  printf(" already uptodate.\n");
2088  return;
2089  }
2090 
2091  count = map->tiled_maps.count;
2092  if (count == 0) {
2093  printf("Tiled map without tiled maps?\n");
2094  abort();
2095  }
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;
2099 
2100  while (count > 0) {
2101  last = count;
2102 
2103  for (tiled = 0; tiled < map->tiled_maps.count; tiled++) {
2104  current = map->tiled_maps.maps[tiled];
2105  if (current->processed != 1)
2106  continue;
2107 
2108  count--;
2109 
2110  if ((current->tiles[0]) && (current->tiles[0]->processed == 0)) {
2111  current->tiles[0]->processed = 1;
2112  current->tiles[0]->tiled_x_from = current->tiled_x_from;
2113  current->tiles[0]->tiled_y_from = current->tiled_y_from-current->tiles[0]->height;
2114  }
2115  if ((current->tiles[1]) && (current->tiles[1]->processed == 0)) {
2116  current->tiles[1]->processed = 1;
2117  current->tiles[1]->tiled_x_from = current->tiled_x_from+current->width;
2118  current->tiles[1]->tiled_y_from = current->tiled_y_from;
2119  }
2120  if ((current->tiles[2]) && (current->tiles[2]->processed == 0)) {
2121  current->tiles[2]->processed = 1;
2122  current->tiles[2]->tiled_x_from = current->tiled_x_from;
2123  current->tiles[2]->tiled_y_from = current->tiled_y_from+current->height;
2124  }
2125  if ((current->tiles[3]) && (current->tiles[3]->processed == 0)) {
2126  current->tiles[3]->processed = 1;
2127  current->tiles[3]->tiled_x_from = current->tiled_x_from-current->tiles[3]->width;
2128  current->tiles[3]->tiled_y_from = current->tiled_y_from;
2129  }
2130  }
2131 
2132  if (last == count) {
2133  printf("do_tiled_map_picture: didn't process any map in %s (%d left)??\n", map->path, last);
2134  abort();
2135  }
2136  }
2137 
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;
2147  }
2148 
2149  large = gdImageCreateTrueColor(size_large*(xmax-xmin), size_large*(ymax-ymin));
2150 
2151  for (tiled = 0; tiled < map->tiled_maps.count; tiled++) {
2152  generate_picture_path(map->tiled_maps.maps[tiled]->path, 0, picpath, sizeof(picpath));
2153 
2154  out = fopen(picpath, "rb");
2155  if (!out) {
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);
2157  continue;
2158  }
2159  if (output_format == OF_PNG)
2160  load = gdImageCreateFromPng(out);
2161  else
2162  load = gdImageCreateFromJpeg(out);
2163  fclose(out);
2164  if (!load) {
2165  printf("\n do_tiled_map_picture: warning: pic not found for %s\n", map->tiled_maps.maps[tiled]->path);
2166  continue;
2167  }
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);
2170  }
2171 
2172  write_pictures_from_real_size(map->path, large, xmax-xmin, ymax-ymin);
2173 
2174  gdImageDestroy(large);
2175 
2176  printf(" done.\n");
2177 }
2178 
2181 
2183 
2186 // write_map_page(map);
2187 }
2188 
2190 static void write_tiled_maps(void) {
2191  printf("Writing tiled map information...\n");
2192 
2193  for (size_t map = 0; map < tiled_map_list.count; map++)
2195 
2196  printf(" done.\n");
2197 }
2198 
2199 static size_t system_quests_count = 0;
2200 static const quest_definition *system_quests[500];
2201 
2202 static void quest_callback(const quest_definition *quest, void *) {
2203  if (list_system_quests || !quest->quest_is_system) {
2205  }
2206 }
2207 
2208 static int sort_system_quest(const void *a, const void *b) {
2209  return strcmp((*((quest_definition **)a))->quest_code, (*((quest_definition **)b))->quest_code);
2210 }
2211 
2212 static int sort_system_quest_step(const void *a, const void *b) {
2213  return (*((quest_step_definition**)a))->step - (*((quest_step_definition**)b))->step;
2214 }
2215 
2216 static std::shared_ptr<inja::Environment> env;
2218 static std::set<std::string> rendered_templates;
2219 static std::map<struct_map_info *, std::string> reverse_maps;
2220 static std::map<region *, std::string> reverse_regions;
2227 static struct_map_info *find_map_by_key(const std::string &key) {
2228  auto found = std::find_if(reverse_maps.cbegin(), reverse_maps.cend(), [&key] (auto c) { return c.second == key; });
2229  if (found != reverse_maps.cend())
2230  return found->first;
2231  return nullptr;
2232 }
2233 
2239 static region *find_region_by_key(const std::string &key) {
2240  auto found = std::find_if(reverse_regions.cbegin(), reverse_regions.cend(), [&key] (auto c) { return c.second == key; });
2241  if (found != reverse_regions.cend())
2242  return found->first;
2243  return nullptr;
2244 }
2245 
2253  for (size_t m = 0; m < maps.count; m++) {
2254  auto map = reverse_maps.find(maps.maps[m]);
2255  if (map != reverse_maps.end()) {
2256  result.push_back(map->second);
2257  }
2258  }
2259  return result;
2260 }
2261 
2269  for (size_t n = 0; n < list.count; n++) {
2270  auto npc = list.npc[n];
2271  result.push_back({
2272  { "name", npc->name },
2273  { "x", npc->x },
2274  { "y", npc->y },
2275  { "message", npc->message },
2276  });
2277  }
2278  return result;
2279 }
2280 
2288  for (size_t n = 0; n < list.count; n++) {
2289  auto race = list.races[n];
2290  result.push_back({
2291  { "name", race->name },
2292  { "count", race->count },
2293  });
2294  }
2295  return result;
2296 }
2297 
2305  for (size_t m = 0; m < list.count; m++) {
2306  auto q = list.list[m];
2307  if (!q->map || !q->description)
2308  continue;
2309  ret.push_back({
2310  { "map", reverse_maps.find(q->map)->second },
2311  { "description", q->description },
2312  { "quest", q->quest->name },
2313  { "number", q->quest->number },
2314  });
2315  }
2316 
2317  return ret;
2318 }
2319 
2327  return {
2328  { "_key", key },
2329  { "name", map->name },
2330  { "path", map->path },
2331  { "region", map->cfregion ? reverse_regions[map->cfregion] : "reg_ffff" },
2332  { "level", map->level },
2333  { "lore", map->lore && map->lore[0] ? map->lore : "" },
2334  { "exits_to", create_maps_array(map->exits_to) },
2335  { "exits_from", create_maps_array(map->exits_from) },
2336  { "npcs", create_npc_array(map->npcs) },
2337  { "readables", create_npc_array(map->readable) },
2338  { "monsters", create_race_array(map->monsters) },
2339  { "quests", create_map_in_quest_array(map->quests) },
2340  };
2341 }
2342 
2350  return {
2351  { "_key", key },
2352  { "number", quest->number },
2353  { "name", quest->name ? quest->name : "" },
2354  { "description", quest->description ? quest->description : "" },
2355  { "main_map", quest->mainmap ? reverse_maps.find(quest->mainmap)->second : "" },
2356  { "maps", create_map_in_quest_array(quest->maps) },
2357  };
2358 }
2359 
2365  char buf[50];
2366  for (size_t map = 0; map < list.count; map++) {
2367  auto cur = list.maps[map];
2368  if (cur->tiled_group)
2369  continue;
2370  snprintf(buf, sizeof(buf), "map_%04lu", map);
2371  reverse_maps.insert(std::make_pair(cur, buf));
2372  qsort(cur->exits_to.maps, cur->exits_to.count, sizeof(struct_map_info *), sort_map_info);
2373  qsort(cur->exits_from.maps, cur->exits_from.count, sizeof(struct_map_info *), sort_map_info);
2374  qsort(cur->monsters.races, cur->monsters.count, sizeof(struct_race *), sort_race);
2375  }
2376 }
2377 
2384  for (size_t map = 0; map < src.count; map++)
2385  add_map(src.maps[map], &dest);
2386 }
2387 
2393 static nlohmann::json create_region_array(const std::set<region *> &regions) {
2395  for (auto reg : regions) {
2396  auto r = reverse_regions.find(reg);
2397  if (r != reverse_regions.end()) {
2398  ret.push_back((*r).second);
2399  }
2400  }
2401  return ret;
2402 }
2403 
2410  char buf[10];
2411  struct_map_list all_maps;
2412  bool need_unknown_region = false;
2413 
2414  init_map_list(&all_maps);
2415  append_map_list(all_maps, maps_list);
2416  append_map_list(all_maps, tiled_map_list);
2417  qsort(all_maps.maps, all_maps.count, sizeof(struct_map_info *), sort_map_info);
2418 
2419  fill_reverse_maps(all_maps);
2420 
2421  for (size_t reg = 0; reg < region_count; reg++) {
2422  auto region = regions[reg];
2423  snprintf(buf, sizeof(buf), "reg_%04lu", reg);
2424  reverse_regions.insert(std::make_pair(region->reg, buf));
2425  }
2426 
2427  for (size_t reg = 0; reg < region_count; reg++) {
2428  auto region = regions[reg];
2429  qsort(region->maps_list.maps, region->maps_list.count, sizeof(struct_map_info *), sort_map_info);
2430 
2431  json["regions"].push_back({
2432  { "_key", reverse_regions[region->reg] },
2433  { "name", region->reg->name },
2434  { "longname", region->reg->longname },
2435  { "description", region->reg->msg ? region->reg->msg : "" },
2436  { "maps", create_maps_array(region->maps_list) },
2437  { "links", create_region_array(region_links[region->reg]) },
2438  });
2439  }
2440 
2441  for (auto map : reverse_maps) {
2442  auto cur = map.first;
2443  if (cur->tiled_group)
2444  continue;
2445  if (cur->cfregion == nullptr)
2446  need_unknown_region = true;
2447  json["maps"].push_back(create_map_object(cur, map.second));
2448  }
2449 
2450  if (need_unknown_region) {
2451  json["regions"].push_back({
2452  { "_key", "reg_ffff" },
2453  { "name", "unknown" },
2454  { "longname", "unknown" },
2455  { "description", "unknown" },
2456  { "maps", nlohmann::json::array() },
2457  { "links", nlohmann::json::array() },
2458  });
2459  }
2460 
2461  json["items"] = nlohmann::json::array();
2462  for (size_t idx = 0; idx < equipment_count; idx++) {
2463  auto eq = special_equipment[idx];
2464  json["items"][idx] = {
2465  { "name", eq->name },
2466  { "power", eq->power },
2467  { "calc_power", eq->calc_power },
2468  { "diff", eq->diff },
2469  { "maps", create_maps_array(eq->origin) },
2470  };
2471  }
2472 
2473  json["monsters"] = nlohmann::json::array();
2474  for (size_t item = 0; item < races.count; item++) {
2475  auto race = races.races[item];
2476  qsort(race->origin.maps, race->origin.count, sizeof(struct_map_info *), sort_map_info);
2477  json["monsters"].push_back({
2478  { "name", race->name },
2479  { "count", race->count },
2480  { "maps", create_maps_array(race->origin) },
2481  });
2482  }
2483 
2484  json["system_quests"] = nlohmann::json::array();
2485  for (size_t q = 0; q < system_quests_count; q++) {
2486  auto quest = system_quests[q];
2487  nlohmann::json j({
2488  { "code", quest->quest_code },
2489  { "title", quest->quest_title },
2490  { "description", quest->quest_description ? quest->quest_description : "" },
2491  { "replayable", quest->quest_restart },
2492  { "steps", nlohmann::json::array() },
2493  { "maps", nlohmann::json::array() },
2494  });
2495 
2496  if (detail_quests) {
2497  quest_step_definition *steps[100];
2498  size_t steps_count = 0;
2499  quest_step_definition *step = quest->steps;
2500  while (step) {
2501  steps[steps_count++] = step;
2502  step = step->next;
2503  }
2504  qsort(steps, steps_count, sizeof(quest_step_definition *), sort_system_quest_step);
2505  for (size_t s = 0; s < steps_count; s++) {
2506  j["steps"].push_back({
2507  { "description", steps[s]->step_description ? steps[s]->step_description : "" },
2508  { "is_completion", steps[s]->is_completion_step ? true : false },
2509  });
2510  }
2511 
2512  auto qim = find_quest_info(quest->quest_code);
2513  if (qim) {
2514  for (size_t m = 0; m < qim->maps.count; m++) {
2515  auto map = reverse_maps.find(qim->maps.list[m]->map);
2516  assert(map != reverse_maps.end());
2517  j["maps"].push_back({
2518  { "description", qim->maps.list[m]->description },
2519  { "map", map->second },
2520  });
2521  }
2522  }
2523  }
2524  json["system_quests"].push_back(j);
2525  }
2526 
2527  json["slaying"] = nlohmann::json::array();
2528  for (size_t s = 0; s < slaying_count; s++) {
2529  auto info = slaying_info[s];
2530  json["slaying"].push_back({
2531  { "slaying", info->slaying },
2532  { "doors", create_maps_array(info->maps[S_DOOR]) },
2533  { "keys", create_maps_array(info->maps[S_KEY]) },
2534  { "containers", create_maps_array(info->maps[S_CONTAINER]) },
2535  { "detectors", create_maps_array(info->maps[S_DETECTOR]) },
2536  { "connections", create_maps_array(info->maps[S_CONNECT]) },
2537  });
2538  }
2539 
2540  json["quests"] = nlohmann::json::array();
2541  for (int quest = 0; quest < quests_count; quest++) {
2543  char buf[100];
2544  snprintf(buf, sizeof(buf), "quest_%d", quests[quest]->number);
2546  }
2547 }
2548 
2550 static std::vector<std::string> path_stack;
2551 
2552 void add_template_to_render(const std::string &template_name, const std::string &output_name, const std::string &param);
2553 
2559 static std::string path_from_current(const std::string &path) {
2560  auto p(path);
2561  char rel[1000];
2562  if (p[0] != '/')
2563  p = '/' + p;
2564  auto current(path_stack.back());
2565  if (current[0] != '/')
2566  current = '/' + current;
2567  relative_path(current.c_str(), p.c_str(), rel);
2568  return rel;
2569 }
2570 
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>() : "");
2580 
2581  if (!param.empty()) {
2582  output_name = param + "_" + output_name;
2583  if (param.substr(0, 4) == "map_") {
2584  auto map = find_map_by_key(param);
2585  if (map != nullptr) {
2586  output_name = std::string(map->path + 1) + ".html";
2587  }
2588  }
2589  if (param.substr(0, 4) == "reg_") {
2590  auto reg = find_region_by_key(param);
2591  if (reg != nullptr) {
2592  output_name = std::string(reg->name) + ".html";
2593  }
2594  }
2595  }
2596 
2597  add_template_to_render(template_name, output_name, param);
2598  return path_from_current(output_name);
2599 }
2600 
2607  auto what = args.at(0)->get<std::string>();
2608  if (what.substr(0, 4) == "map_") {
2609  auto map = find_map_by_key(what);
2610  if (map == nullptr)
2611  return "";
2612  int size = 0;
2613  if (args.size() > 1) {
2614  size = args.at(1)->get<int>() - 1;
2615  }
2616  char picpath[1000];
2617  snprintf(picpath, sizeof(picpath), "%s.x%d%s", map->path, size + 1, output_extensions[output_format]);
2618  return path_from_current(picpath);
2619  }
2620  return "";
2621 }
2622 
2627 public:
2628  std::string template_name;
2629  std::string output_name;
2630  std::string param;
2631 };
2632 static std::vector<pageToRender> pages;
2640 void add_template_to_render(const std::string &template_name, const std::string &output_name, const std::string &param) {
2641  auto on(output_name);
2642  if (on[0] != '/')
2643  on = '/' + on;
2644  if (rendered_templates.find(on) != rendered_templates.end())
2645  return;
2646 
2647  rendered_templates.insert(on);
2648  pageToRender r;
2649  r.template_name = template_name;
2650  r.output_name = on;
2651  r.param = param;
2652  pages.push_back(r);
2653 }
2654 
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));
2660  start = found + 1;
2661  }
2662  result.push_back(field.substr(start));
2663  return result;
2664 }
2665 
2666 static std::string templates_root("templates/");
2667 static std::vector<std::string> templates;
2672 static void init_renderer_env() {
2673  env = std::make_shared<inja::Environment>(templates_root, std::string(root) + "/");
2674  env->add_callback("link_to_page", generate_page_and_link);
2675  env->add_callback("substr", [] (inja::Arguments &args) {
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);
2680  });
2681  env->add_callback("picture", generate_picture_link);
2682  env->add_callback("pad", [] (inja::Arguments &args) {
2683  char buf[50];
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);
2687  });
2688  env->add_callback("path_to_root", 0, [] (inja::Arguments &) {
2689  std::string r(root);
2690  char rel[1000];
2691  auto current(path_stack.back() + '/');
2692  if (current[0] != '/')
2693  current = '/' + current;
2694  relative_path(current.c_str(), r.c_str(), rel);
2695  return std::string(rel);
2696  });
2697  env->add_callback("get_by_field", 3, [] (inja::Arguments &args) {
2698  const auto &src = args.at(0);
2699  auto field = args.at(1)->get<std::string>();
2700  const auto &value = args.at(2);
2701  auto found = std::find_if(src->begin(), src->end(), [&field, &value] (auto item) {
2702  return item[field] == *value;
2703  });
2704  if (found == src->end()) {
2705  return nlohmann::json();
2706  }
2707  return *found;
2708  });
2709  env->add_callback("get_list_by_field", 3, [] (inja::Arguments &args) {
2710  const auto &src = args.at(0);
2711  auto field = args.at(1)->get<std::string>();
2712  const auto &list = args.at(2);
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();
2717  });
2718  return ret;
2719  });
2720  env->add_callback("sort", [] (inja::Arguments &args) {
2721  const auto &src = args.at(0);
2722  std::vector<nlohmann::json> ret;
2723  for (auto i : *src) {
2724  ret.push_back(i);
2725  }
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); });
2736  if (ls == rs) {
2737  continue;
2738  }
2739  return invert ? (rs < ls) : (ls < rs);
2740  }
2741  if (r == l) {
2742  continue;
2743  }
2744  return invert ? (r < l) : (l < r);
2745  }
2746  return false;
2747  });
2748  return ret;
2749  });
2750 
2751  env->set_trim_blocks(true);
2752  env->set_lstrip_blocks(true);
2753 }
2754 
2756 static const char *ignore_path[] = {
2757  "/Info",
2758  "/editor",
2759  "/python",
2760  "/styles",
2761  "/templates",
2762  "/test",
2763  "/unlinked",
2764  NULL };
2765 
2767 static const char *ignore_name[] = {
2768  ".",
2769  "..",
2770  ".svn",
2771  "README",
2772  NULL };
2773 
2780 static void find_maps(const char *from) {
2781  struct dirent *file;
2782  struct stat statbuf;
2783  int status, ignore;
2784  char path[1024], full[1024];
2785  DIR *dir;
2786 
2787  for (ignore = 0; ignore_path[ignore] != NULL; ignore++) {
2788  if (strcmp(from, ignore_path[ignore]) == 0)
2789  return;
2790  }
2791 
2792  snprintf(path, sizeof(path), "%s/%s%s", settings.datadir, settings.mapdir, from);
2793  dir = opendir(path);
2794 
2795  if (dir) {
2796  for (file = readdir(dir); file; file = readdir(dir)) {
2797 
2798  for (ignore = 0; ignore_name[ignore] != NULL; ignore++) {
2799  if (strcmp(file->d_name, ignore_name[ignore]) == 0)
2800  break;
2801  }
2802  if (ignore_name[ignore] != NULL)
2803  continue;
2804 
2805  snprintf(full, sizeof(full), "%s/%s", path, file->d_name);
2806 
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);
2810  find_maps(full);
2811  continue;
2812  }
2814  found_maps_allocated += 50;
2815  found_maps = (char **)realloc(found_maps, found_maps_allocated*sizeof(char *));
2816  }
2817  snprintf(full, sizeof(full), "%s/%s", from, file->d_name);
2818  found_maps[found_maps_count++] = strdup(full);
2819  }
2820  closedir(dir);
2821  }
2822 }
2823 
2825 static void dump_unused_maps(void) {
2826  FILE *dump;
2827  char path[1024];
2828  int index, found = 0;
2829 
2830  snprintf(path, sizeof(path), "%s/%s", root, "maps.unused");
2831  dump = fopen(path, "w+");
2832  if (dump == NULL) {
2833  printf("Unable to open file maps.unused!\n");
2834  return;
2835  }
2836  for (index = 0; index < found_maps_count; index++) {
2837  if (found_maps[index] != NULL) {
2838  fprintf(dump, "%s\n", found_maps[index]);
2839  free(found_maps[index]);
2840  found++;
2841  }
2842  }
2843  fclose(dump);
2844  printf("%d unused maps.\n", found);
2845 }
2846 
2848 static void write_world_info(void) {
2849  FILE *file;
2850  char path[MAX_BUF];
2851  int x, y;
2852  gdImagePtr elevationmap;
2853 
2854  if (!world_exit_info)
2855  return;
2856 
2857  printf("Saving exit/blocking/road information...");
2858  snprintf(path, sizeof(path), "%s/%s%s", root, "world_info", output_extensions[output_format]);
2859  file = fopen(path, "wb+");
2861  fclose(file);
2862  printf("done.\n");
2863  gdImageDestroy(infomap);
2864  infomap = NULL;
2865 
2866  if (elevation_min == 0 || elevation_max == 0) {
2867  puts("Error: Could not save elevation world map due to not finding any minimum or maximum elevation.");
2868  return;
2869  }
2870 
2871  elevationmap = gdImageCreateTrueColor(30*50, 30*50);;
2872 
2873  for (x = 0; x < 30*50; x++) {
2874  for (y = 0; y < 30*50; y++) {
2875  gdImageSetPixel(elevationmap, x, y, get_elevation_color(elevation_info[x][y], elevationmap));
2876  }
2877  }
2878 
2879  printf("Saving elevation world map...");
2880  snprintf(path, sizeof(path), "%s/%s%s", root, "world_elevation", output_extensions[output_format]);
2881  file = fopen(path, "wb+");
2882  save_picture(file, elevationmap);
2883  fclose(file);
2884  printf("done.\n");
2885  gdImageDestroy(elevationmap);
2886  elevationmap = NULL;
2887 }
2888 
2899 static int sort_slaying(const void *left, const void *right) {
2902 
2903  return strcasecmp(l->slaying, r->slaying);
2904 }
2905 
2912 static void do_help(const char *program) {
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.");
2937  printf("\n\n");
2938  exit(0);
2939 }
2940 
2949 static void do_parameters(int argc, char **argv) {
2950  int arg = 1;
2951  char path[500];
2952 
2953  root[0] = '\0';
2954 
2955  while (arg < argc) {
2956  if (strcmp(argv[arg], "-nopics") == 0)
2957  generate_pics = 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)
2961  map_limit = atoi(argv[arg]+7);
2962  else if (strcmp(argv[arg], "-showmaps") == 0)
2963  show_maps = 1;
2964  else if (strcmp(argv[arg], "-jpg") == 0) {
2966  if (argv[arg][4] == '=') {
2967  jpeg_quality = atoi(argv[arg]+5);
2968  if (jpeg_quality < 0)
2969  jpeg_quality = -1;
2970  }
2971  }
2972  else if (strcmp(argv[arg], "-forcepics") == 0)
2973  force_pics = 1;
2974  else if (strncmp(argv[arg], "-addmap=", 8) == 0) {
2975  if (*(argv[arg]+8) == '/')
2976  strncpy(path, argv[arg]+8, 500);
2977  else
2978  snprintf(path, 500, "/%s", argv[arg]+8);
2980  }
2981  else if (strcmp(argv[arg], "-rawmaps") == 0)
2982  rawmaps = 1;
2983  else if (strcmp(argv[arg], "-warnnopath") == 0)
2984  warn_no_path = 1;
2985  else if (strcmp(argv[arg], "-listunusedmaps") == 0)
2986  list_unused_maps = 1;
2987  else if (strcmp(argv[arg], "-noworldmap") == 0)
2988  world_map = 0;
2989  else if (strcmp(argv[arg], "-noregionslink") == 0)
2990  do_regions_link = false;
2991  else if (strcmp(argv[arg], "-regionslink") == 0)
2992  do_regions_link = true;
2993  else if (strcmp(argv[arg], "-noexitmap") == 0)
2994  world_exit_info = 0;
2995  else if (strcmp(argv[arg], "-exitmap") == 0)
2996  world_exit_info = 1;
2997  else if (strncmp(argv[arg], "-tileset=", 9) == 0) {
2998  tileset = atoi(argv[arg]+9);
2999  /* check of validity is done in main() as we need to actually have the sets loaded. */
3000  } else if (strcmp(argv[arg], "-detail-quests") == 0) {
3001  detail_quests = 1;
3002  } else if (strcmp(argv[arg], "-list-system-quests") == 0) {
3003  list_system_quests = 1;
3004  } else if (strncmp(argv[arg], "-templates-dir=", 15) == 0) {
3005  templates_root = argv[arg] + 15;
3006  } else if (strncmp(argv[arg], "-add-template=", 14) == 0) {
3007  templates.push_back(argv[arg] + 14);
3008  } else if (strcmp(argv[arg], "-list-template-to-process") == 0) {
3010  } else
3011  do_help(argv[0]);
3012  arg++;
3013  }
3014  if (!strlen(root))
3015  strcpy(root, "html");
3016  if (root[strlen(root)-1] == '/')
3017  root[strlen(root)-1] = '\0';
3018  if (map_limit < -1)
3019  map_limit = -1;
3020 
3021  if (templates_root.empty()) {
3022  templates_root = "templates/";
3023  } else if (templates_root[templates_root.length() - 1] != '/') {
3024  templates_root.append("/");
3025  }
3026 }
3027 
3031 static void create_destination(void) {
3032  char dummy[502];
3033 
3034  strcpy(dummy, root);
3035  strcat(dummy, "/a");
3036  make_path_to_file(dummy);
3037 }
3038 
3047 static const char *yesno(int value) {
3048  return (value ? "yes" : "no");
3049 }
3050 
3052 static inja::Template get_template(const std::string &filename) {
3053  auto find = templateCache.find(filename);
3054  if (find != templateCache.end()) {
3055  return find->second;
3056  }
3057  inja::Template parsed = env->parse_template(filename);
3058  templateCache[filename] = parsed;
3059  return parsed;
3060 }
3061 
3062 int main(int argc, char **argv) {
3063  size_t current_map = 0, i;
3064  char max[50];
3065  region *dummy;
3066 
3070  pics_allocated = 0;
3071 
3072  do_parameters(argc, argv);
3073 
3074  printf("Initializing Crossfire data...\n");
3075 
3077 
3078  init_globals();
3079  init_library();
3080  init_readable();
3081 
3082  init_gods();
3083 
3084  /* Add a dummy region so unlinked maps can be identified. */
3085  dummy = get_region_struct();
3086  dummy->fallback = 1;
3087  dummy->name = strdup_local("unlinked");
3088  dummy->longname = strdup_local("This dummy region contains all maps without a region set.");
3089  dummy->longname = strdup_local("This dummy region contains all maps without a region set.");
3090  dummy->next = first_region;
3091  first_region = dummy;
3092 
3093  printf("\n\n done.\n\n");
3094 
3095  if (!is_valid_faceset(tileset)) {
3096  printf("Erreor: invalid tileset %d!\n", tileset);
3097  exit(1);
3098  }
3099 
3100  if (templates.empty()) {
3101  templates.push_back("index.html");
3102  }
3103 
3105  gdfaces = (gdImagePtr *)calloc(get_faces_count(), sizeof(gdImagePtr));
3106 
3107  if (map_limit != -1)
3108  snprintf(max, sizeof(max), "%d", map_limit);
3109  else
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);
3116  printf(" will generate map picture: %s\n", yesno(generate_pics));
3117  printf(" will always generate map picture: %s\n", yesno(force_pics));
3118  printf(" picture output format: %s\n", output_extensions[output_format]);
3119  if (output_format == OF_JPG)
3120  printf(" JPEG quality: %d\n", jpeg_quality);
3121  printf(" show map being processed: %s\n", yesno(show_maps));
3122  printf(" generate raw maps: %s\n", yesno(rawmaps));
3123  printf(" warn of exit without path: %s\n", yesno(warn_no_path));
3124  printf(" list unused maps: %s\n", yesno(list_unused_maps));
3125  printf(" generate world map: %s\n", yesno(world_map));
3126  printf(" generate exit map: %s\n", yesno(world_exit_info));
3127  printf(" generate regions link file: %s\n", yesno(do_regions_link));
3128  printf(" tileset: %s\n", find_faceset(tileset)->fullname);
3129  printf(" detail quest steps: %s\n", yesno(detail_quests));
3130  printf(" list system quests: %s\n", yesno(list_system_quests));
3131  printf(" templates directory: %s\n", templates_root.c_str());
3132  printf(" templates to process: ");
3133  const char *sep = "";
3134  for (auto f : templates) {
3135  printf("%s%s", sep, f.c_str());
3136  sep = ", ";
3137  }
3138  printf("\n");
3139  printf(" display template to process: %s\n", yesno(display_rendered_template));
3140  printf("\n");
3141 
3142  if (list_unused_maps) {
3143  printf("listing all maps...");
3144  find_maps("");
3145  printf("done, %d maps found.\n", found_maps_count);
3146  qsort(found_maps, found_maps_count, sizeof(char *), sortbyname);
3147  }
3148 
3149  /* exit/blocking information. */
3150  infomap = gdImageCreateTrueColor(30*50, 30*50);
3151  color_unlinked_exit = gdImageColorResolve(infomap, 255, 0, 0);
3152  color_linked_exit = gdImageColorResolve(infomap, 255, 255, 255);
3153  color_road = gdImageColorResolve(infomap, 0, 255, 0);
3154  color_blocking = gdImageColorResolve(infomap, 0, 0, 255);
3155  color_slowing = gdImageColorResolve(infomap, 0, 0, 127);
3156  elevation_info = (int **)calloc(50*30, sizeof(int *));
3157  for (i = 0; i < 50*30; i++)
3158  elevation_info[i] = (int *)calloc(50*30, sizeof(int));
3159  elevation_min = 0;
3160  elevation_max = 0;
3161 
3162  printf("browsing maps...\n");
3163 
3165 
3166  while (current_map < maps_list.count) {
3168  if (current_map%100 == 0) {
3169  printf(" %zu maps processed, %d map pictures created, %d map pictures were uptodate. %d faces used.\n", current_map, created_pics, cached_pics, pics_allocated);
3170  }
3171  if ((map_limit != -1) && (current_map == static_cast<size_t>(map_limit))) {
3172  printf(" --- map limit reached, stopping ---\n");
3173  break;
3174  }
3175  }
3176 
3177  printf(" finished map parsing, %zu maps processed, %d map pictures created, %d map pictures were uptodate. Total %d faces used.\n", current_map, created_pics, cached_pics, pics_allocated);
3178 
3179  if (list_unused_maps)
3180  dump_unused_maps();
3181 
3183  fix_map_names();
3184  fix_tiled_map();
3186  write_tiled_maps();
3187 
3188  write_world_map();
3189  write_world_info();
3190 
3192  qsort(regions, region_count, sizeof(struct_region_info *), sort_region);
3195  qsort(races.races, races.count, sizeof(struct_race *), sort_race);
3196  qsort(quests, quests_count, sizeof(struct_quest *), sort_struct_quest);
3197 
3200 
3202 
3204 
3205  for (auto file : templates) {
3206  if (!file.empty()) {
3208  }
3209  }
3210 
3211  const auto fullStart = time(nullptr);
3212  printf("rendering pages...");
3214  printf("\n");
3215  fflush(stdout);
3216 
3217  while (!pages.empty()) {
3218  auto p = pages.back();
3219  pages.pop_back();
3220  if (p.param.empty())
3221  all_data.erase("param");
3222  else
3223  all_data["param"] = p.param;
3224  const auto start = time(nullptr);
3226  printf(" rendering page %s (%s)... ", p.template_name.c_str(), p.param.c_str());
3227  fflush(stdout);
3228  }
3229  path_stack.push_back(p.output_name);
3230  inja::Template temp = get_template(p.template_name);
3231  env->write(temp, all_data, p.output_name);
3232  path_stack.pop_back();
3233  const auto elapsed = time(nullptr) - start;
3235  printf("took %ld seconds\n", elapsed);
3236  }
3237  }
3238 
3239  const auto elapsed = time(nullptr) - fullStart;
3240  printf(" done, took %ld seconds\n", elapsed);
3241 
3242  return 0;
3243 }
3244 
3246  int x, y;
3247 
3248  if (m == NULL)
3249  return;
3250 
3251  for (x = 0; x < MAP_WIDTH(m); x++)
3252  for (y = 0; y < MAP_HEIGHT(m); y++)
3253  FOR_MAP_PREPARE(m, x, y, tmp) {
3254  if (tmp->inv) {
3255  FOR_INV_PREPARE(tmp, invtmp) {
3256  if (QUERY_FLAG(invtmp, FLAG_AUTO_APPLY))
3257  apply_auto(invtmp);
3258  else if (invtmp->type == TREASURE && HAS_RANDOM_ITEMS(invtmp)) {
3259  while ((invtmp->stats.hp--) > 0)
3260  create_treasure(invtmp->randomitems, invtmp, 0, m->difficulty, 0);
3261  invtmp->randomitems = NULL;
3262  } else if (invtmp
3263  && invtmp->arch
3264  && invtmp->type != TREASURE
3265  && invtmp->type != SPELL
3266  && invtmp->type != CLASS
3267  && HAS_RANDOM_ITEMS(invtmp)) {
3268  create_treasure(invtmp->randomitems, invtmp, 0, m->difficulty, 0);
3269  /* Need to clear this so that we never try to create
3270  * treasure again for this object
3271  */
3272  invtmp->randomitems = NULL;
3273  }
3274  } FOR_INV_FINISH();
3275  /* This is really temporary - the code at the bottom will
3276  * also set randomitems to null. The problem is there are bunches
3277  * of maps/players already out there with items that have spells
3278  * which haven't had the randomitems set to null yet.
3279  * MSW 2004-05-13
3280  *
3281  * And if it's a spellbook, it's better to set randomitems to NULL too,
3282  * else you get two spells in the book ^_-
3283  * Ryo 2004-08-16
3284  */
3285  if (tmp->type == WAND
3286  || tmp->type == ROD
3287  || tmp->type == SCROLL
3288  || tmp->type == FIREWALL
3289  || tmp->type == POTION
3290  || tmp->type == ALTAR
3291  || tmp->type == SPELLBOOK)
3292  tmp->randomitems = NULL;
3293  }
3294 
3296  apply_auto(tmp);
3297  else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && HAS_RANDOM_ITEMS(tmp)) {
3298  while ((tmp->stats.hp--) > 0)
3299  create_treasure(tmp->randomitems, tmp, 0, m->difficulty, 0);
3300  tmp->randomitems = NULL;
3301  } else if (tmp->type == TIMED_GATE) {
3302  object *head = HEAD(tmp);
3303 
3304  if (QUERY_FLAG(head, FLAG_IS_LINKED)) {
3305  tmp->speed = 0;
3307  }
3308  /* This function can be called everytime a map is loaded, even when
3309  * swapping back in. As such, we don't want to create the treasure
3310  * over and ove again, so after we generate the treasure, blank out
3311  * randomitems so if it is swapped in again, it won't make anything.
3312  * This is a problem for the above objects, because they have counters
3313  * which say how many times to make the treasure.
3314  */
3315  } else if (tmp
3316  && tmp->arch
3317  && tmp->type != PLAYER
3318  && tmp->type != TREASURE
3319  && tmp->type != SPELL
3320  && tmp->type != PLAYER_CHANGER
3321  && tmp->type != CLASS
3322  && HAS_RANDOM_ITEMS(tmp)) {
3323  create_treasure(tmp->randomitems, tmp, 0, m->difficulty, 0);
3324  tmp->randomitems = NULL;
3325  }
3326  } FOR_MAP_FINISH();
3327 
3328  for (x = 0; x < MAP_WIDTH(m); x++)
3329  for (y = 0; y < MAP_HEIGHT(m); y++)
3330  FOR_MAP_PREPARE(m, x, y, tmp) {
3331  if (tmp->above
3332  && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
3333  check_trigger(tmp, tmp->above);
3334  } FOR_MAP_FINISH();
3335 }
3336 
3337 #ifndef DOXYGEN_SHOULD_SKIP_THIS
3338 
3343 void draw_ext_info(int, int, const object *, uint8_t, uint8_t, const char *txt) {
3344  fprintf(logfile, "%s\n", txt);
3345 }
3346 
3347 void draw_ext_info_format(int, int, const object *, uint8_t, uint8_t, const char *format, ...) {
3348  va_list ap;
3349 
3350  va_start(ap, format);
3351  vfprintf(logfile, format, ap);
3352  va_end(ap);
3353 }
3354 
3355 void ext_info_map(int, const mapstruct *, uint8_t, uint8_t, const char *str1) {
3356  fprintf(logfile, "ext_info_map: %s\n", str1);
3357 }
3358 
3359 void move_firewall(object *) {
3360 }
3361 
3362 void emergency_save(int) {
3363 }
3364 
3365 void clean_tmp_files(void) {
3366 }
3367 
3368 void esrv_send_item(object *, object *) {
3369 }
3370 
3371 void dragon_ability_gain(object *, int, int) {
3372 }
3373 
3375 }
3376 
3377 object *find_skill_by_number(object *, int) {
3378  return NULL;
3379 }
3380 
3381 void esrv_del_item(player *, object *) {
3382 }
3383 
3384 void esrv_update_item(int, object *, object *) {
3385 }
3386 
3388 }
3389 
3390 void rod_adjust(object *) {
3391 }
3392 
3393 /*
3394  * This a modified version of apply_auto: BOOK are not generated, so they don't pollute
3395  * the readable list.
3396  */
3397 int apply_auto(object *op) {
3398  object *tmp = NULL;
3399  int i;
3400 
3401  switch (op->type) {
3402  case SHOP_FLOOR:
3403  if (!HAS_RANDOM_ITEMS(op))
3404  return 0;
3405  do {
3406  i = 10; /* let's give it 10 tries */
3407  while ((tmp = generate_treasure(op->randomitems, op->stats.exp ? (int)op->stats.exp : MAX(op->map->difficulty, 5))) == NULL && --i)
3408  ;
3409  if (tmp == NULL)
3410  return 0;
3411  if (QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED) || tmp->type == BOOK) {
3413  tmp = NULL;
3414  }
3415  } while (!tmp);
3417  object_insert_in_map_at(tmp, op->map, NULL, 0, op->x, op->y);
3419  tmp = identify(tmp);
3420  break;
3421 
3422  case TREASURE:
3424  return 0;
3425 
3426  while ((op->stats.hp--) > 0)
3427  create_treasure(op->randomitems, op, 0, op->stats.exp ? (int)op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
3428 
3429  /* If we generated an object and put it in this object inventory,
3430  * move it to the parent object as the current object is about
3431  * to disappear. An example of this item is the random_ *stuff
3432  * that is put inside other objects.
3433  */
3434  FOR_INV_PREPARE(op, tmp) {
3435  object_remove(tmp);
3436  if (op->env && tmp->type != BOOK)
3437  object_insert_in_ob(tmp, op->env);
3438  else
3440  }
3441  FOR_INV_FINISH();
3442  object_remove(op);
3444  break;
3445  }
3446  return tmp ? 1 : 0;
3447 }
3448 
3450 }
3451 
3453  return NULL;
3454 }
3455 
3457  return NULL;
3458 }
3459 
3461  return NULL;
3462 }
3463 
3465 }
3466 
3468 }
3469 
3470 void command_help(object *, const char *) {
3471 }
3472 
3473 #endif /* dummy DOXYGEN_SHOULD_SKIP_THIS */
get_race
static struct_race * get_race(const char *name)
Definition: mapper.cpp:613
struct_map_info::tiles
struct struct_map_info * tiles[4]
Definition: mapper.cpp:232
CLASS
@ CLASS
Definition: object.h:138
struct_region_info::sum_x
int sum_x
Definition: mapper.cpp:359
give.next
def next
Definition: give.py:44
move_firewall
void move_firewall(object *)
Definition: mapper.cpp:3359
write_tiled_map_page
static void write_tiled_map_page(struct_map_info *map)
Definition: mapper.cpp:2180
fix_tiled_map_monsters
static void fix_tiled_map_monsters(void)
Definition: mapper.cpp:2015
ready_map_name
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.c:1785
do_auto_apply
void do_auto_apply(mapstruct *m)
Definition: mapper.cpp:3245
add_map
static void add_map(struct_map_info *info, struct_map_list *list)
Definition: mapper.cpp:1208
HAS_RANDOM_ITEMS
#define HAS_RANDOM_ITEMS(op)
Definition: define.h:184
PLAYER
@ PLAYER
Definition: object.h:107
artifact
struct artifactstruct artifact
Settings::mapdir
const char * mapdir
Definition: global.h:246
struct_map_in_quest
struct struct_map_in_quest struct_map_in_quest
global.h
FREE_OBJ_NO_DESTROY_CALLBACK
#define FREE_OBJ_NO_DESTROY_CALLBACK
Definition: object.h:531
object_free
void object_free(object *ob, int flags)
Definition: object.c:1578
ignore_name
static const char * ignore_name[]
Definition: mapper.cpp:2767
struct_npc_info
struct struct_npc_info struct_npc_info
struct_equipment::diff
char * diff
Definition: mapper.cpp:246
banquet.l
l
Definition: banquet.py:164
get_quest_info
static struct_quest * get_quest_info(const char *name)
Definition: mapper.cpp:958
find_region_by_key
static region * find_region_by_key(const std::string &key)
Definition: mapper.cpp:2239
object_remove
void object_remove(object *op)
Definition: object.c:1819
FOR_MAP_FINISH
#define FOR_MAP_FINISH()
Definition: define.h:730
stringbuffer_new
StringBuffer * stringbuffer_new(void)
Definition: stringbuffer.c:57
found_maps_allocated
static int found_maps_allocated
Definition: mapper.cpp:370
process_map_lore
static void process_map_lore(struct_map_info *map)
Definition: mapper.cpp:1072
llevError
@ llevError
Definition: logger.h:11
give_artifact_abilities
void give_artifact_abilities(object *op, const object *artifact)
Definition: artifact.c:238
get_region_struct
region * get_region_struct(void)
Definition: region.cpp:300
maps
static std::unordered_map< std::string, mapzone * > maps
Definition: citylife.cpp:94
compare_map_info
static int compare_map_info(const struct_map_info *left, const struct_map_info *right)
Definition: mapper.cpp:851
path_from_current
static std::string path_from_current(const std::string &path)
Definition: mapper.cpp:2559
MOVE_ALL
#define MOVE_ALL
Definition: define.h:398
WAND
@ WAND
Definition: object.h:220
quest_for_each
void quest_for_each(quest_op op, void *user)
Definition: assets.cpp:709
struct_region_info::is_world
int is_world
Definition: mapper.cpp:360
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
generate_picture_link
static nlohmann::json generate_picture_link(inja::Arguments &args)
Definition: mapper.cpp:2606
struct_map_info::tiled_group
struct struct_map_info * tiled_group
Definition: mapper.cpp:229
struct_map_info::filename
char * filename
Definition: mapper.cpp:214
num_sizes
static const int num_sizes
Definition: mapper.cpp:315
add_slaying
static void add_slaying(struct_map_info *map, object *item)
Definition: mapper.cpp:1474
strdup_local
#define strdup_local
Definition: compat.h:29
diamondslots.x
x
Definition: diamondslots.py:15
write_tiled_maps
static void write_tiled_maps(void)
Definition: mapper.cpp:2190
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
struct_quest::maps
struct_map_in_quest_list maps
Definition: mapper.cpp:913
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
create_quest_object
static nlohmann::json create_quest_object(struct_quest *quest, const std::string &key)
Definition: mapper.cpp:2349
create_map_info
static struct_map_info * create_map_info(void)
Definition: mapper.cpp:1229
struct_race::count
int count
Definition: mapper.cpp:260
TRIGGER_PEDESTAL
@ TRIGGER_PEDESTAL
Definition: object.h:134
nlohmann::json
basic_json<> json
default JSON class
Definition: json.hpp:3404
struct_map_in_quest::map
struct_map_info * map
Definition: mapper.cpp:904
esrv_del_item
void esrv_del_item(player *, object *)
Definition: mapper.cpp:3381
pageToRender::param
std::string param
Definition: mapper.cpp:2630
S_CONNECT
#define S_CONNECT
Definition: mapper.cpp:394
write_pictures_from_real_size
static void write_pictures_from_real_size(const char *path, gdImagePtr real, int width, int height)
Definition: mapper.cpp:1514
region_links
static std::map< region *, std::set< region * > > region_links
Definition: mapper.cpp:387
struct_npc_list
struct struct_npc_list struct_npc_list
calc_item_power
int calc_item_power(const object *op)
Definition: item.c:239
Settings::datadir
const char * datadir
Definition: global.h:243
c
static event_registration c
Definition: citylife.cpp:427
disinfect.a
a
Definition: disinfect.py:13
output_format
static enum output_format_type output_format
Definition: mapper.cpp:344
quests_count
static int quests_count
Definition: mapper.cpp:918
SHOP_FLOOR
@ SHOP_FLOOR
Definition: object.h:183
Ice.g
def g
Definition: Ice.py:63
pl
Definition: player.h:105
get_map_info
static struct_map_info * get_map_info(const char *path)
Definition: mapper.cpp:1301
EXIT_PATH
#define EXIT_PATH(xyz)
Definition: define.h:439
fix_exits_to_tiled_maps
static void fix_exits_to_tiled_maps(void)
Definition: mapper.cpp:1987
reverse_maps
static std::map< struct_map_info *, std::string > reverse_maps
Definition: mapper.cpp:2219
dump
static int dump(const std::set< std::string > &items, const char *name)
Definition: AssetsManager.cpp:55
get_ob_diff
void get_ob_diff(StringBuffer *sb, const object *op, const object *op2)
Definition: object.c:4956
guildoracle.list
list
Definition: guildoracle.py:87
struct_map_in_quest
Definition: mapper.cpp:901
slaying_allocated
static size_t slaying_allocated
Definition: mapper.cpp:405
get_equipment
static struct_equipment * get_equipment(void)
Definition: mapper.cpp:439
is_special_equipment
static int is_special_equipment(object *item)
Definition: mapper.cpp:420
TIMED_GATE
@ TIMED_GATE
Definition: object.h:128
region_allocated
static size_t region_allocated
Definition: mapper.cpp:365
struct_map_list
Definition: mapper.cpp:204
generate_page_and_link
static nlohmann::json generate_page_and_link(inja::Arguments &args)
Definition: mapper.cpp:2576
struct_equipment::origin
struct_map_list origin
Definition: mapper.cpp:247
find_faceset
face_sets * find_faceset(int id)
Definition: assets.cpp:366
commongive.inv
inv
Definition: commongive.py:28
root
static char root[500]
Definition: mapper.cpp:306
create_map_in_quest_array
static nlohmann::json create_map_in_quest_array(struct_map_in_quest_list &list)
Definition: mapper.cpp:2303
yesno
static const char * yesno(int value)
Definition: mapper.cpp:3047
AMULET
@ AMULET
Definition: object.h:139
CHECK_INV
@ CHECK_INV
Definition: object.h:169
mapdef::in_memory
uint32_t in_memory
Definition: map.h:338
struct_map_info::name
char * name
Definition: mapper.cpp:213
fix_map_names
static void fix_map_names(void)
Definition: mapper.cpp:1881
struct_slaying_info::maps
struct_map_list maps[S_MAX]
Definition: mapper.cpp:400
mad_mage_user.file
file
Definition: mad_mage_user.py:15
MIN
#define MIN(x, y)
Definition: compat.h:21
SIZE
#define SIZE
maps_list
static struct_map_list maps_list
Definition: mapper.cpp:236
TREASURE
@ TREASURE
Definition: object.h:110
color_unlinked_exit
static int color_unlinked_exit
Definition: mapper.cpp:374
struct_region_info::sum_y
int sum_y
Definition: mapper.cpp:359
create_pathname
char * create_pathname(const char *name, char *buf, size_t size)
Definition: map.c:103
pages
static std::vector< pageToRender > pages
Definition: mapper.cpp:2632
list_unused_maps
static int list_unused_maps
Definition: mapper.cpp:367
struct_map_info
Definition: mapper.cpp:211
path_combine_and_normalize
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
Definition: path.c:172
draw_ext_info_format
void draw_ext_info_format(int, int, const object *, uint8_t, uint8_t, const char *format,...)
Definition: mapper.cpp:3347
esrv_send_item
void esrv_send_item(object *, object *)
Definition: mapper.cpp:3368
struct_map_info::min_monster
int min_monster
Definition: mapper.cpp:217
Ice.tmp
int tmp
Definition: Ice.py:207
nlohmann::basic_json::push_back
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:22807
create_region_array
static nlohmann::json create_region_array(const std::set< region * > &regions)
Definition: mapper.cpp:2393
struct_region_info
Definition: mapper.cpp:356
clean_tmp_files
void clean_tmp_files(void)
Definition: mapper.cpp:3365
inja::Template
The main inja Template.
Definition: inja.hpp:2836
nlohmann::basic_json::diff
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
Definition: json.hpp:26097
SIGN
@ SIGN
Definition: object.h:211
first_map_path
EXTERN char first_map_path[MAX_BUF]
Definition: global.h:141
struct_equipment::name
char * name
Definition: mapper.cpp:243
TRIGGER_BUTTON
@ TRIGGER_BUTTON
Definition: object.h:132
npc_dialog.filename
filename
Definition: npc_dialog.py:99
smoking_pipe.color
color
Definition: smoking_pipe.py:5
account_chars_struct
Definition: account_char.h:28
create_treasure
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
Definition: treasure.c:241
struct_map_info::max_monster
int max_monster
Definition: mapper.cpp:217
is_valid_faceset
int is_valid_faceset(int fsn)
Definition: image.c:116
struct_slaying_info
Definition: mapper.cpp:398
struct_equipment::calc_power
int calc_power
Definition: mapper.cpp:245
make_path_to_file
void make_path_to_file(const char *filename)
Definition: porting.c:162
quest_step_definition
Definition: quest.h:33
MAX
#define MAX(x, y)
Definition: compat.h:24
apply_auto_fix
void apply_auto_fix(mapstruct *)
Definition: mapper.cpp:3449
account_char_save
void account_char_save(Account_Chars *)
Definition: mapper.cpp:3464
obj::nrof
uint32_t nrof
Definition: object.h:337
FLAG_NO_PICK
#define FLAG_NO_PICK
Definition: define.h:239
find_artifact
const artifact * find_artifact(const object *op, const char *name)
Definition: artifact.c:590
force_pics
static int force_pics
Definition: mapper.cpp:313
reputation_trigger_connect.check
def check()
Definition: reputation_trigger_connect.py:18
world_exit_info
static int world_exit_info
Definition: mapper.cpp:321
sort_struct_quest
static int sort_struct_quest(const void *left, const void *right)
Definition: mapper.cpp:1037
struct_quest
Definition: mapper.cpp:908
archt
Definition: object.h:469
settings
struct Settings settings
Definition: init.c:39
struct_map_in_quest_list
Definition: mapper.cpp:197
struct_region_info::reg
region * reg
Definition: mapper.cpp:357
init_readable
void init_readable(void)
Definition: readable.c:903
struct_map_in_quest::quest
struct struct_quest * quest
Definition: mapper.cpp:906
object_get_value
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4317
FLAG_IS_A_TEMPLATE
#define FLAG_IS_A_TEMPLATE
Definition: define.h:366
obj::slaying
sstring slaying
Definition: object.h:322
identify
object * identify(object *op)
Definition: item.c:1409
init_renderer_env
static void init_renderer_env()
Definition: mapper.cpp:2672
struct_quest::description
char * description
Definition: mapper.cpp:910
init_gods
void init_gods(void)
Definition: holy.cpp:63
regiondef::next
struct regiondef * next
Definition: map.h:276
m
static event_registration m
Definition: citylife.cpp:427
quest
Definition: quest.py:1
MAP_IN_MEMORY
#define MAP_IN_MEMORY
Definition: map.h:131
S_CONTAINER
#define S_CONTAINER
Definition: mapper.cpp:392
struct_race
struct struct_race struct_race
item.q
q
Definition: item.py:32
opendir
DIR * opendir(const char *)
quest_step_definition::next
struct quest_step_definition * next
Definition: quest.h:37
templateCache
static inja::TemplateStorage templateCache
Definition: mapper.cpp:3051
disinfect.map
map
Definition: disinfect.py:4
regions
static struct struct_region_info ** regions
Definition: mapper.cpp:363
struct_npc_info::y
int y
Definition: mapper.cpp:179
struct_map_info::exits_from
struct_map_list exits_from
Definition: mapper.cpp:218
Settings::debug
LogLevel debug
Definition: global.h:239
detail_quests
static bool detail_quests
Definition: mapper.cpp:323
ensure_unique
static struct_equipment * ensure_unique(struct_equipment *item)
Definition: mapper.cpp:466
struct_npc_info::message
const char * message
Definition: mapper.cpp:178
special_equipment
static struct_equipment ** special_equipment
Definition: mapper.cpp:250
obj::name
sstring name
Definition: object.h:314
quest_step_definition::is_completion_step
int is_completion_step
Definition: quest.h:36
get_slaying_struct
static struct_slaying_info * get_slaying_struct(const char *slaying)
Definition: mapper.cpp:1431
generate_picture_path
static void generate_picture_path(const char *path, size_t pic_size, char *out, size_t len)
Definition: mapper.cpp:1510
make_face_from_files.args
args
Definition: make_face_from_files.py:31
OF_JPG
@ OF_JPG
Definition: mapper.cpp:334
struct_npc_list::count
size_t count
Definition: mapper.cpp:185
rotate-tower.result
bool result
Definition: rotate-tower.py:13
elevation_max
static int elevation_max
Definition: mapper.cpp:382
struct_map_info::pic_was_done
int pic_was_done
Definition: mapper.cpp:217
add_npc_to_map
static void add_npc_to_map(struct_npc_list *list, const object *npc)
Definition: mapper.cpp:1186
struct_map_info
struct struct_map_info struct_map_info
set_darkness_map
void set_darkness_map(mapstruct *)
Definition: mapper.cpp:3374
system_quests_count
static size_t system_quests_count
Definition: mapper.cpp:2199
POTION
@ POTION
Definition: object.h:111
struct_npc_info
Definition: mapper.cpp:176
define_quest
static void define_quest(const char *name, struct_map_info *mainmap, const char *description)
Definition: mapper.cpp:1053
add_to_struct_map_in_quest_list
static void add_to_struct_map_in_quest_list(struct_map_in_quest_list *list, struct_map_in_quest *item)
Definition: mapper.cpp:928
do_tiled_map_picture
static void do_tiled_map_picture(struct_map_info *map)
Definition: mapper.cpp:2072
slaying_info
static struct_slaying_info ** slaying_info
Definition: mapper.cpp:403
obj::name_pl
sstring name_pl
Definition: object.h:318
races
static struct_race_list races
Definition: mapper.cpp:264
main
int main(int argc, char **argv)
Definition: mapper.cpp:3062
HEAD
#define HEAD(op)
Definition: object.h:593
output_extensions
static const char * output_extensions[]
Definition: mapper.cpp:338
create_maps_array
static nlohmann::json create_maps_array(struct_map_list &maps)
Definition: mapper.cpp:2251
ROD
@ ROD
Definition: object.h:109
show_maps
static int show_maps
Definition: mapper.cpp:319
CONTAINER
@ CONTAINER
Definition: object.h:231
get_elevation_color
static int get_elevation_color(int elevation, gdImagePtr elevationmap)
Definition: mapper.cpp:727
make_face_from_files.str
str
Definition: make_face_from_files.py:24
S_MAX
#define S_MAX
Definition: mapper.cpp:395
quest_callback
static void quest_callback(const quest_definition *quest, void *)
Definition: mapper.cpp:2202
readdir
struct dirent * readdir(DIR *)
python_init.path
path
Definition: python_init.py:8
LOCKED_DOOR
@ LOCKED_DOOR
Definition: object.h:123
struct_race::name
char * name
Definition: mapper.cpp:259
dump
Definition: quest.c:859
is_slaying
static int is_slaying(object *item)
Definition: mapper.cpp:1418
struct_equipment::power
int power
Definition: mapper.cpp:244
create_race_array
static nlohmann::json create_race_array(struct_race_list &list)
Definition: mapper.cpp:2286
account_char_load
Account_Chars * account_char_load(const char *)
Definition: mapper.cpp:3460
dragon_ability_gain
void dragon_ability_gain(object *, int, int)
Definition: mapper.cpp:3371
nlohmann::basic_json::array
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:18360
SPECIAL_KEY
@ SPECIAL_KEY
Definition: object.h:124
inja::json
nlohmann::json json
Definition: inja.hpp:1565
struct_race::origin
struct_map_list origin
Definition: mapper.cpp:261
color_slowing
static int color_slowing
Definition: mapper.cpp:378
Ice.b
b
Definition: Ice.py:48
regiondef::name
char * name
Definition: map.h:277
obj::x
int16_t x
Definition: object.h:330
system_quests
static const quest_definition * system_quests[500]
Definition: mapper.cpp:2200
struct_map_info::quests
struct_map_in_quest_list quests
Definition: mapper.cpp:220
write_world_map
static void write_world_map(void)
Definition: mapper.cpp:1778
FLAG_DAMNED
#define FLAG_DAMNED
Definition: define.h:317
struct_map_info::width
int width
Definition: mapper.cpp:230
add_map_to_quest
static void add_map_to_quest(struct_map_info *map, const char *name, const char *description)
Definition: mapper.cpp:987
create_npc_info
static struct_npc_info * create_npc_info(const object *npc)
Definition: mapper.cpp:1168
struct_quest
struct struct_quest struct_quest
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
face_info::data
uint8_t * data
Definition: image.h:11
color_road
static int color_road
Definition: mapper.cpp:376
tileset
static int tileset
Definition: mapper.cpp:322
esrv_update_item
void esrv_update_item(int, object *, object *)
Definition: mapper.cpp:3384
FOR_INV_FINISH
#define FOR_INV_FINISH()
Definition: define.h:677
is_blocking
static int is_blocking(object *item)
Definition: mapper.cpp:713
do_exit_map
static void do_exit_map(mapstruct *map)
Definition: mapper.cpp:742
create_destination
static void create_destination(void)
Definition: mapper.cpp:3031
struct_map_info::tiled_y_from
int tiled_y_from
Definition: mapper.cpp:231
struct_race_list::races
struct struct_race ** races
Definition: mapper.cpp:191
sstring
const typedef char * sstring
Definition: global.h:40
disinfect.count
int count
Definition: disinfect.py:7
FLAG_UNAGGRESSIVE
#define FLAG_UNAGGRESSIVE
Definition: define.h:272
check_slaying_inventory
static void check_slaying_inventory(struct_map_info *map, object *item)
Definition: mapper.cpp:1502
say.max
dictionary max
Definition: say.py:148
object_give_identified_properties
void object_give_identified_properties(object *op)
Definition: item.c:1344
jpeg_quality
static int jpeg_quality
Definition: mapper.cpp:347
sort_system_quest_step
static int sort_system_quest_step(const void *a, const void *b)
Definition: mapper.cpp:2212
sproto.h
append_map_list
static void append_map_list(struct_map_list &dest, struct_map_list &src)
Definition: mapper.cpp:2383
IS_SHIELD
#define IS_SHIELD(op)
Definition: define.h:170
mapdef
Definition: map.h:317
BOOK
@ BOOK
Definition: object.h:114
rawmaps
static int rawmaps
Definition: mapper.cpp:350
init_struct_map_in_quest_list
static void init_struct_map_in_quest_list(struct_map_in_quest_list *list)
Definition: mapper.cpp:922
struct_race_list
Definition: mapper.cpp:190
struct_race
Definition: mapper.cpp:258
emergency_save
void emergency_save(int)
Definition: mapper.cpp:3362
logfile
EXTERN FILE * logfile
Definition: global.h:134
struct_race_list::allocated
size_t allocated
Definition: mapper.cpp:193
struct_map_list::maps
struct struct_map_info ** maps
Definition: mapper.cpp:205
RING
@ RING
Definition: object.h:185
delete_map
void delete_map(mapstruct *m)
Definition: map.c:1722
struct_race_list::count
size_t count
Definition: mapper.cpp:192
fill_json
static void fill_json(nlohmann::json &json)
Definition: mapper.cpp:2408
add_map_to_region
static void add_map_to_region(struct_map_info *map, region *reg)
Definition: mapper.cpp:1351
init_globals
void init_globals(void)
Definition: init.c:265
image.h
struct_map_info::level
int level
Definition: mapper.cpp:217
found_maps_count
static int found_maps_count
Definition: mapper.cpp:369
struct_equipment
struct struct_equipment struct_equipment
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
list_system_quests
static bool list_system_quests
Definition: mapper.cpp:324
generate_pics
static int generate_pics
Definition: mapper.cpp:312
MAP_WIDTH
#define MAP_WIDTH(m)
Definition: map.h:78
create_map_object
static nlohmann::json create_map_object(struct_map_info *map, const std::string &key)
Definition: mapper.cpp:2326
struct_quest::mainmap
struct_map_info * mainmap
Definition: mapper.cpp:912
env
static std::shared_ptr< inja::Environment > env
Definition: mapper.cpp:2216
MAX_BUF
#define MAX_BUF
Definition: define.h:35
S_KEY
#define S_KEY
Definition: mapper.cpp:391
object_get_multi_size
void object_get_multi_size(const object *ob, int *sx, int *sy, int *hx, int *hy)
Definition: object.c:4714
artifactstruct
Definition: artifact.h:14
sort_map_info
static int sort_map_info(const void *left, const void *right)
Definition: mapper.cpp:876
fill_reverse_maps
static void fill_reverse_maps(struct_map_list &list)
Definition: mapper.cpp:2364
struct_map_info::tiled_x_from
int tiled_x_from
Definition: mapper.cpp:231
pageToRender
Definition: mapper.cpp:2626
IS_WEAPON
#define IS_WEAPON(op)
Definition: define.h:163
check_trigger
int check_trigger(object *op, object *cause)
Definition: button.c:518
sort_slaying
static int sort_slaying(const void *left, const void *right)
Definition: mapper.cpp:2899
tiled_map_list
static struct_map_list tiled_map_list
Definition: mapper.cpp:239
add_race_to_list
static void add_race_to_list(struct_race *race, struct_race_list *list, int check)
Definition: mapper.cpp:287
StringBuffer
Definition: stringbuffer.c:25
equipment_count
static size_t equipment_count
Definition: mapper.cpp:252
struct_race_list
struct struct_race_list struct_race_list
is_valid_types_gen.found
found
Definition: is_valid_types_gen.py:39
check_equipment
static void check_equipment(object *item, struct_map_info *map)
Definition: mapper.cpp:578
sort_system_quest
static int sort_system_quest(const void *a, const void *b)
Definition: mapper.cpp:2208
FOR_MAP_PREPARE
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Definition: define.h:723
EXIT
@ EXIT
Definition: object.h:181
obj::y
int16_t y
Definition: object.h:330
sortbyname
static int sortbyname(const void *a, const void *b)
Definition: mapper.cpp:796
path_stack
static std::vector< std::string > path_stack
Definition: mapper.cpp:2550
create_npc_array
static nlohmann::json create_npc_array(struct_npc_list &list)
Definition: mapper.cpp:2267
merge_tiled_maps
static void merge_tiled_maps(struct_map_info *map, struct_map_info *tiled_map)
Definition: mapper.cpp:1267
cached_pics
static int cached_pics
Definition: mapper.cpp:329
struct_map_list::allocated
size_t allocated
Definition: mapper.cpp:207
list_map
static void list_map(const char *path)
Definition: mapper.cpp:1328
struct_map_info::exits_to
struct_map_list exits_to
Definition: mapper.cpp:219
struct_map_info::lore
char * lore
Definition: mapper.cpp:215
rendered_templates
static std::set< std::string > rendered_templates
Definition: mapper.cpp:2218
apply_auto
int apply_auto(object *op)
Definition: mapper.cpp:3397
make_face_from_files.out
out
Definition: make_face_from_files.py:75
quest.h
obj::type
uint8_t type
Definition: object.h:343
dirent
#define dirent
Definition: xdir.h:12
S_DETECTOR
#define S_DETECTOR
Definition: mapper.cpp:393
struct_map_info::path
char * path
Definition: mapper.cpp:212
struct_map_in_quest_list::count
size_t count
Definition: mapper.cpp:199
init_map_list
static void init_map_list(struct_map_list *list)
Definition: mapper.cpp:412
add_region_link
static void add_region_link(mapstruct *source, mapstruct *dest)
Definition: mapper.cpp:1399
FLAG_FRIENDLY
#define FLAG_FRIENDLY
Definition: define.h:246
struct_region_info
struct struct_region_info struct_region_info
obj::move_slow
MoveType move_slow
Definition: object.h:434
free_equipment
static void free_equipment(struct_equipment *equip)
Definition: mapper.cpp:452
esrv_update_spells
void esrv_update_spells(player *)
Definition: mapper.cpp:3387
created_pics
static int created_pics
Definition: mapper.cpp:328
size_large
#define size_large
Definition: mapper.cpp:316
add_map_to_slaying
static void add_map_to_slaying(struct_slaying_info *info, int item, struct_map_info *map)
Definition: mapper.cpp:1462
struct_region_info::sum
int sum
Definition: mapper.cpp:359
inja::TemplateStorage
std::map< std::string, Template > TemplateStorage
Definition: inja.hpp:2852
IS_ARMOR
#define IS_ARMOR(op)
Definition: define.h:166
OF_PNG
@ OF_PNG
Definition: mapper.cpp:333
account_char_free
void account_char_free(Account_Chars *)
Definition: mapper.cpp:3467
struct_region_info::maps_list
struct_map_list maps_list
Definition: mapper.cpp:358
init_npc_list
static void init_npc_list(struct_npc_list *list)
Definition: mapper.cpp:1155
item
Definition: item.py:1
struct_map_info::processed
int processed
Definition: mapper.cpp:231
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
FIREWALL
@ FIREWALL
Definition: object.h:168
PLAYER_CHANGER
@ PLAYER_CHANGER
Definition: object.h:162
get_face_fallback
int get_face_fallback(int faceset, uint16_t imageno)
Definition: image.c:132
inja::Arguments
std::vector< const json * > Arguments
Definition: inja.hpp:1567
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:3380
give.op
op
Definition: give.py:33
autojail.value
value
Definition: autojail.py:6
save_picture
static void save_picture(FILE *file, gdImagePtr pic)
Definition: mapper.cpp:1385
create-tower.current_map
current_map
Definition: create-tower.py:7
display_rendered_template
static bool display_rendered_template
Definition: mapper.cpp:325
templates_root
static std::string templates_root("templates/")
FLAG_AUTO_APPLY
#define FLAG_AUTO_APPLY
Definition: define.h:250
quest_definition
Definition: quest.h:42
struct_map_info::monsters
struct_race_list monsters
Definition: mapper.cpp:224
find_archetype
archetype * find_archetype(const char *name)
Definition: assets.cpp:284
elevation_info
static int ** elevation_info
Definition: mapper.cpp:380
color_blocking
static int color_blocking
Definition: mapper.cpp:377
struct_map_in_quest::description
char * description
Definition: mapper.cpp:905
get_template
static inja::Template get_template(const std::string &filename)
Definition: mapper.cpp:3052
convert.dest
dest
Definition: convert.py:25
struct_map_info::tiled_maps
struct_map_list tiled_maps
Definition: mapper.cpp:222
inja.hpp
diamondslots.y
y
Definition: diamondslots.py:16
ext_info_map
void ext_info_map(int, const mapstruct *, uint8_t, uint8_t, const char *str1)
Definition: mapper.cpp:3355
region_count
static size_t region_count
Definition: mapper.cpp:364
command_help
void command_help(object *, const char *)
Definition: mapper.cpp:3470
do_parameters
static void do_parameters(int argc, char **argv)
Definition: mapper.cpp:2949
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
npc_dialog.index
int index
Definition: npc_dialog.py:102
mapdef::reset_time
uint32_t reset_time
Definition: map.h:324
buf
StringBuffer * buf
Definition: readable.c:1610
all_data
static nlohmann::json all_data
Definition: mapper.cpp:2217
face_info::datalen
uint16_t datalen
Definition: image.h:12
add_monster
static void add_monster(object *monster, struct_map_info *map)
Definition: mapper.cpp:642
struct_map_in_quest_list::list
struct struct_map_in_quest ** list
Definition: mapper.cpp:198
MAP_HEIGHT
#define MAP_HEIGHT(m)
Definition: map.h:80
struct_quest::number
int number
Definition: mapper.cpp:911
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2833
pageToRender::template_name
std::string template_name
Definition: mapper.cpp:2628
struct_map_info::cfregion
region * cfregion
Definition: mapper.cpp:216
object_update_speed
void object_update_speed(object *op)
Definition: object.c:1330
sort_race
static int sort_race(const void *a, const void *b)
Definition: mapper.cpp:664
obj::head
struct obj * head
Definition: object.h:299
do_regions_link
static bool do_regions_link
Definition: mapper.cpp:385
arch_to_object
object * arch_to_object(archetype *at)
Definition: arch.cpp:232
init_race_list
static void init_race_list(struct_race_list *list)
Definition: mapper.cpp:271
create-tower.tile
tile
Definition: create-tower.py:8
process_map
static void process_map(struct_map_info *info)
Definition: mapper.cpp:1542
quests_allocated
static int quests_allocated
Definition: mapper.cpp:920
region
struct regiondef region
strcasecmp
int strcasecmp(const char *s1, const char *s2)
artifactstruct::item
object * item
Definition: artifact.h:15
castle_read.key
key
Definition: castle_read.py:64
npc_dialog.npc
npc
Definition: npc_dialog.py:95
found_maps
static char ** found_maps
Definition: mapper.cpp:368
find_skill_by_number
object * find_skill_by_number(object *, int)
Definition: mapper.cpp:3377
sizes
static int sizes[]
Definition: mapper.cpp:314
reverse_regions
static std::map< region *, std::string > reverse_regions
Definition: mapper.cpp:2220
get_region_by_map
region * get_region_by_map(mapstruct *m)
Definition: region.cpp:76
S_DOOR
#define S_DOOR
Definition: mapper.cpp:390
object_insert_in_map_at
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.c:2080
create_tiled_map
static struct_map_info * create_tiled_map(void)
Definition: mapper.cpp:1251
world_map
static int world_map
Definition: mapper.cpp:320
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.c:1546
templates
static std::vector< std::string > templates
Definition: mapper.cpp:2667
ignore_path
static const char * ignore_path[]
Definition: mapper.cpp:2756
sort_equipment
static int sort_equipment(const void *a, const void *b)
Definition: mapper.cpp:595
struct_map_list::count
size_t count
Definition: mapper.cpp:206
slaying_count
static size_t slaying_count
Definition: mapper.cpp:404
player_get_delayed_buffer
SockList * player_get_delayed_buffer(player *)
Definition: mapper.cpp:3452
add_template_to_render
void add_template_to_render(const std::string &template_name, const std::string &output_name, const std::string &param)
Definition: mapper.cpp:2640
struct_npc_list::allocated
size_t allocated
Definition: mapper.cpp:186
regiondef::fallback
int8_t fallback
Definition: map.h:287
infomap
static gdImagePtr infomap
Definition: mapper.cpp:373
sort_struct_map_in_quest
static int sort_struct_map_in_quest(const void *left, const void *right)
Definition: mapper.cpp:1009
struct_map_info::height
int height
Definition: mapper.cpp:230
ALTAR
@ ALTAR
Definition: object.h:122
struct_npc_info::x
int x
Definition: mapper.cpp:179
relative_path
static void relative_path(const char *from, const char *to, char *result)
Definition: mapper.cpp:812
FLAG_UNPAID
#define FLAG_UNPAID
Definition: define.h:236
dump_unused_maps
static void dump_unused_maps(void)
Definition: mapper.cpp:2825
struct_npc_list::npc
struct_npc_info ** npc
Definition: mapper.cpp:184
rod_adjust
void rod_adjust(object *)
Definition: mapper.cpp:3390
struct_map_info::readable
struct_npc_list readable
Definition: mapper.cpp:227
sort_region
static int sort_region(const void *left, const void *right)
Definition: mapper.cpp:892
generate_treasure
object * generate_treasure(treasurelist *t, int difficulty)
Definition: treasure.c:273
FREE_OBJ_FREE_INVENTORY
#define FREE_OBJ_FREE_INVENTORY
Definition: object.h:530
fix_exits_for_map
static void fix_exits_for_map(struct_map_info *current, struct_map_list *from, int is_from)
Definition: mapper.cpp:1968
struct_npc_list
Definition: mapper.cpp:183
quest_step_definition::step_description
sstring step_description
Definition: quest.h:35
SCROLL
@ SCROLL
Definition: object.h:221
FLAG_IS_LINKED
#define FLAG_IS_LINKED
Definition: define.h:315
struct_npc_info::name
const char * name
Definition: mapper.cpp:177
draw_ext_info
void draw_ext_info(int, int, const object *, uint8_t, uint8_t, const char *txt)
Definition: mapper.cpp:3343
split
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2655
say.item
dictionary item
Definition: say.py:149
do_help
static void do_help(const char *program)
Definition: mapper.cpp:2912
struct_quest::name
char * name
Definition: mapper.cpp:909
nlohmann::basic_json::erase
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:21582
init_library
void init_library(void)
Definition: init.c:192
get_faces_count
size_t get_faces_count()
Definition: assets.cpp:319
write_world_info
static void write_world_info(void)
Definition: mapper.cpp:2848
struct_map_in_quest_list::allocated
size_t allocated
Definition: mapper.cpp:200
tiled_map_need_pic
static int tiled_map_need_pic(struct_map_info *map)
Definition: mapper.cpp:2042
regiondef::msg
char * msg
Definition: map.h:285
face_sets
Definition: image.h:17
equipment_allocated
static size_t equipment_allocated
Definition: mapper.cpp:254
SPELL
@ SPELL
Definition: object.h:214
map_limit
static int map_limit
Definition: mapper.cpp:318
replace.current
current
Definition: replace.py:64
closedir
int closedir(DIR *)
quests
static struct_quest ** quests
Definition: mapper.cpp:916
guildbuy.temp
def temp
Definition: guildbuy.py:26
fix_tiled_map
static void fix_tiled_map(void)
Definition: mapper.cpp:1899
FLAG_CURSED
#define FLAG_CURSED
Definition: define.h:316
first_region
EXTERN region * first_region
Definition: global.h:117
output_format_type
output_format_type
Definition: mapper.cpp:332
TELEPORTER
@ TELEPORTER
Definition: object.h:141
regiondef::longname
char * longname
Definition: map.h:283
gdfaces
static gdImagePtr * gdfaces
Definition: mapper.cpp:173
pics_allocated
static int pics_allocated
Definition: mapper.cpp:309
struct_equipment
Definition: mapper.cpp:242
face_sets::faces
face_info * faces
Definition: image.h:26
SockList
Definition: newclient.h:681
IS_ARROW
#define IS_ARROW(op)
Definition: define.h:178
SPELLBOOK
@ SPELLBOOK
Definition: object.h:203
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:670
takeitem.status
status
Definition: takeitem.py:35
find_player_partial_name
player * find_player_partial_name(const char *)
Definition: mapper.cpp:3456
find_map_by_key
static struct_map_info * find_map_by_key(const std::string &key)
Definition: mapper.cpp:2227
warn_no_path
static int warn_no_path
Definition: mapper.cpp:353
find_quest_info
static struct_quest * find_quest_info(const char *name)
Definition: mapper.cpp:941
DETECTOR
@ DETECTOR
Definition: object.h:149
find_maps
static void find_maps(const char *from)
Definition: mapper.cpp:2780
struct_slaying_info::slaying
char * slaying
Definition: mapper.cpp:399
ring_occidental_mages.r
r
Definition: ring_occidental_mages.py:6
is_road
static int is_road(object *item)
Definition: mapper.cpp:677
obj::level
int16_t level
Definition: object.h:356
elevation_min
static int elevation_min
Definition: mapper.cpp:381
struct_map_info::npcs
struct_npc_list npcs
Definition: mapper.cpp:226
color_linked_exit
static int color_linked_exit
Definition: mapper.cpp:375
FLAG_IS_FLOOR
#define FLAG_IS_FLOOR
Definition: define.h:302
add_one_item
static void add_one_item(object *item, struct_map_info *map)
Definition: mapper.cpp:504
FLAG_IDENTIFIED
#define FLAG_IDENTIFIED
Definition: define.h:261
give.name
name
Definition: give.py:27
pageToRender::output_name
std::string output_name
Definition: mapper.cpp:2629
regiondef
Definition: map.h:275