Crossfire Server, Trunk
AssetsManager.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 "AssetsManager.h"
14 
15 #include <functional>
16 extern "C" {
17 #include "image.h"
18 }
19 
21  m_listener = std::bind(&AssetsManager::archetypeUpdated, this, std::placeholders::_1, std::placeholders::_2);
23 
24  auto bug = m_animations.get("###none");
25  bug->faces = (const Face **)malloc(sizeof(Face*));
26  bug->faces[0] = m_faces.get("bug.111");
27  bug->num_animations = 1;
28 }
29 
35  m_faces.clear();
36  m_messages.clear();
37  m_facesets.clear();
38  m_quests.clear();
39 }
40 
42  auto artifacts = first_artifactlist;
43  while (artifacts != NULL) {
44  auto items = artifacts->items;
45  while (items != NULL) {
46  if (items->item) {
47  Archetypes::recursive_update(items->item->inv, update);
48  }
49  items = items->next;
50  }
51  artifacts = artifacts->next;
52  }
53 }
54 
55 static int dump(const std::set<std::string>& items, const char *name) {
56  if (!items.empty()) {
57  LOG(llevError, "Referenced %s which are not defined:\n", name);
58  for (const auto& item : items) {
59  LOG(llevError, " - %s\n", item.c_str());
60  }
61  }
62  return items.size();
63 }
64 
66  size_t count = 0;
67  count += dump(m_archetypes.undefined(), "archetypes");
68  count += dump(m_treasures.undefined(), "treasures");
69  // count += dump(m_faces.undefined(), "faces"); /** Faces are actually not defined usually, just referenced. */
70  count += dump(m_animations.undefined(), "animations");
71  count += dump(m_facesets.undefined(), "facesets");
72  count += dump(m_quests.undefined(), "quests");
73  return count;
74 }
Face
Definition: face.h:14
AssetsCollection::undefined
const std::set< Key > & undefined() const
Definition: AssetsCollection.h:154
AssetsManager::AssetsManager
AssetsManager()
Definition: AssetsManager.cpp:20
llevError
@ llevError
Definition: logger.h:11
AssetsManager.h
AssetsManager::~AssetsManager
virtual ~AssetsManager()
Definition: AssetsManager.cpp:30
dump
static int dump(const std::set< std::string > &items, const char *name)
Definition: AssetsManager.cpp:55
AssetsManager::dumpUndefined
size_t dumpUndefined()
Definition: AssetsManager.cpp:65
first_artifactlist
EXTERN artifactlist * first_artifactlist
Definition: global.h:118
artifactliststruct::items
struct artifactstruct * items
Definition: artifact.h:30
AssetsManager::m_facesets
Facesets m_facesets
Definition: AssetsManager.h:87
archt
Definition: object.h:468
Archetypes::recursive_update
static void recursive_update(object *item, archetype *updated)
Definition: Archetypes.cpp:29
AssetsManager::m_animations
AllAnimations m_animations
Definition: AssetsManager.h:84
AssetsManager::m_archetypes
Archetypes m_archetypes
Definition: AssetsManager.h:82
disinfect.count
int count
Definition: disinfect.py:7
AssetsCollection::get
T * get(const Key &name)
Definition: AssetsCollection.h:66
Archetypes::clearReplaceListener
void clearReplaceListener()
Definition: Archetypes.h:51
image.h
item
Definition: item.py:1
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
animations_struct::faces
const Face ** faces
Definition: face.h:30
AssetsManager::m_treasures
Treasures m_treasures
Definition: AssetsManager.h:85
AssetsManager::archetypeUpdated
void archetypeUpdated(archetype *existing, archetype *update)
Definition: AssetsManager.cpp:41
AssetsManager::m_faces
Faces m_faces
Definition: AssetsManager.h:81
AssetsCollection::clear
void clear()
Definition: AssetsCollection.h:46
AssetsManager::m_quests
Quests m_quests
Definition: AssetsManager.h:88
AssetsManager::m_listener
Archetypes::updateListener m_listener
Definition: AssetsManager.h:83
AssetsManager::m_messages
Messages m_messages
Definition: AssetsManager.h:86
Archetypes::setReplaceListener
void setReplaceListener(updateListener fct)
Definition: Archetypes.h:44
give.name
name
Definition: give.py:27