Crossfire Server, Trunk
FacesetLoader.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 
13 #include "FacesetLoader.h"
14 
15 #include "global.h"
16 #include "image.h"
17 #include "string.h"
18 #include "Facesets.h"
19 
20 FacesetLoader::FacesetLoader(Facesets *facesets) : m_facesets(facesets) {
21 }
22 
23 void FacesetLoader::load(BufferReader *reader, const std::string& filename) {
24  char *buf;
25  char *cps[7+1];
26 
27  while ((buf = bufferreader_next_line(reader)) != NULL) {
28  if (buf[0] == '#' || buf[0] == '\0')
29  continue;
30  if (split_string(buf, cps, sizeof(cps)/sizeof(*cps), ':') != 6)
31  LOG(llevError, "Bad line in image_info file %s, ignoring line:\n %s", filename.c_str(), buf);
32  else {
33  face_sets *added = static_cast<face_sets *>(calloc(1, sizeof(face_sets)));
34  added->prefix = strdup_local(cps[0]);
35  added->fullname = strdup_local(cps[1]);
36  if (cps[2][0] != '\0') {
37  added->fallback = m_facesets->get(cps[2]);
38  }
39  added->size = strdup_local(cps[3]);
40  added->extension = strdup_local(cps[4]);
41  added->comment = strdup_local(cps[5]);
42 
43  m_facesets->define(added->prefix, added);
44  }
45  }
46 }
FacesetLoader::FacesetLoader
FacesetLoader(Facesets *facesets)
Definition: FacesetLoader.cpp:20
global.h
llevError
@ llevError
Definition: logger.h:11
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:58
strdup_local
#define strdup_local
Definition: compat.h:29
Facesets
Definition: Facesets.h:23
Facesets.h
FacesetLoader::load
virtual void load(BufferReader *reader, const std::string &filename) override
Definition: FacesetLoader.cpp:23
npc_dialog.filename
filename
Definition: npc_dialog.py:99
buf
StringBuffer * buf
Definition: readable.cpp:1565
face_sets::prefix
char * prefix
Definition: image.h:19
face_sets::extension
char * extension
Definition: image.h:23
AssetsCollection::define
T * define(const Key &name, T *asset)
Definition: AssetsCollection.h:120
split_string
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Definition: utils.cpp:473
face_sets::comment
char * comment
Definition: image.h:24
face_sets::size
char * size
Definition: image.h:22
AssetsCollection::get
T * get(const Key &name)
Definition: AssetsCollection.h:89
image.h
face_sets::fallback
struct face_sets * fallback
Definition: image.h:21
FacesetLoader::m_facesets
Facesets * m_facesets
Definition: FacesetLoader.h:32
face_sets::fullname
char * fullname
Definition: image.h:20
face_sets
Definition: image.h:17
BufferReader
Definition: bufferreader.cpp:21
FacesetLoader.h
bufferreader_next_line
char * bufferreader_next_line(BufferReader *br)
Definition: bufferreader.cpp:102