From c623250fbc8524a1ab78791595bf1fc4344fec49 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Oct 2014 21:24:28 +0300 Subject: read guild position flags. --- src/being/playerinfo.cpp | 11 +++++++++++ src/being/playerinfo.h | 5 +++++ src/guild.cpp | 4 ++-- src/guild.h | 6 ++++-- src/guildpositionflags.h | 3 ++- src/net/eathena/guildhandler.cpp | 16 +++++++--------- src/net/tmwa/guildhandler.cpp | 14 ++++++++------ 7 files changed, 39 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp index 4f7b714cf..0000825fe 100644 --- a/src/being/playerinfo.cpp +++ b/src/being/playerinfo.cpp @@ -61,6 +61,7 @@ Equipment *mEquipment = nullptr; MercenaryInfo *mMercenary = nullptr; HomunculusInfo *mHomunculus = nullptr; PetInfo *mPet = nullptr; +GuildPositionFlags::Type mGuildPositionFlags = GuildPositionFlags::None; bool mTrading = false; int mLevelProgress = 0; @@ -556,4 +557,14 @@ void updateAttackAi(const int targetId, const bool keep) homunculusHandler->attack(targetId, keep); } +void setGuildPositionFlags(const GuildPositionFlags::Type pos) +{ + mGuildPositionFlags = pos; +} + +GuildPositionFlags::Type getGuildPositionFlags() +{ + return mGuildPositionFlags; +} + } // namespace PlayerInfo diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h index c4ccfd4be..e3b156d9e 100644 --- a/src/being/playerinfo.h +++ b/src/being/playerinfo.h @@ -23,6 +23,7 @@ #define BEING_PLAYERINFO_H #include "equipment.h" +#include "guildpositionflags.h" #include "state.h" #include @@ -264,6 +265,10 @@ namespace PlayerInfo void updateMoveAI(); void updateAttackAi(const int targetId, const bool keep); + + void setGuildPositionFlags(const GuildPositionFlags::Type pos); + + GuildPositionFlags::Type getGuildPositionFlags(); } // namespace PlayerInfo #endif // BEING_PLAYERINFO_H diff --git a/src/guild.cpp b/src/guild.cpp index a6e5c5ad7..fd1f99b28 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -89,11 +89,11 @@ Guild::GuildMap Guild::guilds; Guild::Guild(const int16_t id) : mMembers(), + mPositions(), mName(), + mEmblemId(0), mId(id), mCanInviteUsers(false), - mEmblemId(0), - mPositions(), mServerGuild(true) { guilds[id] = this; diff --git a/src/guild.h b/src/guild.h index 08b8b936e..50870288d 100644 --- a/src/guild.h +++ b/src/guild.h @@ -25,6 +25,8 @@ #include "avatar.h" +#include "guildpositionflags.h" + #include "gui/models/avatarlistmodel.h" #include "utils/dtor.h" @@ -210,11 +212,11 @@ class Guild final : public AvatarListModel explicit Guild(const int16_t id); MemberList mMembers; + PositionsMap mPositions; std::string mName; + int mEmblemId; int16_t mId; bool mCanInviteUsers; - int mEmblemId; - PositionsMap mPositions; bool mServerGuild; }; diff --git a/src/guildpositionflags.h b/src/guildpositionflags.h index b9964c5b3..7307c3444 100644 --- a/src/guildpositionflags.h +++ b/src/guildpositionflags.h @@ -29,8 +29,9 @@ namespace GuildPositionFlags { enum Type { + None = 0x00, Invite = 0x01, - Expel = 0x10 + Expel = 0x10 }; } diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp index 03c5a34ef..2d23eaa16 100644 --- a/src/net/eathena/guildhandler.cpp +++ b/src/net/eathena/guildhandler.cpp @@ -355,12 +355,13 @@ void GuildHandler::checkMaster() const void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) const { - const int guildId = msg.readInt32(); - const int emblem = msg.readInt32(); - const int posMode = msg.readInt32(); - msg.readInt32(); // Unused - msg.readUInt8(); // Unused - std::string guildName = msg.readString(24); + const int guildId = msg.readInt32("guild id"); + const int emblem = msg.readInt32("elblem id"); + PlayerInfo::setGuildPositionFlags( + static_cast(msg.readInt32("mode"))); + msg.readUInt8("guild master"); + msg.readInt32("unused"); + std::string guildName = msg.readString(24, "guild name"); Guild *const g = Guild::getGuild(static_cast(guildId)); if (!g) @@ -385,9 +386,6 @@ void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) const localPlayer->setGuild(g); localPlayer->setGuildName(g->getName()); } - - logger->log("Guild position info: %d %d %d %s\n", guildId, - emblem, posMode, guildName.c_str()); } } // namespace EAthena diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 9445a4760..24bb06514 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -342,12 +342,14 @@ void GuildHandler::checkMaster() const void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) const { - const int guildId = msg.readInt32(); - const int emblem = msg.readInt32(); - const int posMode = msg.readInt32(); - msg.readInt32(); // Unused - msg.readUInt8(); // Unused - std::string guildName = msg.readString(24); + const int guildId = msg.readInt32("guild id"); + const int emblem = msg.readInt32("emblem"); + const int posMode = msg.readInt32("position"); + msg.readInt32("unused"); + msg.readUInt8("usused"); + std::string guildName = msg.readString(24, "guild name"); + + PlayerInfo::setGuildPositionFlags(GuildPositionFlags::Invite); Guild *const g = Guild::getGuild(static_cast(guildId)); if (!g) -- cgit v1.2.3-70-g09d2