GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/inventoryhandler.cpp Lines: 8 354 2.3 %
Date: 2017-11-29 Branches: 0 594 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2004-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2017  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#include "net/eathena/inventoryhandler.h"
24
25
#include "const/net/inventory.h"
26
27
#include "enums/equipslot.h"
28
29
#include "net/eathena/inventoryrecv.h"
30
#include "net/eathena/menu.h"
31
#include "net/eathena/messageout.h"
32
#include "net/eathena/protocolout.h"
33
34
#include "utils/foreach.h"
35
36
#include "resources/item/item.h"
37
38
#include "debug.h"
39
40
extern int packetVersion;
41
extern int serverVersion;
42
43
// this conversion from bit corrupted LOOK_* to EquipSlot
44
// for how it corrupted, see BeingRecv::processBeingChangeLookContinue
45
const EquipSlot::Type EQUIP_CONVERT[] =
46
{
47
    EquipSlot::PROJECTILE_SLOT,    // 0    SPRITE_BASE
48
    EquipSlot::FEET_SLOT,          // 1    SPRITE_HAIR
49
    EquipSlot::LEGS_SLOT,          // 2    SPRITE_WEAPON
50
    EquipSlot::TORSO_SLOT,         // 3    SPRITE_HEAD_BOTTOM
51
    EquipSlot::GLOVES_SLOT,        // 4    SPRITE_HEAD_TOP
52
    EquipSlot::EVOL_RING1_SLOT,    // 5    SPRITE_HEAD_MID
53
    EquipSlot::PROJECTILE_SLOT,    // 6    SPRITE_HAIR_COLOR
54
    EquipSlot::HEAD_SLOT,          // 7    SPRITE_CLOTHES_COLOR
55
    EquipSlot::RING2_SLOT,         // 8    SPRITE_SHIELD
56
    EquipSlot::PROJECTILE_SLOT,    // 9    SPRITE_SHOES
57
    EquipSlot::FIGHT1_SLOT,        // 10   SPRITE_BODY
58
    EquipSlot::FIGHT2_SLOT,        // 11   SPRITE_FLOOR
59
    EquipSlot::EVOL_RING2_SLOT,    // 12   SPRITE_ROBE
60
    EquipSlot::PROJECTILE_SLOT,    // 13   SPRITE_EVOL2
61
    EquipSlot::COSTUME_ROBE_SLOT,  // 14   SPRITE_EVOL3
62
    EquipSlot::RING1_SLOT,         // 15   SPRITE_EVOL4
63
    EquipSlot::NECK_SLOT,          // 16   SPRITE_EVOL5
64
    EquipSlot::RING2_SLOT,         // 17   SPRITE_EVOL6
65
};
66
67
namespace EAthena
68
{
69
70
152
InventoryHandler::InventoryHandler() :
71
    Ea::InventoryHandler(),
72
152
    mItemIndex(0)
73
{
74
152
    inventoryHandler = this;
75
76
152
    InventoryRecv::mCartItems.clear();
77
152
}
78
79
304
InventoryHandler::~InventoryHandler()
80
{
81
152
    inventoryHandler = nullptr;
82
152
}
83
84
void InventoryHandler::equipItem(const Item *const item) const
85
{
86
    if (item == nullptr)
87
        return;
88
89
    createOutPacket(CMSG_PLAYER_EQUIP);
90
    outMsg.writeInt16(CAST_S16(
91
        item->getInvIndex() + INVENTORY_OFFSET), "index");
92
    // here we set flag for any slots,
93
    // probably better set to slot from item properties
94
    if (packetVersion >= 20130320)
95
        outMsg.writeInt32(0xFFFFFFFFU, "wear location");
96
    else
97
        outMsg.writeInt16(0x7FFFU, "wear location");
98
}
99
100
void InventoryHandler::unequipItem(const Item *const item) const
101
{
102
    if (item == nullptr)
103
        return;
104
105
    createOutPacket(CMSG_PLAYER_UNEQUIP);
106
    outMsg.writeInt16(CAST_S16(
107
        item->getInvIndex() + INVENTORY_OFFSET), "index");
108
}
109
110
void InventoryHandler::useItem(const Item *const item) const
111
{
112
    if (item == nullptr)
113
        return;
114
115
    createOutPacket(CMSG_PLAYER_INVENTORY_USE);
116
    outMsg.writeInt16(CAST_S16(
117
        item->getInvIndex() + INVENTORY_OFFSET), "index");
118
    outMsg.writeInt32(item->getId(), "unused");
119
}
120
121
void InventoryHandler::useItem(const Item *const item,
122
                               const int16_t useType) const
123
{
124
    if (item == nullptr)
125
        return;
126
127
    if (serverVersion >= 19)
128
    {
129
        createOutPacket(CMSG_PLAYER_INVENTORY_USE2);
130
        outMsg.writeInt16(CAST_S16(
131
            item->getInvIndex() + INVENTORY_OFFSET), "index");
132
        outMsg.writeInt16(useType, "use type");
133
    }
134
    else
135
    {
136
        createOutPacket(CMSG_PLAYER_INVENTORY_USE);
137
        outMsg.writeInt16(CAST_S16(
138
            item->getInvIndex() + INVENTORY_OFFSET), "index");
139
        outMsg.writeInt32(item->getId(), "unused");
140
    }
141
}
142
143
void InventoryHandler::dropItem(const Item *const item, const int amount) const
144
{
145
    if (item == nullptr)
146
        return;
147
148
    createOutPacket(CMSG_PLAYER_INVENTORY_DROP);
149
    const int16_t index = CAST_S16(item->getInvIndex() + INVENTORY_OFFSET);
150
    if (packetVersion >= 20101124)
151
    {
152
        outMsg.writeInt16(index, "index");
153
        outMsg.writeInt16(CAST_S16(amount), "amount");
154
    }
155
    else if (packetVersion >= 20080827)
156
    {
157
        outMsg.writeInt16(0, "unknown");
158
        outMsg.writeInt16(index, "index");
159
        outMsg.writeInt32(0, "unknown");
160
        outMsg.writeInt16(0, "unknown");
161
        outMsg.writeInt8(0, "unknown");
162
        outMsg.writeInt16(CAST_S16(amount), "amount");
163
    }
164
    else if (packetVersion >= 20070212)
165
    {
166
        outMsg.writeInt16(0, "unknown");
167
        outMsg.writeInt8(0, "unknown");
168
        outMsg.writeInt16(index, "index");
169
        outMsg.writeInt8(0, "unknown");
170
        outMsg.writeInt16(CAST_S16(amount), "amount");
171
    }
172
    else if (packetVersion >= 20070108)
173
    {
174
        outMsg.writeInt32(0, "unknown");
175
        outMsg.writeInt32(0, "unknown");
176
        outMsg.writeInt16(0, "unknown");
177
        outMsg.writeInt16(index, "index");
178
        outMsg.writeInt32(0, "unknown");
179
        outMsg.writeInt16(CAST_S16(amount), "amount");
180
    }
181
    else if (packetVersion >= 20060327)
182
    {
183
        outMsg.writeInt32(0, "unknown");
184
        outMsg.writeInt16(0, "unknown");
185
        outMsg.writeInt16(index, "index");
186
        outMsg.writeInt32(0, "unknown");
187
        outMsg.writeInt8(0, "unknown");
188
        outMsg.writeInt16(CAST_S16(amount), "amount");
189
    }
190
    else if (packetVersion >= 20050719)
191
    {
192
        outMsg.writeInt8(0, "unknown");
193
        outMsg.writeInt16(index, "index");
194
        outMsg.writeInt8(0, "unknown");
195
        outMsg.writeInt32(0, "unknown");
196
        outMsg.writeInt16(CAST_S16(amount), "amount");
197
    }
198
    else if (packetVersion >= 20050718)
199
    {
200
        outMsg.writeInt32(0, "unknown");
201
        outMsg.writeInt16(index, "index");
202
        outMsg.writeInt16(0, "unknown");
203
        outMsg.writeInt16(CAST_S16(amount), "amount");
204
    }
205
    else if (packetVersion >= 20050628)
206
    {
207
        outMsg.writeInt8(0, "unknown");
208
        outMsg.writeInt16(index, "index");
209
        outMsg.writeInt32(0, "unknown");
210
        outMsg.writeInt8(0, "unknown");
211
        outMsg.writeInt16(CAST_S16(amount), "amount");
212
    }
213
    else if (packetVersion >= 20050509)
214
    {
215
        outMsg.writeInt16(0, "unknown");
216
        outMsg.writeInt8(0, "unknown");
217
        outMsg.writeInt16(index, "index");
218
        outMsg.writeInt8(0, "unknown");
219
        outMsg.writeInt16(CAST_S16(amount), "amount");
220
    }
221
    else if (packetVersion >= 20050110)
222
    {
223
        outMsg.writeInt32(0, "unknown");
224
        outMsg.writeInt32(0, "unknown");
225
        outMsg.writeInt32(0, "unknown");
226
        outMsg.writeInt8(0, "unknown");
227
        outMsg.writeInt16(index, "index");
228
        outMsg.writeInt8(0, "unknown");
229
        outMsg.writeInt16(CAST_S16(amount), "amount");
230
    }
231
    else if (packetVersion >= 20041129)
232
    {
233
        outMsg.writeInt16(0, "unknown");
234
        outMsg.writeInt16(index, "index");
235
        outMsg.writeInt32(0, "unknown");
236
        outMsg.writeInt16(CAST_S16(amount), "amount");
237
    }
238
    else if (packetVersion >= 20041025)
239
    {
240
        outMsg.writeInt32(0, "unknown");
241
        outMsg.writeInt16(index, "index");
242
        outMsg.writeInt16(0, "unknown");
243
        outMsg.writeInt16(CAST_S16(amount), "amount");
244
    }
245
    else if (packetVersion >= 20041005)
246
    {
247
        outMsg.writeInt16(0, "unknown");
248
        outMsg.writeInt8(0, "unknown");
249
        outMsg.writeInt16(index, "index");
250
        outMsg.writeInt32(0, "unknown");
251
        outMsg.writeInt8(0, "unknown");
252
        outMsg.writeInt16(CAST_S16(amount), "amount");
253
    }
254
    else if (packetVersion >= 20040920)
255
    {
256
        outMsg.writeInt32(0, "unknown");
257
        outMsg.writeInt32(0, "unknown");
258
        outMsg.writeInt16(0, "unknown");
259
        outMsg.writeInt16(index, "index");
260
        outMsg.writeInt16(0, "unknown");
261
        outMsg.writeInt8(0, "unknown");
262
        outMsg.writeInt16(CAST_S16(amount), "amount");
263
    }
264
    else if (packetVersion >= 20040906)
265
    {
266
        outMsg.writeInt32(0, "unknown");
267
        outMsg.writeInt16(index, "index");
268
        outMsg.writeInt32(0, "unknown");
269
        outMsg.writeInt16(0, "unknown");
270
        outMsg.writeInt8(0, "unknown");
271
        outMsg.writeInt16(CAST_S16(amount), "amount");
272
    }
273
    else if (packetVersion >= 20040809)
274
    {
275
        outMsg.writeInt32(0, "unknown");
276
        outMsg.writeInt16(0, "unknown");
277
        outMsg.writeInt16(index, "index");
278
        outMsg.writeInt32(0, "unknown");
279
        outMsg.writeInt8(0, "unknown");
280
        outMsg.writeInt16(CAST_S16(amount), "amount");
281
    }
282
    else if (packetVersion >= 20040726)
283
    {
284
        outMsg.writeInt16(0, "unknown");
285
        outMsg.writeInt8(0, "unknown");
286
        outMsg.writeInt16(index, "index");
287
        outMsg.writeInt32(0, "unknown");
288
        outMsg.writeInt8(0, "unknown");
289
        outMsg.writeInt16(CAST_S16(amount), "amount");
290
    }
291
    else
292
    {
293
        outMsg.writeInt16(index, "index");
294
        outMsg.writeInt16(CAST_S16(amount), "amount");
295
    }
296
}
297
298
void InventoryHandler::closeStorage() const
299
{
300
    createOutPacket(CMSG_CLOSE_STORAGE);
301
}
302
303
void InventoryHandler::moveItemInventoryToStorage(const int slot,
304
                                                  const int amount) const
305
{
306
    createOutPacket(CMSG_MOVE_TO_STORAGE);
307
    if (packetVersion >= 20101124)
308
    {
309
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
310
        outMsg.writeInt32(amount, "amount");
311
    }
312
    else if (packetVersion >= 20080827)
313
    {
314
        outMsg.writeInt8(0, "unknown");
315
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
316
        outMsg.writeInt32(0, "unknown");
317
        outMsg.writeInt32(0, "unknown");
318
        outMsg.writeInt32(0, "unknown");
319
        outMsg.writeInt16(0, "unknown");
320
        outMsg.writeInt8(0, "unknown");
321
        outMsg.writeInt32(amount, "amount");
322
    }
323
    else if (packetVersion >= 20070212)
324
    {
325
        outMsg.writeInt32(0, "unknown");
326
        outMsg.writeInt8(0, "unknown");
327
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
328
        outMsg.writeInt8(0, "unknown");
329
        outMsg.writeInt32(amount, "amount");
330
    }
331
    else if (packetVersion >= 20070108)
332
    {
333
        outMsg.writeInt16(0, "unknown");
334
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
335
        outMsg.writeInt32(0, "unknown");
336
        outMsg.writeInt16(0, "unknown");
337
        outMsg.writeInt8(0, "unknown");
338
        outMsg.writeInt32(amount, "amount");
339
    }
340
    else if (packetVersion >= 20060327)
341
    {
342
        outMsg.writeInt16(0, "unknown");
343
        outMsg.writeInt8(0, "unknown");
344
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
345
        outMsg.writeInt32(0, "unknown");
346
        outMsg.writeInt32(0, "unknown");
347
        outMsg.writeInt32(0, "unknown");
348
        outMsg.writeInt32(amount, "amount");
349
    }
350
    else if (packetVersion >= 20050719)
351
    {
352
        outMsg.writeInt32(0, "unknown");
353
        outMsg.writeInt32(0, "unknown");
354
        outMsg.writeInt32(0, "unknown");
355
        outMsg.writeInt16(0, "unknown");
356
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
357
        outMsg.writeInt32(0, "unknown");
358
        outMsg.writeInt32(0, "unknown");
359
        outMsg.writeInt8(0, "unknown");
360
        outMsg.writeInt32(amount, "amount");
361
    }
362
    else if (packetVersion >= 20050718)
363
    {
364
        outMsg.writeInt32(0, "unknown");
365
        outMsg.writeInt32(0, "unknown");
366
        outMsg.writeInt16(0, "unknown");
367
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
368
        outMsg.writeInt16(0, "unknown");
369
        outMsg.writeInt8(0, "unknown");
370
        outMsg.writeInt32(amount, "amount");
371
    }
372
    else if (packetVersion >= 20050628)
373
    {
374
        outMsg.writeInt32(0, "unknown");
375
        outMsg.writeInt32(0, "unknown");
376
        outMsg.writeInt32(0, "unknown");
377
        outMsg.writeInt16(0, "unknown");
378
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
379
        outMsg.writeInt32(0, "unknown");
380
        outMsg.writeInt32(0, "unknown");
381
        outMsg.writeInt16(0, "unknown");
382
        outMsg.writeInt32(amount, "amount");
383
    }
384
    else if (packetVersion >= 20050509)
385
    {
386
        outMsg.writeInt32(0, "unknown");
387
        outMsg.writeInt8(0, "unknown");
388
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
389
        outMsg.writeInt8(0, "unknown");
390
        outMsg.writeInt32(amount, "amount");
391
    }
392
    else if (packetVersion >= 20050110)
393
    {
394
        outMsg.writeInt32(0, "unknown");
395
        outMsg.writeInt32(0, "unknown");
396
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
397
        outMsg.writeInt32(0, "unknown");
398
        outMsg.writeInt16(0, "unknown");
399
        outMsg.writeInt32(amount, "amount");
400
    }
401
    else if (packetVersion >= 20041129)
402
    {
403
        outMsg.writeInt16(0, "unknown");
404
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
405
        outMsg.writeInt32(0, "unknown");
406
        outMsg.writeInt32(amount, "amount");
407
    }
408
    else if (packetVersion >= 20041025)
409
    {
410
        outMsg.writeInt32(0, "unknown");
411
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
412
        outMsg.writeInt8(0, "unknown");
413
        outMsg.writeInt32(amount, "amount");
414
    }
415
    else if (packetVersion >= 20041005)
416
    {
417
        outMsg.writeInt16(0, "unknown");
418
        outMsg.writeInt8(0, "unknown");
419
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
420
        outMsg.writeInt32(0, "unknown");
421
        outMsg.writeInt8(0, "unknown");
422
        outMsg.writeInt32(amount, "amount");
423
    }
424
    else if (packetVersion >= 20040920)
425
    {
426
        outMsg.writeInt32(0, "unknown");
427
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
428
        outMsg.writeInt32(0, "unknown");
429
        outMsg.writeInt32(0, "unknown");
430
        outMsg.writeInt32(0, "unknown");
431
        outMsg.writeInt8(0, "unknown");
432
        outMsg.writeInt32(amount, "amount");
433
    }
434
    else if (packetVersion >= 20040906)
435
    {
436
        outMsg.writeInt8(0, "unknown");
437
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
438
        outMsg.writeInt32(0, "unknown");
439
        outMsg.writeInt32(0, "unknown");
440
        outMsg.writeInt16(0, "unknown");
441
        outMsg.writeInt32(amount, "amount");
442
    }
443
    else if (packetVersion >= 20040809)
444
    {
445
        outMsg.writeInt16(0, "unknown");
446
        outMsg.writeInt8(0, "unknown");
447
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
448
        outMsg.writeInt32(0, "unknown");
449
        outMsg.writeInt32(0, "unknown");
450
        outMsg.writeInt32(0, "unknown");
451
        outMsg.writeInt32(amount, "amount");
452
    }
453
    else if (packetVersion >= 20040726)
454
    {
455
        outMsg.writeInt16(0, "unknown");
456
        outMsg.writeInt8(0, "unknown");
457
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
458
        outMsg.writeInt32(0, "unknown");
459
        outMsg.writeInt8(0, "unknown");
460
        outMsg.writeInt32(amount, "amount");
461
    }
462
    else
463
    {
464
        outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
465
        outMsg.writeInt32(amount, "amount");
466
    }
467
}
468
469
void InventoryHandler::moveItem2(const InventoryTypeT source,
470
                                 const int slot,
471
                                 const int amount,
472
                                 const InventoryTypeT destination) const
473
{
474
    int packet = 0;
475
    int offset = INVENTORY_OFFSET;
476
    if (source == InventoryType::Inventory)
477
    {
478
        if (destination == InventoryType::Storage)
479
        {
480
            moveItemInventoryToStorage(slot, amount);
481
            return;
482
        }
483
        else if (destination == InventoryType::Cart)
484
        {
485
            packet = CMSG_MOVE_TO_CART;
486
        }
487
    }
488
    else if (source == InventoryType::Storage)
489
    {
490
        offset = STORAGE_OFFSET;
491
        if (destination == InventoryType::Inventory)
492
            packet = CMSG_MOVE_FROM_STORAGE;
493
        else if (destination == InventoryType::Cart)
494
            packet = CMSG_MOVE_FROM_STORAGE_TO_CART;
495
    }
496
    else if (source == InventoryType::Cart)
497
    {
498
        if (destination == InventoryType::Inventory)
499
            packet = CMSG_MOVE_FROM_CART;
500
        else if (destination == InventoryType::Storage)
501
            packet = CMSG_MOVE_FROM_CART_TO_STORAGE;
502
    }
503
504
    // for packetVersion < 20101124 need use other packet offset
505
    if (packet != 0)
506
    {
507
        createOutPacket(packet);
508
        outMsg.writeInt16(CAST_S16(slot + offset), "index");
509
        outMsg.writeInt32(amount, "amount");
510
    }
511
}
512
513
void InventoryHandler::useCard(const Item *const item)
514
{
515
    if (item == nullptr)
516
        return;
517
518
    mItemIndex = item->getInvIndex();
519
    createOutPacket(CMSG_PLAYER_USE_CARD);
520
    outMsg.writeInt16(CAST_S16(
521
        mItemIndex + INVENTORY_OFFSET), "index");
522
}
523
524
void InventoryHandler::insertCard(const int cardIndex,
525
                                  const int itemIndex) const
526
{
527
    createOutPacket(CMSG_PLAYER_INSERT_CARD);
528
    outMsg.writeInt16(CAST_S16(cardIndex + INVENTORY_OFFSET),
529
        "card index");
530
    outMsg.writeInt16(CAST_S16(itemIndex + INVENTORY_OFFSET),
531
        "item index");
532
}
533
534
void InventoryHandler::favoriteItem(const Item *const item,
535
                                    const bool favorite) const
536
{
537
    if (item == nullptr)
538
        return;
539
    if (packetVersion < 20120410)
540
        return;
541
    createOutPacket(CMSG_PLAYER_FAVORITE_ITEM);
542
    outMsg.writeInt16(CAST_S16(item->getInvIndex()
543
        + INVENTORY_OFFSET),
544
        "item index");
545
    outMsg.writeInt8(static_cast<int8_t>(favorite), "favorite flag");
546
}
547
548
void InventoryHandler::selectEgg(const Item *const item) const
549
{
550
    if (item == nullptr)
551
        return;
552
    createOutPacket(CMSG_PET_SELECT_EGG);
553
    outMsg.writeInt16(CAST_S16(
554
        item->getInvIndex() + INVENTORY_OFFSET), "index");
555
    menu = MenuType::Unknown;
556
}
557
558
int InventoryHandler::convertFromServerSlot(const int serverSlot) const
559
{
560
    if (serverSlot < 0 || serverSlot >= 17)
561
        return 0;
562
563
    return CAST_S32(EQUIP_CONVERT[serverSlot]);
564
}
565
566
void InventoryHandler::selectCart(const BeingId accountId,
567
                                  const int type) const
568
{
569
    if (packetVersion < 20150805)
570
        return;
571
    createOutPacket(CMSG_SELECT_CART);
572
    outMsg.writeBeingId(accountId, "account id");
573
    outMsg.writeInt8(CAST_S8(type), "type");
574
}
575
576
void InventoryHandler::identifyItem(const Item *const item) const
577
{
578
    if (packetVersion < 20150513)
579
        return;
580
    createOutPacket(CMSG_QUICK_IDENTIFY_ITEM);
581
    outMsg.writeInt16(CAST_S16(item->getInvIndex()),
582
        "item index");
583
}
584
585
void InventoryHandler::mergeItemsAck(const STD_VECTOR<Item*> &items) const
586
{
587
    createOutPacket(CMSG_MERGE_ITEM_ACK);
588
    const size_t sz = items.size();
589
    outMsg.writeInt16(CAST_S16(sz * 2 + 4),
590
        "len");
591
    FOR_EACH (STD_VECTOR<Item*>::const_iterator, it, items)
592
    {
593
        outMsg.writeInt16(CAST_S16((*it)->getInvIndex() + 2),
594
            "item index");
595
    }
596
}
597
598
void InventoryHandler::mergetItemsCancel() const
599
{
600
    createOutPacket(CMSG_MERGE_ITEM_CANCEL);
601
}
602
603
}  // namespace EAthena