ManaPlus
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
ChatObject Struct Reference

#include <chatobject.h>

Public Member Functions

 ChatObject ()
 
 ~ChatObject ()
 
void update ()
 

Static Public Member Functions

static ChatObjectfindByName (const std::string &name)
 
static ChatObjectfindById (const int id)
 

Data Fields

BeingId ownerId
 
int chatId
 
uint16_t maxUsers
 
uint16_t currentUsers
 
uint8_t type
 
std::string title
 

Static Public Attributes

static std::map< std::string, ChatObject * > chatNameMap
 
static std::map< int, ChatObject * > chatIdMap
 

Detailed Description

Definition at line 31 of file chatobject.h.

Constructor & Destructor Documentation

◆ ChatObject()

ChatObject::ChatObject ( )

Definition at line 28 of file chatobject.cpp.

28  :
30  chatId(0),
31  maxUsers(0),
32  currentUsers(0),
33  type(0),
34  title()
35 {
36 }
uint16_t maxUsers
Definition: chatobject.h:47
uint16_t currentUsers
Definition: chatobject.h:48
std::string title
Definition: chatobject.h:50
int chatId
Definition: chatobject.h:46
const BeingId BeingId_zero
Definition: beingid.h:29
BeingId ownerId
Definition: chatobject.h:45
uint8_t type
Definition: chatobject.h:49

◆ ~ChatObject()

ChatObject::~ChatObject ( )

Definition at line 38 of file chatobject.cpp.

References chatId, chatIdMap, chatNameMap, and title.

39 {
40  std::map<std::string, ChatObject*>::iterator it = chatNameMap.find(title);
41  if (it != chatNameMap.end() && (*it).second == this)
42  chatNameMap.erase(it);
43  std::map<int, ChatObject*>::iterator it2 = chatIdMap.find(chatId);
44  if (it2 != chatIdMap.end() && (*it2).second == this)
45  chatIdMap.erase(it2);
46 }
static std::map< int, ChatObject * > chatIdMap
Definition: chatobject.h:53
static std::map< std::string, ChatObject * > chatNameMap
Definition: chatobject.h:52
std::string title
Definition: chatobject.h:50
int chatId
Definition: chatobject.h:46

Member Function Documentation

◆ findById()

ChatObject * ChatObject::findById ( const int  id)
static

Definition at line 63 of file chatobject.cpp.

References chatIdMap.

Referenced by EAthena::ChatRecv::processChatRoomJoinAck().

64 {
65  const std::map<int, ChatObject*>::iterator it = chatIdMap.find(id);
66  if (it == chatIdMap.end())
67  return nullptr;
68  return (*it).second;
69 }
static std::map< int, ChatObject * > chatIdMap
Definition: chatobject.h:53

◆ findByName()

ChatObject * ChatObject::findByName ( const std::string &  name)
static

Definition at line 54 of file chatobject.cpp.

References chatNameMap.

Referenced by Actions::changeRelation().

55 {
56  const std::map<std::string, ChatObject*>::iterator it =
57  chatNameMap.find(name);
58  if (it == chatNameMap.end())
59  return nullptr;
60  return (*it).second;
61 }
static std::map< std::string, ChatObject * > chatNameMap
Definition: chatobject.h:52

◆ update()

void ChatObject::update ( )

Definition at line 48 of file chatobject.cpp.

References chatId, chatIdMap, chatNameMap, and title.

Referenced by EAthena::ChatRecv::processChatDisplay(), and EAthena::ChatRecv::processChatRoomCreateAck().

49 {
50  chatNameMap[title] = this;
51  chatIdMap[chatId] = this;
52 }
static std::map< int, ChatObject * > chatIdMap
Definition: chatobject.h:53
static std::map< std::string, ChatObject * > chatNameMap
Definition: chatobject.h:52
std::string title
Definition: chatobject.h:50
int chatId
Definition: chatobject.h:46

Field Documentation

◆ chatId

int ChatObject::chatId

◆ chatIdMap

std::map< int, ChatObject * > ChatObject::chatIdMap
static

Definition at line 53 of file chatobject.h.

Referenced by findById(), update(), and ~ChatObject().

◆ chatNameMap

std::map< std::string, ChatObject * > ChatObject::chatNameMap
static

Definition at line 52 of file chatobject.h.

Referenced by findByName(), update(), and ~ChatObject().

◆ currentUsers

uint16_t ChatObject::currentUsers

◆ maxUsers

uint16_t ChatObject::maxUsers

◆ ownerId

BeingId ChatObject::ownerId

◆ title

std::string ChatObject::title

◆ type

uint8_t ChatObject::type

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