33
33
#include "net/serverfeatures.h"
35
#include "net/ea/gui/guildtab.h"
35
#include "gui/widgets/tabs/chat/guildtab.h"
37
37
#include "net/tmwa/messageout.h"
38
38
#include "net/tmwa/protocol.h"
208
208
void GuildHandler::create(const std::string &name) const
210
MessageOut msg(CMSG_GUILD_CREATE);
211
msg.writeInt32(0); // unused
212
msg.writeString(name, 24);
210
createOutPacket(CMSG_GUILD_CREATE);
211
outMsg.writeInt32(0, "unused");
212
outMsg.writeString(name, 24, "guild name");
215
215
void GuildHandler::invite(const int guildId A_UNUSED,
222
222
name, ActorType::Player);
225
MessageOut msg(CMSG_GUILD_INVITE);
226
msg.writeInt32(being->getId());
227
msg.writeInt32(0); // unused
228
msg.writeInt32(0); // unused
225
createOutPacket(CMSG_GUILD_INVITE);
226
outMsg.writeInt32(being->getId(), "account id");
227
outMsg.writeInt32(0, "unused");
228
outMsg.writeInt32(0, "unused");
238
MessageOut msg(CMSG_GUILD_INVITE);
239
msg.writeInt32(being->getId());
240
msg.writeInt32(0); // unused
241
msg.writeInt32(0); // unused
238
createOutPacket(CMSG_GUILD_INVITE);
239
outMsg.writeInt32(being->getId(), "account id");
240
outMsg.writeInt32(0, "unused");
241
outMsg.writeInt32(0, "unused");
244
244
void GuildHandler::inviteResponse(const int guildId, const bool response) const
246
MessageOut msg(CMSG_GUILD_INVITE_REPLY);
247
msg.writeInt32(guildId);
248
msg.writeInt8(response);
249
msg.writeInt8(0); // unused
250
msg.writeInt16(0); // unused
246
createOutPacket(CMSG_GUILD_INVITE_REPLY);
247
outMsg.writeInt32(guildId, "guild id");
248
outMsg.writeInt8(response, "response");
249
outMsg.writeInt8(0, "unused");
250
outMsg.writeInt16(0, "unused");
253
253
void GuildHandler::leave(const int guildId) const
255
255
if (!localPlayer)
258
MessageOut msg(CMSG_GUILD_LEAVE);
259
msg.writeInt32(guildId);
260
msg.writeInt32(localPlayer->getId()); // Account ID
261
msg.writeInt32(PlayerInfo::getCharId()); // Char ID
262
msg.writeString("", 40); // Message
258
createOutPacket(CMSG_GUILD_LEAVE);
259
outMsg.writeInt32(guildId, "guild id");
260
outMsg.writeInt32(localPlayer->getId(), "account id");
261
outMsg.writeInt32(PlayerInfo::getCharId(), "char id");
262
outMsg.writeString("", 40, "message");
265
265
void GuildHandler::kick(const GuildMember *restrict const member,
268
268
if (!member || !member->getGuild())
271
MessageOut msg(CMSG_GUILD_EXPULSION);
272
msg.writeInt32(member->getGuild()->getId());
273
msg.writeInt32(member->getID()); // Account ID
274
msg.writeInt32(member->getCharId()); // Char ID
275
msg.writeString(reason, 40); // Message
271
createOutPacket(CMSG_GUILD_EXPULSION);
272
outMsg.writeInt32(member->getGuild()->getId(), "guild id");
273
outMsg.writeInt32(member->getID(), "account id");
274
outMsg.writeInt32(member->getCharId(), "char id");
275
outMsg.writeString(reason, 40, "message");
278
278
void GuildHandler::chat(const int guildId A_UNUSED,
284
284
const std::string str = std::string(localPlayer->getName()).append(
285
285
" : ").append(text);
286
MessageOut msg(CMSG_GUILD_MESSAGE);
287
msg.writeInt16(static_cast<uint16_t>(str.size() + 4));
288
msg.writeString(str, static_cast<int>(str.length()));
286
createOutPacket(CMSG_GUILD_MESSAGE);
287
outMsg.writeInt16(static_cast<uint16_t>(str.size() + 4), "len");
288
outMsg.writeString(str, static_cast<int>(str.length()), "message");
291
291
void GuildHandler::memberList(const int guildId A_UNUSED) const
296
296
// 3 = skill info
297
297
// 4 = expulsion list
299
MessageOut msg(CMSG_GUILD_REQUEST_INFO);
300
msg.writeInt32(1); // Request member list
299
createOutPacket(CMSG_GUILD_REQUEST_INFO);
300
outMsg.writeInt32(1, "action"); // Request member list
303
303
void GuildHandler::info(const int guildId A_UNUSED)
309
309
// 4 = expulsion list
311
311
showBasicInfo = true;
312
MessageOut msg(CMSG_GUILD_REQUEST_INFO);
313
msg.writeInt32(0); // Request basic info
312
createOutPacket(CMSG_GUILD_REQUEST_INFO);
313
outMsg.writeInt32(0, "action"); // Request basic info
316
316
void GuildHandler::changeMemberPostion(const GuildMember *const member,
319
319
if (!member || !member->getGuild())
322
MessageOut msg(CMSG_GUILD_CHANGE_MEMBER_POS);
323
msg.writeInt16(16); // size less then 16 <= 4 + 12
324
msg.writeInt32(member->getID()); // Account ID
325
msg.writeInt32(member->getCharId()); // Char ID
326
msg.writeInt32(level); // pos
322
createOutPacket(CMSG_GUILD_CHANGE_MEMBER_POS);
323
outMsg.writeInt16(16, "len");
324
outMsg.writeInt32(member->getID(), "account id");
325
outMsg.writeInt32(member->getCharId(), "char id");
326
outMsg.writeInt32(level, "position");
329
329
void GuildHandler::changeNotice(const int guildId,
330
330
const std::string &restrict msg1,
331
331
const std::string &restrict msg2) const
333
MessageOut msg(CMSG_GUILD_CHANGE_NOTICE);
334
msg.writeInt32(guildId);
335
msg.writeString(msg1, 60); // msg1
336
msg.writeString(msg2, 120); // msg2
333
createOutPacket(CMSG_GUILD_CHANGE_NOTICE);
334
outMsg.writeInt32(guildId, "guild id");
335
outMsg.writeString(msg1, 60, "msg1");
336
outMsg.writeString(msg2, 120, "msg2");
339
339
void GuildHandler::checkMaster() const
341
MessageOut msg(CMSG_GUILD_CHECK_MASTER);
341
createOutPacket(CMSG_GUILD_CHECK_MASTER);
344
void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) const
344
void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg)
346
const int guildId = msg.readInt32("guild id");
347
const int emblem = msg.readInt32("emblem");
348
const int posMode = msg.readInt32("position");
346
const int guildId = msg.readInt32("guild id");
347
const int emblem = msg.readInt32("emblem");
348
const int posMode = msg.readInt32("position");
349
349
msg.readInt32("unused");
350
350
msg.readUInt8("usused");
351
351
std::string guildName = msg.readString(24, "guild name");
360
360
g->setEmblemId(emblem);
361
361
if (!Ea::taGuild)
363
if (!Ea::guildTab && chatWindow)
363
if (!guildTab && chatWindow)
365
Ea::guildTab = new Ea::GuildTab(chatWindow);
365
guildTab = new GuildTab(chatWindow);
366
366
if (config.getBoolValue("showChatHistory"))
367
Ea::guildTab->loadFromLogFile("#Guild");
367
guildTab->loadFromLogFile("#Guild");
369
369
localPlayer->addGuild(Ea::taGuild);
370
guildHandler->memberList(guildId);
380
380
emblem, posMode, guildName.c_str());
383
void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) const
383
void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg)
385
385
const int accountId = msg.readInt32("account id");
386
386
const int charId = msg.readInt32("char id");
393
393
m->setOnline(online);
395
Ea::guildTab->showOnline(m->getName(), online);
395
guildTab->showOnline(m->getName(), online);
396
396
if (socialWindow)
397
397
socialWindow->updateGuildCounter();
402
void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) const
402
void GuildHandler::processGuildExpulsion(Net::MessageIn &msg)
404
msg.readInt16("len?");
405
405
const std::string nick = msg.readString(24, "name?");
406
406
msg.skip(24, "player name");
407
msg.readString(44, "message"); // Message
407
msg.readString(44, "message");
409
408
processGuildExpulsionContinue(nick);
412
void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg) const
411
void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg)
414
413
const int length = msg.readInt16("len");