23 : m_faces(faces), m_animations(animations), m_tracker(tracker)
29 int num_frames = 0, i;
45 if (!strncmp(buf,
"mina", 4)) {
46 anim->
faces =
static_cast<const Face **
>(malloc(
sizeof(
Face*)*num_frames));
47 for (i = 0; i < num_frames; i++)
48 anim->
faces[i] = faces[i];
50 if (num_frames <= 1) {
51 LOG(
llevDebug,
"anim: %s has less then two faces in %s\n",
52 anim->
name, full_path.c_str());
54 if (num_frames % anim->
facings) {
55 LOG(
llevDebug,
"anim: %s has %d frames: not a multiple of facings (%d) in %s\n",
56 anim->
name, num_frames,
57 anim->
facings, full_path.c_str());
64 }
else if (!strncmp(buf,
"facings", 7)) {
65 if (!(anim->
facings = atoi(buf+7))) {
66 LOG(
llevDebug,
"anim: %s has 0 facings in %s (line %s)\n",
67 anim->
name, full_path.c_str(),
buf);
72 faces[num_frames++] = face;
82 if (*buf ==
'#' || *buf ==
'\0')
84 if (!strncmp(buf,
"end", 3)) {
95 if (!strncmp(buf,
"smoothface ", 11)) {
99 char *space = strchr(buf + 11,
' ');
101 LOG(
llevError,
"Invalid 'smoothface' %s in %s\n", buf, filename.c_str());
113 if (!strncmp(buf,
"face ", 5)) {
117 LOG(
llevError,
"'face' within a 'face' in %s\n", filename.c_str());
123 on_face =
static_cast<Face *
>(calloc(1,
sizeof(
Face)));
130 if (!strncmp(buf,
"animation ", 10)) {
132 LOG(
llevError,
"faces: 'animation' in 'face' block is deprecated in %s\n", filename.c_str());
137 if (on_face == NULL) {
138 LOG(
llevError,
"faces: got line with no face set in %s: %s\n", filename.c_str(),
buf);
139 }
else if (!strncmp(buf,
"visibility", 10)) {
141 }
else if (!strncmp(buf,
"magicmap", 8)) {
144 }
else if (!strncmp(buf,
"is_floor", 8)) {
145 int value = atoi(buf+9);
149 LOG(
llevError,
"faces: unknown line in file %s: %s\n", filename.c_str(),
buf);
153 LOG(
llevError,
"unfinished face in %s\n", filename.c_str());
This represents one animation.
Face * smoothface
Smoothed face for this, NULL for none.
T * get(const Key &name)
Get a named asset.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
New face structure - this enforces the notion that data is face by face only - you can not change the...
virtual void load(BufferReader *reader, const std::string &filename) override
Load assets from the specified reader.
sstring add_string(const char *str)
Share a string.
Global type definitions and header inclusions.
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
uint8_t num_animations
How many different faces to animate, size of the faces array.
AssetsTracker * m_tracker
Base class to be informed of where an asset is defined.
FaceLoader(Faces *faces, AllAnimations *animations, AssetsTracker *tracker)
Compatibility implementations of useful nonstandard types and functions.
uint8_t facings
How many facings (1,2,4,8).
AllAnimations * m_animations
virtual void assetDefined(const archetype *asset, const std::string &filename)
Function called when an asset is defined in a file.
void loadAnimationBlock(BufferReader *reader, const std::string &full_path, const char *animation_name)
uint8_t visibility
How visible is the face compared to other faces, highest wins.
Only for debugging purposes.
const Face * find_face(const char *name)
const Face ** faces
The actual faces for the animation.
uint8_t find_color(const char *name)
Finds a color by name.
sstring name
Name of the animation sequence.
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.
uint8_t magicmap
Color to show this in magic map.
sstring name
Face name, as used by archetypes and such.
T * define(const Key &name, T *asset)
Define an asset, erasing an existing one.