From fd20692fa893b5e96ddd7647b1487b9b3cca5f50 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Feb 2018 19:56:40 +0300 Subject: Collect clan info information in clan object. --- src/CMakeLists.txt | 2 ++ src/Makefile.am | 2 ++ src/being/claninfo.cpp | 25 +++++++++++++++ src/being/claninfo.h | 72 ++++++++++++++++++++++++++++++++++++++++++++ src/net/eathena/clanrecv.cpp | 22 ++++++++------ 5 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 src/being/claninfo.cpp create mode 100644 src/being/claninfo.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea69c1c9e..4181bcd5b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1051,6 +1051,8 @@ SET(SRCS being/beingspeech.h being/castingeffect.cpp being/castingeffect.h + being/claninfo.cpp + being/claninfo.h beingequipbackend.cpp beingequipbackend.h spellmanager.cpp diff --git a/src/Makefile.am b/src/Makefile.am index d23d5f586..a33e140fd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1022,6 +1022,8 @@ SRC = ${BASE_SRC} \ being/beingspeech.h \ being/castingeffect.cpp \ being/castingeffect.h \ + being/claninfo.cpp \ + being/claninfo.h \ being/localplayer.cpp \ being/localplayer.h \ being/mercenaryinfo.h \ diff --git a/src/being/claninfo.cpp b/src/being/claninfo.cpp new file mode 100644 index 000000000..bba4fcd5e --- /dev/null +++ b/src/being/claninfo.cpp @@ -0,0 +1,25 @@ +/* + * The ManaPlus Client + * Copyright (C) 2018 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "being/claninfo.h" + +#include "debug.h" + +ClanInfo clanInfo; diff --git a/src/being/claninfo.h b/src/being/claninfo.h new file mode 100644 index 000000000..307044cb3 --- /dev/null +++ b/src/being/claninfo.h @@ -0,0 +1,72 @@ +/* + * The ManaPlus Client + * Copyright (C) 2018 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BEING_CLANINFO_H +#define BEING_CLANINFO_H + +#include "enums/simpletypes/beingid.h" + +#include "utils/vector.h" + +#include + +#include "localconsts.h" + +struct ClanInfo final +{ + ClanInfo() : + allyClans(), + antagonistClans(), + name(), + masterName(), + mapName(), + id(0), + onlineMembers(0), + totalMembers(0) + { + } + + A_DELETE_COPY(ClanInfo) + + void clear() + { + allyClans.clear(); + antagonistClans.clear(); + name.clear(); + masterName.clear(); + mapName.clear(); + id = 0; + onlineMembers = 0; + totalMembers = 0; + } + + STD_VECTOR allyClans; + STD_VECTOR antagonistClans; + std::string name; + std::string masterName; + std::string mapName; + int id; + int onlineMembers; + int totalMembers; +}; + +extern ClanInfo clanInfo; + +#endif // BEING_CLANINFO_H diff --git a/src/net/eathena/clanrecv.cpp b/src/net/eathena/clanrecv.cpp index acc962c0d..bf16627b2 100644 --- a/src/net/eathena/clanrecv.cpp +++ b/src/net/eathena/clanrecv.cpp @@ -20,6 +20,8 @@ #include "net/eathena/clanrecv.h" +#include "being/claninfo.h" + #include "net/messagein.h" #include "logger.h" @@ -31,29 +33,29 @@ namespace EAthena void ClanRecv::processClanInfo(Net::MessageIn &msg) { - UNIMPLEMENTEDPACKET; msg.readInt16("len"); - msg.readInt32("clan id"); - msg.readString(24, "clan name"); - msg.readString(24, "master name"); - msg.readString(16, "map name"); + clanInfo.id = msg.readInt32("clan id"); + clanInfo.name = msg.readString(24, "clan name"); + clanInfo.masterName = msg.readString(24, "master name"); + clanInfo.mapName = msg.readString(16, "map name"); const int allyCount = msg.readUInt8("ally clans count"); const int antagonistCount = msg.readUInt8("antagonist clans count"); for (int f = 0; f < allyCount; f ++) { - msg.readString(24, "ally clan name"); + clanInfo.allyClans.push_back( + msg.readString(24, "ally clan name")); } for (int f = 0; f < antagonistCount; f ++) { - msg.readString(24, "antagonist clan name"); + clanInfo.antagonistClans.push_back( + msg.readString(24, "antagonist clan name")); } } void ClanRecv::processClanOnlineCount(Net::MessageIn &msg) { - UNIMPLEMENTEDPACKET; - msg.readInt16("online members count"); - msg.readInt16("total members count"); + clanInfo.onlineMembers = msg.readInt16("online members count"); + clanInfo.totalMembers = msg.readInt16("total members count"); } void ClanRecv::processClanLeave(Net::MessageIn &msg) -- cgit v1.2.3-70-g09d2