Crossfire Server, Trunk  1.75.0
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 
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
New face structure - this enforces the notion that data is face by face only - you can not change the...
Definition: face.h:14
AssetsCollection::undefined
const std::set< Key > & undefined() const
Return the list of undefined assets, that is assets requested through get() but not defined through d...
Definition: AssetsCollection.h:177
AssetsManager::AssetsManager
AssetsManager()
Constructor.
Definition: AssetsManager.cpp:18
llevError
@ llevError
Error, serious thing.
Definition: logger.h:11
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
treasurelist::items
treasure * items
Items in this list, linked.
Definition: treasure.h:92
AssetsManager.h
AssetsManager::~AssetsManager
virtual ~AssetsManager()
Destructor.
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()
Dump through LOG undefined assets (except faces), and return the total number of referenced but not d...
Definition: AssetsManager.cpp:52
AssetsManager::m_facesets
Facesets m_facesets
Cilent image variants.
Definition: AssetsManager.h:87
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
Archetypes::recursive_update
static void recursive_update(object *item, archetype *updated)
Update if needed item based on the updated archetype, then recurse on item->below and item->inv.
Definition: Archetypes.cpp:31
AssetsManager::m_animations
AllAnimations m_animations
Animations.
Definition: AssetsManager.h:84
AssetsManager::m_archetypes
Archetypes m_archetypes
Archetypes.
Definition: AssetsManager.h:82
archetype
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:483
AssetsCollection::get
T * get(const Key &name)
Get a named asset.
Definition: AssetsCollection.h:89
Archetypes::clearReplaceListener
void clearReplaceListener()
Remvove the listener for archetypes changes.
Definition: Archetypes.h:47
image.h
Animations::faces
const Face ** faces
The actual faces for the animation.
Definition: face.h:30
AssetsManager::m_treasures
Treasures m_treasures
Treasures.
Definition: AssetsManager.h:85
first_artifactlist
artifactlist * first_artifactlist
First artifact.
Definition: init.cpp:109
AssetsManager::archetypeUpdated
void archetypeUpdated(archetype *existing, archetype *update)
Update artifacts if needed when an archetype changes.
Definition: AssetsManager.cpp:32
AssetsManager::m_faces
Faces m_faces
Faces.
Definition: AssetsManager.h:81
AssetsManager::m_quests
Quests m_quests
Quests.
Definition: AssetsManager.h:88
AssetsManager::m_listener
Archetypes::updateListener m_listener
Listener to archetypes changes.
Definition: AssetsManager.h:83
artifacts
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn though Notes on Specific and settings file datadir Usually usr share crossfire Contains data that the server does not need to modify while such as the etc A default install will pack the and treasurelist definitions into a single artifacts
Definition: server-directories.txt:47
Archetypes::setReplaceListener
void setReplaceListener(updateListener fct)
Set the listener to be called when an archetype is updated.
Definition: Archetypes.h:40