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 }
global.h
asset_create
Animations * asset_create(const std::string &name)
Definition: Animations.cpp:18
AllAnimations::added
virtual void added(Animations *anim) override
Definition: Animations.cpp:47
asset_destroy
void asset_destroy(Animations *item)
Definition: Animations.cpp:26
AllAnimations::replace
virtual void replace(Animations *existing, Animations *update) override
Definition: Animations.cpp:37
AssetsCollection< Animations >::m_assets
std::map< std::string, Animations * > m_assets
Definition: AssetsCollection.h:190
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
AssetsCollection< Animations >::m_undefined
std::set< std::string > m_undefined
Definition: AssetsCollection.h:191
Animations::facings
uint8_t facings
Definition: face.h:28
AssetsCollection< Animations >::get
Animations * get(const std::string &name)
Definition: AssetsCollection.h:89
animate.anim
string anim
Definition: animate.py:20
Animations::num_animations
uint8_t num_animations
Definition: face.h:27
free_string
void free_string(sstring str)
Definition: shstr.cpp:280
Animations::faces
const Face ** faces
Definition: face.h:30
item
Definition: item.py:1
Animations
Definition: face.h:25
Animations.h
assets.h
AllAnimations::AllAnimations
AllAnimations()
Definition: Animations.cpp:32
Animations::name
sstring name
Definition: face.h:26
give.name
name
Definition: give.py:27