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  for (uint8_t hook = 0; hook < settings.hooks_count; hook++) {
147  collector.addLoader(new WrapperLoader(settings.hooks_filename[hook], settings.hooks[hook]));
148  }
149  collector.addLoader(new TarLoader(&collector));
150  collector.collect(datadir);
151 
152  LOG(llevInfo, "Finished collecting assets from %s\n", datadir);
153 }
154 
158 static void check_generators(void) {
159  int abort = 0;
160 
161  manager->archetypes()->each([&abort] (const auto& arch) {
162  if (!QUERY_FLAG(&arch->clone, FLAG_GENERATOR))
163  return;
164 
165  if (!QUERY_FLAG(&arch->clone, FLAG_CONTENT_ON_GEN) && arch->clone.other_arch == NULL) {
166  LOG(llevError, "Fatal: %s is generator without content_on_gen but lacks other_arch.\n", arch->name);
167  abort = 1;
168  return;
169  }
170  if (QUERY_FLAG(&arch->clone, FLAG_CONTENT_ON_GEN) && arch->clone.inv == NULL) {
171  LOG(llevError, "Fatal: %s is generator with content_on_gen but lacks inventory.\n", arch->name);
172  abort = 1;
173  return;
174  }
175  });
176 
177  if (abort)
179 }
180 
185 void check_summoned(void) {
186  manager->archetypes()->each([] (const auto& arch) {
187  if (arch->clone.type == SPELL && arch->clone.subtype == SP_SUMMON_GOLEM && arch->clone.other_arch) {
188  if (arch->clone.other_arch->clone.move_type == 0) {
189  LOG(llevError, "Summonable archetype %s [%s] has no move_type defined!\n", arch->clone.other_arch->name, arch->clone.other_arch->clone.name);
190  fatal(SEE_LAST_ERROR);
191  }
192  }
193  });
194 }
195 
202 static void check_spells(void) {
203  int abort = 0;
204 
205  manager->archetypes()->each([&abort] (const auto& arch) {
206  if (arch->clone.type == SPELL && arch->clone.skill) {
207  auto skill = manager->archetypes()->first([&arch] (const archetype *skill) {
208  return skill->clone.type == SKILL && arch->clone.skill == skill->clone.name;
209  });
210  if (!skill) {
211  LOG(llevError, "Spell %s has improper associated skill %s\n", arch->name, arch->clone.skill);
212  abort = 1;
213  }
214  }
215  });
216 
217  for (size_t i = 0; i < sizeof(spell_mapping) / sizeof(spell_mapping[0]); i++) {
219  LOG(llevError, "Unable to find spell mapping %s (%i)\n", spell_mapping[i], i);
220  abort = 1;
221  }
222  }
223 
224  if (abort)
226 }
227 
233  return manager->dumpUndefined();
234 }
235 
241  check_spells();
242  check_summoned();
243  manager->treasures()->each([] (auto list) {
244  if (list->items) {
245  check_treasurelist(list->items, list);
246  }
247  });
248  check_recipes();
249  check_formulae();
250 }
251 
262  if (!strcmp(name, "none"))
263  return NULL;
264  return manager->treasures()->get(name);
265 }
266 
268  return nroftreasures;
269 }
271  return manager->treasures()->count();
272 }
273 
275  return manager->archetypes()->count();
276 }
277 
279  return manager->archetypes()->next(current);
280 }
281 
283  return manager->archetypes()->get(name);
284 }
285 
287  return manager->archetypes()->find(name);
288 }
289 
291  return manager->animations()->count();
292 }
293 
295  return manager->animations()->get(name);
296 }
297 
299  return manager->animations()->find(name);
300 }
301 
303  manager->animations()->each(*op);
304 }
305 
306 const Face *find_face(const char *name) {
307  return manager->faces()->get(name);
308 }
309 
310 const Face *try_find_face(const char *name, const Face *error) {
311  auto found = manager->faces()->find(name);
312  if (found)
313  return found;
314  return error;
315 }
316 
317 size_t get_faces_count() {
318  return manager->faces()->count();
319 }
320 
322  manager->faces()->each(*op);
323 }
324 
326  manager->facesets()->each(*op);
327 }
328 
330  manager->archetypes()->each(*op);
331 }
332 
334  return manager;
335 }
336 
343 const Face *get_face_by_id(uint16_t id) {
344  return manager->faces()->findById(id);
345 }
346 
348  return manager->messages()->random();
349 }
350 
356 const GeneralMessage *get_message_from_identifier(const char *identifier) {
357  return manager->messages()->find(identifier);
358 }
359 
361  return manager->faces()->checksum();
362 }
363 
365  return manager->facesets()->findById(id);
366 }
367 
368 template<class T>
369 static void do_pack(AssetWriter<T> *writer, AssetsCollection<T> *assets, StringBuffer *buf) {
370  assets->each([writer, buf] (T *asset) {
371  writer->write(asset, buf);
372  });
373  delete writer;
374 }
375 
377  ArtifactWriter writer;
379  while (list) {
380  auto item = list->items;
381  while (item) {
382  writer.write(item, buf);
383  item = item->next;
384  }
385  list = list->next;
386  }
387 }
388 
390  FormulaeWriter writer;
392  while (list) {
393  writer.write(list, buf);
394  list = list->next;
395  }
396 }
397 
398 static void build_filename(const char *name, const char *prefix, char *dest, size_t max) {
399  auto dot = strrchr(name, '.');
400  if (!dot) {
401  snprintf(dest, max, "%s.%s", name, prefix);
402  return;
403  }
404  memset(dest, 0, max);
405  dot++;
406 
407  memcpy(dest, name, dot - name);
408  strncat(dest, prefix, max);
409  strncat(dest, ".", max);
410  strncat(dest, dot, max);
411  strncat(dest, ".png", max);
412 }
413 
421 static void add_to_tar(mtar_t *tar, void *data, size_t len, const char *filename) {
422  mtar_header_t h;
423  memset(&h, 0, sizeof(h));
424  strncpy(h.name, filename, sizeof(h.name));
425  h.size = len;
426  h.type = MTAR_TREG;
427  h.mode = 0664;
428  h.mtime = time(NULL);
429  /* Build raw header and write */
430  if (MTAR_ESUCCESS != mtar_write_header(tar, &h)) {
431  LOG(llevError, "Failed to write tar header for %s\n", filename);
433  }
434  if (MTAR_ESUCCESS != mtar_write_data(tar, data, len)) {
435  LOG(llevError, "Failed to write tar data for %s\n", filename);
437  }
438 }
439 
444 static void pack_images(mtar_t *tar) {
445  manager->faces()->each([&tar] (const auto face) {
446  manager->facesets()->each([&tar, &face] (const auto fs) {
447  if (!fs->prefix || fs->allocated <= face->number || !fs->faces[face->number].datalen) {
448  return;
449  }
450  char filename[500];
451  build_filename(face->name, fs->prefix, filename, sizeof(filename));
452  add_to_tar(tar, fs->faces[face->number].data, fs->faces[face->number].datalen, filename);
453  });
454  });
455 }
456 
457 void assets_pack(const char *what, const char *filename) {
458 #define MAX_PACK 100
459  char *split[MAX_PACK];
460  char *dup = strdup_local(what);
461  size_t count = split_string(dup, split, MAX_PACK, '+');
462  if (count == 0) {
463  LOG(llevError, "Invalid pack type %s\n", what);
465  }
466  bool isTar = (count > 1) || (strcmp(split[0], "images") == 0);
467  mtar_t tar;
468  if (isTar) {
469  if (MTAR_ESUCCESS != mtar_open(&tar, filename, "w")) {
470  LOG(llevError, "Failed to open tar file %s\n", filename);
472  }
473  }
474 
475  for (size_t t = 0; t < count; t++) {
476  const char *type = split[t];
477  const char *name = nullptr;
478 
480  if (strcmp(type, "treasures") == 0) {
482  name = "crossfire.trs";
483  } else if (strcmp(type, "faces") == 0) {
484  do_pack(new FaceWriter(), manager->faces(), buf);
486  name = "crossfire.face";
487  } else if (strcmp(type, "archs") == 0) {
489  name = "crossfire.arc";
490  } else if (strcmp(type, "messages") == 0) {
492  name = "messages";
493  } else if (strcmp(type, "facesets") == 0) {
495  name = "image_info";
496  } else if (strcmp(type, "artifacts") == 0) {
498  name = "artifacts";
499  } else if (strcmp(type, "formulae") == 0) {
501  name = "formulae";
502  } else if (strcmp(type, "quests") == 0) {
503  do_pack(new QuestWriter(), manager->quests(), buf);
504  name = "crossfire.quests";
505  } else if (strcmp(type, "images") == 0) {
506  pack_images(&tar);
508  continue; // Already stored in tar.
509  } else {
510  LOG(llevError, "Invalid asset type '%s'\n", type);
512  }
513 
514  size_t length = stringbuffer_length(buf);
515  char *data = stringbuffer_finish(buf);
516 
517  if (isTar) {
518  add_to_tar(&tar, data, length, name);
519  } else {
520  FILE *out = fopen(filename, "w+");
521  if (!out) {
522  LOG(llevError, "Failed to open file '%s'\n", filename);
524  }
525  if (fwrite(static_cast<void*>(data), 1, length, out) != length) {
526  LOG(llevError, "Failed to write all data!\n", filename);
527  fclose(out);
529  }
530  fclose(out);
531  }
532  free(data);
533  }
534 
535  if (isTar) {
536  if (MTAR_ESUCCESS != mtar_finalize(&tar)) {
537  LOG(llevError, "Failed to finalize tar file %s\n", filename);
539  }
540  if (MTAR_ESUCCESS != mtar_close(&tar)) {
541  LOG(llevError, "Failed to closed tar file %s\n", filename);
543  }
544  }
545  free(dup);
546 }
547 
549  manager->archetypes()->each([] (archetype *arch) {
550  object *op = &arch->clone;
551  if (op->speed < 0) {
552  op->speed_left = op->speed_left - RANDOM() % 100 / 100.0;
553  op->speed = -op->speed; // Make this always positive
554  }
555  });
556 }
557 
581  long mult;
582  const char *cp;
583  char part1[100];
584  char part2[100];
585 
586  /* same as atoi(), but skip number */
587  mult = 0;
588  while (isdigit(*name)) {
589  mult = 10*mult+(*name-'0');
590  name++;
591  }
592  if (mult > 0)
593  name++;
594  else
595  mult = 1;
596  /* first, try to match the name of an archetype */
597 
598  long value = 0;
599  bool found = false;
600  manager->archetypes()->each([&value, &found, &name, &part1] (const archetype *at) {
601  if (found) {
602  return;
603  }
604 
605  if (at->clone.title != NULL) {
606  /* inefficient, but who cares? */
607  snprintf(part1, sizeof(part1), "%s %s", at->clone.name, at->clone.title);
608  if (!strcasecmp(part1, name)) {
609  value = at->clone.value;
610  found = true;
611  return;
612  }
613  }
614  if (!strcasecmp(at->clone.name, name)) {
615  value = at->clone.value;
616  found = true;
617  return;
618  }
619  });
620  if (found) {
621  return mult * value;
622  }
623 
624  /* second, try to match an artifact ("arch of something") */
625  cp = strstr(name, " of ");
626  if (cp != NULL) {
627  safe_strncpy(part1, name, sizeof(part1));
628  part1[cp-name] = '\0';
629  safe_strncpy(part2, cp + 4, sizeof(part2));
630  manager->archetypes()->each([&value, &found, &part1, &part2] (const archetype *at) {
631  if (found) {
632  return;
633  }
634 
635  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL) {
636  /* find the first artifact derived from that archetype (same type) */
637  for (auto al = first_artifactlist; al != NULL; al = al->next) {
638  if (al->type == at->clone.type) {
639  for (auto art = al->items; art != NULL; art = art->next) {
640  if (!strcasecmp(art->item->name, part2)) {
641  value = at->clone.value * art->item->value;
642  found = true;
643  return;
644  }
645  }
646  }
647  }
648  }
649  });
650  }
651  if (found) {
652  return mult * value;
653  }
654 
655  /* third, try to match a body part ("arch's something") */
656  cp = strstr(name, "'s ");
657  if (cp != NULL) {
658  safe_strncpy(part1, name, sizeof(part1));
659  part1[cp-name] = '\0';
660  safe_strncpy(part2, cp + 3, sizeof(part2));
661  /* examine all archetypes matching the first part of the name */
662  manager->archetypes()->each([&value, &found, &part1, &part2] (const archetype *at) {
663  if (found) {
664  return;
665  }
666  if (!strcasecmp(at->clone.name, part1) && at->clone.title == NULL) {
667  if (at->clone.randomitems != NULL) {
668  auto at2 = find_treasure_by_name(at->clone.randomitems->items, part2, 0);
669  if (at2 != NULL) {
670  value = at2->clone.value * isqrt(at->clone.level * 2);
671  found = true;
672  return;
673  }
674  }
675  }
676  });
677  }
678  if (found) {
679  return mult * value;
680  }
681 
682  /* failed to find any matching items -- formula should be checked */
683  LOG(llevError, "Couldn't find cost for ingredient %s\n", name);
684  return -1;
685 }
686 
689 
690  quest = quest_get_by_code(code);
691  if (!quest) {
692  LOG(llevError, "quest %s required but not found!\n", code);
693  return NULL;
694  }
695  return quest;
696 }
697 
699  return manager->quests()->find(code);
700 }
701 
707 void quest_for_each(quest_op op, void *user) {
708  manager->quests()->each([&op, &user] (auto q) { op(q, user); });
709 }
710 
711 size_t quests_count(bool includeSystem) {
712  return includeSystem ? manager->quests()->count() : manager->quests()->visibleCount();
713 }
AssetsCollection::count
size_t count() const
Definition: AssetsCollection.h:57
facesets_for_each
void facesets_for_each(faceset_op op)
Definition: assets.cpp:325
Face
Definition: face.h:14
do_pack
static void do_pack(AssetWriter< T > *writer, AssetsCollection< T > *assets, StringBuffer *buf)
Definition: assets.cpp:369
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:329
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:290
ArchetypeWriter.h
Settings::archetypes_tracker
void * archetypes_tracker
Definition: global.h:333
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:707
ArchetypeWriter
Definition: ArchetypeWriter.h:22
AssetsManager::messages
Messages * messages()
Definition: AssetsManager.h:59
assets_dump_undefined
size_t assets_dump_undefined()
Definition: assets.cpp:232
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:329
get_next_archetype
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:278
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
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:347
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:302
find_faceset
face_sets * find_faceset(int id)
Definition: assets.cpp:364
face_op
void(* face_op)(const Face *)
Definition: assets.h:47
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
inja::string_view::split
std::pair< nonstd::string_view, nonstd::string_view > split(nonstd::string_view view, char Separator)
Definition: inja.hpp:1886
MAX_PACK
#define MAX_PACK
find_treasurelist
treasurelist * find_treasurelist(const char *name)
Definition: assets.cpp:261
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:274
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:158
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:306
getManager
AssetsManager * getManager()
Definition: assets.cpp:333
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:470
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:360
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:49
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:398
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:711
check_summoned
void check_summoned(void)
Definition: assets.cpp:185
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:389
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:548
Settings::hooks_filename
const char * hooks_filename[20]
Definition: global.h:330
AssetCollector::addLoader
void addLoader(AssetLoader *loader)
Definition: AssetCollector.h:40
pack_images
static void pack_images(mtar_t *tar)
Definition: assets.cpp:444
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:343
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:698
AssetsManager::facesets
Facesets * facesets()
Definition: AssetsManager.h:65
check_spells
static void check_spells(void)
Definition: assets.cpp:202
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:356
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:298
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:580
quest_find_by_code
quest_definition * quest_find_by_code(sstring code)
Definition: assets.cpp:687
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:421
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:474
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:270
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:282
init_attackmess
void init_attackmess(BufferReader *reader, const char *filename)
Definition: init.c:459
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:331
WrapperLoader
Definition: WrapperLoader.h:27
find_animation
Animations * find_animation(const char *name)
Definition: assets.cpp:294
anim_op
void(* anim_op)(const Animations *)
Definition: assets.h:48
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:321
TarLoader
Definition: TarLoader.h:8
try_find_archetype
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:286
try_find_face
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:310
assets_pack
void assets_pack(const char *what, const char *filename)
Definition: assets.cpp:457
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:376
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
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:46
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:317
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:267
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:239
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