ManaPlus
Functions
EAthena::ClanRecv Namespace Reference

Functions

void processClanInfo (Net::MessageIn &msg)
 
void processClanOnlineCount (Net::MessageIn &msg)
 
void processClanLeave (Net::MessageIn &msg)
 
void processClanChat (Net::MessageIn &msg)
 
void createTab ()
 

Function Documentation

◆ createTab()

void EAthena::ClanRecv::createTab ( )

Definition at line 123 of file clanrecv.cpp.

124 {
125  if (clanTab != nullptr)
126  return;
127  clanTab = new ClanTab(chatWindow);
128  if (config.getBoolValue("showChatHistory"))
129  clanTab->loadFromLogFile("#Clan");
130 }
ChatWindow * chatWindow
Definition: chatwindow.cpp:94
ClanTab * clanTab
Definition: clantab.cpp:36
void loadFromLogFile(const std::string &name)
Definition: chattab.cpp:510
bool getBoolValue(const std::string &key) const
Configuration config

References chatWindow, clanTab, config, Configuration::getBoolValue(), and ChatTab::loadFromLogFile().

◆ processClanChat()

void EAthena::ClanRecv::processClanChat ( Net::MessageIn msg)

Definition at line 94 of file clanrecv.cpp.

95 {
96  const int chatMsgLength = msg.readInt16("len") - 4 - 24;
97  if (chatMsgLength <= 0)
98  return;
99  msg.readString(24, "player name (unused)");
100  std::string chatMsg = msg.readString(chatMsgLength, "message");
101  if (clanTab == nullptr)
102  {
103  reportAlways("received clan chat messages without clan.")
104  return;
105  }
106  const size_t pos = chatMsg.find(" : ", 0);
107  if (pos != std::string::npos)
108  {
109  const std::string sender_name = chatMsg.substr(0, pos);
110  chatMsg.erase(0, pos + 3);
111  trim(chatMsg);
112  clanTab->chatLog(sender_name, chatMsg);
113  }
114  else
115  {
116  clanTab->chatLog(chatMsg,
120  }
121 }
#define reportAlways(...)
Definition: checkutils.h:253
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:111
if(!vert) return
const bool IgnoreRecord_false
Definition: ignorerecord.h:30
bool msg(InputEvent &event)
Definition: chat.cpp:39
bool find(const std::string &key)
std::string trim(std::string const &str)
const bool TryRemoveColors_true

References ChatMsgType::BY_SERVER, ChatTab::chatLog(), clanTab, IgnoreRecord_false, Actions::msg(), reportAlways, Catch::trim(), and TryRemoveColors_true.

◆ processClanInfo()

void EAthena::ClanRecv::processClanInfo ( Net::MessageIn msg)

Definition at line 47 of file clanrecv.cpp.

48 {
49  msg.readInt16("len");
50  localClan.id = msg.readInt32("clan id");
51  localClan.name = msg.readString(24, "clan name");
52  localClan.masterName = msg.readString(24, "master name");
53  localClan.mapName = msg.readString(16, "map name");
54  const int allyCount = msg.readUInt8("ally clans count");
55  const int antagonistCount = msg.readUInt8("antagonist clans count");
56  for (int f = 0; f < allyCount; f ++)
57  {
58  localClan.allyClans.push_back(
59  msg.readString(24, "ally clan name"));
60  }
61  for (int f = 0; f < antagonistCount; f ++)
62  {
63  localClan.antagonistClans.push_back(
64  msg.readString(24, "antagonist clan name"));
65  }
66  const ClanInfo *const info = ClanDb::get(localClan.id);
67  if (info == nullptr)
68  {
69  reportAlways("missing clan %d in clandb",
70  localClan.id)
71  }
72  else
73  {
74  localClan.stats = info->stats;
75  }
76  createTab();
78 }
ClanWindow * clanWindow
Definition: clanwindow.cpp:38
void updateClan()
Definition: clanwindow.cpp:136
LocalClan localClan
Definition: localclan.cpp:26
bool info(InputEvent &event)
Definition: commands.cpp:57
const ClanInfo * get(const int clanId)
Definition: clandb.cpp:122
void createTab()
Definition: partyrecv.cpp:226
std::string masterName
Definition: localclan.h:64
std::string mapName
Definition: localclan.h:65
std::string name
Definition: localclan.h:63
std::vector< std::string > allyClans
Definition: localclan.h:61
std::vector< std::string > stats
Definition: localclan.h:66
std::vector< std::string > antagonistClans
Definition: localclan.h:62
int id
Definition: localclan.h:67

References LocalClan::allyClans, LocalClan::antagonistClans, clanWindow, Ea::PartyRecv::createTab(), ClanDb::get(), LocalClan::id, Actions::info(), localClan, LocalClan::mapName, LocalClan::masterName, Actions::msg(), LocalClan::name, reportAlways, LocalClan::stats, and ClanWindow::updateClan().

◆ processClanLeave()

void EAthena::ClanRecv::processClanLeave ( Net::MessageIn msg)

Definition at line 87 of file clanrecv.cpp.

88 {
90  localClan.clear();
92 }
void resetClan()
Definition: clanwindow.cpp:144
#define delete2(var)
Definition: delete2.h:25
void clear()
Definition: localclan.h:48

References clanTab, clanWindow, LocalClan::clear(), delete2, localClan, and ClanWindow::resetClan().

◆ processClanOnlineCount()

void EAthena::ClanRecv::processClanOnlineCount ( Net::MessageIn msg)

Definition at line 80 of file clanrecv.cpp.

81 {
82  localClan.onlineMembers = msg.readInt16("online members count");
83  localClan.totalMembers = msg.readInt16("total members count");
85 }
void updateClanMembers()
Definition: clanwindow.cpp:152
int onlineMembers
Definition: localclan.h:68
int totalMembers
Definition: localclan.h:69

References clanWindow, localClan, Actions::msg(), LocalClan::onlineMembers, LocalClan::totalMembers, and ClanWindow::updateClanMembers().