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 #include "global.h"
15 #include "assets.h"
16 
17 template<>
18 Animations *asset_create(const std::string& name) {
19  Animations *anim = (Animations *)calloc(1, sizeof(Animations));
20  anim->name = add_string(name.c_str());
21  anim->num_animations = 1;
22  return anim;
23 }
24 
25 template<>
27  free_string(item->name);
28  free(item->faces);
29  free(item);
30 }
31 
33  get("###none");
34  m_undefined.clear();
35 }
36 
37 void AllAnimations::replace(Animations *existing, Animations *update) {
38  free(existing->faces);
39  existing->faces = update->faces;
40  update->faces = nullptr;
41  existing->facings = update->facings;
42  existing->num_animations = update->num_animations;
43  free_string(update->name);
44  free(update);
45 }
46 
48  anim->num = m_assets.size() - 1;
49 }
asset_create
Animations * asset_create(const std::string &name)
Definition: Animations.cpp:18
global.h
Animations::faces
const Face ** faces
Definition: face.h:30
AssetsCollection< Animations >::get
Animations * get(const std::string &name)
Definition: AssetsCollection.h:89
asset_destroy
void asset_destroy(Animations *item)
Definition: Animations.cpp:26
AllAnimations::AllAnimations
AllAnimations()
Definition: Animations.cpp:32
AssetsCollection< Animations >::m_undefined
std::set< std::string > m_undefined
Definition: AssetsCollection.h:191
Animations::num_animations
uint8_t num_animations
Definition: face.h:27
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
Animations::name
sstring name
Definition: face.h:26
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
animate.anim
string anim
Definition: animate.py:20
free_string
void free_string(sstring str)
Definition: shstr.cpp:280
AllAnimations::added
virtual void added(Animations *anim) override
Definition: Animations.cpp:47
Animations.h
item
Definition: item.py:1
AssetsCollection< Animations >::m_assets
std::map< std::string, Animations * > m_assets
Definition: AssetsCollection.h:190
assets.h
AllAnimations::replace
virtual void replace(Animations *existing, Animations *update) override
Definition: Animations.cpp:37
Animations
Definition: face.h:25
Animations::facings
uint8_t facings
Definition: face.h:28