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