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