~ubuntu-branches/ubuntu/vivid/manaplus/vivid-proposed

« back to all changes in this revision

Viewing changes to src/net/tmwa/guildhandler.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi, Andrei Karas, Patrick Matthäi
  • Date: 2014-10-27 18:15:40 UTC
  • mfrom: (1.1.37)
  • Revision ID: package-import@ubuntu.com-20141027181540-jvyjufjo9igruklh
Tags: 1.4.10.25-1
[ Andrei Karas ]
* Updated debian/copyright.

[ Patrick Matthäi ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
#include "net/serverfeatures.h"
34
34
 
35
 
#include "net/ea/gui/guildtab.h"
 
35
#include "gui/widgets/tabs/chat/guildtab.h"
36
36
 
37
37
#include "net/tmwa/messageout.h"
38
38
#include "net/tmwa/protocol.h"
207
207
 
208
208
void GuildHandler::create(const std::string &name) const
209
209
{
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");
213
213
}
214
214
 
215
215
void GuildHandler::invite(const int guildId A_UNUSED,
222
222
        name, ActorType::Player);
223
223
    if (being)
224
224
    {
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");
229
229
    }
230
230
}
231
231
 
235
235
    if (!being)
236
236
        return;
237
237
 
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");
242
242
}
243
243
 
244
244
void GuildHandler::inviteResponse(const int guildId, const bool response) const
245
245
{
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");
251
251
}
252
252
 
253
253
void GuildHandler::leave(const int guildId) const
255
255
    if (!localPlayer)
256
256
        return;
257
257
 
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");
263
263
}
264
264
 
265
265
void GuildHandler::kick(const GuildMember *restrict const member,
268
268
    if (!member || !member->getGuild())
269
269
        return;
270
270
 
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");
276
276
}
277
277
 
278
278
void GuildHandler::chat(const int guildId A_UNUSED,
283
283
 
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");
289
289
}
290
290
 
291
291
void GuildHandler::memberList(const int guildId A_UNUSED) const
296
296
    // 3 = skill info
297
297
    // 4 = expulsion list
298
298
 
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
301
301
}
302
302
 
303
303
void GuildHandler::info(const int guildId A_UNUSED)
309
309
    // 4 = expulsion list
310
310
 
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
314
314
}
315
315
 
316
316
void GuildHandler::changeMemberPostion(const GuildMember *const member,
319
319
    if (!member || !member->getGuild())
320
320
        return;
321
321
 
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");
327
327
}
328
328
 
329
329
void GuildHandler::changeNotice(const int guildId,
330
330
                                const std::string &restrict msg1,
331
331
                                const std::string &restrict msg2) const
332
332
{
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");
337
337
}
338
338
 
339
339
void GuildHandler::checkMaster() const
340
340
{
341
 
    MessageOut msg(CMSG_GUILD_CHECK_MASTER);
 
341
    createOutPacket(CMSG_GUILD_CHECK_MASTER);
342
342
}
343
343
 
344
 
void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) const
 
344
void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg)
345
345
{
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)
362
362
        Ea::taGuild = g;
363
 
    if (!Ea::guildTab && chatWindow)
 
363
    if (!guildTab && chatWindow)
364
364
    {
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");
368
368
        if (localPlayer)
369
369
            localPlayer->addGuild(Ea::taGuild);
370
 
        memberList(guildId);
 
370
        guildHandler->memberList(guildId);
371
371
    }
372
372
 
373
373
    if (localPlayer)
380
380
                emblem, posMode, guildName.c_str());
381
381
}
382
382
 
383
 
void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) const
 
383
void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg)
384
384
{
385
385
    const int accountId = msg.readInt32("account id");
386
386
    const int charId = msg.readInt32("char id");
391
391
        if (m)
392
392
        {
393
393
            m->setOnline(online);
394
 
            if (Ea::guildTab)
395
 
                Ea::guildTab->showOnline(m->getName(), online);
 
394
            if (guildTab)
 
395
                guildTab->showOnline(m->getName(), online);
396
396
            if (socialWindow)
397
397
                socialWindow->updateGuildCounter();
398
398
        }
399
399
    }
400
400
}
401
401
 
402
 
void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) const
 
402
void GuildHandler::processGuildExpulsion(Net::MessageIn &msg)
403
403
{
404
 
    msg.skip(2, "len?");
 
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
408
 
 
 
407
    msg.readString(44, "message");
409
408
    processGuildExpulsionContinue(nick);
410
409
}
411
410
 
412
 
void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg) const
 
411
void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg)
413
412
{
414
413
    const int length = msg.readInt16("len");
415
414
    if (length < 4)