Crossfire Server, Trunk
assets.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2020 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
18 #ifndef WIN32 /* ---win32 exclude headers */
19 #include <sys/stat.h>
20 #include "autoconf.h"
21 #endif
22 
23 extern "C" {
24 #include "global.h"
25 #include "compat.h"
26 }
27 #include "assets.h"
28 #include "AssetsManager.h"
29 #include "AssetCollector.h"
30 #include "TreasureLoader.h"
31 #include "ArchetypeLoader.h"
32 #include "PngLoader.h"
33 #include "FacesetLoader.h"
34 #include "FaceLoader.h"
35 #include "WrapperLoader.h"
36 #include "MessageLoader.h"
37 #include "QuestLoader.h"
38 #include "ArtifactLoader.h"
39 #include "Faces.h"
40 #include <string.h>
41 
42 #include <vector>
43 #include <string>
44 #include <set>
45 #include <algorithm>
46 #include <map>
47 #include <memory>
48 
49 #include "AssetWriter.h"
50 #include "TreasureWriter.h"
51 #include "FaceWriter.h"
52 #include "AnimationWriter.h"
53 #include "ArchetypeWriter.h"
54 #include "MessageWriter.h"
55 #include "image.h"
56 #include "FacesetWriter.h"
57 #include "ArtifactWriter.h"
58 #include "FormulaeWriter.h"
59 #include "QuestWriter.h"
60 
61 #include "microtar.h"
62 #include "TarLoader.h"
63 
64 static AssetsManager *manager = nullptr;
65 
69 void assets_init() {
70  manager = new AssetsManager();
71 }
72 
76 void assets_free() {
77  delete manager;
78  manager = nullptr;
79 }
80 
84 size_t nroftreasures = 0;
85 
97 static void check_treasurelist(treasure *t, const treasurelist *tl) {
98  if (t->item == NULL && t->name == NULL)
99  LOG(llevError, "Treasurelist %s has element with no name or archetype\n", tl->name);
100  if (t->chance >= 100 && t->next_yes && (t->next || t->next_no))
101  LOG(llevError, "Treasurelist %s has element that has 100%% generation, next_yes field as well as next or next_no\n", tl->name);
102  if (t->name && strcmp(t->name, "NONE"))
103  find_treasurelist(t->name);
104  if (t->next)
105  check_treasurelist(t->next, tl);
106  if (t->next_yes)
107  check_treasurelist(t->next_yes, tl);
108  if (t->next_no)
109  check_treasurelist(t->next_no, tl);
110 }
111 
117 void assets_collect(const char* datadir, int what) {
118  LOG(llevInfo, "Starting to collect assets from %s\n", datadir);
119 
120  auto tracker = static_cast<AssetsTracker *>(settings.archetypes_tracker);
121 
122  AssetCollector collector;
123  if (what & ASSETS_TREASURES)
124  collector.addLoader(new TreasureLoader(manager->treasures(), manager->archetypes(), tracker));
125  if (what & ASSETS_ARCHETYPES)
126  collector.addLoader(new ArchetypeLoader(manager->archetypes(), tracker));
127  if (what & ASSETS_PNG)
128  collector.addLoader(new PngLoader(manager->faces(), manager->facesets()));
129  if (what & ASSETS_FACESETS)
130  collector.addLoader(new FacesetLoader(manager->facesets()));
131  if (what & ASSETS_FACES)
132  collector.addLoader(new FaceLoader(manager->faces(), manager->animations()));
133  if (what & ASSETS_MESSAGES)
134  collector.addLoader(new MessageLoader(manager->messages(), tracker));
135  if (what & ASSETS_ARTIFACTS) {
136  collector.addLoader(new ArtifactLoader(tracker));
137  }
138  if (what & ASSETS_FORMULAE) {
139  collector.addLoader(new WrapperLoader("/formulae", init_formulae));
140  collector.addLoader(new WrapperLoader(".formulae", init_formulae));
141  }
142  if (what & ASSETS_ATTACK_MESSAGES)
143  collector.addLoader(new WrapperLoader("/attackmess", init_attackmess));
144  if (what & ASSETS_QUESTS)
145  collector.addLoader(new QuestLoader(manager->quests(), manager->faces(), tracker));
146  if (what & ASSETS_REGIONS)
147  collector.addLoader(new WrapperLoader("regions.reg", init_regions));
148  for (uint8_t hook = 0; hook < settings.hooks_count; hook++) {
149  collector.addLoader(new WrapperLoader(settings.hooks_filename[hook], settings.hooks[hook]));
150  }
151  collector.addLoader(new TarLoader(&collector));
152  collector.collect(datadir);
153 
154  LOG(llevInfo, "Finished collecting assets from %s\n", datadir);
155 }
156 
160 static void check_generators(void) {
161  int abort = 0;
162 
163  manager->archetypes()->each([&abort] (const auto& arch) {
164  if (!QUERY_FLAG(&arch->clone, FLAG_GENERATOR))
165  return;
166 
167  if (!QUERY_FLAG(&arch->clone, FLAG_CONTENT_ON_GEN) && arch->clone.other_arch == NULL) {
168  LOG(llevError, "Fatal: %s is generator without content_on_gen but lacks other_arch.\n", arch->name);
169  abort = 1;
170  return;
171  }
172  if (QUERY_FLAG(&arch->clone, FLAG_CONTENT_ON_GEN) && arch->clone.inv == NULL) {
173  LOG(llevError, "Fatal: %s is generator with content_on_gen but lacks inventory.\n", arch->name);
174  abort = 1;
175  return;
176  }
177  });
178 
179  if (abort)
181 }
182 
187 void check_summoned(void) {
188  manager->archetypes()->each([] (const auto& arch) {
189  if (arch->clone.type == SPELL && arch->clone.subtype == SP_SUMMON_GOLEM && arch->clone.other_arch) {
190  if (arch->clone.other_arch->clone.move_type == 0) {
191  LOG(llevError, "Summonable archetype %s [%s] has no move_type defined!\n", arch->clone.other_arch->name, arch->clone.other_arch->clone.name);
192  fatal(SEE_LAST_ERROR);
193  }
194  }
195  });
196 }
197 
204 static void check_spells(void) {
205  int abort = 0;
206 
207  manager->archetypes()->each([&abort] (const auto& arch) {
208  if (arch->clone.type == SPELL && arch->clone.skill) {
209  auto skill = manager->archetypes()->first([&arch] (const archetype *skill) {
210  return skill->clone.type == SKILL && arch->clone.skill == skill->clone.name;
211  });
212  if (!skill) {
213  LOG(llevError, "Spell %s has improper associated skill %s\n", arch->name, arch->clone.skill);
214  abort = 1;
215  }
216  }
217  });
218 
219  for (size_t i = 0; i < sizeof(spell_mapping) / sizeof(spell_mapping[0]); i++) {
221  LOG(llevError, "Unable to find spell mapping %s (%i)\n", spell_mapping[i], i);
222  abort = 1;
223  }
224  }
225 
226  if (abort)
228 }
229 
235  return manager->dumpUndefined();
236 }
237 
243  check_spells();
244  check_summoned();
245  manager->treasures()->each([] (auto list) {
246  if (list->items) {
247  check_treasurelist(list->items, list);
248  }
249  });
250  check_recipes();
251  check_formulae();
252 }
253 
264  if (!strcmp(name, "none"))
265  return NULL;
266  return manager->treasures()->get(name);
267 }
268 
270  return nroftreasures;
271 }
273  return manager->treasures()->count();
274 }
275 
277  return manager->archetypes()->count();
278 }
279 
281  return manager->archetypes()->next(current);
282 }
283 
285  return manager->archetypes()->get(name);
286 }
287 
289  return manager->archetypes()->find(name);
290 }
291 
293  return manager->animations()->count();
294 }
295 
297  return manager->animations()->get(name);
298 }
299 
301  return manager->animations()->find(name);
302 }
303 
305  manager->animations()->each(*op);
306 }
307 
308 const Face *find_face(const char *name) {
309  return manager->faces()->get(name);
310 }
311 
312 const Face *try_find_face(const char *name, const Face *error) {
313  auto found = manager->faces()->find(name);
314  if (found)
315  return found;
316  return error;
317 }
318 
319 size_t get_faces_count() {
320  return manager->faces()->count();
321 }
322 
324  manager->faces()->each(*op);
325 }
326 
328  manager->facesets()->each(*op);
329 }
330 
332  manager->archetypes()->each(*op);
333 }
334 
336  return manager;
337 }
338 
345 const Face *get_face_by_id(uint16_t id) {
346  return manager->faces()->findById(id);
347 }
348 
350  return manager->messages()->random();
351 }
352 
358 const GeneralMessage *get_message_from_identifier(const char *identifier) {
359  return manager->messages()->find(identifier);
360 }
361 
363  return manager->faces()->checksum();
364 }
365 
367  return manager->facesets()->findById(id);
368 }
369 
370 template<class T>
371 static void do_pack(AssetWriter<T> *writer, AssetsCollection<T> *assets, StringBuffer *buf) {
372  assets->each([writer, buf] (T *asset) {
373  writer->write(asset, buf);
374  });
375  delete writer;
376 }
377 
379  ArtifactWriter writer;
381  while (list) {
382  auto item = list->items;
383  while (item) {
384  writer.write(item, buf);
385  item = item->next;
386  }
387  list = list->next;
388  }
389 }
390 
392  FormulaeWriter writer;
394  while (list) {
395  writer.write(list, buf);
396  list = list->next;
397  }
398 }
399 
400 static void build_filename(const char *name, const char *prefix, char *dest, size_t max) {
401  auto dot = strrchr(name, '.');
402  if (!dot) {
403  snprintf(dest, max, "%s.%s", name, prefix);
404  return;
405  }
406  memset(dest, 0, max);
407  dot++;
408 
409  memcpy(dest, name, dot - name);
410  strncat(dest, prefix, max);
411  strncat(dest, ".", max);
412  strncat(dest, dot, max);
413  strncat(dest, ".png", max);
414 }
415 
423 static void add_to_tar(mtar_t *tar, void *data, size_t len, const char *filename) {
424  mtar_header_t h;
425  memset(&h, 0, sizeof(h));
426  strncpy(h.name, filename, sizeof(h.name));
427  h.size = len;
428  h.type = MTAR_TREG;
429  h.mode = 0664;
430  h.mtime = time(NULL);
431  /* Build raw header and write */
432  if (MTAR_ESUCCESS != mtar_write_header(tar, &h)) {
433  LOG(llevError, "Failed to write tar header for %s\n", filename);
435  }
436  if (MTAR_ESUCCESS != mtar_write_data(tar, data, len)) {
437  LOG(llevError, "Failed to write tar data for %s\n", filename);
439  }
440 }
441 
446 static void pack_images(mtar_t *tar) {
447  manager->faces()->each([&tar] (const auto face) {
448  manager->facesets()->each([&tar, &face] (const auto fs) {
449  if (!fs->prefix || fs->allocated <= face->number || !fs->faces[face->number].datalen) {
450  return;
451  }
452  char filename[500];
453  build_filename(face->name, fs->prefix, filename, sizeof(filename));
454  add_to_tar(tar, fs->faces[face->number].data, fs->faces[face->number].datalen, filename);
455  });
456  });
457 }
458 
459 void assets_pack(const char *what, const char *filename) {
460 #define MAX_PACK 100
461  char *split[MAX_PACK];
462  char *dup = strdup_local(what);
463  size_t count = split_string(dup, split, MAX_PACK, '+');
464  if (count == 0) {
465  LOG(llevError, "Invalid pack type %s\n", what);
467  }
468  bool isTar = (count > 1) || (strcmp(split[0], "images") == 0);
469  mtar_t tar;
470  if (isTar) {
471  if (MTAR_ESUCCESS != mtar_open(&tar, filename, "w")) {
472  LOG(llevError, "Failed to open tar file %s\n", filename);
474  }
475  }
476 
477  for (size_t t = 0; t < count; t++) {
478  const char *type = split[t];
479  const char *name = nullptr;
480 
482  if (strcmp(type, "treasures") == 0) {
484  name = "crossfire.trs";
485  } else if (strcmp(type, "faces") == 0) {
486  do_pack(new FaceWriter(), manager->faces(), buf);
488  name = "crossfire.face";
489  } else if (strcmp(type, "archs") == 0) {
491  name = "crossfire.arc";
492  } else if (strcmp(type, "messages") == 0) {
494  name = "messages";
495  } else if (strcmp(type, "facesets") == 0) {
497  name = "image_info";
498  } else if (strcmp(type, "artifacts") == 0) {
500  name = "artifacts";
501  } else if (strcmp(type, "formulae") == 0) {
503  name = "formulae";
504  } else if (strcmp(type, "quests") == 0) {
505  do_pack(new QuestWriter(), manager->quests(), buf);
506  name = "crossfire.quests";
507  } else if (strcmp(type, "images") == 0) {
508  pack_images(&tar);
510  continue; // Already stored in tar.
511  } else {
512  LOG(llevError, "Invalid asset type '%s'\n", type);
514  }
515 
516  size_t length = stringbuffer_length(buf);
517  char *data = stringbuffer_finish(buf);
518 
519  if (isTar) {
520  add_to_tar(&tar, data, length, name);
521  } else {
522  FILE *out = fopen(filename, "w+");
523  if (!out) {
524  LOG(llevError, "Failed to open file '%s'\n", filename);
526  }
527  if (fwrite(static_cast<void*>(data), 1, length, out) != length) {
528  LOG(llevError, "Failed to write all data!\n", filename);
529  fclose(out);
531  }
532  fclose(out);
533  }
534  free(data);
535  }
536 
537  if (isTar) {
538  if (MTAR_ESUCCESS != mtar_finalize(&tar)) {
539  LOG(llevError, "Failed to finalize tar file %s\n", filename);
541  }
542  if (MTAR_ESUCCESS != mtar_close(&tar)) {
543  LOG(llevError, "Failed to closed tar file %s\n", filename);
545  }
546  }
547  free(dup);
548 }
549 
551  manager->archetypes()->each([] (archetype *arch) {
552  object *op = &arch->clone;
553  if (op->speed < 0) {
554  op->speed_left = op->speed_left - RANDOM() % 100 / 100.0;
555  op->speed = -op->speed; // Make this always positive
556  }
557  });
558 }
559 
583  long mult;
584  const char *cp;
585  char part1[100];
586  char part2[100];
587 
588  /* same as atoi(), but skip number */
589  mult = 0;
590  while (isdigit(*name)) {
591  mult = 10*mult+(*name-'0');
592  name++;
593  }
594  if (mult > 0)
595  name++;
596  else
597  mult = 1;
598  /* first, try to match the name of an archetype */
599 
600  long value = 0;
601  bool found = false;
602  manager->archetypes()->each([&value, &found, &name, &part1] (const archetype *at) {
603  if (found) {
604  return;
605  }
606 
607  if (at->clone.title != NULL) {
608  /* inefficient, but who cares? */
609  snprintf(part1, sizeof(part1), "%s %s", at->clone.name, at->clone.title);
610  if (!strcasecmp(part1, name)) {
611  value = at->clone.value;
612  found = true;
613  return;
614  }
615  }
616  if (!strcasecmp(at->clone.name, name)) {
617  value = at->clone.value;
618  found = true;
619  return;
620  }
621  });
622  if (found) {
623  return mult * value;
624  }
625 
626  /* second, try to match an artifact ("arch of something") */
627  cp = strstr(name, " of ");
628  if (cp != NULL) {
629  safe_strncpy(part1, name, sizeof(part1));
630  part1[cp-name] = '\0';
631  safe_strncpy(part2, cp + 4, sizeof(part2));
632  manager->archetypes()->each([&value, &found, &part1, &part2] (const archetype *at) {
633  if (found) {
634  return;
635  }
636 
637  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL) {
638  /* find the first artifact derived from that archetype (same type) */
639  for (auto al = first_artifactlist; al != NULL; al = al->next) {
640  if (al->type == at->clone.type) {
641  for (auto art = al->items; art != NULL; art = art->next) {
642  if (!strcasecmp(art->item->name, part2)) {
643  value = at->clone.value * art->item->value;
644  found = true;
645  return;
646  }
647  }
648  }
649  }
650  }
651  });
652  }
653  if (found) {
654  return mult * value;
655  }
656 
657  /* third, try to match a body part ("arch's something") */
658  cp = strstr(name, "'s ");
659  if (cp != NULL) {
660  safe_strncpy(part1, name, sizeof(part1));
661  part1[cp-name] = '\0';
662  safe_strncpy(part2, cp + 3, sizeof(part2));
663  /* examine all archetypes matching the first part of the name */
664  manager->archetypes()->each([&value, &found, &part1, &part2] (const archetype *at) {
665  if (found) {
666  return;
667  }
668  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL) {
669  if (at->clone.randomitems != NULL) {
670  auto at2 = find_treasure_by_name(at->clone.randomitems->items, part2, 0);
671  if (at2 != NULL) {
672  value = at2->clone.value * isqrt(at->clone.level * 2);
673  found = true;
674  return;
675  }
676  }
677  }
678  });
679  }
680  if (found) {
681  return mult * value;
682  }
683 
684  /* failed to find any matching items -- formula should be checked */
685  LOG(llevError, "Couldn't find cost for ingredient %s\n", name);
686  return -1;
687 }
688 
691 
692  quest = quest_get_by_code(code);
693  if (!quest) {
694  LOG(llevError, "quest %s required but not found!\n", code);
695  return NULL;
696  }
697  return quest;
698 }
699 
701  return manager->quests()->find(code);
702 }
703 
709 void quest_for_each(quest_op op, void *user) {
710  manager->quests()->each([&op, &user] (auto q) { op(q, user); });
711 }
712 
713 size_t quests_count(bool includeSystem) {
714  return includeSystem ? manager->quests()->count() : manager->quests()->visibleCount();
715 }
AssetsCollection::count
size_t count() const
Definition: AssetsCollection.h:57
facesets_for_each
void facesets_for_each(faceset_op op)
Definition: assets.cpp:327
Face
Definition: face.h:14
do_pack
static void do_pack(AssetWriter< T > *writer, AssetsCollection< T > *assets, StringBuffer *buf)
Definition: assets.cpp:371
global.h
castle_read.prefix
string prefix
Definition: castle_read.py:31
get_formulalist
recipelist * get_formulalist(int i)
Definition: recipe.c:96
Settings::hooks_count
uint8_t hooks_count
Definition: global.h:327
GeneralMessage
Definition: book.h:44
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
stringbuffer_new
StringBuffer * stringbuffer_new(void)
Definition: stringbuffer.c:57
FormulaeWriter.h
AssetWriter.h
assets_number_of_animations
size_t assets_number_of_animations()
Definition: assets.cpp:292
ArchetypeWriter.h
Settings::archetypes_tracker
void * archetypes_tracker
Definition: global.h:331
mtar_open
int mtar_open(mtar_t *tar, const char *filename, const char *mode)
Definition: microtar.c:177
llevError
@ llevError
Definition: logger.h:11
ASSETS_FACESETS
#define ASSETS_FACESETS
Definition: assets.h:27
quest_for_each
void quest_for_each(quest_op op, void *user)
Definition: assets.cpp:709
ArchetypeWriter
Definition: ArchetypeWriter.h:22
AssetsManager::messages
Messages * messages()
Definition: AssetsManager.h:59
assets_dump_undefined
size_t assets_dump_undefined()
Definition: assets.cpp:234
FLAG_GENERATOR
#define FLAG_GENERATOR
Definition: define.h:248
strdup_local
#define strdup_local
Definition: compat.h:29
quest_op
void(* quest_op)(const quest_definition *, void *)
Definition: quest.h:55
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
archetypes_for_each
void archetypes_for_each(arch_op op)
Definition: assets.cpp:331
get_next_archetype
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:280
AssetsManager.h
FLAG_CONTENT_ON_GEN
#define FLAG_CONTENT_ON_GEN
Definition: define.h:365
obj::value
int32_t value
Definition: object.h:355
mtar_header_t::type
unsigned type
Definition: microtar.h:48
Faces::checksum
int checksum() const
Definition: Faces.h:27
init_regions
void init_regions(BufferReader *reader, const char *filename)
Definition: region.cpp:317
QuestWriter.h
mtar_t
Definition: microtar.h:56
MessageWriter.h
Faces::findById
const Face * findById(uint16_t id)
Definition: Faces.cpp:43
guildoracle.list
list
Definition: guildoracle.py:87
ASSETS_MESSAGES
#define ASSETS_MESSAGES
Definition: assets.h:30
get_random_message
GeneralMessage * get_random_message()
Definition: assets.cpp:349
mtar_header_t::size
unsigned size
Definition: microtar.h:46
AssetsManager::animations
AllAnimations * animations()
Definition: AssetsManager.h:49
animations_for_each
void animations_for_each(anim_op op)
Definition: assets.cpp:304
find_faceset
face_sets * find_faceset(int id)
Definition: assets.cpp:366
face_op
void(* face_op)(const Face *)
Definition: assets.h:48
ArtifactWriter.h
FaceWriter
Definition: FaceWriter.h:22
FaceWriter.h
AssetsManager::dumpUndefined
size_t dumpUndefined()
Definition: AssetsManager.cpp:65
TreasureLoader
Definition: TreasureLoader.h:27
first_artifactlist
EXTERN artifactlist * first_artifactlist
Definition: global.h:118
MAX_PACK
#define MAX_PACK
find_treasurelist
treasurelist * find_treasurelist(const char *name)
Definition: assets.cpp:263
TreasureLoader.h
mtar_header_t::mtime
unsigned mtime
Definition: microtar.h:47
SEE_LAST_ERROR
@ SEE_LAST_ERROR
Definition: define.h:52
treasureliststruct::name
sstring name
Definition: treasure.h:83
Quests::visibleCount
size_t visibleCount() const
Definition: Quests.h:26
assets_number_of_archetypes
size_t assets_number_of_archetypes()
Definition: assets.cpp:276
npc_dialog.filename
filename
Definition: npc_dialog.py:99
assets_free
void assets_free()
Definition: assets.cpp:76
check_generators
static void check_generators(void)
Definition: assets.cpp:160
init_formulae
void init_formulae(BufferReader *reader, const char *filename)
Definition: recipe.c:167
find_face
const Face * find_face(const char *name)
Definition: assets.cpp:308
getManager
AssetsManager * getManager()
Definition: assets.cpp:335
treasurestruct
Definition: treasure.h:63
AssetsCollection::find
T * find(const Key &name)
Definition: AssetsCollection.h:85
AssetCollector::collect
void collect(const std::string &directory)
Definition: AssetCollector.cpp:57
archt
Definition: object.h:469
settings
struct Settings settings
Definition: init.c:39
AnimationWriter
Definition: AnimationWriter.h:22
FacesetLoader
Definition: FacesetLoader.h:21
ASSETS_QUESTS
#define ASSETS_QUESTS
Definition: assets.h:34
quest
Definition: quest.py:1
get_bitmap_checksum
int get_bitmap_checksum()
Definition: assets.cpp:362
Messages::random
GeneralMessage * random()
Definition: Messages.cpp:50
item.q
q
Definition: item.py:32
mtar_header_t::name
char name[100]
Definition: microtar.h:49
AssetsTracker
Definition: AssetsTracker.h:28
AnimationWriter.h
check_recipes
void check_recipes()
Definition: recipe.c:146
QuestLoader
Definition: QuestLoader.h:24
obj::name
sstring name
Definition: object.h:314
AssetsCollection
Definition: AssetsCollection.h:39
faceset_op
void(* faceset_op)(const face_sets *)
Definition: assets.h:50
AssetsManager::treasures
Treasures * treasures()
Definition: AssetsManager.h:54
ASSETS_FACES
#define ASSETS_FACES
Definition: assets.h:25
ArchetypeLoader
Definition: ArchetypeLoader.h:22
microtar.h
ASSETS_ARCHETYPES
#define ASSETS_ARCHETYPES
Definition: assets.h:24
mtar_finalize
int mtar_finalize(mtar_t *tar)
Definition: microtar.c:373
build_filename
static void build_filename(const char *name, const char *prefix, char *dest, size_t max)
Definition: assets.cpp:400
fatal
void fatal(enum fatal_error err)
Definition: utils.c:580
FacesetWriter
Definition: FacesetWriter.h:23
compat.h
FormulaeWriter::write
virtual void write(const recipelist *list, StringBuffer *buf)
Definition: FormulaeWriter.cpp:52
AssetsManager::quests
Quests * quests()
Definition: AssetsManager.h:71
AssetsManager::faces
Faces * faces()
Definition: AssetsManager.h:39
quests_count
size_t quests_count(bool includeSystem)
Definition: assets.cpp:713
check_summoned
void check_summoned(void)
Definition: assets.cpp:187
navar-midane_time.data
data
Definition: navar-midane_time.py:11
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
Facesets::findById
face_sets * findById(int id)
Definition: Facesets.cpp:19
pack_formulae
static void pack_formulae(StringBuffer *buf)
Definition: assets.cpp:391
ArtifactWriter
Definition: ArtifactWriter.h:22
FacesetWriter.h
artifactliststruct
Definition: artifact.h:26
QuestWriter
Definition: QuestWriter.h:19
sstring
const typedef char * sstring
Definition: global.h:40
disinfect.count
int count
Definition: disinfect.py:7
say.max
dictionary max
Definition: say.py:148
assets_finish_archetypes_for_play
void assets_finish_archetypes_for_play()
Definition: assets.cpp:550
Settings::hooks_filename
const char * hooks_filename[20]
Definition: global.h:328
AssetCollector::addLoader
void addLoader(AssetLoader *loader)
Definition: AssetCollector.h:40
pack_images
static void pack_images(mtar_t *tar)
Definition: assets.cpp:446
AssetsCollection::get
T * get(const Key &name)
Definition: AssetsCollection.h:66
recipeliststruct
Definition: recipe.h:37
AssetsCollection::each
void each(std::function< void(T *)> op)
Definition: AssetsCollection.h:135
get_face_by_id
const Face * get_face_by_id(uint16_t id)
Definition: assets.cpp:345
mtar_write_data
int mtar_write_data(mtar_t *tar, const void *data, unsigned size)
Definition: microtar.c:357
mtar_header_t
Definition: microtar.h:43
quest_get_by_code
quest_definition * quest_get_by_code(sstring code)
Definition: assets.cpp:700
AssetsManager::facesets
Facesets * facesets()
Definition: AssetsManager.h:65
check_spells
static void check_spells(void)
Definition: assets.cpp:204
ASSETS_ATTACK_MESSAGES
#define ASSETS_ATTACK_MESSAGES
Definition: assets.h:33
AssetsCollection::next
T * next(T *current)
Definition: AssetsCollection.h:116
image.h
get_message_from_identifier
const GeneralMessage * get_message_from_identifier(const char *identifier)
Definition: assets.cpp:358
ASSETS_REGIONS
#define ASSETS_REGIONS
Definition: assets.h:35
ASSETS_ARTIFACTS
#define ASSETS_ARTIFACTS
Definition: assets.h:31
mtar_write_header
int mtar_write_header(mtar_t *tar, const mtar_header_t *h)
Definition: microtar.c:323
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
split_string
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Definition: utils.c:483
ASSETS_TREASURES
#define ASSETS_TREASURES
Definition: assets.h:28
try_find_animation
Animations * try_find_animation(const char *name)
Definition: assets.cpp:300
StringBuffer
Definition: stringbuffer.c:25
is_valid_types_gen.found
found
Definition: is_valid_types_gen.py:39
mtar_header_t::mode
unsigned mode
Definition: microtar.h:44
mtar_close
int mtar_close(mtar_t *tar)
Definition: microtar.c:211
obj::title
sstring title
Definition: object.h:320
recipe_find_ingredient_cost
long recipe_find_ingredient_cost(const char *name)
Definition: assets.cpp:582
quest_find_by_code
quest_definition * quest_find_by_code(sstring code)
Definition: assets.cpp:689
MessageLoader
Definition: MessageLoader.h:22
animations_struct
Definition: face.h:25
add_to_tar
static void add_to_tar(mtar_t *tar, void *data, size_t len, const char *filename)
Definition: assets.cpp:423
make_face_from_files.out
out
Definition: make_face_from_files.py:75
QuestLoader.h
MTAR_TREG
@ MTAR_TREG
Definition: microtar.h:34
llevInfo
@ llevInfo
Definition: logger.h:12
Floor.t
t
Definition: Floor.py:62
MessageWriter
Definition: MessageWriter.h:22
archt::clone
object clone
Definition: object.h:473
ArtifactLoader
Definition: ArtifactLoader.h:18
item
Definition: item.py:1
Faces.h
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
AssetWriter::write
virtual void write(const T *asset, StringBuffer *buf)=0
WrapperLoader.h
give.op
op
Definition: give.py:33
assets_number_of_treasurelists
size_t assets_number_of_treasurelists()
Definition: assets.cpp:272
autojail.value
value
Definition: autojail.py:6
AssetCollector
Definition: AssetCollector.h:24
MTAR_ESUCCESS
@ MTAR_ESUCCESS
Definition: microtar.h:22
quest_definition
Definition: quest.h:42
find_archetype
archetype * find_archetype(const char *name)
Definition: assets.cpp:284
init_attackmess
void init_attackmess(BufferReader *reader, const char *filename)
Definition: init.c:445
stringbuffer_length
size_t stringbuffer_length(StringBuffer *sb)
Definition: stringbuffer.c:218
convert.dest
dest
Definition: convert.py:25
FormulaeWriter
Definition: FormulaeWriter.h:22
PngLoader.h
assets.h
buf
StringBuffer * buf
Definition: readable.c:1610
ASSETS_PNG
#define ASSETS_PNG
Definition: assets.h:29
Settings::hooks
collectorHook hooks[20]
Definition: global.h:329
WrapperLoader
Definition: WrapperLoader.h:27
find_animation
Animations * find_animation(const char *name)
Definition: assets.cpp:296
anim_op
void(* anim_op)(const Animations *)
Definition: assets.h:49
FaceLoader.h
TreasureWriter
Definition: TreasureWriter.h:22
ArchetypeLoader.h
strcasecmp
int strcasecmp(const char *s1, const char *s2)
FaceLoader
Definition: FaceLoader.h:22
faces_for_each
void faces_for_each(face_op op)
Definition: assets.cpp:323
TarLoader
Definition: TarLoader.h:8
try_find_archetype
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:288
try_find_face
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:312
assets_pack
void assets_pack(const char *what, const char *filename)
Definition: assets.cpp:459
SP_SUMMON_GOLEM
#define SP_SUMMON_GOLEM
Definition: spells.h:86
AssetsManager
Definition: AssetsManager.h:28
pack_artifacts
static void pack_artifacts(StringBuffer *buf)
Definition: assets.cpp:378
ArtifactLoader.h
TreasureWriter.h
MessageLoader.h
assets_collect
void assets_collect(const char *datadir, int what)
Definition: assets.cpp:117
nroftreasures
size_t nroftreasures
Definition: assets.cpp:84
split
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2655
TarLoader.h
ArtifactWriter::write
virtual void write(const artifact *item, StringBuffer *buf)
Definition: ArtifactWriter.cpp:21
arch_op
void(* arch_op)(archetype *)
Definition: assets.h:47
PngLoader
Definition: PngLoader.h:22
stringbuffer_delete
void stringbuffer_delete(StringBuffer *sb)
Definition: stringbuffer.c:71
check_formulae
void check_formulae(void)
Definition: recipe.c:293
get_faces_count
size_t get_faces_count()
Definition: assets.cpp:319
face_sets
Definition: image.h:17
SPELL
@ SPELL
Definition: object.h:214
replace.current
current
Definition: replace.py:64
spell_mapping
const char *const spell_mapping[SPELL_MAPPINGS]
Definition: object.c:74
if
if(!(yy_init))
Definition: loader.c:2626
manager
static AssetsManager * manager
Definition: assets.cpp:64
AssetWriter
Definition: AssetWriter.h:24
FacesetLoader.h
AssetCollector.h
assets_init
void assets_init()
Definition: assets.cpp:69
assets_number_of_treasures
size_t assets_number_of_treasures()
Definition: assets.cpp:269
treasureliststruct
Definition: treasure.h:82
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
autoconf.h
assets_end_load
void assets_end_load()
Definition: assets.cpp:241
check_treasurelist
static void check_treasurelist(treasure *t, const treasurelist *tl)
Definition: assets.cpp:97
give.name
name
Definition: give.py:27
ASSETS_FORMULAE
#define ASSETS_FORMULAE
Definition: assets.h:32