GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/searchstorehandler.cpp Lines: 0 31 0.0 %
Date: 2018-11-12 Branches: 0 36 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2011-2018  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "net/eathena/searchstorehandler.h"
22
23
#include "net/eathena/messageout.h"
24
#include "net/eathena/protocolout.h"
25
26
#include "debug.h"
27
28
extern int packetVersion;
29
30
namespace EAthena
31
{
32
33
SearchStoreHandler::SearchStoreHandler() :
34
    Net::SearchStoreHandler()
35
{
36
    searchStoreHandler = this;
37
}
38
39
SearchStoreHandler::~SearchStoreHandler()
40
{
41
    searchStoreHandler = nullptr;
42
}
43
44
void SearchStoreHandler::search(const StoreSearchTypeT type,
45
                                const int minPrice,
46
                                const int maxPrice,
47
                                const int itemId) const
48
{
49
    if (packetVersion < 20100601)
50
        return;
51
52
    createOutPacket(CMSG_SEARCHSTORE_SEARCH);
53
    outMsg.writeInt16(23, "len");
54
    outMsg.writeInt8(CAST_U8(type), "search type");
55
    outMsg.writeInt32(maxPrice, "max price");
56
    outMsg.writeInt32(minPrice, "min price");
57
    outMsg.writeInt32(1, "items count");
58
    outMsg.writeInt32(0, "cards count");
59
    outMsg.writeItemId(itemId, "item id");
60
    // +++ missing for by items and cards
61
}
62
63
void SearchStoreHandler::nextPage() const
64
{
65
    if (packetVersion < 20100608)
66
        return;
67
    createOutPacket(CMSG_SEARCHSTORE_NEXT_PAGE);
68
}
69
70
void SearchStoreHandler::close() const
71
{
72
    if (packetVersion < 20100608)
73
        return;
74
    createOutPacket(CMSG_SEARCHSTORE_CLOSE);
75
}
76
77
void SearchStoreHandler::select(const int accountId,
78
                                const int storeId,
79
                                const int itemId) const
80
{
81
    if (packetVersion < 20100608)
82
        return;
83
    createOutPacket(CMSG_SEARCHSTORE_CLICK);
84
    outMsg.writeInt32(accountId, "account id");
85
    outMsg.writeInt32(storeId, "store id");
86
    outMsg.writeItemId(itemId, "item id");
87
}
88
89
}  // namespace EAthena