~ubuntu-branches/ubuntu/trusty/manaplus/trusty-proposed

« back to all changes in this revision

Viewing changes to src/net/ea/chathandler.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-07-11 10:09:41 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20130711100941-f0rwuvcwgl8ulqo8
Tags: 1.3.7.7.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
 
58
58
void ChatHandler::processWhisperResponse(Net::MessageIn &msg)
59
59
{
 
60
    BLOCK_START("ChatHandler::processWhisperResponse")
 
61
 
60
62
    std::string nick;
61
 
 
62
63
    if (mSentWhispers.empty())
63
64
    {
64
65
        nick = "user";
101
102
                            + toString(type));
102
103
            }
103
104
    }
 
105
    BLOCK_END("ChatHandler::processWhisperResponse")
104
106
}
105
107
 
106
108
void ChatHandler::processWhisper(Net::MessageIn &msg) const
107
109
{
 
110
    BLOCK_START("ChatHandler::processWhisper")
108
111
    const int chatMsgLength = msg.readInt16() - 28;
109
112
    std::string nick = msg.readString(24);
110
113
 
111
114
    if (chatMsgLength <= 0)
 
115
    {
 
116
        BLOCK_END("ChatHandler::processWhisper")
112
117
        return;
 
118
    }
113
119
 
114
120
    std::string chatMsg = msg.readString(chatMsgLength);
115
121
    // ignoring future whisper messages
116
122
    if (chatMsg.find("\302\202G") == 0 || chatMsg.find("\302\202A") == 0)
 
123
    {
 
124
        BLOCK_END("ChatHandler::processWhisper")
117
125
        return;
 
126
    }
118
127
    // remove first unicode space if this is may be whisper command.
119
128
    if (chatMsg.find("\302\202!") == 0)
120
129
        chatMsg = chatMsg.substr(2);
124
133
        if (guildManager && GuildManager::getEnableGuildBot()
125
134
            && nick == "guild" && guildManager->processGuildMessage(chatMsg))
126
135
        {
 
136
            BLOCK_END("ChatHandler::processWhisper")
127
137
            return;
128
138
        }
129
139
 
223
233
            localChatTab->chatLog(chatMsg, BY_SERVER);
224
234
        }
225
235
    }
 
236
    BLOCK_END("ChatHandler::processWhisper")
226
237
}
227
238
 
228
239
void ChatHandler::processBeingChat(Net::MessageIn &msg,
231
242
    if (!actorSpriteManager)
232
243
        return;
233
244
 
 
245
    BLOCK_START("ChatHandler::processBeingChat")
234
246
    int chatMsgLength = msg.readInt16() - 8;
235
247
    Being *const being = actorSpriteManager->findBeing(msg.readInt32());
236
248
    if (!being)
 
249
    {
 
250
        BLOCK_END("ChatHandler::processBeingChat")
237
251
        return;
 
252
    }
238
253
 
239
254
    std::string channel;
240
255
    if (channels)
246
261
    }
247
262
 
248
263
    if (chatMsgLength <= 0)
 
264
    {
 
265
        BLOCK_END("ChatHandler::processBeingChat")
249
266
        return;
 
267
    }
250
268
 
251
269
    std::string chatMsg = msg.readRawString(chatMsgLength);
252
270
 
284
302
    {
285
303
        being->setSpeech(chatMsg, channel);
286
304
    }
 
305
    BLOCK_END("ChatHandler::processBeingChat")
287
306
}
288
307
 
289
308
void ChatHandler::processChat(Net::MessageIn &msg, const bool normalChat,
290
309
                              const bool channels) const
291
310
{
 
311
    BLOCK_START("ChatHandler::processChat")
292
312
    int chatMsgLength = msg.readInt16() - 4;
293
313
    std::string channel;
294
314
    if (channels)
299
319
        channel += msg.readInt8();
300
320
    }
301
321
    if (chatMsgLength <= 0)
 
322
    {
 
323
        BLOCK_END("ChatHandler::processChat")
302
324
        return;
 
325
    }
303
326
 
304
327
    std::string chatMsg = msg.readRawString(chatMsgLength);
305
328
    const size_t pos = chatMsg.find(" : ", 0);
334
357
    {
335
358
        localChatTab->chatLog(chatMsg, BY_GM);
336
359
    }
 
360
    BLOCK_END("ChatHandler::processChat")
337
361
}
338
362
 
339
363
void ChatHandler::processMVP(Net::MessageIn &msg) const
340
364
{
 
365
    BLOCK_START("ChatHandler::processMVP")
341
366
    // Display MVP player
342
367
    const int id = msg.readInt32();  // id
343
368
    if (localChatTab && actorSpriteManager && config.getBoolValue("showMVP"))
348
373
        else
349
374
            NotifyManager::notify(NotifyManager::MVP_PLAYER, being->getName());
350
375
    }
 
376
    BLOCK_END("ChatHandler::processMVP")
351
377
}
352
378
 
353
379
void ChatHandler::processIgnoreAllResponse(Net::MessageIn &msg) const
354
380
{
 
381
    BLOCK_START("ChatHandler::processIgnoreAllResponse")
355
382
    const int action = msg.readInt8();
356
383
    const int fail = msg.readInt8();
357
384
    if (!localChatTab)
 
385
    {
 
386
        BLOCK_END("ChatHandler::processIgnoreAllResponse")
358
387
        return;
 
388
    }
359
389
 
360
390
    switch (action)
361
391
    {
391
421
            // unknown result
392
422
            break;
393
423
    }
 
424
    BLOCK_END("ChatHandler::processIgnoreAllResponse")
394
425
}
395
426
 
396
427
}  // namespace Ea