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 
150 #include <ctype.h>
151 #include <errno.h>
152 #include <stdio.h>
153 #include <stdlib.h>
154 #include <string.h>
155 #include <strings.h>
156 #include <sys/stat.h>
157 #include <sys/types.h>
158 #include <time.h>
159 
160 #include "global.h"
161 #include "sproto.h"
162 #include "image.h"
163 #include "quest.h"
164 
165 extern "C" {
166 #include <gd.h>
167 #include <gdfonts.h>
168 #include <gdfontl.h>
169 #include <gdfontg.h>
170 }
171 
172 #include "inja.hpp"
173 #include <map>
174 #include <set>
175 
176 static gdImagePtr *gdfaces;
177 
180  const char *name;
181  const char *message;
182  int x, y;
183 };
184 
186 typedef std::vector<struct_npc_info *> npc_list;
187 
190  struct struct_race **races;
191  size_t count;
192  size_t allocated;
193 };
194 
198  size_t count;
199  size_t allocated;
200 };
201 
205  size_t count;
206  size_t allocated;
207 };
208 
211  char *path;
212  char *name;
213  char *filename;
214  char *lore;
221 
223 
225 
228 
230  int height, width;
232  struct struct_map_info *tiles[4];
233 };
234 
237 
240 
243  char *name;
244  int power;
246  char *diff;
248 };
249 
250 static std::vector<struct_equipment *> special_equipment;
254 struct struct_race {
255  char *name;
256  int count;
258 };
259 
262 static std::set<std::string> reset_groups;
270  list->races = NULL;
271  list->count = 0;
272  list->allocated = 0;
273 }
274 
286  if (check) {
287  size_t test;
288 
289  for (test = 0; test < list->count; test++) {
290  if (list->races[test] == race)
291  return;
292  }
293  }
294 
295  if (list->allocated == list->count) {
296  list->allocated += 50;
297  list->races = (struct_race **)realloc(list->races, sizeof(struct_race *)*list->allocated);
298  }
299  list->races[list->count] = race;
300  list->count++;
301 }
302 
304 static char root[500];
305 
307 static int pics_allocated;
308 
309 /* Options */
310 static int generate_pics = 1;
311 static int force_pics = 0;
312 static int sizes[] = {32, 16, 8, 4, 2};
313 static const int num_sizes = sizeof(sizes)/sizeof(int);
314 #define size_large sizes[0]
315 #define size_small sizes[1]
316 static int map_limit = -1;
317 static int show_maps = 0;
318 static int world_map = 1;
319 static int world_exit_info = 1;
320 static int tileset = 0;
321 static bool detail_quests = false;
322 static bool list_system_quests = false;
323 static bool display_rendered_template = false;
326 static int created_pics = 0;
327 static int cached_pics = 0;
331  OF_PNG = 0,
332  OF_JPG = 1
333 };
334 
336 static const char *output_extensions[] = {
337  ".png",
338  ".jpg"
339 };
340 
343 
345 static int jpeg_quality = -1;
346 
348 static int rawmaps = 0;
349 
351 static int warn_no_path = 0;
352 
357  int sum_x, sum_y, sum;
358  int is_world;
359 };
360 
361 static struct struct_region_info **regions = NULL;
362 static size_t region_count = 0;
363 static size_t region_allocated = 0;
365 static int list_unused_maps = 0;
366 static std::vector<char *> found_maps;
368 /* Path/exit info */
369 static gdImagePtr infomap;
371 static int color_linked_exit;
372 static int color_road;
373 static int color_blocking;
374 static int color_slowing;
376 static int **elevation_info;
377 static int elevation_min;
378 static int elevation_max;
380 /* Whether to compute links between regions or not (expensive). */
381 static bool do_regions_link = false;
382 /* Links between regions, key is source, value are destinations. */
383 static std::map<region *, std::set<region *>> region_links;
384 
386 #define S_DOOR 0
387 #define S_KEY 1
388 #define S_CONTAINER 2
389 #define S_DETECTOR 3
390 #define S_CONNECT 4
391 #define S_MAX 5
392 
395  char *slaying;
397 };
398 
400 static size_t slaying_count = 0;
401 static size_t slaying_allocated = 0;
409  list->maps = NULL;
410  list->count = 0;
411  list->allocated = 0;
412 }
413 
414 static void add_map(struct_map_info *info, struct_map_list *list);
415 
416 static int is_special_equipment(object *item) {
417  if (item->name == item->arch->clone.name && item->title == item->arch->clone.title)
418  return 0;
420  return 0;
421  if (item->move_block == MOVE_ALL)
422  return 0;
423 
424  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))
425  return 1;
426 
427  return 0;
428 }
429 
436  struct_equipment *add = (struct_equipment *)calloc(1, sizeof(struct_equipment));
437 
438  init_map_list(&add->origin);
439  return add;
440 }
441 
448 static void free_equipment(struct_equipment *equip) {
449  free(equip->diff);
450  free(equip->name);
451  free(equip);
452 }
453 
463  struct_equipment *comp;
464 
465  for (size_t check = 0; check < special_equipment.size(); check++) {
466  comp = special_equipment[check];
467 
468  if (strcmp(comp->name, item->name))
469  continue;
470  if (comp->power != item->power)
471  continue;
472  if (comp->calc_power != item->calc_power)
473  continue;
474  if (strcmp(comp->diff, item->diff))
475  continue;
476 
478  return comp;
479  }
480 
481  special_equipment.push_back(item);
482 
483  return item;
484 }
485 
495 static void add_one_item(object *item, struct_map_info *map) {
498  int x, y;
499  sstring name, namepl;
500  uint32_t nrof;
501  object *base;
502 
503  x = item->x;
504  y = item->y;
505  name = item->name;
506  namepl = item->name_pl;
507  nrof = item->nrof;
508 
509  if (item->artifact != NULL) {
510  const artifact *artifact;
511 
512  artifact = find_artifact(item, item->artifact);
513  if (artifact == NULL) {
514  LOG(llevError, "could not find artifact %s [%d] to save data\n", item->artifact, item->type);
515  base = arch_to_object(item->arch);
516  } else {
517  base = arch_to_object(item->arch);
519  }
520  }
521  else {
522  base = arch_to_object(item->arch);
523  }
524 
525  item->x = base->x;
526  item->y = base->y;
527  item->name = base->name;
528  item->name_pl = base->name_pl;
529  item->nrof = base->nrof;
530 
533  SET_FLAG(base, FLAG_IDENTIFIED);
534  }
536  SET_FLAG(base, FLAG_UNPAID);
537  get_ob_diff(bf, item, base);
539 
540  add->diff = stringbuffer_finish(bf);
541 
542  item->x = x;
543  item->y = y;
544  item->name = name;
545  item->name_pl = namepl;
546  item->nrof = nrof;
547 
548  if (add->diff == NULL || strcmp(add->diff, "") == 0) {
549  free_equipment(add);
550  return;
551  }
552 
553  add->name = strdup(item->name);
554  add->power = item->item_power;
556 
557  add = ensure_unique(add);
558  add_map(map, &add->origin);
559 }
560 
569 static void check_equipment(object *item, struct_map_info *map) {
572 
575  FOR_INV_FINISH();
576 }
577 
586 static bool sort_equipment(const struct_equipment *l, const struct_equipment *r) {
587  if (l->power < r->power)
588  return true;
589  return strcasecmp(l->name, r->name) < 0;
590 }
591 
600 static struct_race *get_race(const char *name) {
601  size_t test;
602  struct_race *item;
603 
604  for (test = 0; test < races.count; test++) {
605  if (strcmp(races.races[test]->name, name) == 0) {
606  races.races[test]->count++;
607  return races.races[test];
608  }
609  }
610 
611  item = (struct_race *)calloc(1, sizeof(struct_race));
612  item->name = strdup(name);
613  item->count = 1;
614  init_map_list(&item->origin);
615 
617 
618  return item;
619 }
620 
629 static void add_monster(object *monster, struct_map_info *map) {
630  struct_race *race;
631 
632  if (monster->head && monster != monster->head)
633  return;
634 
635  map->min_monster = MIN(monster->level, map->min_monster);
636  map->max_monster = MAX(monster->level, map->max_monster);
637 
638  race = get_race(monster->name);
639  add_map(map, &race->origin);
640  add_race_to_list(race, &map->monsters, 1);
641 }
642 
651 static int sort_race(const void *a, const void *b) {
652  const struct_race *l = *(const struct_race **)a;
653  const struct_race *r = *(const struct_race **)b;
654  return strcasecmp(l->name, r->name);
655 }
656 
664 static int is_road(object *item) {
665  int test;
666  /* Archetypes used as roads. */
667  const char *roads[] = {
668  "cobblestones",
669  "flagstone",
670  "ice_stone",
671  "snow",
672  NULL };
673  const char *partial[] = {
674  "dirtroad_",
675  NULL };
676 
677  for (test = 0; partial[test] != NULL; test++) {
678  if (strstr(item->arch->name, partial[test]) != NULL)
679  return 1;
680  }
681 
683  return 0;
684 
685  for (test = 0; roads[test] != NULL; test++) {
686  if (strcmp(item->arch->name, roads[test]) == 0)
687  return 1;
688  }
689 
690  return 0;
691 }
692 
700 static int is_blocking(object *item) {
701  return item->move_block == MOVE_ALL ? 1 : 0;
702 }
703 
714 static int get_elevation_color(int elevation, gdImagePtr elevationmap) {
715  if (elevation > 0)
716  return gdImageColorResolve(elevationmap, 200*elevation/elevation_max, 0, 0);
717  else
718  return gdImageColorResolve(elevationmap, 0, 0, 200*elevation/elevation_min);
719 }
720 
729 static void do_exit_map(mapstruct *map) {
730  int tx, ty, x, y;
731  object *test;
732  sstring selevation;
733 
734  if (sscanf(map->path, "/world/world_%d_%d", &x, &y) != 2)
735  return;
736 
737  x -= 100;
738  y -= 100;
739 
740  for (tx = 0; tx < MAP_WIDTH(map); tx++) {
741  for (ty = 0; ty < MAP_HEIGHT(map); ty++) {
742  FOR_MAP_PREPARE(map, tx, ty, item) {
743  test = HEAD(item);
744 
745  if (test->type == EXIT || test->type == TELEPORTER) {
746  if (!test->slaying)
747  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_unlinked_exit);
748  else
749  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_linked_exit);
750  } else if (is_road(test))
751  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_road);
752  else if (is_blocking(test)) {
753  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_blocking);
754  /* can't get on the spot, so no need to go on. */
755  break;
756  } else if (test->move_slow != 0)
757  gdImageSetPixel(infomap, x*50+tx, y*50+ty, color_slowing);
758 
759  selevation = object_get_value(item, "elevation");
760  if (selevation) {
761  int32_t elevation = atoi(selevation);
762  elevation_min = MIN(elevation_min, elevation);
763  elevation_max = MAX(elevation_max, elevation);
764  elevation_info[x*50+tx][y*50+ty] = elevation;
765  }
766  } FOR_MAP_FINISH();
767  }
768  }
769 }
770 
771 void do_auto_apply(mapstruct *m);
772 
785 static void relative_path(const char *from, const char *to, char *result) {
786  const char *fslash;
787  const char *rslash;
788 
789  result[0] = '\0';
790 
791  fslash = strchr(from+1, '/');
792  if (!fslash) {
793  strcpy(result, to+1);
794  return;
795  }
796 
797  rslash = strchr(to+1, '/');
798  while (fslash && rslash && (fslash-from == rslash-to) && strncmp(from, to, fslash-from+1) == 0) {
799  from = fslash+1;
800  to = rslash+1;
801  fslash = strchr(fslash+1, '/');
802  rslash = strchr(rslash+1, '/');
803  }
804 
805  while (fslash) {
806  strcat(result, "../");
807  fslash = strchr(fslash+1, '/');
808  }
809  if (strlen(result) && result[strlen(result)-1] == '/' && *to == '/')
810  result[strlen(result)-1] = '\0';
811  strcat(result, to);
812 }
813 
824 static int compare_map_info(const struct_map_info *left, const struct_map_info *right) {
825  int c;
826 
827  if (left->tiled_group)
828  left = left->tiled_group;
829  if (right->tiled_group)
830  right = right->tiled_group;
831 
832  c = strcasecmp(left->name, right->name);
833  if (c)
834  return c;
835 
836  return strcasecmp(left->path, right->path);
837 }
838 
849 static int sort_map_info(const void *left, const void *right) {
850  const struct_map_info *l = *(const struct_map_info **)left;
851  const struct_map_info *r = *(const struct_map_info **)right;
852  return compare_map_info(l, r);
853 }
854 
865 static int sort_region(const void *left, const void *right) {
866  return strcmp((*((struct_region_info **)left))->reg->name, (*((struct_region_info **)right))->reg->name);
867 }
868 
869 /************************************
870  Start of quest-related definitions.
871 ************************************/
872 
876  char *description;
877  struct struct_quest *quest;
878 };
879 
881 struct struct_quest {
882  char *name;
883  char *description;
884  int number;
887 };
888 
889 static struct_quest **quests = NULL;
891 static int quests_count = 0;
893 static int quests_allocated = 0;
896  list->list = NULL;
897  list->count = 0;
898  list->allocated = 0;
899 }
900 
902  if (list->count == list->allocated) {
903  list->allocated += 10;
904  list->list = (struct_map_in_quest **)realloc(list->list, sizeof(struct_map_in_quest *)*list->allocated);
905  }
906  list->list[list->count++] = item;
907 }
908 
914 static struct_quest *find_quest_info(const char *name) {
915  int test;
916  for (test = 0; test < quests_count; test++) {
917  if (strcmp(quests[test]->name, name) == 0)
918  return quests[test];
919  }
920  return NULL;
921 }
922 
931 static struct_quest *get_quest_info(const char *name) {
933  if (add) {
934  return add;
935  }
936 
938  quests_allocated += 10;
939  quests = (struct_quest **)realloc(quests, sizeof(struct_quest *)*quests_allocated);
940  }
941  add = (struct_quest *)calloc(1, sizeof(struct_quest));
942  add->name = strdup(name);
943  add->number = quests_count;
945  quests[quests_count] = add;
946  quests_count++;
947  return add;
948 }
949 
960 static void add_map_to_quest(struct_map_info *map, const char *name, const char *description) {
961  struct_map_in_quest *add;
963 
964  add = (struct_map_in_quest *)calloc(1, sizeof(struct_map_in_quest));
965  add->map = map;
966  add->quest = quest;
967  add->description = strdup(description);
968  while (strlen(add->description) && add->description[strlen(add->description)-1] == '\n')
969  add->description[strlen(add->description)-1] = '\0';
971  add_to_struct_map_in_quest_list(&map->quests, add);
972 }
973 
982 static int sort_struct_map_in_quest(const void *left, const void *right) {
983  int c;
984 
985  const struct_map_in_quest *l = *(const struct_map_in_quest **)left;
986  const struct_map_in_quest *r = *(const struct_map_in_quest **)right;
987  const struct_map_info *ml = l->map;
988  const struct_map_info *mr = r->map;
989 
990  if (ml->tiled_group)
991  ml = ml->tiled_group;
992  if (mr->tiled_group)
993  mr = mr->tiled_group;
994 
995  c = strcasecmp(ml->name, mr->name);
996  if (c)
997  return c;
998 
999  return strcasecmp(ml->path, mr->path);
1000 }
1001 
1010 static int sort_struct_quest(const void *left, const void *right) {
1011  const struct_quest *l = *(const struct_quest **)left;
1012  const struct_quest *r = *(const struct_quest **)right;
1013  return strcasecmp(l->name, r->name);
1014 }
1015 
1026 static void define_quest(const char *name, struct_map_info *mainmap, const char *description) {
1028 
1029  if (quest->description || quest->mainmap) {
1030  printf("warning, multiple quest definition for %s, found in %s and %s.\n", quest->name, quest->mainmap ? quest->mainmap->path : "(unknown map)", mainmap->path);
1031  return;
1032  }
1033  quest->description = strdup(description);
1034  while (strlen(quest->description) && quest->description[strlen(quest->description)-1] == '\n')
1035  quest->description[strlen(quest->description)-1] = '\0';
1036  quest->mainmap = mainmap;
1037 }
1038 
1046  char *start, *end, *next;
1047  char name[500];
1048  char description[500];
1049 
1050  start = strstr(map->lore, "@def");
1051  while (start) {
1052  description[0] = '\0';
1053  /* find name */
1054  end = strstr(start, "\n");
1055  if (end) {
1056  strncpy(name, start+5, end-start-5);
1057  name[end-start-5] = '\0';
1058  next = end+1;
1059  end = strstr(next, "@end");
1060  if (end) {
1061  strncpy(description, next, end-next);
1062  description[end-next] = '\0';
1063  /* need to erase the text. */
1064  memmove(start, end+4, strlen(map->lore)-(end-start+3));
1065  end = start;
1066  }
1067  else {
1068  strcpy(description, next);
1069  *start = '\0';
1070  end = NULL;
1071  }
1072  } else {
1073  strcpy(name, start);
1074  *start = '\0';
1075  end = NULL;
1076  }
1077 
1078  define_quest(name, map, description);
1079  start = end ? strstr(end, "@def") : NULL;
1080  }
1081 
1082  start = strstr(map->lore, "@quest");
1083  while (start) {
1084  description[0] = '\0';
1085  /* find name */
1086  end = strstr(start, "\n");
1087  if (end) {
1088  strncpy(name, start+7, end-start-7);
1089  name[end-start-7] = '\0';
1090  next = end+1;
1091  end = strstr(next, "@end");
1092  if (end) {
1093  strncpy(description, next, end-next);
1094  description[end-next] = '\0';
1095  /* need to erase the text. */
1096  memmove(start, end+4, strlen(map->lore)-(end-start+3));
1097  end = start;
1098  }
1099  else {
1100  strcpy(description, next);
1101  *start = '\0';
1102  end = NULL;
1103  }
1104  } else {
1105  strcpy(name, start);
1106  *start = '\0';
1107  end = NULL;
1108  }
1109 
1110  add_map_to_quest(map, name, description);
1111  start = end ? strstr(end, "@quest") : NULL;
1112  }
1113 }
1114 
1115 /************************************
1116  End of quest-related definitions.
1117 ************************************/
1118 
1119 /*********
1120 NPC-related stuff
1121 ********/
1122 
1130 static struct_npc_info *create_npc_info(const object *npc) {
1131  struct_npc_info *info = (struct_npc_info *)calloc(1, sizeof(struct_npc_info));
1132 
1133  info->name = strdup(npc->name);
1134  info->message = strdup(npc->msg);
1135  info->x = npc->x;
1136  info->y = npc->y;
1137 
1138  return info;
1139 }
1140 
1148 static void add_npc_to_map(npc_list *list, const object *npc) {
1149  list->push_back(create_npc_info(npc));
1150 }
1151 /* end of NPC stuff */
1152 
1165  size_t map;
1166 
1167  for (map = 0; map < list->count; map++)
1168  if (list->maps[map] == info)
1169  return;
1170 
1171  if (list->count == list->allocated) {
1172  list->allocated += 50;
1173  list->maps = (struct_map_info **)realloc(list->maps, list->allocated*sizeof(struct_map_info *));
1174  }
1175  list->maps[list->count] = info;
1176  list->count++;
1177 }
1178 
1186  struct_map_info *add = (struct_map_info *)calloc(1, sizeof(struct_map_info));
1187 
1188  add->min_monster = 2000;
1189  init_map_list(&add->exits_to);
1190  init_map_list(&add->exits_from);
1191  init_map_list(&add->tiled_maps);
1193  init_race_list(&add->monsters);
1194  add->npcs = new npc_list();
1195  add->readable = new npc_list();
1196  add->tiled_group = NULL;
1197 
1198  return add;
1199 }
1200 
1209 
1210  add_map(add, &tiled_map_list);
1211  return add;
1212 }
1213 
1224  size_t g;
1225  struct_map_info *group = tiled_map->tiled_group;
1226  struct_map_info *change;
1227 
1228  while (group->tiled_maps.count > 0) {
1229  change = group->tiled_maps.maps[group->tiled_maps.count-1];
1230  change->tiled_group = map->tiled_group;
1231  add_map(change, &map->tiled_group->tiled_maps);
1232  group->tiled_maps.count--;
1233  }
1234 
1235  for (g = 0; g < tiled_map_list.count; g++) {
1236  if (tiled_map_list.maps[g] == group) {
1237  if (g < tiled_map_list.count-1)
1240  free(group);
1241  return;
1242  }
1243  }
1244  printf("tiled_map not in tiled_map_list!");
1245  abort();
1246 
1247 }
1248 
1257 static struct_map_info *get_map_info(const char *path) {
1258  struct_map_info *add;
1259  char *tmp;
1260 
1261  for (size_t map = 0; map < maps_list.count; map++) {
1262  if (strcmp(maps_list.maps[map]->path, path) == 0)
1263  return maps_list.maps[map];
1264  }
1265 
1266  add = create_map_info();
1267  add->path = strdup(path);
1268  tmp = strrchr((char *)path, '/');
1269  if (tmp)
1270  add->filename = strdup(tmp+1);
1271  else
1272  add->filename = strdup(path);
1273 
1274  add_map(add, &maps_list);
1275  return add;
1276 }
1277 
1284 static void list_map(const char *path) {
1285  for (auto map = found_maps.begin(); map != found_maps.end(); ++map) {
1286  if (strcmp(path, *map) == 0) {
1287  free(*map);
1288  found_maps.erase(map);
1289  return;
1290  }
1291  }
1292  printf("Map processed but not found in directory reading? %s\n", path);
1293 }
1294 
1306  size_t test;
1307  int x, y;
1308 
1309  for (test = 0; test < region_count; test++) {
1310  if (regions[test]->reg == reg)
1311  break;
1312  }
1313  if (test == region_count) {
1314  if (test == region_allocated) {
1315  region_allocated++;
1317  regions[test] = (struct_region_info *)calloc(1, sizeof(struct_region_info));
1318  }
1319  region_count++;
1320  regions[test]->reg = reg;
1321  }
1322  add_map(map, &regions[test]->maps_list);
1323  if (sscanf(map->path, "/world/world_%d_%d", &x, &y) == 2) {
1324  regions[test]->sum_x += (x-100);
1325  regions[test]->sum_y += (y-100);
1326  regions[test]->sum++;
1327  regions[test]->is_world = 1;
1328  }
1329 }
1330 
1339 static void save_picture(FILE *file, gdImagePtr pic) {
1340  if (output_format == OF_PNG)
1341  gdImagePng(pic, file);
1342  else
1343  gdImageJpeg(pic, file, jpeg_quality);
1344 }
1345 
1353 static void add_region_link(mapstruct *source, mapstruct *dest) {
1354  region *s, *d;
1355 
1356  s = get_region_by_map(source);
1357  d = get_region_by_map(dest);
1358  if (s == d)
1359  return;
1360 
1361  region_links[s].insert(d);
1362 }
1363 
1372 static int is_slaying(object *item) {
1373  return (item->type == LOCKED_DOOR || item->type == SPECIAL_KEY || item->type == CONTAINER || item->type == CHECK_INV);
1374 }
1375 
1376 
1385 static struct_slaying_info *get_slaying_struct(const char *slaying) {
1386  for (size_t l = 0; l < slaying_count; l++) {
1387  if (!strcmp(slaying_info[l]->slaying, slaying))
1388  return slaying_info[l];
1389  }
1391  slaying_allocated += 10;
1393  }
1394 
1395  struct_slaying_info *add = (struct_slaying_info *)calloc(1, sizeof(struct_slaying_info));
1396  add->slaying = strdup(slaying);
1397  for (size_t l = 0; l < S_MAX; l++)
1398  init_map_list(&add->maps[l]);
1399 
1400  slaying_info[slaying_count] = add;
1401  slaying_count++;
1402 
1403  return add;
1404 }
1405 
1417  add_map(map, &info->maps[item]);
1418 }
1419 
1428 static void add_slaying(struct_map_info *map, object *item) {
1429  struct_slaying_info *info;
1430 
1431  if (!item->slaying)
1432  /* can be undefined */
1433  return;
1434 
1435  info = get_slaying_struct(item->slaying);
1436  if (item->type == LOCKED_DOOR)
1437  add_map_to_slaying(info, S_DOOR, map);
1438  else if (item->type == SPECIAL_KEY)
1439  add_map_to_slaying(info, S_KEY, map);
1440  else if (item->type == CONTAINER)
1442  else if (item->type == DETECTOR)
1444  else
1446 }
1447 
1458  if (is_slaying(inv))
1459  add_slaying(map, inv);
1461  } FOR_INV_FINISH();
1462 }
1463 
1464 static void generate_picture_path(const char *path, size_t pic_size, char *out, size_t len) {
1465  snprintf(out, len, "%s%s.x%zu%s", root, path, pic_size + 1, output_extensions[output_format]);
1466 }
1467 
1468 static void write_pictures_from_real_size(const char *path, gdImagePtr real, int width, int height) {
1469  char picpath[MAX_BUF];
1470 
1471  generate_picture_path(path, 0, picpath, sizeof(picpath));
1472  make_path_to_file(picpath);
1473  FILE *out = fopen(picpath, "wb+");
1474  save_picture(out, real);
1475  fclose(out);
1476 
1477  for (size_t i = 1; i < num_sizes; i++) {
1478  generate_picture_path(path, i, picpath, sizeof(picpath));
1479  gdImagePtr small = gdImageCreateTrueColor(width*sizes[i], height*sizes[i]);
1480  gdImageCopyResampled(small, real, 0, 0, 0, 0, width*sizes[i], height*sizes[i], width*size_large, height*size_large);
1481  out = fopen(picpath, "wb+");
1482  save_picture(out, small);
1483  fclose(out);
1484  gdImageDestroy(small);
1485  }
1486 }
1487 
1496 static void process_map(struct_map_info *info) {
1497  mapstruct *m;
1498  int x, y, isworld;
1499  gdImagePtr pic = nullptr;
1500  struct stat stats;
1501  struct stat statspic;
1502  char exit_path[500];
1503  char tmppath[MAX_BUF];
1504  char picpath[num_sizes][MAX_BUF];
1505  int needpic = 0;
1506  struct_map_info *link;
1507 
1508  if (list_unused_maps)
1509  list_map(info->path);
1510 
1511  if (show_maps)
1512  printf(" processing map %s\n", info->path);
1513 
1514  m = ready_map_name(info->path, 0);
1515  if (!m) {
1516  printf("couldn't load map %s\n", info->path);
1517  return;
1518  }
1519 
1520  do_exit_map(m);
1521 
1522  if (!rawmaps)
1523  do_auto_apply(m);
1524 
1525  info->level = m->difficulty;
1526  if (m->maplore) {
1527  info->lore = strdup(m->maplore);
1528  process_map_lore(info);
1529  }
1530  if (m->reset_group) {
1531  info->reset_group = add_string(m->reset_group);
1532  reset_groups.insert(m->reset_group);
1533  }
1534 
1535  isworld = (sscanf(info->path, "/world/world_%d_%d", &x, &y) == 2);
1536 
1537  if (m->name)
1538  info->name = strdup(m->name);
1539  else
1540  info->name = strdup(info->filename);
1541 
1542  info->cfregion = get_region_by_map(m);
1543  add_map_to_region(info, info->cfregion);
1544 
1545  for (int i = 0; i < num_sizes; i++) {
1546  generate_picture_path(info->path, i, picpath[i], sizeof(picpath[i]));
1547  }
1548 
1549  if (force_pics)
1550  needpic = 1;
1551  else if (generate_pics) {
1552  create_pathname(info->path, tmppath, MAX_BUF);
1553  stat(tmppath, &stats);
1554  if (stat(picpath[0], &statspic) || (statspic.st_mtime < stats.st_mtime))
1555  needpic = 1;
1556  }
1557  else
1558  needpic = 0;
1559 
1560  if (needpic) {
1561  pic = gdImageCreateTrueColor(MAP_WIDTH(m)*size_large, MAP_HEIGHT(m)*size_large);
1562  created_pics++;
1563  }
1564  else
1565  cached_pics++;
1566 
1567  for (x = 0; x < 4; x++)
1568  if (m->tile_path[x] != NULL) {
1569  path_combine_and_normalize(m->path, m->tile_path[x], exit_path, sizeof(exit_path));
1570  create_pathname(exit_path, tmppath, MAX_BUF);
1571  if (stat(tmppath, &stats)) {
1572  printf(" map %s doesn't exist in map %s, for tile %d.\n", exit_path, info->path, x);
1573  }
1574 
1575  if (isworld) {
1576  link = get_map_info(exit_path);
1577  add_map(link, &info->exits_from);
1578  add_map(info, &link->exits_to);
1579 
1580  if (do_regions_link) {
1581  mapstruct *link = ready_map_name(exit_path, 0);
1582 
1583  if (link && link != m) {
1584  /* no need to link a map with itself. Also, if the exit points to the same map, we don't
1585  * want to reset it. */
1586  add_region_link(m, link);
1587  link->reset_time = 1;
1588  link->in_memory = MAP_IN_MEMORY;
1589  delete_map(link);
1590  }
1591  }
1592  } else {
1593  link = get_map_info(exit_path);
1594  info->tiles[x] = link;
1595  if (link->tiled_group) {
1596  if (info->tiled_group && link->tiled_group != info->tiled_group) {
1597  merge_tiled_maps(info, link);
1598  continue;
1599  }
1600  if (link->tiled_group == info->tiled_group) {
1601  continue;
1602  }
1603  if (!info->tiled_group) {
1604  add_map(info, &link->tiled_group->tiled_maps);
1605  continue;
1606  }
1607  }
1608 
1609  if (!info->tiled_group) {
1610  info->tiled_group = create_tiled_map();
1611  add_map(info, &info->tiled_group->tiled_maps);
1612  }
1613  link->tiled_group = info->tiled_group;
1614  add_map(link, &info->tiled_group->tiled_maps);
1615  }
1616  }
1617 
1618  info->width = MAP_WIDTH(m);
1619  info->height = MAP_HEIGHT(m);
1620 
1621  for (x = MAP_WIDTH(m)-1; x >= 0; x--)
1622  for (y = MAP_HEIGHT(m)-1; y >= 0; y--) {
1623  FOR_MAP_PREPARE(m, x, y, item) {
1624  if (item->type == EXIT || item->type == TELEPORTER || item->type == PLAYER_CHANGER) {
1625  char ep[500];
1626  const char *start;
1627 
1628  if (!item->slaying) {
1629  ep[0] = '\0';
1630  if (warn_no_path)
1631  printf(" exit without any path at %d, %d on %s\n", item->x, item->y, info->path);
1632  } else {
1633  memset(ep, 0, 500);
1634  if (strcmp(item->slaying, "/!"))
1635  strcpy(ep, EXIT_PATH(item));
1636  else {
1637  if (!item->msg) {
1638  printf(" random map without message in %s at %d, %d\n", info->path, item->x, item->y);
1639  } else {
1640  /* Some maps have a 'exit_on_final_map' flag, ignore it. */
1641  start = strstr(item->msg, "\nfinal_map ");
1642  if (!start && strncmp(item->msg, "final_map", strlen("final_map")) == 0)
1643  /* Message start is final_map, nice */
1644  start = item->msg;
1645  if (start) {
1646  char *end = strchr((char *)start+1, '\n');
1647 
1648  start += strlen("final_map")+2;
1649  strncpy(ep, start, end-start);
1650  }
1651  }
1652  }
1653 
1654  if (strlen(ep)) {
1655  path_combine_and_normalize(m->path, ep, exit_path, 500);
1656  create_pathname(exit_path, tmppath, MAX_BUF);
1657  if (stat(tmppath, &stats)) {
1658  printf(" map %s doesn't exist in map %s, at %d, %d.\n", ep, info->path, item->x, item->y);
1659  } else {
1660  link = get_map_info(exit_path);
1661  add_map(link, &info->exits_from);
1662  add_map(info, &link->exits_to);
1663 
1664  if (do_regions_link) {
1665  mapstruct *link = ready_map_name(exit_path, 0);
1666 
1667  if (link && link != m) {
1668  /* no need to link a map with itself. Also, if the exit points to the same map, we don't
1669  * want to reset it. */
1670  add_region_link(m, link);
1671  link->reset_time = 1;
1672  link->in_memory = MAP_IN_MEMORY;
1673  delete_map(link);
1674  }
1675  }
1676  }
1677  }
1678  }
1679  } else if (is_slaying(item))
1680  add_slaying(info, item);
1681 
1682  check_equipment(item, info);
1683 
1685 
1686  if (QUERY_FLAG(item, FLAG_MONSTER)) {
1687  /* need to get the "real" archetype, as the item's archetype can certainly be a temporary one. */
1688  archetype *arch = find_archetype(item->arch->name);
1689 
1690  add_monster(item, info);
1691  if (arch != NULL && (QUERY_FLAG(item, FLAG_UNAGGRESSIVE) || QUERY_FLAG(item, FLAG_FRIENDLY)) && (item->msg != arch->clone.msg) && (item->msg != NULL))
1692  add_npc_to_map(info->npcs, item);
1693  } else if ((item->type == SIGN || item->type == BOOK) && (item->msg != item->arch->clone.msg) && (item->msg != NULL)) {
1694  add_npc_to_map(info->readable, item);
1695  }
1696 
1697  if (item->invisible)
1698  continue;
1699 
1700  if (needpic) {
1701  int sx, sy, hx, hy;
1702 
1703  if (gdfaces[item->face->number] == NULL) {
1704  face_sets *fs = find_faceset(get_face_fallback(tileset, item->face->number));
1705 
1706  gdfaces[item->face->number] = gdImageCreateFromPngPtr(fs->faces[item->face->number].datalen, fs->faces[item->face->number].data);
1707  pics_allocated++;
1708  }
1709  if (item->head || item->more) {
1710  object_get_multi_size(item, &sx, &sy, &hx, &hy);
1711  } else {
1712  hx = 0;
1713  hy = 0;
1714  }
1715  if (gdfaces[item->face->number] != NULL && ((!item->head && !item->more) || (item->arch->clone.x+hx == 0 && item->arch->clone.y+hy == 0))) {
1716  gdImageCopy(pic, gdfaces[item->face->number], x*size_large, y*size_large, 0, 0, gdfaces[item->face->number]->sx, gdfaces[item->face->number]->sy);
1717  }
1718  }
1719  } FOR_MAP_FINISH();
1720  }
1721 
1722  if (needpic) {
1724  gdImageDestroy(pic);
1725  info->pic_was_done = 1;
1726  }
1727 
1728  m->reset_time = 1;
1729  m->in_memory = MAP_IN_MEMORY;
1730  delete_map(m);
1731 }
1732 
1736 static void write_world_map(void) {
1737 #define SIZE 50
1738  int x, y;
1739  FILE *out;
1740  int wx, wy;
1741  char file[500];
1742  char mapleft[10], maptop[10], mapright[10], mapbottom[10], mappath[5000];
1743  char name[100];
1744  gdImagePtr pic;
1745  gdImagePtr small;
1746  gdFontPtr font;
1747  int color;
1748 
1749  if (!world_map)
1750  return;
1751 
1752  printf("Generating world map in world.html...");
1753  fflush(stdout);
1754 
1755  pic = gdImageCreateTrueColor(SIZE*30, SIZE*30);
1756 
1757  strcpy(file, root);
1758  strcat(file, "/world.html");
1759 
1760  wx = 100;
1761  wy = 100;
1762 
1763  for (y = 0; y < 30; y++) {
1764  for (x = 0; x < 30; x++) {
1765  snprintf(name, sizeof(name), "world_%d_%d", wx, wy);
1766  snprintf(mapleft, sizeof(mapleft), "%d", SIZE*x);
1767  snprintf(maptop, sizeof(maptop), "%d", SIZE*y);
1768  snprintf(mapright, sizeof(mapright), "%d", SIZE*(x+1)-1);
1769  snprintf(mapbottom, sizeof(mapbottom), "%d", SIZE*(y+1)-1);
1770 
1771  snprintf(mappath, sizeof(mappath), "%s/world/%s.x1%s", root, name, output_extensions[output_format]);
1772 
1773  out = fopen(mappath, "rb");
1774  if (!out) {
1775  printf("\n warning: large pic not found for world_%d_%d", wx, wy);
1776  wx++;
1777  continue;
1778  }
1779  if (output_format == OF_PNG)
1780  small = gdImageCreateFromPng(out);
1781  else
1782  small = gdImageCreateFromJpeg(out);
1783  fclose(out);
1784  if (!small) {
1785  printf("\n warning: pic not found for world_%d_%d", wx, wy);
1786  wx++;
1787  continue;
1788  }
1789  gdImageCopyResized(pic, small, SIZE*x, SIZE*y, 0, 0, SIZE, SIZE, small->sx, small->sy);
1790  gdImageDestroy(small);
1791 
1792  wx++;
1793  }
1794  wy++;
1795  wx = 100;
1796  }
1797 
1798  snprintf(mappath, sizeof(mappath), "%s/world_raw%s", root, output_extensions[output_format]);
1799  out = fopen(mappath, "wb+");
1800  save_picture(out, pic);
1801  fclose(out);
1802 
1803  /* Write region names. */
1804  small = gdImageCreateTrueColor(SIZE*30, SIZE*30);
1805  font = gdFontGetGiant();
1806  color = gdImageColorAllocateAlpha(pic, 255, 0, 0, 20);
1807  for (size_t region = 0; region < region_allocated; region++) {
1808  if (!regions[region]->is_world || regions[region]->sum == 0)
1809  continue;
1810 
1811  x = regions[region]->sum_x*SIZE/regions[region]->sum+SIZE/2-strlen(regions[region]->reg->name)*font->w/2;
1812  y = regions[region]->sum_y*SIZE/regions[region]->sum+SIZE/2-font->h/2;
1813  gdImageString(small, font, x, y, (unsigned char *)regions[region]->reg->name, color);
1814  gdImageString(pic, font, x, y, (unsigned char *)regions[region]->reg->name, color);
1815 
1816  /* For exit/road map, size isn't the same. */
1817  x = regions[region]->sum_x*50/regions[region]->sum+50/2-strlen(regions[region]->reg->name)*font->w/2;
1818  y = regions[region]->sum_y*50/regions[region]->sum+50/2-font->h/2;
1819  gdImageString(infomap, font, x, y, (unsigned char *)regions[region]->reg->name, color);
1820  }
1821 
1822  snprintf(mappath, sizeof(mappath), "%s/world_regions%s", root, output_extensions[output_format]);
1823  out = fopen(mappath, "wb+");
1824  save_picture(out, small);
1825  fclose(out);
1826  gdImageDestroy(small);
1827 
1828  snprintf(mappath, sizeof(mappath), "%s/world%s", root, output_extensions[output_format]);
1829  out = fopen(mappath, "wb+");
1830  save_picture(out, pic);
1831  fclose(out);
1832  gdImageDestroy(pic);
1833 
1834  printf(" done.\n");
1835 #undef SIZE
1836 }
1837 
1839 static void fix_map_names(void) {
1840  for (size_t map = 0; map < maps_list.count; map++) {
1841  if (maps_list.maps[map]->name)
1842  continue;
1843  if (!maps_list.maps[map]->filename) {
1844  printf("map without path!\n");
1845  abort();
1846  }
1847  maps_list.maps[map]->name = strdup(maps_list.maps[map]->filename);
1848  }
1849 }
1850 
1857 static void fix_tiled_map(void) {
1858  size_t map, tile;
1859  char name[500];
1860  char *slash, *test;
1861  region *cfregion;
1862 
1863  for (map = 0; map < tiled_map_list.count; map++) {
1864  if (tiled_map_list.maps[map]->tiled_maps.count == 0) {
1865  printf("empty tiled map group!");
1866  abort();
1867  }
1868 
1869  snprintf(name, sizeof(name), "tiled_map_group_%zu", map);
1870  tiled_map_list.maps[map]->filename = strdup(name);
1871 
1872  cfregion = NULL;
1873  test = NULL;
1874 
1875  for (tile = 0; tile < tiled_map_list.maps[map]->tiled_maps.count; tile++) {
1877  /* map not processed, ignore it. */
1878  continue;
1879 
1880  if (!cfregion)
1882  else if (cfregion != tiled_map_list.maps[map]->tiled_maps.maps[tile]->cfregion) {
1883  printf("*** warning: tiled maps %s and %s not in same region (%s and %s).\n",
1886  cfregion = NULL;
1887  }
1888 
1890  /* map has a custom name, use it */
1891  if (!test)
1893  }
1894  }
1895 
1896  if (!test) {
1897  /* this can happen of course if only partial maps were processed, but well... */
1898  printf("*** warning: tiled map without any name. First map path %s\n", tiled_map_list.maps[map]->tiled_maps.maps[0]->path);
1899  test = name;
1900  }
1901 
1902  tiled_map_list.maps[map]->name = strdup(test);
1903  tiled_map_list.maps[map]->cfregion = cfregion;
1904 
1905  strncpy(name, tiled_map_list.maps[map]->tiled_maps.maps[0]->path, sizeof(name));
1906  slash = strrchr(name, '/');
1907  if (!slash)
1908  snprintf(name, sizeof(name), "/");
1909  else
1910  *(slash+1) = '\0';
1911  strncat(name, tiled_map_list.maps[map]->filename, sizeof(name) - strlen(name) - 1);
1912  tiled_map_list.maps[map]->path = strdup(name);
1913  }
1914 }
1915 
1926 static void fix_exits_for_map(struct_map_info *current, struct_map_list *from, int is_from) {
1927  int map, max;
1928  struct_map_info *group;
1929 
1930  max = from->count-1;
1931  for (map = max; map >= 0; map--) {
1932  if (from->maps[map]->tiled_group) {
1933  group = from->maps[map]->tiled_group;
1934  if (map != max)
1935  from->maps[map] = from->maps[max];
1936  from->count--;
1937  max--;
1938  add_map(group, from);
1939  add_map(current->tiled_group ? current->tiled_group : current, is_from ? &group->exits_to : &group->exits_from);
1940  }
1941  }
1942 }
1943 
1945 static void fix_exits_to_tiled_maps(void) {
1946  int map, max;
1947  struct_map_info *group;
1948 
1949  for (map = 0; static_cast<size_t>(map) < maps_list.count; map++) {
1952  }
1953 
1954  for (size_t region = 0; region < region_count; region++) {
1956  for (map = max; map >= 0; map--) {
1959  if (map != max)
1962  max--;
1963  add_map(group, &regions[region]->maps_list);
1964  }
1965  }
1966  }
1967 }
1968 
1973 static void fix_tiled_map_monsters(void) {
1974  int map, max;
1975  struct_map_info *group;
1976 
1977  for (size_t race = 0; race < races.count; race++) {
1978  max = races.races[race]->origin.count-1;
1979  for (map = max; map >= 0; map--) {
1980  if (races.races[race]->origin.maps[map]->tiled_group) {
1981  group = races.races[race]->origin.maps[map]->tiled_group;
1982  if (map != max)
1983  races.races[race]->origin.maps[map] = races.races[race]->origin.maps[max];
1984  races.races[race]->origin.count--;
1985  max--;
1986  add_map(group, &races.races[race]->origin);
1987  }
1988  }
1989  }
1990 
1991  for (map = 0; static_cast<size_t>(map) < maps_list.count; map++) {
1992  if (maps_list.maps[map]->tiled_group) {
1993  for (size_t race = 0; race < maps_list.maps[map]->monsters.count; race++) {
1995  }
1996  }
1997  }
1998 }
1999 
2001  size_t test;
2002  char picpath[500];
2003  struct stat stats;
2004 
2005  for (size_t size = 0; size < num_sizes; size++) {
2006  generate_picture_path(map->path, size, picpath, sizeof(picpath));
2007  if (stat(picpath, &stats))
2008  return 1;
2009  }
2010 
2011  for (test = 0; test < map->tiled_maps.count; test++) {
2012  if (map->tiled_maps.maps[test]->pic_was_done)
2013  return 1;
2014  }
2015 
2016  return 0;
2017 }
2018 
2031  int xmin = 0, xmax = 0, ymin = 0, ymax = 0, count, last;
2032  size_t tiled;
2033  char picpath[500];
2034  gdImagePtr large, load;
2035  FILE *out;
2037 
2038  if (!generate_pics)
2039  return;
2040 
2041  printf(" Generating composite map for %s...", map->name);
2042  fflush(stdout);
2043 
2044  if (!tiled_map_need_pic(map)) {
2045  printf(" already uptodate.\n");
2046  return;
2047  }
2048 
2049  count = map->tiled_maps.count;
2050  if (count == 0) {
2051  printf("Tiled map without tiled maps?\n");
2052  abort();
2053  }
2054  map->tiled_maps.maps[0]->processed = 1;
2055  map->tiled_maps.maps[0]->tiled_x_from = 0;
2056  map->tiled_maps.maps[0]->tiled_y_from = 0;
2057 
2058  while (count > 0) {
2059  last = count;
2060 
2061  for (tiled = 0; tiled < map->tiled_maps.count; tiled++) {
2062  current = map->tiled_maps.maps[tiled];
2063  if (current->processed != 1)
2064  continue;
2065 
2066  count--;
2067 
2068  if ((current->tiles[0]) && (current->tiles[0]->processed == 0)) {
2069  current->tiles[0]->processed = 1;
2070  current->tiles[0]->tiled_x_from = current->tiled_x_from;
2071  current->tiles[0]->tiled_y_from = current->tiled_y_from-current->tiles[0]->height;
2072  }
2073  if ((current->tiles[1]) && (current->tiles[1]->processed == 0)) {
2074  current->tiles[1]->processed = 1;
2075  current->tiles[1]->tiled_x_from = current->tiled_x_from+current->width;
2076  current->tiles[1]->tiled_y_from = current->tiled_y_from;
2077  }
2078  if ((current->tiles[2]) && (current->tiles[2]->processed == 0)) {
2079  current->tiles[2]->processed = 1;
2080  current->tiles[2]->tiled_x_from = current->tiled_x_from;
2081  current->tiles[2]->tiled_y_from = current->tiled_y_from+current->height;
2082  }
2083  if ((current->tiles[3]) && (current->tiles[3]->processed == 0)) {
2084  current->tiles[3]->processed = 1;
2085  current->tiles[3]->tiled_x_from = current->tiled_x_from-current->tiles[3]->width;
2086  current->tiles[3]->tiled_y_from = current->tiled_y_from;
2087  }
2088  }
2089 
2090  if (last == count) {
2091  printf("do_tiled_map_picture: didn't process any map in %s (%d left)??\n", map->path, last);
2092  abort();
2093  }
2094  }
2095 
2096  for (tiled = 0; tiled < map->tiled_maps.count; tiled++) {
2097  if (map->tiled_maps.maps[tiled]->tiled_x_from < xmin)
2098  xmin = map->tiled_maps.maps[tiled]->tiled_x_from;
2099  if (map->tiled_maps.maps[tiled]->tiled_y_from < ymin)
2100  ymin = map->tiled_maps.maps[tiled]->tiled_y_from;
2101  if (map->tiled_maps.maps[tiled]->tiled_x_from+map->tiled_maps.maps[tiled]->width > xmax)
2102  xmax = map->tiled_maps.maps[tiled]->tiled_x_from+map->tiled_maps.maps[tiled]->width;
2103  if (map->tiled_maps.maps[tiled]->tiled_y_from+map->tiled_maps.maps[tiled]->height > ymax)
2104  ymax = map->tiled_maps.maps[tiled]->tiled_y_from+map->tiled_maps.maps[tiled]->height;
2105  }
2106 
2107  large = gdImageCreateTrueColor(size_large*(xmax-xmin), size_large*(ymax-ymin));
2108 
2109  for (tiled = 0; tiled < map->tiled_maps.count; tiled++) {
2110  generate_picture_path(map->tiled_maps.maps[tiled]->path, 0, picpath, sizeof(picpath));
2111 
2112  out = fopen(picpath, "rb");
2113  if (!out) {
2114  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);
2115  continue;
2116  }
2117  if (output_format == OF_PNG)
2118  load = gdImageCreateFromPng(out);
2119  else
2120  load = gdImageCreateFromJpeg(out);
2121  fclose(out);
2122  if (!load) {
2123  printf("\n do_tiled_map_picture: warning: pic not found for %s\n", map->tiled_maps.maps[tiled]->path);
2124  continue;
2125  }
2126  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);
2127  gdImageDestroy(load);
2128  }
2129 
2130  write_pictures_from_real_size(map->path, large, xmax-xmin, ymax-ymin);
2131 
2132  gdImageDestroy(large);
2133 
2134  printf(" done.\n");
2135 }
2136 
2139 
2141 
2144 // write_map_page(map);
2145 }
2146 
2148 static void write_tiled_maps(void) {
2149  printf("Writing tiled map information...\n");
2150 
2151  for (size_t map = 0; map < tiled_map_list.count; map++)
2153 
2154  printf(" done.\n");
2155 }
2156 
2157 static std::vector<quest_definition *> system_quests;
2158 
2159 static void quest_callback(const quest_definition *quest, void *) {
2160  if (list_system_quests || !quest->quest_is_system) {
2161  system_quests.push_back(const_cast<quest_definition *>(quest));
2162  }
2163 }
2164 
2165 static std::shared_ptr<inja::Environment> env;
2167 static std::set<std::string> rendered_templates;
2168 static std::map<struct_map_info *, std::string> reverse_maps;
2169 static std::map<region *, std::string> reverse_regions;
2176 static struct_map_info *find_map_by_key(const std::string &key) {
2177  auto found = std::find_if(reverse_maps.cbegin(), reverse_maps.cend(), [&key] (auto c) { return c.second == key; });
2178  if (found != reverse_maps.cend())
2179  return found->first;
2180  return nullptr;
2181 }
2182 
2188 static region *find_region_by_key(const std::string &key) {
2189  auto found = std::find_if(reverse_regions.cbegin(), reverse_regions.cend(), [&key] (auto c) { return c.second == key; });
2190  if (found != reverse_regions.cend())
2191  return found->first;
2192  return nullptr;
2193 }
2194 
2202  for (size_t m = 0; m < maps.count; m++) {
2203  auto map = reverse_maps.find(maps.maps[m]);
2204  if (map != reverse_maps.end()) {
2205  result.push_back(map->second);
2206  }
2207  }
2208  return result;
2209 }
2210 
2218  for (size_t n = 0; n < list.size(); n++) {
2219  auto npc = list[n];
2220  result.push_back({
2221  { "name", npc->name },
2222  { "x", npc->x },
2223  { "y", npc->y },
2224  { "message", npc->message },
2225  });
2226  }
2227  return result;
2228 }
2229 
2237  for (size_t n = 0; n < list.count; n++) {
2238  auto race = list.races[n];
2239  result.push_back({
2240  { "name", race->name },
2241  { "count", race->count },
2242  });
2243  }
2244  return result;
2245 }
2246 
2254  for (size_t m = 0; m < list.count; m++) {
2255  auto q = list.list[m];
2256  if (!q->map || !q->description)
2257  continue;
2258  ret.push_back({
2259  { "map", reverse_maps.find(q->map)->second },
2260  { "description", q->description },
2261  { "quest", q->quest->name },
2262  { "number", q->quest->number },
2263  });
2264  }
2265 
2266  return ret;
2267 }
2268 
2276  return {
2277  { "_key", key },
2278  { "name", map->name },
2279  { "path", map->path },
2280  { "region", map->cfregion ? reverse_regions[map->cfregion] : "reg_ffff" },
2281  { "level", map->level },
2282  { "reset_group", map->reset_group ? map->reset_group : "" },
2283  { "lore", map->lore && map->lore[0] ? map->lore : "" },
2284  { "exits_to", create_maps_array(map->exits_to) },
2285  { "exits_from", create_maps_array(map->exits_from) },
2286  { "npcs", create_npc_array(*map->npcs) },
2287  { "readables", create_npc_array(*map->readable) },
2288  { "monsters", create_race_array(map->monsters) },
2289  { "quests", create_map_in_quest_array(map->quests) },
2290  };
2291 }
2292 
2300  return {
2301  { "_key", key },
2302  { "number", quest->number },
2303  { "name", quest->name ? quest->name : "" },
2304  { "description", quest->description ? quest->description : "" },
2305  { "main_map", quest->mainmap ? reverse_maps.find(quest->mainmap)->second : "" },
2306  { "maps", create_map_in_quest_array(quest->maps) },
2307  };
2308 }
2309 
2315  char buf[50];
2316  for (size_t map = 0; map < list.count; map++) {
2317  auto cur = list.maps[map];
2318  if (cur->tiled_group)
2319  continue;
2320  snprintf(buf, sizeof(buf), "map_%04lu", map);
2321  reverse_maps.insert(std::make_pair(cur, buf));
2322  qsort(cur->exits_to.maps, cur->exits_to.count, sizeof(struct_map_info *), sort_map_info);
2323  qsort(cur->exits_from.maps, cur->exits_from.count, sizeof(struct_map_info *), sort_map_info);
2324  qsort(cur->monsters.races, cur->monsters.count, sizeof(struct_race *), sort_race);
2325  }
2326 }
2327 
2334  for (size_t map = 0; map < src.count; map++)
2335  add_map(src.maps[map], &dest);
2336 }
2337 
2343 static nlohmann::json create_region_array(const std::set<region *> &regions) {
2345  for (auto reg : regions) {
2346  auto r = reverse_regions.find(reg);
2347  if (r != reverse_regions.end()) {
2348  ret.push_back((*r).second);
2349  }
2350  }
2351  return ret;
2352 }
2353 
2360  char buf[10];
2361  struct_map_list all_maps;
2362  bool need_unknown_region = false;
2363 
2364  init_map_list(&all_maps);
2365  append_map_list(all_maps, maps_list);
2366  append_map_list(all_maps, tiled_map_list);
2367  qsort(all_maps.maps, all_maps.count, sizeof(struct_map_info *), sort_map_info);
2368 
2369  fill_reverse_maps(all_maps);
2370 
2371  for (size_t reg = 0; reg < region_count; reg++) {
2372  auto region = regions[reg];
2373  snprintf(buf, sizeof(buf), "reg_%04lu", reg);
2374  reverse_regions.insert(std::make_pair(region->reg, buf));
2375  }
2376 
2377  for (size_t reg = 0; reg < region_count; reg++) {
2378  auto region = regions[reg];
2379  qsort(region->maps_list.maps, region->maps_list.count, sizeof(struct_map_info *), sort_map_info);
2380 
2381  json["regions"].push_back({
2382  { "_key", reverse_regions[region->reg] },
2383  { "name", region->reg->name },
2384  { "longname", region->reg->longname },
2385  { "description", region->reg->msg ? region->reg->msg : "" },
2386  { "maps", create_maps_array(region->maps_list) },
2387  { "links", create_region_array(region_links[region->reg]) },
2388  });
2389  }
2390 
2391  for (auto map : reverse_maps) {
2392  auto cur = map.first;
2393  if (cur->tiled_group)
2394  continue;
2395  if (cur->cfregion == nullptr)
2396  need_unknown_region = true;
2397  json["maps"].push_back(create_map_object(cur, map.second));
2398  }
2399 
2400  if (need_unknown_region) {
2401  json["regions"].push_back({
2402  { "_key", "reg_ffff" },
2403  { "name", "unknown" },
2404  { "longname", "unknown" },
2405  { "description", "unknown" },
2406  { "maps", nlohmann::json::array() },
2407  { "links", nlohmann::json::array() },
2408  });
2409  }
2410 
2411  json["reset_groups"] = nlohmann::json::array();
2412  for (const auto &rg : reset_groups) {
2413  json["reset_groups"].push_back(rg);
2414  }
2415 
2416  json["items"] = nlohmann::json::array();
2417  for (size_t idx = 0; idx < special_equipment.size(); idx++) {
2418  auto eq = special_equipment[idx];
2419  json["items"][idx] = {
2420  { "name", eq->name },
2421  { "power", eq->power },
2422  { "calc_power", eq->calc_power },
2423  { "diff", eq->diff },
2424  { "maps", create_maps_array(eq->origin) },
2425  };
2426  }
2427 
2428  json["monsters"] = nlohmann::json::array();
2429  for (size_t item = 0; item < races.count; item++) {
2430  auto race = races.races[item];
2431  qsort(race->origin.maps, race->origin.count, sizeof(struct_map_info *), sort_map_info);
2432  json["monsters"].push_back({
2433  { "name", race->name },
2434  { "count", race->count },
2435  { "maps", create_maps_array(race->origin) },
2436  });
2437  }
2438 
2439  json["system_quests"] = nlohmann::json::array();
2440  for (size_t q = 0; q < system_quests.size(); q++) {
2441  auto quest = system_quests[q];
2442  nlohmann::json j({
2443  { "code", quest->quest_code },
2444  { "title", quest->quest_title },
2445  { "description", quest->quest_description ? quest->quest_description : "" },
2446  { "replayable", quest->quest_restart },
2447  { "steps", nlohmann::json::array() },
2448  { "maps", nlohmann::json::array() },
2449  });
2450 
2451  if (detail_quests) {
2452  std::sort(quest->steps.begin(), quest->steps.end(), [] (auto left, auto right) { return left->step < right->step; });
2453  for (size_t s = 0; s < quest->steps.size(); s++) {
2454  j["steps"].push_back({
2455  { "description", quest->steps[s]->step_description ? quest->steps[s]->step_description : "" },
2456  { "is_completion", quest->steps[s]->is_completion_step ? true : false },
2457  });
2458  }
2459 
2460  auto qim = find_quest_info(quest->quest_code);
2461  if (qim) {
2462  for (size_t m = 0; m < qim->maps.count; m++) {
2463  auto map = reverse_maps.find(qim->maps.list[m]->map);
2464  assert(map != reverse_maps.end());
2465  j["maps"].push_back({
2466  { "description", qim->maps.list[m]->description },
2467  { "map", map->second },
2468  });
2469  }
2470  }
2471  }
2472  json["system_quests"].push_back(j);
2473  }
2474 
2475  json["slaying"] = nlohmann::json::array();
2476  for (size_t s = 0; s < slaying_count; s++) {
2477  auto info = slaying_info[s];
2478  json["slaying"].push_back({
2479  { "slaying", info->slaying },
2480  { "doors", create_maps_array(info->maps[S_DOOR]) },
2481  { "keys", create_maps_array(info->maps[S_KEY]) },
2482  { "containers", create_maps_array(info->maps[S_CONTAINER]) },
2483  { "detectors", create_maps_array(info->maps[S_DETECTOR]) },
2484  { "connections", create_maps_array(info->maps[S_CONNECT]) },
2485  });
2486  }
2487 
2488  json["quests"] = nlohmann::json::array();
2489  for (int quest = 0; quest < quests_count; quest++) {
2491  char buf[100];
2492  snprintf(buf, sizeof(buf), "quest_%d", quests[quest]->number);
2494  }
2495 }
2496 
2498 static std::vector<std::string> path_stack;
2499 
2500 void add_template_to_render(const std::string &template_name, const std::string &output_name, const std::string &param);
2501 
2507 static std::string path_from_current(const std::string &path) {
2508  auto p(path);
2509  char rel[1000];
2510  if (p[0] != '/')
2511  p = '/' + p;
2512  auto current(path_stack.back());
2513  if (current[0] != '/')
2514  current = '/' + current;
2515  relative_path(current.c_str(), p.c_str(), rel);
2516  return rel;
2517 }
2518 
2525  auto template_name = args.at(0)->get<std::string>();
2526  auto output_name(template_name);
2527  auto param = (args.size() > 1 ? args.at(1)->get<std::string>() : "");
2528 
2529  if (!param.empty()) {
2530  output_name = param + "_" + output_name;
2531  if (param.substr(0, 4) == "map_") {
2532  auto map = find_map_by_key(param);
2533  if (map != nullptr) {
2534  output_name = std::string(map->path + 1) + ".html";
2535  }
2536  }
2537  if (param.substr(0, 4) == "reg_") {
2538  auto reg = find_region_by_key(param);
2539  if (reg != nullptr) {
2540  output_name = std::string(reg->name) + ".html";
2541  }
2542  }
2543  }
2544 
2545  add_template_to_render(template_name, output_name, param);
2546  return path_from_current(output_name);
2547 }
2548 
2555  auto what = args.at(0)->get<std::string>();
2556  if (what.substr(0, 4) == "map_") {
2557  auto map = find_map_by_key(what);
2558  if (map == nullptr)
2559  return "";
2560  int size = 0;
2561  if (args.size() > 1) {
2562  size = args.at(1)->get<int>() - 1;
2563  }
2564  char picpath[1000];
2565  snprintf(picpath, sizeof(picpath), "%s.x%d%s", map->path, size + 1, output_extensions[output_format]);
2566  return path_from_current(picpath);
2567  }
2568  return "";
2569 }
2570 
2575 public:
2576  std::string template_name;
2577  std::string output_name;
2578  std::string param;
2579 };
2580 static std::vector<pageToRender> pages;
2588 void add_template_to_render(const std::string &template_name, const std::string &output_name, const std::string &param) {
2589  auto on(output_name);
2590  if (on[0] != '/')
2591  on = '/' + on;
2592  if (rendered_templates.find(on) != rendered_templates.end())
2593  return;
2594 
2595  rendered_templates.insert(on);
2596  pageToRender r;
2597  r.template_name = template_name;
2598  r.output_name = on;
2599  r.param = param;
2600  pages.push_back(r);
2601 }
2602 
2603 static std::vector<std::string> split(const std::string &field, const std::string &by) {
2604  std::vector<std::string> result;
2605  size_t start = 0, found;
2606  while ((found = field.find(by, start)) != std::string::npos) {
2607  result.push_back(field.substr(start, found - start));
2608  start = found + 1;
2609  }
2610  result.push_back(field.substr(start));
2611  return result;
2612 }
2613 
2614 static std::string templates_root("templates/");
2615 static std::vector<std::string> templates;
2620 static void init_renderer_env() {
2621  env = std::make_shared<inja::Environment>(templates_root, std::string(root) + "/");
2622  env->add_callback("link_to_page", generate_page_and_link);
2623  env->add_callback("substr", [] (inja::Arguments &args) {
2624  std::string str = args.at(0)->get<std::string>();
2625  size_t start = args.at(1)->get<size_t>();
2626  size_t len = args.size() > 2 ? args.at(2)->get<size_t>() : std::string::npos;
2627  return str.substr(start, len);
2628  });
2629  env->add_callback("picture", generate_picture_link);
2630  env->add_callback("pad", [] (inja::Arguments &args) {
2631  char buf[50];
2632  int val = args.at(0)->get<int>(), digits = args.at(1)->get<int>();
2633  snprintf(buf, sizeof(buf), "%0*d", digits, val);
2634  return std::string(buf);
2635  });
2636  env->add_callback("path_to_root", 0, [] (inja::Arguments &) {
2637  std::string r(root);
2638  char rel[1000];
2639  auto current(path_stack.back() + '/');
2640  if (current[0] != '/')
2641  current = '/' + current;
2642  relative_path(current.c_str(), r.c_str(), rel);
2643  return std::string(rel);
2644  });
2645  env->add_callback("get_by_field", 3, [] (inja::Arguments &args) {
2646  const auto &src = args.at(0);
2647  auto field = args.at(1)->get<std::string>();
2648  const auto &value = args.at(2);
2649  auto found = std::find_if(src->begin(), src->end(), [&field, &value] (auto item) {
2650  return item[field] == *value;
2651  });
2652  if (found == src->end()) {
2653  return nlohmann::json();
2654  }
2655  return *found;
2656  });
2657  env->add_callback("get_list_by_field", 3, [] (inja::Arguments &args) {
2659  const auto &src = args.at(0);
2660  auto field = args.at(1)->get<std::string>();
2661  const auto filter = args.at(2);
2662  if (filter->is_array()) {
2663  std::copy_if(src->begin(), src->end(), std::back_inserter(ret), [&] (auto &item) {
2664  auto val = item[field];
2665  return std::find_if(filter->begin(), filter->end(), [&] (auto li) { return val == li; }) != filter->end();
2666  });
2667  } else {
2668  std::copy_if(src->begin(), src->end(), std::back_inserter(ret), [&] (auto &item) {
2669  return filter->get<std::string>() == item[field];
2670  });
2671  }
2672  return ret;
2673  });
2674  env->add_callback("sort", [] (inja::Arguments &args) {
2675  const auto &src = args.at(0);
2676  std::vector<nlohmann::json> ret;
2677  for (auto i : *src) {
2678  ret.push_back(i);
2679  }
2680  auto fields = split(args.at(1)->get<std::string>(), ",");
2681  bool invert = args.size() > 2 ? args.at(2)->get<bool>() : false;
2682  bool ignore_case = args.size() > 3 ? args.at(3)->get<bool>() : true;
2683  std::sort(ret.begin(), ret.end(), [&] (auto left, auto right) {
2684  for (auto field : fields) {
2685  nlohmann::json l = left[field], r = right[field];
2686  if (ignore_case && l.is_string() && r.is_string()) {
2687  std::string ls(l.get<std::string>()), rs(r.get<std::string>());
2688  std::transform(ls.begin(), ls.end(), ls.begin(), [](unsigned char c){ return std::tolower(c); });
2689  std::transform(rs.begin(), rs.end(), rs.begin(), [](unsigned char c){ return std::tolower(c); });
2690  if (ls == rs) {
2691  continue;
2692  }
2693  return invert ? (rs < ls) : (ls < rs);
2694  }
2695  if (r == l) {
2696  continue;
2697  }
2698  return invert ? (r < l) : (l < r);
2699  }
2700  return false;
2701  });
2702  return ret;
2703  });
2704 
2705  env->set_trim_blocks(true);
2706  env->set_lstrip_blocks(true);
2707 }
2708 
2710 static const char *ignore_path[] = {
2711  "/Info",
2712  "/editor",
2713  "/python",
2714  "/styles",
2715  "/templates",
2716  "/test",
2717  "/unlinked",
2718  NULL };
2719 
2721 static const char *ignore_name[] = {
2722  ".",
2723  "..",
2724  ".svn",
2725  "README",
2726  NULL };
2727 
2734 static void find_maps(const char *from) {
2735  struct dirent *file;
2736  struct stat statbuf;
2737  int status, ignore;
2738  char path[1024], full[1024];
2739  DIR *dir;
2740 
2741  for (ignore = 0; ignore_path[ignore] != NULL; ignore++) {
2742  if (strcmp(from, ignore_path[ignore]) == 0)
2743  return;
2744  }
2745 
2746  snprintf(path, sizeof(path), "%s/%s%s", settings.datadir, settings.mapdir, from);
2747  dir = opendir(path);
2748 
2749  if (dir) {
2750  for (file = readdir(dir); file; file = readdir(dir)) {
2751 
2752  for (ignore = 0; ignore_name[ignore] != NULL; ignore++) {
2753  if (strcmp(file->d_name, ignore_name[ignore]) == 0)
2754  break;
2755  }
2756  if (ignore_name[ignore] != NULL)
2757  continue;
2758 
2759  snprintf(full, sizeof(full), "%s/%s", path, file->d_name);
2760 
2761  status = stat(full, &statbuf);
2762  snprintf(full, sizeof(full), "%s/%s", from, file->d_name);
2763  if ((status != -1) && (S_ISDIR(statbuf.st_mode))) {
2764  find_maps(full);
2765  continue;
2766  }
2767  found_maps.push_back(strdup(full));
2768  }
2769  closedir(dir);
2770  }
2771 }
2772 
2774 static void dump_unused_maps(void) {
2775  FILE *dump;
2776  char path[1024];
2777 
2778  snprintf(path, sizeof(path), "%s/%s", root, "maps.unused");
2779  dump = fopen(path, "w+");
2780  if (dump == NULL) {
2781  printf("Unable to open file maps.unused!\n");
2782  return;
2783  }
2784  for (auto map = found_maps.cbegin(); map != found_maps.cend(); ++map) {
2785  fprintf(dump, "%s\n", *map);
2786  }
2787  fclose(dump);
2788  printf("%ld unused maps.\n", found_maps.size());
2789 }
2790 
2792 static void write_world_info(void) {
2793  FILE *file;
2794  char path[MAX_BUF];
2795  int x, y;
2796  gdImagePtr elevationmap;
2797 
2798  if (!world_exit_info)
2799  return;
2800 
2801  printf("Saving exit/blocking/road information...");
2802  snprintf(path, sizeof(path), "%s/%s%s", root, "world_info", output_extensions[output_format]);
2803  file = fopen(path, "wb+");
2805  fclose(file);
2806  printf("done.\n");
2807  gdImageDestroy(infomap);
2808  infomap = NULL;
2809 
2810  if (elevation_min == 0 || elevation_max == 0) {
2811  puts("Error: Could not save elevation world map due to not finding any minimum or maximum elevation.");
2812  return;
2813  }
2814 
2815  elevationmap = gdImageCreateTrueColor(30*50, 30*50);;
2816 
2817  for (x = 0; x < 30*50; x++) {
2818  for (y = 0; y < 30*50; y++) {
2819  gdImageSetPixel(elevationmap, x, y, get_elevation_color(elevation_info[x][y], elevationmap));
2820  }
2821  }
2822 
2823  printf("Saving elevation world map...");
2824  snprintf(path, sizeof(path), "%s/%s%s", root, "world_elevation", output_extensions[output_format]);
2825  file = fopen(path, "wb+");
2826  save_picture(file, elevationmap);
2827  fclose(file);
2828  printf("done.\n");
2829  gdImageDestroy(elevationmap);
2830  elevationmap = NULL;
2831 }
2832 
2843 static int sort_slaying(const void *left, const void *right) {
2846 
2847  return strcasecmp(l->slaying, r->slaying);
2848 }
2849 
2856 static void do_help(const char *program) {
2857  printf("Crossfire Mapper will generate pictures of maps, and create indexes for all maps and regions.\n\n");
2858  printf("Syntax: %s\n\n", program);
2859  printf("Optional arguments:\n");
2860  printf(" -nopics don't generate pictures.\n");
2861  printf(" -root=<path> destination path. Default 'html'.\n");
2862  printf(" -limit=<number> stop processing after this number of maps, -1 to do all maps (default).\n");
2863  printf(" -showmaps outputs the name of maps as they are processed.\n");
2864  printf(" -jpg[=quality] generate jpg pictures, instead of default png. Quality should be 0-95, -1 for automatic.\n");
2865  printf(" -forcepics force to regenerate pics, even if pics's date is after map's.\n");
2866  printf(" -addmap=<map> adds a map to process. Path is relative to map's directory root.\n");
2867  printf(" -rawmaps generates maps pics without items on random (shop, treasure) tiles.\n");
2868  printf(" -warnnopath inform when an exit has no path set.\n");
2869  printf(" -listunusedmaps finds all unused maps in the maps directory.\n");
2870  printf(" -noworldmap don't write the world map in world.png.\n");
2871  printf(" -noregionslink don't generate regions relation file.\n");
2872  printf(" -regionslink generate regions relation file.\n");
2873  printf(" -noexitmap don't generate map of exits.\n");
2874  printf(" -exitmap generate map of exits.\n");
2875  printf(" -tileset=<number> use specified tileset to generate the pictures. Default 0 (standard).\n");
2876  printf(" -details-quests list all quests steps. Default no.\n");
2877  printf(" -list-system-quests include 'system' quests in quest list. Default no.\n");
2878  printf(" -templates-dir=[dir] set the directory to get templates from. Default 'templates/'.\n");
2879  printf(" -add-template=[file] add a template to process. May be specified multiple times. If empty, 'index.html' is used.\n");
2880  printf(" -list-template-to-process display the name of the template about to be rendered. Useful for debugging.");
2881  printf("\n\n");
2882  exit(0);
2883 }
2884 
2893 static void do_parameters(int argc, char **argv) {
2894  int arg = 1;
2895  char path[500];
2896 
2897  root[0] = '\0';
2898 
2899  while (arg < argc) {
2900  if (strcmp(argv[arg], "-nopics") == 0)
2901  generate_pics = 0;
2902  else if (strncmp(argv[arg], "-root=", 6) == 0)
2903  strncpy(root, argv[arg]+6, 500);
2904  else if (strncmp(argv[arg], "-limit=", 7) == 0)
2905  map_limit = atoi(argv[arg]+7);
2906  else if (strcmp(argv[arg], "-showmaps") == 0)
2907  show_maps = 1;
2908  else if (strcmp(argv[arg], "-jpg") == 0) {
2910  if (argv[arg][4] == '=') {
2911  jpeg_quality = atoi(argv[arg]+5);
2912  if (jpeg_quality < 0)
2913  jpeg_quality = -1;
2914  }
2915  }
2916  else if (strcmp(argv[arg], "-forcepics") == 0)
2917  force_pics = 1;
2918  else if (strncmp(argv[arg], "-addmap=", 8) == 0) {
2919  if (*(argv[arg]+8) == '/')
2920  strncpy(path, argv[arg]+8, 500);
2921  else
2922  snprintf(path, 500, "/%s", argv[arg]+8);
2924  }
2925  else if (strcmp(argv[arg], "-rawmaps") == 0)
2926  rawmaps = 1;
2927  else if (strcmp(argv[arg], "-warnnopath") == 0)
2928  warn_no_path = 1;
2929  else if (strcmp(argv[arg], "-listunusedmaps") == 0)
2930  list_unused_maps = 1;
2931  else if (strcmp(argv[arg], "-noworldmap") == 0)
2932  world_map = 0;
2933  else if (strcmp(argv[arg], "-noregionslink") == 0)
2934  do_regions_link = false;
2935  else if (strcmp(argv[arg], "-regionslink") == 0)
2936  do_regions_link = true;
2937  else if (strcmp(argv[arg], "-noexitmap") == 0)
2938  world_exit_info = 0;
2939  else if (strcmp(argv[arg], "-exitmap") == 0)
2940  world_exit_info = 1;
2941  else if (strncmp(argv[arg], "-tileset=", 9) == 0) {
2942  tileset = atoi(argv[arg]+9);
2943  /* check of validity is done in main() as we need to actually have the sets loaded. */
2944  } else if (strcmp(argv[arg], "-detail-quests") == 0) {
2945  detail_quests = 1;
2946  } else if (strcmp(argv[arg], "-list-system-quests") == 0) {
2947  list_system_quests = 1;
2948  } else if (strncmp(argv[arg], "-templates-dir=", 15) == 0) {
2949  templates_root = argv[arg] + 15;
2950  } else if (strncmp(argv[arg], "-add-template=", 14) == 0) {
2951  templates.push_back(argv[arg] + 14);
2952  } else if (strcmp(argv[arg], "-list-template-to-process") == 0) {
2954  } else
2955  do_help(argv[0]);
2956  arg++;
2957  }
2958  if (!strlen(root))
2959  strcpy(root, "html");
2960  if (root[strlen(root)-1] == '/')
2961  root[strlen(root)-1] = '\0';
2962  if (map_limit < -1)
2963  map_limit = -1;
2964 
2965  if (templates_root.empty()) {
2966  templates_root = "templates/";
2967  } else if (templates_root[templates_root.length() - 1] != '/') {
2968  templates_root.append("/");
2969  }
2970 }
2971 
2975 static void create_destination(void) {
2976  char dummy[502];
2977 
2978  strcpy(dummy, root);
2979  strcat(dummy, "/a");
2980  make_path_to_file(dummy);
2981 }
2982 
2991 static const char *yesno(int value) {
2992  return (value ? "yes" : "no");
2993 }
2994 
2996 static inja::Template get_template(const std::string &filename) {
2997  auto find = templateCache.find(filename);
2998  if (find != templateCache.end()) {
2999  return find->second;
3000  }
3001  inja::Template parsed = env->parse_template(filename);
3002  templateCache[filename] = parsed;
3003  return parsed;
3004 }
3005 
3006 int main(int argc, char **argv) {
3007  size_t current_map = 0, i;
3008  char max[50];
3009  region *dummy;
3010 
3014  pics_allocated = 0;
3015 
3016  do_parameters(argc, argv);
3017 
3018  printf("Initializing Crossfire data...\n");
3019 
3021 
3022  init_globals();
3023  init_library();
3024  init_readable();
3025 
3026  init_gods();
3027 
3028  /* Add a dummy region so unlinked maps can be identified. */
3029  dummy = get_region_struct();
3030  dummy->fallback = 1;
3031  dummy->name = strdup_local("unlinked");
3032  dummy->longname = strdup_local("This dummy region contains all maps without a region set.");
3033  dummy->longname = strdup_local("This dummy region contains all maps without a region set.");
3034  all_regions.push_back(dummy);
3035 
3036  printf("\n\n done.\n\n");
3037 
3038  if (!is_valid_faceset(tileset)) {
3039  printf("Erreor: invalid tileset %d!\n", tileset);
3040  exit(1);
3041  }
3042 
3043  if (templates.empty()) {
3044  templates.push_back("index.html");
3045  }
3046 
3048  gdfaces = (gdImagePtr *)calloc(get_faces_count(), sizeof(gdImagePtr));
3049 
3050  if (map_limit != -1)
3051  snprintf(max, sizeof(max), "%d", map_limit);
3052  else
3053  strcpy(max, "(none)");
3054  printf("Crossfire map browser generator\n");
3055  printf("-------------------------------\n\n");
3056  printf("Parameters:\n");
3057  printf(" path to write files: %s\n", root);
3058  printf(" maximum number of maps to process: %s\n", max);
3059  printf(" will generate map picture: %s\n", yesno(generate_pics));
3060  printf(" will always generate map picture: %s\n", yesno(force_pics));
3061  printf(" picture output format: %s\n", output_extensions[output_format]);
3062  if (output_format == OF_JPG)
3063  printf(" JPEG quality: %d\n", jpeg_quality);
3064  printf(" show map being processed: %s\n", yesno(show_maps));
3065  printf(" generate raw maps: %s\n", yesno(rawmaps));
3066  printf(" warn of exit without path: %s\n", yesno(warn_no_path));
3067  printf(" list unused maps: %s\n", yesno(list_unused_maps));
3068  printf(" generate world map: %s\n", yesno(world_map));
3069  printf(" generate exit map: %s\n", yesno(world_exit_info));
3070  printf(" generate regions link file: %s\n", yesno(do_regions_link));
3071  printf(" tileset: %s\n", find_faceset(tileset)->fullname);
3072  printf(" detail quest steps: %s\n", yesno(detail_quests));
3073  printf(" list system quests: %s\n", yesno(list_system_quests));
3074  printf(" templates directory: %s\n", templates_root.c_str());
3075  printf(" templates to process: ");
3076  const char *sep = "";
3077  for (auto f : templates) {
3078  printf("%s%s", sep, f.c_str());
3079  sep = ", ";
3080  }
3081  printf("\n");
3082  printf(" display template to process: %s\n", yesno(display_rendered_template));
3083  printf("\n");
3084 
3085  if (list_unused_maps) {
3086  printf("listing all maps...");
3087  find_maps("");
3088  printf("done, %ld maps found.\n", found_maps.size());
3089  }
3090 
3091  /* exit/blocking information. */
3092  infomap = gdImageCreateTrueColor(30*50, 30*50);
3093  color_unlinked_exit = gdImageColorResolve(infomap, 255, 0, 0);
3094  color_linked_exit = gdImageColorResolve(infomap, 255, 255, 255);
3095  color_road = gdImageColorResolve(infomap, 0, 255, 0);
3096  color_blocking = gdImageColorResolve(infomap, 0, 0, 255);
3097  color_slowing = gdImageColorResolve(infomap, 0, 0, 127);
3098  elevation_info = (int **)calloc(50*30, sizeof(int *));
3099  for (i = 0; i < 50*30; i++)
3100  elevation_info[i] = (int *)calloc(50*30, sizeof(int));
3101  elevation_min = 0;
3102  elevation_max = 0;
3103 
3104  printf("browsing maps...\n");
3105 
3107 
3108  while (current_map < maps_list.count) {
3110  if (current_map%100 == 0) {
3111  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);
3112  }
3113  if ((map_limit != -1) && (current_map == static_cast<size_t>(map_limit))) {
3114  printf(" --- map limit reached, stopping ---\n");
3115  break;
3116  }
3117  }
3118 
3119  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);
3120 
3121  if (list_unused_maps)
3122  dump_unused_maps();
3123 
3125  fix_map_names();
3126  fix_tiled_map();
3128  write_tiled_maps();
3129 
3130  write_world_map();
3131  write_world_info();
3132 
3134  qsort(regions, region_count, sizeof(struct_region_info *), sort_region);
3135  std::sort(special_equipment.begin(), special_equipment.end(), sort_equipment);
3137  qsort(races.races, races.count, sizeof(struct_race *), sort_race);
3138  qsort(quests, quests_count, sizeof(struct_quest *), sort_struct_quest);
3139 
3141  std::sort(system_quests.begin(), system_quests.end(), [] (const auto &left, const auto &right) { return strcmp(left->quest_code, right->quest_code) < 0; });
3142 
3144 
3146 
3147  for (auto file : templates) {
3148  if (!file.empty()) {
3150  }
3151  }
3152 
3153  const auto fullStart = time(nullptr);
3154  printf("rendering pages...");
3156  printf("\n");
3157  fflush(stdout);
3158 
3159  while (!pages.empty()) {
3160  auto p = pages.back();
3161  pages.pop_back();
3162  if (p.param.empty())
3163  all_data.erase("param");
3164  else
3165  all_data["param"] = p.param;
3166  const auto start = time(nullptr);
3168  printf(" rendering page %s (%s)... ", p.template_name.c_str(), p.param.c_str());
3169  fflush(stdout);
3170  }
3171  path_stack.push_back(p.output_name);
3172  inja::Template temp = get_template(p.template_name);
3173  env->write(temp, all_data, p.output_name);
3174  path_stack.pop_back();
3175  const auto elapsed = time(nullptr) - start;
3177  printf("took %ld seconds\n", elapsed);
3178  }
3179  }
3180 
3181  const auto elapsed = time(nullptr) - fullStart;
3182  printf(" done, took %ld seconds\n", elapsed);
3183 
3184  return 0;
3185 }
3186 
3188  int x, y;
3189 
3190  if (m == NULL)
3191  return;
3192 
3193  for (x = 0; x < MAP_WIDTH(m); x++)
3194  for (y = 0; y < MAP_HEIGHT(m); y++)
3195  FOR_MAP_PREPARE(m, x, y, tmp) {
3196  if (tmp->inv) {
3197  FOR_INV_PREPARE(tmp, invtmp) {
3198  if (QUERY_FLAG(invtmp, FLAG_AUTO_APPLY))
3199  apply_auto(invtmp);
3200  else if (invtmp->type == TREASURE && HAS_RANDOM_ITEMS(invtmp)) {
3201  while ((invtmp->stats.hp--) > 0)
3202  create_treasure(invtmp->randomitems, invtmp, 0, m->difficulty, 0);
3203  invtmp->randomitems = NULL;
3204  } else if (invtmp
3205  && invtmp->arch
3206  && invtmp->type != TREASURE
3207  && invtmp->type != SPELL
3208  && invtmp->type != CLASS
3209  && HAS_RANDOM_ITEMS(invtmp)) {
3210  create_treasure(invtmp->randomitems, invtmp, 0, m->difficulty, 0);
3211  /* Need to clear this so that we never try to create
3212  * treasure again for this object
3213  */
3214  invtmp->randomitems = NULL;
3215  }
3216  } FOR_INV_FINISH();
3217  /* This is really temporary - the code at the bottom will
3218  * also set randomitems to null. The problem is there are bunches
3219  * of maps/players already out there with items that have spells
3220  * which haven't had the randomitems set to null yet.
3221  * MSW 2004-05-13
3222  *
3223  * And if it's a spellbook, it's better to set randomitems to NULL too,
3224  * else you get two spells in the book ^_-
3225  * Ryo 2004-08-16
3226  */
3227  if (tmp->type == WAND
3228  || tmp->type == ROD
3229  || tmp->type == SCROLL
3230  || tmp->type == FIREWALL
3231  || tmp->type == POTION
3232  || tmp->type == ALTAR
3233  || tmp->type == SPELLBOOK)
3234  tmp->randomitems = NULL;
3235  }
3236 
3238  apply_auto(tmp);
3239  else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && HAS_RANDOM_ITEMS(tmp)) {
3240  while ((tmp->stats.hp--) > 0)
3241  create_treasure(tmp->randomitems, tmp, 0, m->difficulty, 0);
3242  tmp->randomitems = NULL;
3243  } else if (tmp->type == TIMED_GATE) {
3244  object *head = HEAD(tmp);
3245 
3246  if (QUERY_FLAG(head, FLAG_IS_LINKED)) {
3247  tmp->speed = 0;
3249  }
3250  /* This function can be called everytime a map is loaded, even when
3251  * swapping back in. As such, we don't want to create the treasure
3252  * over and ove again, so after we generate the treasure, blank out
3253  * randomitems so if it is swapped in again, it won't make anything.
3254  * This is a problem for the above objects, because they have counters
3255  * which say how many times to make the treasure.
3256  */
3257  } else if (tmp
3258  && tmp->arch
3259  && tmp->type != PLAYER
3260  && tmp->type != TREASURE
3261  && tmp->type != SPELL
3262  && tmp->type != PLAYER_CHANGER
3263  && tmp->type != CLASS
3264  && HAS_RANDOM_ITEMS(tmp)) {
3265  create_treasure(tmp->randomitems, tmp, 0, m->difficulty, 0);
3266  tmp->randomitems = NULL;
3267  }
3268  } FOR_MAP_FINISH();
3269 
3270  for (x = 0; x < MAP_WIDTH(m); x++)
3271  for (y = 0; y < MAP_HEIGHT(m); y++)
3272  FOR_MAP_PREPARE(m, x, y, tmp) {
3273  if (tmp->above
3274  && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
3275  check_trigger(tmp, tmp->above);
3276  } FOR_MAP_FINISH();
3277 }
3278 
3279 #ifndef DOXYGEN_SHOULD_SKIP_THIS
3280 
3285 void draw_ext_info(int, int, const object *, uint8_t, uint8_t, const char *txt) {
3286  fprintf(logfile, "%s\n", txt);
3287 }
3288 
3289 void draw_ext_info_format(int, int, const object *, uint8_t, uint8_t, const char *format, ...) {
3290  va_list ap;
3291 
3292  va_start(ap, format);
3293  vfprintf(logfile, format, ap);
3294  va_end(ap);
3295 }
3296 
3297 void ext_info_map(int, const mapstruct *, uint8_t, uint8_t, const char *str1) {
3298  fprintf(logfile, "ext_info_map: %s\n", str1);
3299 }
3300 
3301 void move_firewall(object *) {
3302 }
3303 
3304 void emergency_save(int) {
3305 }
3306 
3307 void clean_tmp_files(void) {
3308 }
3309 
3310 void esrv_send_item(object *, object *) {
3311 }
3312 
3313 void dragon_ability_gain(object *, int, int) {
3314 }
3315 
3317 }
3318 
3319 object *find_skill_by_number(object *, int) {
3320  return NULL;
3321 }
3322 
3323 void esrv_del_item(player *, object *) {
3324 }
3325 
3326 void esrv_update_item(int, object *, object *) {
3327 }
3328 
3330 }
3331 
3332 void rod_adjust(object *) {
3333 }
3334 
3335 /*
3336  * This a modified version of apply_auto: BOOK are not generated, so they don't pollute
3337  * the readable list.
3338  */
3339 int apply_auto(object *op) {
3340  object *tmp = NULL;
3341  int i;
3342 
3343  switch (op->type) {
3344  case SHOP_FLOOR:
3345  if (!HAS_RANDOM_ITEMS(op))
3346  return 0;
3347  do {
3348  i = 10; /* let's give it 10 tries */
3349  while ((tmp = generate_treasure(op->randomitems, op->stats.exp ? (int)op->stats.exp : MAX(op->map->difficulty, 5))) == NULL && --i)
3350  ;
3351  if (tmp == NULL)
3352  return 0;
3353  if (QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED) || tmp->type == BOOK) {
3355  tmp = NULL;
3356  }
3357  } while (!tmp);
3359  object_insert_in_map_at(tmp, op->map, NULL, 0, op->x, op->y);
3361  tmp = identify(tmp);
3362  break;
3363 
3364  case TREASURE:
3366  return 0;
3367 
3368  while ((op->stats.hp--) > 0)
3369  create_treasure(op->randomitems, op, 0, op->stats.exp ? (int)op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
3370 
3371  /* If we generated an object and put it in this object inventory,
3372  * move it to the parent object as the current object is about
3373  * to disappear. An example of this item is the random_ *stuff
3374  * that is put inside other objects.
3375  */
3376  FOR_INV_PREPARE(op, tmp) {
3377  object_remove(tmp);
3378  if (op->env && tmp->type != BOOK)
3379  object_insert_in_ob(tmp, op->env);
3380  else
3382  }
3383  FOR_INV_FINISH();
3384  object_remove(op);
3386  break;
3387  }
3388  return tmp ? 1 : 0;
3389 }
3390 
3392 }
3393 
3395  return NULL;
3396 }
3397 
3399  return NULL;
3400 }
3401 
3403  return NULL;
3404 }
3405 
3407 }
3408 
3410 }
3411 
3412 void command_help(object *, const char *) {
3413 }
3414 
3415 void account_logout(const char *) {
3416 }
3417 
3418 #endif /* dummy DOXYGEN_SHOULD_SKIP_THIS */
get_race
static struct_race * get_race(const char *name)
Definition: mapper.cpp:600
struct_map_info::tiles
struct struct_map_info * tiles[4]
Definition: mapper.cpp:232
CLASS
@ CLASS
Definition: object.h:141
object::name_pl
sstring name_pl
Definition: object.h:321
struct_region_info::sum_x
int sum_x
Definition: mapper.cpp:357
give.next
def next
Definition: give.py:44
move_firewall
void move_firewall(object *)
Definition: mapper.cpp:3301
init_globals
void init_globals(void)
Definition: init.cpp:395
write_tiled_map_page
static void write_tiled_map_page(struct_map_info *map)
Definition: mapper.cpp:2138
fix_tiled_map_monsters
static void fix_tiled_map_monsters(void)
Definition: mapper.cpp:1973
do_auto_apply
void do_auto_apply(mapstruct *m)
Definition: mapper.cpp:3187
add_map
static void add_map(struct_map_info *info, struct_map_list *list)
Definition: mapper.cpp:1164
HAS_RANDOM_ITEMS
#define HAS_RANDOM_ITEMS(op)
Definition: define.h:184
PLAYER
@ PLAYER
Definition: object.h:110
Settings::mapdir
const char * mapdir
Definition: global.h:255
global.h
FREE_OBJ_NO_DESTROY_CALLBACK
#define FREE_OBJ_NO_DESTROY_CALLBACK
Definition: object.h:534
settings
struct Settings settings
Definition: init.cpp:139
ignore_name
static const char * ignore_name[]
Definition: mapper.cpp:2721
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:931
find_region_by_key
static region * find_region_by_key(const std::string &key)
Definition: mapper.cpp:2188
FOR_MAP_FINISH
#define FOR_MAP_FINISH()
Definition: define.h:730
process_map_lore
static void process_map_lore(struct_map_info *map)
Definition: mapper.cpp:1045
find_artifact
const artifact * find_artifact(const object *op, const char *name)
Definition: artifact.cpp:589
llevError
@ llevError
Definition: logger.h:11
get_region_struct
region * get_region_struct(void)
Definition: region.cpp:294
maps
static std::unordered_map< std::string, mapzone * > maps
Definition: citylife.cpp:92
region::fallback
int8_t fallback
Definition: map.h:286
compare_map_info
static int compare_map_info(const struct_map_info *left, const struct_map_info *right)
Definition: mapper.cpp:824
path_from_current
static std::string path_from_current(const std::string &path)
Definition: mapper.cpp:2507
MOVE_ALL
#define MOVE_ALL
Definition: define.h:398
WAND
@ WAND
Definition: object.h:223
quest_for_each
void quest_for_each(quest_op op, void *user)
Definition: assets.cpp:540
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:51
struct_region_info::is_world
int is_world
Definition: mapper.cpp:358
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:2554
struct_map_info::tiled_group
struct struct_map_info * tiled_group
Definition: mapper.cpp:229
struct_map_info::filename
char * filename
Definition: mapper.cpp:213
num_sizes
static const int num_sizes
Definition: mapper.cpp:313
player
Definition: player.h:105
add_slaying
static void add_slaying(struct_map_info *map, object *item)
Definition: mapper.cpp:1428
strdup_local
#define strdup_local
Definition: compat.h:29
diamondslots.x
x
Definition: diamondslots.py:15
ready_map_name
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.cpp:1793
write_tiled_maps
static void write_tiled_maps(void)
Definition: mapper.cpp:2148
first_map_path
char first_map_path[MAX_BUF]
Definition: init.cpp:120
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
struct_quest::maps
struct_map_in_quest_list maps
Definition: mapper.cpp:886
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:2299
create_map_info
static struct_map_info * create_map_info(void)
Definition: mapper.cpp:1185
struct_race::count
int count
Definition: mapper.cpp:256
TRIGGER_PEDESTAL
@ TRIGGER_PEDESTAL
Definition: object.h:137
nlohmann::json
basic_json<> json
default JSON class
Definition: json.hpp:3404
struct_map_in_quest::map
struct_map_info * map
Definition: mapper.cpp:877
esrv_del_item
void esrv_del_item(player *, object *)
Definition: mapper.cpp:3323
pageToRender::param
std::string param
Definition: mapper.cpp:2578
S_CONNECT
#define S_CONNECT
Definition: mapper.cpp:390
write_pictures_from_real_size
static void write_pictures_from_real_size(const char *path, gdImagePtr real, int width, int height)
Definition: mapper.cpp:1468
region_links
static std::map< region *, std::set< region * > > region_links
Definition: mapper.cpp:383
get_face_fallback
int get_face_fallback(int faceset, uint16_t imageno)
Definition: image.cpp:133
Settings::datadir
const char * datadir
Definition: global.h:252
c
static event_registration c
Definition: citylife.cpp:425
filter
Definition: filter.py:1
disinfect.a
a
Definition: disinfect.py:13
output_format
static enum output_format_type output_format
Definition: mapper.cpp:342
stringbuffer_new
StringBuffer * stringbuffer_new(void)
Definition: stringbuffer.cpp:57
quests_count
static int quests_count
Definition: mapper.cpp:891
SHOP_FLOOR
@ SHOP_FLOOR
Definition: object.h:186
Ice.g
def g
Definition: Ice.py:63
create_npc_array
static nlohmann::json create_npc_array(npc_list &list)
Definition: mapper.cpp:2216
get_map_info
static struct_map_info * get_map_info(const char *path)
Definition: mapper.cpp:1257
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:1945
object::x
int16_t x
Definition: object.h:333
reverse_maps
static std::map< struct_map_info *, std::string > reverse_maps
Definition: mapper.cpp:2168
dump
static int dump(const std::set< std::string > &items, const char *name)
Definition: AssetsManager.cpp:42
guildoracle.list
list
Definition: guildoracle.py:87
struct_map_in_quest
Definition: mapper.cpp:874
slaying_allocated
static size_t slaying_allocated
Definition: mapper.cpp:401
give_artifact_abilities
void give_artifact_abilities(object *op, const object *artifact)
Definition: artifact.cpp:230
get_equipment
static struct_equipment * get_equipment(void)
Definition: mapper.cpp:435
is_special_equipment
static int is_special_equipment(object *item)
Definition: mapper.cpp:416
TIMED_GATE
@ TIMED_GATE
Definition: object.h:131
region_allocated
static size_t region_allocated
Definition: mapper.cpp:363
struct_map_list
Definition: mapper.cpp:203
generate_page_and_link
static nlohmann::json generate_page_and_link(inja::Arguments &args)
Definition: mapper.cpp:2524
struct_equipment::origin
struct_map_list origin
Definition: mapper.cpp:247
find_faceset
face_sets * find_faceset(int id)
Definition: assets.cpp:328
artifact::item
object * item
Definition: artifact.h:15
commongive.inv
inv
Definition: commongive.py:29
root
static char root[500]
Definition: mapper.cpp:304
create_map_in_quest_array
static nlohmann::json create_map_in_quest_array(struct_map_in_quest_list &list)
Definition: mapper.cpp:2252
yesno
static const char * yesno(int value)
Definition: mapper.cpp:2991
AMULET
@ AMULET
Definition: object.h:142
CHECK_INV
@ CHECK_INV
Definition: object.h:172
struct_map_info::name
char * name
Definition: mapper.cpp:212
fix_map_names
static void fix_map_names(void)
Definition: mapper.cpp:1839
mad_mage_user.file
file
Definition: mad_mage_user.py:15
struct_slaying_info::maps
struct_map_list maps[S_MAX]
Definition: mapper.cpp:396
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:113
color_unlinked_exit
static int color_unlinked_exit
Definition: mapper.cpp:370
struct_region_info::sum_y
int sum_y
Definition: mapper.cpp:357
pages
static std::vector< pageToRender > pages
Definition: mapper.cpp:2580
list_unused_maps
static int list_unused_maps
Definition: mapper.cpp:365
struct_map_info
Definition: mapper.cpp:210
draw_ext_info_format
void draw_ext_info_format(int, int, const object *, uint8_t, uint8_t, const char *format,...)
Definition: mapper.cpp:3289
esrv_send_item
void esrv_send_item(object *, object *)
Definition: mapper.cpp:3310
struct_map_info::min_monster
int min_monster
Definition: mapper.cpp:216
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:2343
struct_region_info
Definition: mapper.cpp:354
clean_tmp_files
void clean_tmp_files(void)
Definition: mapper.cpp:3307
inja::Template
The main inja Template.
Definition: inja.hpp:2836
add_npc_to_map
static void add_npc_to_map(npc_list *list, const object *npc)
Definition: mapper.cpp:1148
region::name
char * name
Definition: map.h:276
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:214
struct_equipment::name
char * name
Definition: mapper.cpp:243
TRIGGER_BUTTON
@ TRIGGER_BUTTON
Definition: object.h:135
npc_dialog.filename
filename
Definition: npc_dialog.py:99
smoking_pipe.color
color
Definition: smoking_pipe.py:5
object_get_value
const char * object_get_value(const object *op, const char *const key)
Definition: object.cpp:4339
create_treasure
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
Definition: treasure.cpp:258
struct_map_info::max_monster
int max_monster
Definition: mapper.cpp:216
object::level
int16_t level
Definition: object.h:359
struct_slaying_info
Definition: mapper.cpp:394
buf
StringBuffer * buf
Definition: readable.cpp:1551
struct_equipment::calc_power
int calc_power
Definition: mapper.cpp:245
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.cpp:2851
MAX
#define MAX(x, y)
Definition: compat.h:24
apply_auto_fix
void apply_auto_fix(mapstruct *)
Definition: mapper.cpp:3391
account_char_save
void account_char_save(Account_Chars *)
Definition: mapper.cpp:3406
FLAG_NO_PICK
#define FLAG_NO_PICK
Definition: define.h:239
force_pics
static int force_pics
Definition: mapper.cpp:311
world_exit_info
static int world_exit_info
Definition: mapper.cpp:319
sort_struct_quest
static int sort_struct_quest(const void *left, const void *right)
Definition: mapper.cpp:1010
struct_quest
Definition: mapper.cpp:881
struct_map_in_quest_list
Definition: mapper.cpp:196
region::longname
char * longname
Definition: map.h:282
struct_region_info::reg
region * reg
Definition: mapper.cpp:355
struct_map_in_quest::quest
struct struct_quest * quest
Definition: mapper.cpp:879
FLAG_IS_A_TEMPLATE
#define FLAG_IS_A_TEMPLATE
Definition: define.h:366
init_renderer_env
static void init_renderer_env()
Definition: mapper.cpp:2620
struct_quest::description
char * description
Definition: mapper.cpp:883
init_gods
void init_gods(void)
Definition: holy.cpp:59
object::y
int16_t y
Definition: object.h:333
m
static event_registration m
Definition: citylife.cpp:425
quest
Definition: quest.py:1
MAP_IN_MEMORY
#define MAP_IN_MEMORY
Definition: map.h:131
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.cpp:76
S_CONTAINER
#define S_CONTAINER
Definition: mapper.cpp:388
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.cpp:1560
item.q
q
Definition: item.py:32
opendir
DIR * opendir(const char *)
struct_map_info::reset_group
sstring reset_group
Definition: mapper.cpp:220
templateCache
static inja::TemplateStorage templateCache
Definition: mapper.cpp:2995
disinfect.map
map
Definition: disinfect.py:4
regions
static struct struct_region_info ** regions
Definition: mapper.cpp:361
struct_npc_info::y
int y
Definition: mapper.cpp:182
struct_map_info::exits_from
struct_map_list exits_from
Definition: mapper.cpp:217
Settings::debug
LogLevel debug
Definition: global.h:247
detail_quests
static bool detail_quests
Definition: mapper.cpp:321
ensure_unique
static struct_equipment * ensure_unique(struct_equipment *item)
Definition: mapper.cpp:462
struct_npc_info::message
const char * message
Definition: mapper.cpp:181
get_slaying_struct
static struct_slaying_info * get_slaying_struct(const char *slaying)
Definition: mapper.cpp:1385
generate_picture_path
static void generate_picture_path(const char *path, size_t pic_size, char *out, size_t len)
Definition: mapper.cpp:1464
make_face_from_files.args
args
Definition: make_face_from_files.py:31
OF_JPG
@ OF_JPG
Definition: mapper.cpp:332
rotate-tower.result
bool result
Definition: rotate-tower.py:13
elevation_max
static int elevation_max
Definition: mapper.cpp:378
struct_map_info::pic_was_done
int pic_was_done
Definition: mapper.cpp:216
set_darkness_map
void set_darkness_map(mapstruct *)
Definition: mapper.cpp:3316
POTION
@ POTION
Definition: object.h:114
struct_npc_info
Definition: mapper.cpp:179
define_quest
static void define_quest(const char *name, struct_map_info *mainmap, const char *description)
Definition: mapper.cpp:1026
path_combine_and_normalize
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
Definition: path.cpp:172
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:901
do_tiled_map_picture
static void do_tiled_map_picture(struct_map_info *map)
Definition: mapper.cpp:2030
slaying_info
static struct_slaying_info ** slaying_info
Definition: mapper.cpp:399
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
races
static struct_race_list races
Definition: mapper.cpp:260
npc_list
std::vector< struct_npc_info * > npc_list
Definition: mapper.cpp:186
object_get_multi_size
void object_get_multi_size(const object *ob, int *sx, int *sy, int *hx, int *hy)
Definition: object.cpp:4737
main
int main(int argc, char **argv)
Definition: mapper.cpp:3006
HEAD
#define HEAD(op)
Definition: object.h:596
output_extensions
static const char * output_extensions[]
Definition: mapper.cpp:336
create_maps_array
static nlohmann::json create_maps_array(struct_map_list &maps)
Definition: mapper.cpp:2200
ROD
@ ROD
Definition: object.h:112
show_maps
static int show_maps
Definition: mapper.cpp:317
CONTAINER
@ CONTAINER
Definition: object.h:234
system_quests
static std::vector< quest_definition * > system_quests
Definition: mapper.cpp:2157
get_elevation_color
static int get_elevation_color(int elevation, gdImagePtr elevationmap)
Definition: mapper.cpp:714
reset_groups
static std::set< std::string > reset_groups
Definition: mapper.cpp:262
region::msg
char * msg
Definition: map.h:284
init_readable
void init_readable(void)
Definition: readable.cpp:894
make_face_from_files.str
str
Definition: make_face_from_files.py:24
S_MAX
#define S_MAX
Definition: mapper.cpp:391
quest_callback
static void quest_callback(const quest_definition *quest, void *)
Definition: mapper.cpp:2159
readdir
struct dirent * readdir(DIR *)
python_init.path
path
Definition: python_init.py:8
LOCKED_DOOR
@ LOCKED_DOOR
Definition: object.h:126
struct_race::name
char * name
Definition: mapper.cpp:255
dump
Definition: quest.cpp:847
is_slaying
static int is_slaying(object *item)
Definition: mapper.cpp:1372
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:2235
account_char_load
Account_Chars * account_char_load(const char *)
Definition: mapper.cpp:3402
dragon_ability_gain
void dragon_ability_gain(object *, int, int)
Definition: mapper.cpp:3313
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:127
inja::json
nlohmann::json json
Definition: inja.hpp:1565
object_update_speed
void object_update_speed(object *op)
Definition: object.cpp:1349
struct_race::origin
struct_map_list origin
Definition: mapper.cpp:257
color_slowing
static int color_slowing
Definition: mapper.cpp:374
Ice.b
b
Definition: Ice.py:48
object::type
uint8_t type
Definition: object.h:346
struct_map_info::quests
struct_map_in_quest_list quests
Definition: mapper.cpp:219
write_world_map
static void write_world_map(void)
Definition: mapper.cpp:1736
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:960
create_npc_info
static struct_npc_info * create_npc_info(const object *npc)
Definition: mapper.cpp:1130
face_info::data
uint8_t * data
Definition: image.h:11
color_road
static int color_road
Definition: mapper.cpp:372
tileset
static int tileset
Definition: mapper.cpp:320
esrv_update_item
void esrv_update_item(int, object *, object *)
Definition: mapper.cpp:3326
object_free
void object_free(object *ob, int flags)
Definition: object.cpp:1592
FOR_INV_FINISH
#define FOR_INV_FINISH()
Definition: define.h:677
is_blocking
static int is_blocking(object *item)
Definition: mapper.cpp:700
do_exit_map
static void do_exit_map(mapstruct *map)
Definition: mapper.cpp:729
create_destination
static void create_destination(void)
Definition: mapper.cpp:2975
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:190
sstring
const typedef char * sstring
Definition: global.h:47
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:1456
say.max
dictionary max
Definition: say.py:148
archetype
Definition: object.h:472
jpeg_quality
static int jpeg_quality
Definition: mapper.cpp:345
sproto.h
append_map_list
static void append_map_list(struct_map_list &dest, struct_map_list &src)
Definition: mapper.cpp:2333
struct_map_info::npcs
npc_list * npcs
Definition: mapper.cpp:226
IS_SHIELD
#define IS_SHIELD(op)
Definition: define.h:170
logfile
FILE * logfile
Definition: init.cpp:114
BOOK
@ BOOK
Definition: object.h:117
rawmaps
static int rawmaps
Definition: mapper.cpp:348
init_struct_map_in_quest_list
static void init_struct_map_in_quest_list(struct_map_in_quest_list *list)
Definition: mapper.cpp:895
struct_race_list
Definition: mapper.cpp:189
struct_race
Definition: mapper.cpp:254
emergency_save
void emergency_save(int)
Definition: mapper.cpp:3304
delete_map
void delete_map(mapstruct *m)
Definition: map.cpp:1730
struct_race_list::allocated
size_t allocated
Definition: mapper.cpp:192
struct_map_list::maps
struct struct_map_info ** maps
Definition: mapper.cpp:204
RING
@ RING
Definition: object.h:188
struct_race_list::count
size_t count
Definition: mapper.cpp:191
fill_json
static void fill_json(nlohmann::json &json)
Definition: mapper.cpp:2358
add_map_to_region
static void add_map_to_region(struct_map_info *map, region *reg)
Definition: mapper.cpp:1305
image.h
struct_map_info::level
int level
Definition: mapper.cpp:216
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.cpp:2098
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
list_system_quests
static bool list_system_quests
Definition: mapper.cpp:322
generate_pics
static int generate_pics
Definition: mapper.cpp:310
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:2275
struct_quest::mainmap
struct_map_info * mainmap
Definition: mapper.cpp:885
env
static std::shared_ptr< inja::Environment > env
Definition: mapper.cpp:2165
MAX_BUF
#define MAX_BUF
Definition: define.h:35
S_KEY
#define S_KEY
Definition: mapper.cpp:387
sort_map_info
static int sort_map_info(const void *left, const void *right)
Definition: mapper.cpp:849
fill_reverse_maps
static void fill_reverse_maps(struct_map_list &list)
Definition: mapper.cpp:2314
is_valid_faceset
int is_valid_faceset(int fsn)
Definition: image.cpp:117
struct_map_info::tiled_x_from
int tiled_x_from
Definition: mapper.cpp:231
object::head
object * head
Definition: object.h:302
pageToRender
Definition: mapper.cpp:2574
IS_WEAPON
#define IS_WEAPON(op)
Definition: define.h:163
object::move_slow
MoveType move_slow
Definition: object.h:437
sort_slaying
static int sort_slaying(const void *left, const void *right)
Definition: mapper.cpp:2843
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:285
StringBuffer
Definition: stringbuffer.cpp:25
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:569
FOR_MAP_PREPARE
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Definition: define.h:723
EXIT
@ EXIT
Definition: object.h:184
path_stack
static std::vector< std::string > path_stack
Definition: mapper.cpp:2498
merge_tiled_maps
static void merge_tiled_maps(struct_map_info *map, struct_map_info *tiled_map)
Definition: mapper.cpp:1223
cached_pics
static int cached_pics
Definition: mapper.cpp:327
struct_map_list::allocated
size_t allocated
Definition: mapper.cpp:206
list_map
static void list_map(const char *path)
Definition: mapper.cpp:1284
struct_map_info::exits_to
struct_map_list exits_to
Definition: mapper.cpp:218
region
Definition: map.h:275
struct_map_info::lore
char * lore
Definition: mapper.cpp:214
rendered_templates
static std::set< std::string > rendered_templates
Definition: mapper.cpp:2167
apply_auto
int apply_auto(object *op)
Definition: mapper.cpp:3339
check_trigger
int check_trigger(object *op, object *cause)
Definition: button.cpp:518
make_face_from_files.out
out
Definition: make_face_from_files.py:75
quest.h
S_DETECTOR
#define S_DETECTOR
Definition: mapper.cpp:389
struct_map_info::path
char * path
Definition: mapper.cpp:211
struct_map_in_quest_list::count
size_t count
Definition: mapper.cpp:198
object::slaying
sstring slaying
Definition: object.h:325
init_map_list
static void init_map_list(struct_map_list *list)
Definition: mapper.cpp:408
all_regions
std::vector< region * > all_regions
Definition: init.cpp:108
add_region_link
static void add_region_link(mapstruct *source, mapstruct *dest)
Definition: mapper.cpp:1353
FLAG_FRIENDLY
#define FLAG_FRIENDLY
Definition: define.h:246
init_library
void init_library(void)
Definition: init.cpp:323
object::name
sstring name
Definition: object.h:317
free_equipment
static void free_equipment(struct_equipment *equip)
Definition: mapper.cpp:448
esrv_update_spells
void esrv_update_spells(player *)
Definition: mapper.cpp:3329
created_pics
static int created_pics
Definition: mapper.cpp:326
bigchest.check
check
Definition: bigchest.py:10
size_large
#define size_large
Definition: mapper.cpp:314
add_map_to_slaying
static void add_map_to_slaying(struct_slaying_info *info, int item, struct_map_info *map)
Definition: mapper.cpp:1416
struct_region_info::sum
int sum
Definition: mapper.cpp:357
inja::TemplateStorage
std::map< std::string, Template > TemplateStorage
Definition: inja.hpp:2852
struct_map_info::readable
npc_list * readable
Definition: mapper.cpp:227
IS_ARMOR
#define IS_ARMOR(op)
Definition: define.h:166
OF_PNG
@ OF_PNG
Definition: mapper.cpp:331
account_char_free
void account_char_free(Account_Chars *)
Definition: mapper.cpp:3409
struct_region_info::maps_list
struct_map_list maps_list
Definition: mapper.cpp:356
item
Definition: item.py:1
struct_map_info::processed
int processed
Definition: mapper.cpp:231
FIREWALL
@ FIREWALL
Definition: object.h:171
PLAYER_CHANGER
@ PLAYER_CHANGER
Definition: object.h:165
mapstruct
Definition: map.h:316
inja::Arguments
std::vector< const json * > Arguments
Definition: inja.hpp:1567
create_pathname
char * create_pathname(const char *name, char *buf, size_t size)
Definition: map.cpp:103
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:1339
create-tower.current_map
current_map
Definition: create-tower.py:7
display_rendered_template
static bool display_rendered_template
Definition: mapper.cpp:323
templates_root
static std::string templates_root("templates/")
FLAG_AUTO_APPLY
#define FLAG_AUTO_APPLY
Definition: define.h:250
quest_definition
Definition: quest.h:37
struct_map_info::monsters
struct_race_list monsters
Definition: mapper.cpp:224
find_archetype
archetype * find_archetype(const char *name)
Definition: assets.cpp:266
elevation_info
static int ** elevation_info
Definition: mapper.cpp:376
color_blocking
static int color_blocking
Definition: mapper.cpp:373
struct_map_in_quest::description
char * description
Definition: mapper.cpp:878
get_template
static inja::Template get_template(const std::string &filename)
Definition: mapper.cpp:2996
mapstruct::in_memory
uint32_t in_memory
Definition: map.h:337
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:3297
region_count
static size_t region_count
Definition: mapper.cpp:362
command_help
void command_help(object *, const char *)
Definition: mapper.cpp:3412
do_parameters
static void do_parameters(int argc, char **argv)
Definition: mapper.cpp:2893
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
all_data
static nlohmann::json all_data
Definition: mapper.cpp:2166
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:629
struct_map_in_quest_list::list
struct struct_map_in_quest ** list
Definition: mapper.cpp:197
MAP_HEIGHT
#define MAP_HEIGHT(m)
Definition: map.h:80
struct_quest::number
int number
Definition: mapper.cpp:884
pageToRender::template_name
std::string template_name
Definition: mapper.cpp:2576
struct_map_info::cfregion
region * cfregion
Definition: mapper.cpp:215
get_ob_diff
void get_ob_diff(StringBuffer *sb, const object *op, const object *op2)
Definition: object.cpp:4979
sort_race
static int sort_race(const void *a, const void *b)
Definition: mapper.cpp:651
do_regions_link
static bool do_regions_link
Definition: mapper.cpp:381
arch_to_object
object * arch_to_object(archetype *at)
Definition: arch.cpp:229
object_give_identified_properties
void object_give_identified_properties(object *op)
Definition: item.cpp:1344
init_race_list
static void init_race_list(struct_race_list *list)
Definition: mapper.cpp:269
create-tower.tile
tile
Definition: create-tower.py:8
process_map
static void process_map(struct_map_info *info)
Definition: mapper.cpp:1496
quests_allocated
static int quests_allocated
Definition: mapper.cpp:893
strcasecmp
int strcasecmp(const char *s1, const char *s2)
castle_read.key
key
Definition: castle_read.py:64
npc_dialog.npc
npc
Definition: npc_dialog.py:95
find_skill_by_number
object * find_skill_by_number(object *, int)
Definition: mapper.cpp:3319
sizes
static int sizes[]
Definition: mapper.cpp:312
account_logout
void account_logout(const char *)
Definition: mapper.cpp:3415
reverse_regions
static std::map< region *, std::string > reverse_regions
Definition: mapper.cpp:2169
get_region_by_map
region * get_region_by_map(mapstruct *m)
Definition: region.cpp:72
S_DOOR
#define S_DOOR
Definition: mapper.cpp:386
create_tiled_map
static struct_map_info * create_tiled_map(void)
Definition: mapper.cpp:1207
world_map
static int world_map
Definition: mapper.cpp:318
templates
static std::vector< std::string > templates
Definition: mapper.cpp:2615
ignore_path
static const char * ignore_path[]
Definition: mapper.cpp:2710
Account_Chars
Definition: account_char.h:27
struct_map_list::count
size_t count
Definition: mapper.cpp:205
slaying_count
static size_t slaying_count
Definition: mapper.cpp:400
player_get_delayed_buffer
SockList * player_get_delayed_buffer(player *)
Definition: mapper.cpp:3394
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:2588
object_remove
void object_remove(object *op)
Definition: object.cpp:1833
infomap
static gdImagePtr infomap
Definition: mapper.cpp:369
sort_struct_map_in_quest
static int sort_struct_map_in_quest(const void *left, const void *right)
Definition: mapper.cpp:982
struct_map_info::height
int height
Definition: mapper.cpp:230
ALTAR
@ ALTAR
Definition: object.h:125
struct_npc_info::x
int x
Definition: mapper.cpp:182
relative_path
static void relative_path(const char *from, const char *to, char *result)
Definition: mapper.cpp:785
FLAG_UNPAID
#define FLAG_UNPAID
Definition: define.h:236
dump_unused_maps
static void dump_unused_maps(void)
Definition: mapper.cpp:2774
rod_adjust
void rod_adjust(object *)
Definition: mapper.cpp:3332
sort_region
static int sort_region(const void *left, const void *right)
Definition: mapper.cpp:865
special_equipment
static std::vector< struct_equipment * > special_equipment
Definition: mapper.cpp:250
generate_treasure
object * generate_treasure(treasurelist *t, int difficulty)
Definition: treasure.cpp:290
make_path_to_file
void make_path_to_file(const char *filename)
Definition: porting.cpp:164
FREE_OBJ_FREE_INVENTORY
#define FREE_OBJ_FREE_INVENTORY
Definition: object.h:533
fix_exits_for_map
static void fix_exits_for_map(struct_map_info *current, struct_map_list *from, int is_from)
Definition: mapper.cpp:1926
SCROLL
@ SCROLL
Definition: object.h:224
FLAG_IS_LINKED
#define FLAG_IS_LINKED
Definition: define.h:315
struct_npc_info::name
const char * name
Definition: mapper.cpp:180
object::nrof
uint32_t nrof
Definition: object.h:340
draw_ext_info
void draw_ext_info(int, int, const object *, uint8_t, uint8_t, const char *txt)
Definition: mapper.cpp:3285
split
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2603
mapstruct::reset_time
uint32_t reset_time
Definition: map.h:323
say.item
dictionary item
Definition: say.py:149
do_help
static void do_help(const char *program)
Definition: mapper.cpp:2856
artifact
Definition: artifact.h:14
struct_quest::name
char * name
Definition: mapper.cpp:882
nlohmann::basic_json::erase
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:21582
get_faces_count
size_t get_faces_count()
Definition: assets.cpp:293
calc_item_power
int calc_item_power(const object *op)
Definition: item.cpp:239
write_world_info
static void write_world_info(void)
Definition: mapper.cpp:2792
struct_map_in_quest_list::allocated
size_t allocated
Definition: mapper.cpp:199
tiled_map_need_pic
static int tiled_map_need_pic(struct_map_info *map)
Definition: mapper.cpp:2000
face_sets
Definition: image.h:17
SPELL
@ SPELL
Definition: object.h:217
map_limit
static int map_limit
Definition: mapper.cpp:316
replace.current
current
Definition: replace.py:64
closedir
int closedir(DIR *)
quests
static struct_quest ** quests
Definition: mapper.cpp:889
guildbuy.temp
def temp
Definition: guildbuy.py:26
fix_tiled_map
static void fix_tiled_map(void)
Definition: mapper.cpp:1857
FLAG_CURSED
#define FLAG_CURSED
Definition: define.h:316
output_format_type
output_format_type
Definition: mapper.cpp:330
TELEPORTER
@ TELEPORTER
Definition: object.h:144
gdfaces
static gdImagePtr * gdfaces
Definition: mapper.cpp:176
pics_allocated
static int pics_allocated
Definition: mapper.cpp:307
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:206
found_maps
static std::vector< char * > found_maps
Definition: mapper.cpp:366
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:670
takeitem.status
status
Definition: takeitem.py:38
find_player_partial_name
player * find_player_partial_name(const char *)
Definition: mapper.cpp:3398
find_map_by_key
static struct_map_info * find_map_by_key(const std::string &key)
Definition: mapper.cpp:2176
warn_no_path
static int warn_no_path
Definition: mapper.cpp:351
find_quest_info
static struct_quest * find_quest_info(const char *name)
Definition: mapper.cpp:914
DETECTOR
@ DETECTOR
Definition: object.h:152
find_maps
static void find_maps(const char *from)
Definition: mapper.cpp:2734
struct_slaying_info::slaying
char * slaying
Definition: mapper.cpp:395
ring_occidental_mages.r
r
Definition: ring_occidental_mages.py:6
is_road
static int is_road(object *item)
Definition: mapper.cpp:664
elevation_min
static int elevation_min
Definition: mapper.cpp:377
color_linked_exit
static int color_linked_exit
Definition: mapper.cpp:371
FLAG_IS_FLOOR
#define FLAG_IS_FLOOR
Definition: define.h:302
sort_equipment
static bool sort_equipment(const struct_equipment *l, const struct_equipment *r)
Definition: mapper.cpp:586
add_one_item
static void add_one_item(object *item, struct_map_info *map)
Definition: mapper.cpp:495
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:2577
identify
object * identify(object *op)
Definition: item.cpp:1409