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 #include "image.h"
17 
19  m_listener = std::bind(&AssetsManager::archetypeUpdated, this, std::placeholders::_1, std::placeholders::_2);
21 
22  auto bug = m_animations.get("###none");
23  bug->faces = (const Face **)malloc(sizeof(Face*));
24  bug->faces[0] = m_faces.get("bug.111");
25  bug->num_animations = 1;
26 }
27 
30 }
31 
33  auto artifacts = first_artifactlist;
34  while (artifacts != NULL) {
35  for (auto item : artifacts->items) {
36  Archetypes::recursive_update(item->item->inv, update);
37  }
38  artifacts = artifacts->next;
39  }
40 }
41 
42 static int dump(const std::set<std::string>& items, const char *name) {
43  if (!items.empty()) {
44  LOG(llevError, "Referenced %s which are not defined:\n", name);
45  for (const auto& item : items) {
46  LOG(llevError, " - %s\n", item.c_str());
47  }
48  }
49  return items.size();
50 }
51 
53  size_t count = 0;
54  count += dump(m_archetypes.undefined(), "archetypes");
55  count += dump(m_treasures.undefined(), "treasures");
56  // count += dump(m_faces.undefined(), "faces"); /** Faces are actually not defined usually, just referenced. */
57  count += dump(m_animations.undefined(), "animations");
58  count += dump(m_facesets.undefined(), "facesets");
59  count += dump(m_quests.undefined(), "quests");
60  return count;
61 }
Face
Definition: face.h:14
AssetsCollection::undefined
const std::set< Key > & undefined() const
Definition: AssetsCollection.h:177
AssetsManager::AssetsManager
AssetsManager()
Definition: AssetsManager.cpp:18
llevError
@ llevError
Definition: logger.h:11
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:51
AssetsManager.h
AssetsManager::~AssetsManager
virtual ~AssetsManager()
Definition: AssetsManager.cpp:28
dump
static int dump(const std::set< std::string > &items, const char *name)
Definition: AssetsManager.cpp:42
AssetsManager::dumpUndefined
size_t dumpUndefined()
Definition: AssetsManager.cpp:52
AssetsManager::m_facesets
Facesets m_facesets
Definition: AssetsManager.h:87
Archetypes::recursive_update
static void recursive_update(object *item, archetype *updated)
Definition: Archetypes.cpp:31
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
archetype
Definition: object.h:472
AssetsCollection::get
T * get(const Key &name)
Definition: AssetsCollection.h:89
Archetypes::clearReplaceListener
void clearReplaceListener()
Definition: Archetypes.h:47
image.h
Animations::faces
const Face ** faces
Definition: face.h:30
item
Definition: item.py:1
AssetsManager::m_treasures
Treasures m_treasures
Definition: AssetsManager.h:85
first_artifactlist
artifactlist * first_artifactlist
Definition: init.cpp:109
AssetsManager::archetypeUpdated
void archetypeUpdated(archetype *existing, archetype *update)
Definition: AssetsManager.cpp:32
AssetsManager::m_faces
Faces m_faces
Definition: AssetsManager.h:81
AssetsManager::m_quests
Quests m_quests
Definition: AssetsManager.h:88
AssetsManager::m_listener
Archetypes::updateListener m_listener
Definition: AssetsManager.h:83
Archetypes::setReplaceListener
void setReplaceListener(updateListener fct)
Definition: Archetypes.h:40
give.name
name
Definition: give.py:27