Crossfire Server, Trunk
Messages Class Reference

#include <Messages.h>

+ Inheritance diagram for Messages:
+ Collaboration diagram for Messages:

Public Member Functions

 Messages ()
 
GeneralMessagerandom ()
 
- Public Member Functions inherited from AssetsCollection< GeneralMessage >
void clear ()
 
size_t count () const
 
GeneralMessagedefine (const std::string &name, GeneralMessage *asset)
 
void each (std::function< void(GeneralMessage *)> op)
 
GeneralMessagefind (const std::string &name)
 
GeneralMessagefirst (std::function< bool(const GeneralMessage *)> op)
 
GeneralMessageget (const std::string &name)
 
GeneralMessagenext (GeneralMessage *current)
 
const std::set< std::string > & undefined () const
 

Protected Member Functions

virtual void added (GeneralMessage *asset)
 
virtual GeneralMessagecreate (const std::string &name)
 
virtual void destroy (GeneralMessage *item)
 
virtual void replace (GeneralMessage *existing, GeneralMessage *update)
 

Protected Attributes

int m_totalChance
 
- Protected Attributes inherited from AssetsCollection< GeneralMessage >
std::map< std::string, GeneralMessage * > m_assets
 
std::set< std::string > m_undefined
 

Detailed Description

Definition at line 24 of file Messages.h.

Constructor & Destructor Documentation

◆ Messages()

Messages::Messages ( )

Definition at line 18 of file Messages.cpp.

Member Function Documentation

◆ added()

void Messages::added ( GeneralMessage )
protectedvirtual

An asset was either referenced (but undefined) or defined.

Reimplemented from AssetsCollection< GeneralMessage >.

Definition at line 46 of file Messages.cpp.

References GeneralMessage::chance, and m_totalChance.

◆ create()

GeneralMessage * Messages::create ( const std::string &  name)
protectedvirtual

Create a new asset.

Parameters
nameasset unique name.
Returns
asset.

Implements AssetsCollection< GeneralMessage >.

Definition at line 21 of file Messages.cpp.

References add_string(), navar-midane_pickup::msg, and give::name.

+ Here is the call graph for this function:

◆ destroy()

void Messages::destroy ( GeneralMessage item)
protectedvirtual

Destroy an asset.

Parameters
itemasset to destroy.

Implements AssetsCollection< GeneralMessage >.

Definition at line 27 of file Messages.cpp.

References FREE_AND_CLEAR_STR_IF.

Referenced by replace().

+ Here is the caller graph for this function:

◆ random()

GeneralMessage * Messages::random ( )

Definition at line 50 of file Messages.cpp.

References AssetsCollection< GeneralMessage >::m_assets, m_totalChance, navar-midane_pickup::msg, and RANDOM.

Referenced by get_random_message().

+ Here is the caller graph for this function:

◆ replace()

void Messages::replace ( GeneralMessage existing,
GeneralMessage update 
)
protectedvirtual

Replace an asset by an updated version.

Parameters
existingasset to be updated.
updatenew version of the asset, which must be destroyed.

Implements AssetsCollection< GeneralMessage >.

Definition at line 35 of file Messages.cpp.

References GeneralMessage::chance, destroy(), FREE_AND_COPY_IF, GeneralMessage::identifier, m_totalChance, GeneralMessage::message, GeneralMessage::quest_code, and GeneralMessage::title.

+ Here is the call graph for this function:

Field Documentation

◆ m_totalChance

int Messages::m_totalChance
protected

Definition at line 32 of file Messages.h.

Referenced by added(), random(), and replace().


The documentation for this class was generated from the following files: