Crossfire Server, Trunk  1.75.0
Archetypes.h
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2020-2021 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 #ifndef ARCHETYPES_H
14 #define ARCHETYPES_H
15 
16 #include <functional>
17 #include "AssetsCollection.h"
18 #include "global.h"
19 
23 class Archetypes : public AssetsCollection<archetype> {
24 
25 public:
27  typedef std::function<void(archetype*, archetype*)> updateListener;
28 
33  empty_archetype = get("empty_archetype");
34  }
35 
41  m_updateListener = fct;
42  }
43 
49  }
50 
59  archetype *findByObjectName(const char *name);
60 
72  archetype *findByObjectTypeName(int type, const char *name);
73 
83  archetype *findBySkillNameAndType(const char *skill, int type);
84 
100  archetype *findByTypeSubtype(int type, int subtype);
101 
111  static void recursive_update(object *item, archetype *updated);
112 
113 protected:
114  virtual void replace(archetype *existing, archetype *update) override;
115 
117 };
118 
119 #endif /* ARCHETYPES_H */
120 
global.h
Archetypes
All archetypes in the game.
Definition: Archetypes.h:23
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
AssetsCollection
Collection of assets identified by a unique name.
Definition: AssetsCollection.h:55
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
AssetsCollection.h
Archetypes::findBySkillNameAndType
archetype * findBySkillNameAndType(const char *skill, int type)
Retrieve an archetype by skill name and type.
Definition: Archetypes.cpp:109
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< archetype >::get
archetype * get(const std::string &name)
Get a named asset.
Definition: AssetsCollection.h:89
updated
it was updated by reverse engineering the client code accessing the metaserver It therefore describes the as is state rather than what was intended Communication between server and metaserver was not updated
Definition: arch-handbook.txt:126
Archetypes::clearReplaceListener
void clearReplaceListener()
Remvove the listener for archetypes changes.
Definition: Archetypes.h:47
Archetypes::findByTypeSubtype
archetype * findByTypeSubtype(int type, int subtype)
Retrieve an archetype by type and subtype.
Definition: Archetypes.cpp:121
Archetypes::Archetypes
Archetypes()
Standard constructor.
Definition: Archetypes.h:32
Archetypes::replace
virtual void replace(archetype *existing, archetype *update) override
Replace an asset by an updated version.
Definition: Archetypes.cpp:62
skill
skill
Definition: arch-handbook.txt:585
Archetypes::updateListener
std::function< void(archetype *, archetype *)> updateListener
Function prototype to be called when an archetype changes.
Definition: Archetypes.h:27
Archetypes::findByObjectName
archetype * findByObjectName(const char *name)
Retrieve an archetype given the name that appears during the game (for example, "writing pen" instead...
Definition: Archetypes.cpp:82
empty_archetype
archetype * empty_archetype
Nice to have fast access to it.
Definition: init.cpp:119
Archetypes::m_updateListener
updateListener m_updateListener
Definition: Archetypes.h:116
Archetypes::findByObjectTypeName
archetype * findByObjectTypeName(int type, const char *name)
Retrieve an archetype by type and name that appears during the game.
Definition: Archetypes.cpp:97
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
Archetypes::setReplaceListener
void setReplaceListener(updateListener fct)
Set the listener to be called when an archetype is updated.
Definition: Archetypes.h:40