Crossfire Server, Trunk
Animations.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 "Animations.h"
14 extern "C" {
15 #include "global.h"
16 }
17 #include "assets.h"
18 
20  get("###none");
21  m_undefined.clear();
22 }
23 
24 Animations *AllAnimations::create(const std::string& name) {
25  Animations *anim = (Animations *)calloc(1, sizeof(Animations));
26  anim->name = add_string(name.c_str());
27  anim->num_animations = 1;
28  return anim;
29 }
30 
32  free_string(item->name);
33  free(item->faces);
34  free(item);
35 }
36 void AllAnimations::replace(Animations *existing, Animations *update) {
37  free(existing->faces);
38  existing->faces = update->faces;
39  update->faces = nullptr;
40  existing->facings = update->facings;
41  existing->num_animations = update->num_animations;
42  free_string(update->name);
43  free(update);
44 }
45 
47  anim->num = m_assets.size() - 1;
48 }
AllAnimations::destroy
virtual void destroy(Animations *item)
Definition: Animations.cpp:31
global.h
add_string
sstring add_string(const char *str)
Definition: shstr.c:124
AllAnimations::create
virtual Animations * create(const std::string &name)
Definition: Animations.cpp:24
free_string
void free_string(sstring str)
Definition: shstr.c:280
AssetsCollection< Animations >::m_assets
std::map< std::string, Animations * > m_assets
Definition: AssetsCollection.h:157
animations_struct::num_animations
uint8_t num_animations
Definition: face.h:27
AssetsCollection< Animations >::m_undefined
std::set< std::string > m_undefined
Definition: AssetsCollection.h:158
AllAnimations::added
virtual void added(Animations *anim)
Definition: Animations.cpp:46
AssetsCollection< Animations >::get
Animations * get(const std::string &name)
Definition: AssetsCollection.h:66
animate.anim
string anim
Definition: animate.py:20
animations_struct::name
sstring name
Definition: face.h:26
animations_struct
Definition: face.h:25
animations_struct::facings
uint8_t facings
Definition: face.h:28
item
Definition: item.py:1
animations_struct::faces
const Face ** faces
Definition: face.h:30
Animations.h
assets.h
AllAnimations::replace
virtual void replace(Animations *existing, Animations *update)
Definition: Animations.cpp:36
AllAnimations::AllAnimations
AllAnimations()
Definition: Animations.cpp:19
give.name
name
Definition: give.py:27