Crossfire Server  1.75.0
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 #include "global.h"
24 #include "compat.h"
25 #include "assets.h"
26 #include "AssetsManager.h"
27 #include "AssetCollector.h"
28 #include "TreasureLoader.h"
29 #include "ArchetypeLoader.h"
30 #include "PngLoader.h"
31 #include "FacesetLoader.h"
32 #include "FaceLoader.h"
33 #include "WrapperLoader.h"
34 #include "MessageLoader.h"
35 #include "QuestLoader.h"
36 #include "ArtifactLoader.h"
37 #include "Faces.h"
38 #include <string.h>
39 
40 #include <set>
41 #include <unordered_map>
42 #include <memory>
43 
44 #include "AssetWriter.h"
45 #include "TreasureWriter.h"
46 #include "FaceWriter.h"
47 #include "AnimationWriter.h"
48 #include "ArchetypeWriter.h"
49 #include "MessageWriter.h"
50 #include "image.h"
51 #include "FacesetWriter.h"
52 #include "ArtifactWriter.h"
53 #include "FormulaeWriter.h"
54 #include "QuestWriter.h"
55 
56 #include "microtar.h"
57 #include "TarLoader.h"
58 
59 static AssetsManager *manager = nullptr;
60 static std::vector<std::pair<std::string, collectorHook>> collector_hooks;
65 void assets_init() {
66  manager = new AssetsManager();
67 }
68 
72 void assets_free() {
73  delete manager;
74  manager = nullptr;
75 }
76 
80 size_t nroftreasures = 0;
81 
93 static void check_treasurelist(treasure *t, const treasurelist *tl) {
94  if (t->item == NULL && t->name == NULL)
95  LOG(llevError, "Treasurelist %s has element with no name or archetype\n", tl->name);
96  if (t->chance >= 100 && t->next_yes && (t->next || t->next_no))
97  LOG(llevError, "Treasurelist %s has element that has 100%% generation, next_yes field as well as next or next_no\n", tl->name);
98  if (t->name && strcmp(t->name, "NONE"))
100  if (t->next)
101  check_treasurelist(t->next, tl);
102  if (t->next_yes)
104  if (t->next_no)
105  check_treasurelist(t->next_no, tl);
106 }
107 
113 void assets_collect(const char* datadir, int what) {
114  LOG(llevInfo, "Starting to collect assets from %s\n", datadir);
115 
116  AssetCollector collector;
117  if (what & ASSETS_TREASURES)
118  collector.addLoader(new TreasureLoader(manager->treasures(), manager->archetypes(), settings.assets_tracker));
119  if (what & ASSETS_ARCHETYPES)
120  collector.addLoader(new ArchetypeLoader(manager->archetypes(), settings.assets_tracker));
121  if (what & ASSETS_PNG)
122  collector.addLoader(new PngLoader(manager->faces(), manager->facesets()));
123  if (what & ASSETS_FACESETS)
124  collector.addLoader(new FacesetLoader(manager->facesets()));
125  if (what & ASSETS_FACES)
126  collector.addLoader(new FaceLoader(manager->faces(), manager->animations(), settings.assets_tracker));
127  if (what & ASSETS_MESSAGES)
128  collector.addLoader(new MessageLoader(manager->messages(), settings.assets_tracker));
129  if (what & ASSETS_ARTIFACTS) {
131  }
132  if (what & ASSETS_FORMULAE) {
133  collector.addLoader(new WrapperLoader("/formulae", init_formulae));
134  collector.addLoader(new WrapperLoader(".formulae", init_formulae));
135  }
136  if (what & ASSETS_ATTACK_MESSAGES)
137  collector.addLoader(new WrapperLoader("/attackmess", init_attackmess));
138  if (what & ASSETS_QUESTS)
139  collector.addLoader(new QuestLoader(manager->quests(), manager->faces(), settings.assets_tracker));
140  if (what & ASSETS_REGIONS)
141  collector.addLoader(new WrapperLoader("regions.reg", init_regions));
142  for (const auto& hook : collector_hooks) {
143  collector.addLoader(new WrapperLoader(hook.first, hook.second));
144  }
145  collector.addLoader(new TarLoader(&collector));
146  collector.collect(datadir);
147 
148  if (what & ASSETS_ARTIFACTS) {
150  }
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 (%zu)\n", spell_mapping[i], i);
220  abort = 1;
221  }
222  }
223 
224  if (abort)
226 }
227 
233  check_spells();
234  check_summoned();
235  manager->treasures()->each([] (auto list) {
236  if (list->items) {
237  check_treasurelist(list->items, list);
238  }
239  });
240  check_recipes();
241  check_formulae();
242 }
243 
253 treasurelist *find_treasurelist(const char *name) {
254  if (!strcmp(name, "none"))
255  return NULL;
256  return manager->treasures()->get(name);
257 }
258 
260  return nroftreasures;
261 }
263  return manager->treasures()->count();
264 }
265 
267  return manager->archetypes()->next(current);
268 }
269 
270 archetype *find_archetype(const char *name) {
271  return manager->archetypes()->get(name);
272 }
273 
274 archetype *try_find_archetype(const char *name) {
275  return manager->archetypes()->find(name);
276 }
277 
278 Animations *find_animation(const char *name) {
279  return manager->animations()->get(name);
280 }
281 
282 Animations *try_find_animation(const char *name) {
283  return manager->animations()->find(name);
284 }
285 
286 const Face *find_face(const char *name) {
287  return manager->faces()->get(name);
288 }
289 
290 const Face *try_find_face(const char *name, const Face *error) {
291  auto found = manager->faces()->find(name);
292  if (found)
293  return found;
294  return error;
295 }
296 
297 size_t get_faces_count() {
298  return manager->faces()->count();
299 }
300 
302  manager->faces()->each(*op);
303 }
304 
306  manager->archetypes()->each(*op);
307 }
308 
310  return manager;
311 }
312 
319 const Face *get_face_by_id(uint16_t id) {
320  return manager->faces()->findById(id);
321 }
322 
328 const GeneralMessage *get_message_from_identifier(const char *identifier) {
329  return manager->messages()->find(identifier);
330 }
331 
333  return manager->facesets()->findById(id);
334 }
335 
336 template<class T>
337 static void do_pack(AssetWriter<T> *writer, AssetsCollection<T> *assets, StringBuffer *buf) {
338  assets->each([writer, buf] (T *asset) {
339  writer->write(asset, buf);
340  });
341  delete writer;
342 }
343 
345  ArtifactWriter writer;
347  while (list) {
348  for (const auto item : list->items) {
349  writer.write(item, buf);
350  }
351  list = list->next;
352  }
353 }
354 
356  FormulaeWriter writer;
357  recipelist *list = get_formulalist(1);
358  while (list) {
359  writer.write(list, buf);
360  list = list->next;
361  }
362 }
363 
364 static void build_filename(const char *name, const char *prefix, char *dest, size_t max) {
365  auto dot = strrchr(name, '.');
366  // If name has no '.', then just name.prefix
367  if (!dot) {
368  snprintf(dest, max, "%s.%s", name, prefix);
369  return;
370  }
371 
372  // filename for name.111 is name.prefix.111.png
373  memset(dest, 0, max);
374  dot++;
375 
376  snprintf(dest, max, "%.*s%s.%s.png", (int)(dot - name), name, prefix, dot);
377 }
378 
386 static void add_to_tar(mtar_t *tar, void *data, size_t len, const char *filename) {
387  mtar_header_t h;
388  memset(&h, 0, sizeof(h));
389  strncpy(h.name, filename, sizeof(h.name));
390  h.size = len;
391  h.type = MTAR_TREG;
392  h.mode = 0664;
393  h.mtime = time(NULL);
394  /* Build raw header and write */
395  if (MTAR_ESUCCESS != mtar_write_header(tar, &h)) {
396  LOG(llevError, "Failed to write tar header for %s\n", filename);
398  }
399  if (MTAR_ESUCCESS != mtar_write_data(tar, data, len)) {
400  LOG(llevError, "Failed to write tar data for %s\n", filename);
402  }
403 }
404 
409 static void pack_images(mtar_t *tar) {
410  manager->faces()->each([&tar] (const auto face) {
411  manager->facesets()->each([&tar, &face] (const auto fs) {
412  if (!fs->prefix || fs->allocated <= face->number || !fs->faces[face->number].datalen) {
413  return;
414  }
415  char filename[500];
416  build_filename(face->name, fs->prefix, filename, sizeof(filename));
417  add_to_tar(tar, fs->faces[face->number].data, fs->faces[face->number].datalen, filename);
418  });
419  });
420 }
421 
422 void assets_pack(const char *what, const char *filename) {
423 #define MAX_PACK 100
424  char *split[MAX_PACK];
425  char *dup = strdup_local(what);
426  size_t count = split_string(dup, split, MAX_PACK, '+');
427  if (count == 0) {
428  LOG(llevError, "Invalid pack type %s\n", what);
430  }
431  bool isTar = (count > 1) || (strcmp(split[0], "images") == 0);
432  mtar_t tar;
433  if (isTar) {
434  if (MTAR_ESUCCESS != mtar_open(&tar, filename, "w")) {
435  LOG(llevError, "Failed to open tar file %s\n", filename);
437  }
438  }
439 
440  for (size_t t = 0; t < count; t++) {
441  const char *type = split[t];
442  const char *name = nullptr;
443 
445  if (strcmp(type, "treasures") == 0) {
446  do_pack(new TreasureWriter(), manager->treasures(), buf);
447  name = "crossfire.trs";
448  } else if (strcmp(type, "faces") == 0) {
449  do_pack(new FaceWriter(), manager->faces(), buf);
450  do_pack(new AnimationWriter(), manager->animations(), buf);
451  name = "crossfire.face";
452  } else if (strcmp(type, "archs") == 0) {
453  do_pack(new ArchetypeWriter(), manager->archetypes(), buf);
454  name = "crossfire.arc";
455  } else if (strcmp(type, "messages") == 0) {
456  do_pack(new MessageWriter(), manager->messages(), buf);
457  name = "messages";
458  } else if (strcmp(type, "facesets") == 0) {
459  do_pack(new FacesetWriter(), manager->facesets(), buf);
460  name = "image_info";
461  } else if (strcmp(type, "artifacts") == 0) {
462  pack_artifacts(buf);
463  name = "artifacts";
464  } else if (strcmp(type, "formulae") == 0) {
465  pack_formulae(buf);
466  name = "formulae";
467  } else if (strcmp(type, "quests") == 0) {
468  do_pack(new QuestWriter(), manager->quests(), buf);
469  name = "crossfire.quests";
470  } else if (strcmp(type, "images") == 0) {
471  pack_images(&tar);
472  stringbuffer_delete(buf);
473  continue; // Already stored in tar.
474  } else {
475  LOG(llevError, "Invalid asset type '%s'\n", type);
477  }
478 
479  size_t length = stringbuffer_length(buf);
480  char *data = stringbuffer_finish(buf);
481 
482  if (isTar) {
483  add_to_tar(&tar, data, length, name);
484  } else {
485  FILE *out = fopen(filename, "w+");
486  if (!out) {
487  LOG(llevError, "Failed to open file '%s'\n", filename);
489  }
490  if (fwrite(static_cast<void*>(data), 1, length, out) != length) {
491  LOG(llevError, "Failed to write all data for %s!\n", filename);
492  fclose(out);
494  }
495  fclose(out);
496  }
497  free(data);
498  }
499 
500  if (isTar) {
501  if (MTAR_ESUCCESS != mtar_finalize(&tar)) {
502  LOG(llevError, "Failed to finalize tar file %s\n", filename);
504  }
505  if (MTAR_ESUCCESS != mtar_close(&tar)) {
506  LOG(llevError, "Failed to closed tar file %s\n", filename);
508  }
509  }
510  free(dup);
511 }
512 
514  manager->archetypes()->each([] (archetype *arch) {
515  object *op = &arch->clone;
516  if (op->speed < 0) {
517  op->speed_left = op->speed_left - RANDOM() % 100 / 100.0;
518  op->speed = -op->speed; // Make this always positive
519  }
520  });
521 }
522 
524  quest_definition *quest;
525 
526  quest = quest_get_by_code(code);
527  if (!quest) {
528  LOG(llevError, "quest %s required but not found!\n", code);
529  return NULL;
530  }
531  return quest;
532 }
533 
535  return manager->quests()->find(code);
536 }
537 
543 void quest_for_each(quest_op op, void *user) {
544  manager->quests()->each([&op, &user] (auto q) { op(q, user); });
545 }
546 
547 size_t quests_count(bool includeSystem) {
548  return includeSystem ? manager->quests()->count() : manager->quests()->visibleCount();
549 }
550 
551 void load_assets(void) {
553  assets_end_load();
554 }
555 
556 void assets_add_collector_hook(const char *name, collectorHook hook) {
557  collector_hooks.push_back(std::make_pair(name, hook));
558 }
Error, serious thing.
Definition: logger.h:11
T * next(T *current)
Allow browsing assets in a list-like manner.
static void build_filename(const char *name, const char *prefix, char *dest, size_t max)
Definition: assets.cpp:364
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
static void check_spells(void)
This ensures:
Definition: assets.cpp:202
Treasures * treasures()
Get treasures.
Definition: AssetsManager.h:54
Information.
Definition: logger.h:12
This represents one animation.
Definition: face.h:25
void load_assets(void)
Definition: assets.cpp:551
void(* face_op)(const Face *)
Definition: assets.h:46
Assets collector, recursing in directories and calling loaders on found files.
const char *const spell_mapping[SPELL_MAPPINGS]
This table is only necessary to convert objects that existed before the spell object conversion to th...
Definition: object.cpp:74
Definition of an in-game quest.
Definition: quest.h:37
T * get(const Key &name)
Get a named asset.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
virtual void write(const recipelist *list, StringBuffer *buf)
Write the specified asset to the StringBuffer.
#define strdup_local
Definition: compat.h:29
recipelist * next
Pointer to next recipe list.
Definition: recipe.h:41
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2734
AllAnimations * animations()
Get animations.
Definition: AssetsManager.h:49
archetype * find_archetype(const char *name)
Definition: assets.cpp:270
size_t stringbuffer_length(StringBuffer *sb)
Return the current length of the buffer.
void assets_add_collector_hook(const char *name, collectorHook hook)
Definition: assets.cpp:556
int mtar_write_header(mtar_t *tar, const mtar_header_t *h)
Definition: microtar.cpp:323
void archetypes_for_each(arch_op op)
Definition: assets.cpp:305
New face structure - this enforces the notion that data is face by face only - you can not change the...
Definition: face.h:14
Quests * quests()
Get quests.
Definition: AssetsManager.h:71
Represents all assets of the game.
Definition: AssetsManager.h:28
sstring name
If non null, name of list to use instead.
Definition: treasure.h:66
unsigned mode
Definition: microtar.h:39
const Face * findById(uint16_t id)
Definition: Faces.cpp:44
void quest_for_each(quest_op op, void *user)
Iterate over all quests.
Definition: assets.cpp:543
Collection of assets identified by a unique name.
void assets_init()
Init assets-related variables.
Definition: assets.cpp:65
void init_attackmess(BufferReader *reader, const char *filename)
Initializes the attack messages.
Definition: init.cpp:563
face_sets * find_faceset(int id)
Definition: assets.cpp:332
Animations * find_animation(const char *name)
Definition: assets.cpp:278
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
static AssetsManager * manager
Definition: assets.cpp:59
Facesets * facesets()
Get facesets.
Definition: AssetsManager.h:65
static void pack_formulae(StringBuffer *buf)
Definition: assets.cpp:355
Global type definitions and header inclusions.
#define ASSETS_ATTACK_MESSAGES
Definition: assets.h:29
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:274
#define MAX_PACK
void collect(const std::string &directory)
Recurse in the specified directory, finding all files and calling loaders to process them...
int mtar_finalize(mtar_t *tar)
Definition: microtar.cpp:373
#define ASSETS_ARTIFACTS
Definition: assets.h:27
AssetsManager * getManager()
Definition: assets.cpp:309
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:290
void assets_collect(const char *datadir, int what)
Collect all assets from the specified directory and all its subdirectories.
Definition: assets.cpp:113
static void pack_images(mtar_t *tar)
Pack all client-side images in the specified tar file.
Definition: assets.cpp:409
bool check_formulae(void)
Check if formula don&#39;t have the same index.
Definition: recipe.cpp:292
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Splits a string delimited by passed in sep value into characters into an array of strings...
Definition: utils.cpp:473
std::vector< artifact * > items
Artifacts for this type.
Definition: artifact.h:28
bool check_recipes()
Ensure that all recipes have a valid artifact, and that archetypes are correct.
Definition: recipe.cpp:147
static std::vector< std::pair< std::string, collectorHook > > collector_hooks
Collect hooks, as (filename, function) pairs.
Definition: assets.cpp:60
Faces * faces()
Get faces.
Definition: AssetsManager.h:39
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:483
Image-related structures.
size_t assets_number_of_treasurelists()
Definition: assets.cpp:262
void(* quest_op)(const quest_definition *, void *)
Definition: quest.h:50
#define ASSETS_QUESTS
Definition: assets.h:30
float speed
Frequency of object &#39;moves&#39; relative to server tick rate.
Definition: object.h:337
static void add_to_tar(mtar_t *tar, void *data, size_t len, const char *filename)
Add a file to a .tar file.
Definition: assets.cpp:386
face_sets * findById(int id)
Attempt to find a faceset from its identifier.
Definition: Facesets.cpp:35
#define ASSETS_REGIONS
Definition: assets.h:31
#define QUERY_FLAG(xyz, p)
Definition: define.h:386
Abstract writer of an asset to a StringBuffer.
Definition: AssetWriter.h:22
artifactlist * next
Next list of artifacts.
Definition: artifact.h:27
size_t quests_count(bool includeSystem)
Definition: assets.cpp:547
static void check_treasurelist(treasure *t, const treasurelist *tl)
Checks if a treasure if valid.
Definition: assets.cpp:93
uint8_t chance
Percent chance for this item.
Definition: treasure.h:73
List of recipes with a certain number of ingredients.
Definition: recipe.h:37
void init_regions(BufferReader *reader, const char *filename)
Reads/parses the region file, and copies into a linked list of region structs.
Definition: region.cpp:310
artifactlist * first_artifactlist
First artifact.
Definition: init.cpp:109
void(* arch_op)(archetype *)
Definition: assets.h:45
Archetypes * archetypes()
Get archetypes.
Definition: AssetsManager.h:44
#define ASSETS_ARCHETYPES
Definition: assets.h:20
size_t count() const
Get the number of assets.
This represents all archetypes for one particular object type.
Definition: artifact.h:24
static void pack_artifacts(StringBuffer *buf)
Definition: assets.cpp:344
size_t get_faces_count()
Definition: assets.cpp:297
size_t nroftreasures
Number of treasure items, for malloc info.
Definition: assets.cpp:80
struct Settings settings
Global settings.
Definition: init.cpp:139
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:266
#define ASSETS_ALL
Definition: assets.h:32
void artifact_post_load()
Definition: artifact.cpp:680
int mtar_write_data(mtar_t *tar, const void *data, unsigned size)
Definition: microtar.cpp:357
recipelist * get_formulalist(int i)
Gets a formula list by ingredients count.
Definition: recipe.cpp:98
#define ASSETS_PNG
Definition: assets.h:25
Messages * messages()
Get messages.
Definition: AssetsManager.h:59
See Spell.
Definition: object.h:219
treasure * next_no
If this item was not generated, then continue here.
Definition: treasure.h:71
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
Definition: utils.cpp:590
static void check_generators(void)
Check all generators have the other_arch set or something in inventory.
Definition: assets.cpp:158
void assets_pack(const char *what, const char *filename)
Pack the specified assets in a file.
Definition: assets.cpp:422
Compatibility implementations of useful nonstandard types and functions.
unsigned size
Definition: microtar.h:41
void assets_finish_archetypes_for_play()
Definition: assets.cpp:513
unsigned type
Definition: microtar.h:43
void assets_end_load()
Called after collect is complete, to check various things.
Definition: assets.cpp:231
treasurelist represents one logical group of items to be generated together.
Definition: treasure.h:85
class AssetsTracker * assets_tracker
If not NULL, called each time an asset is defined.
Definition: global.h:333
treasure * next_yes
If this item was generated, use this link instead of ->next.
Definition: treasure.h:70
void addLoader(AssetLoader *loader)
Register a loader to be called on found files.
const char * datadir
Read only data files.
Definition: global.h:249
quest_definition * quest_get_by_code(sstring code)
Find a quest from its code if it exists.
Definition: assets.cpp:534
#define FLAG_GENERATOR
Will generate type ob->stats.food.
Definition: define.h:235
Loader calling a function for files ending with a specific string.
Definition: WrapperLoader.h:23
treasure * next
Next treasure-item in a linked list.
Definition: treasure.h:69
virtual void write(const T *asset, StringBuffer *buf)=0
Write the specified asset to the StringBuffer.
Animations * try_find_animation(const char *name)
Definition: assets.cpp:282
void faces_for_each(face_op op)
Definition: assets.cpp:301
std::function< void(BufferReader *, const char *)> collectorHook
Definition: assets.h:35
sstring name
Usually monster-name/combination.
Definition: treasure.h:86
const Face * find_face(const char *name)
Definition: assets.cpp:286
#define ASSETS_FACES
Definition: assets.h:21
int mtar_open(mtar_t *tar, const char *filename, const char *mode)
Definition: microtar.cpp:177
#define ASSETS_MESSAGES
Definition: assets.h:26
#define ASSETS_TREASURES
Definition: assets.h:24
void stringbuffer_delete(StringBuffer *sb)
Totally delete a string buffer.
treasurelist * find_treasurelist(const char *name)
Search for the given treasurelist by name.
Definition: assets.cpp:253
unsigned mtime
Definition: microtar.h:42
char name[100]
Definition: microtar.h:44
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
virtual void write(const artifact *item, StringBuffer *buf)
Write the specified asset to the StringBuffer.
size_t visibleCount() const
Definition: Quests.h:24
const GeneralMessage * get_message_from_identifier(const char *identifier)
Find the message from its identifier.
Definition: assets.cpp:328
T * find(const Key &name)
Get a named asset if it exists.
C function wrappers to interact with assets.
StringBuffer * buf
Definition: readable.cpp:1563
One general message, from the lib/messages file.
Definition: book.h:44
struct archetype * item
Which item this link can be.
Definition: treasure.h:64
void init_formulae(BufferReader *reader, const char *filename)
Builds up the lists of formula from the file in the libdir.
Definition: recipe.cpp:166
A buffer that will be expanded as content is added to it.
#define ASSETS_FACESETS
Definition: assets.h:23
const char * sstring
Definition: sstring.h:2
int mtar_close(mtar_t *tar)
Definition: microtar.cpp:211
quest_definition * quest_find_by_code(sstring code)
Find a quest from its code, logging if no matching quest.
Definition: assets.cpp:523
void check_summoned(void)
This checks all summonable items for move_type and other things.
Definition: assets.cpp:185
Information about one face set.
Definition: image.h:17
#define SP_SUMMON_GOLEM
Definition: spells.h:86
#define FLAG_CONTENT_ON_GEN
Use
Definition: define.h:361
object clone
An object from which to do object_copy()
Definition: object.h:487
static void do_pack(AssetWriter< T > *writer, AssetsCollection< T > *assets, StringBuffer *buf)
Definition: assets.cpp:337
size_t assets_number_of_treasures()
Definition: assets.cpp:259
void assets_free()
Free all assets-related memory.
Definition: assets.cpp:72
const Face * get_face_by_id(uint16_t id)
Get a face from its unique identifier.
Definition: assets.cpp:319
#define ASSETS_FORMULAE
Definition: assets.h:28
void each(std::function< void(T *)> op)
Apply a function to each asset.