GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/auctionhandler.cpp Lines: 0 41 0.0 %
Date: 2021-03-17 Branches: 0 52 0.0 %

Line Branch Exec Source
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/auctionhandler.h"
23
24
#include "const/net/inventory.h"
25
26
#include "net/eathena/messageout.h"
27
#include "net/eathena/protocolout.h"
28
29
#include "resources/item/item.h"
30
31
#include "debug.h"
32
33
namespace EAthena
34
{
35
36
AuctionHandler::AuctionHandler()
37
{
38
    auctionHandler = this;
39
}
40
41
AuctionHandler::~AuctionHandler()
42
{
43
    auctionHandler = nullptr;
44
}
45
46
void AuctionHandler::cancelReg() const
47
{
48
    createOutPacket(CMSG_AUCTION_CANCEL_REG);
49
    outMsg.writeInt16(0, "type");  // unused
50
}
51
52
void AuctionHandler::setItem(const Item *const item,
53
                             const int amount) const
54
{
55
    if (item == nullptr)
56
        return;
57
    createOutPacket(CMSG_AUCTION_SET_ITEM);
58
    outMsg.writeInt16(CAST_S16(
59
        item->getInvIndex() + INVENTORY_OFFSET), "index");
60
    outMsg.writeInt32(amount, "amount");  // always 1
61
}
62
63
void AuctionHandler::reg(const int currentPrice,
64
                         const int maxPrice,
65
                         const int hours) const
66
{
67
    createOutPacket(CMSG_AUCTION_REGISTER);
68
    outMsg.writeInt32(currentPrice, "now money");
69
    outMsg.writeInt32(maxPrice, "max money");
70
    outMsg.writeInt32(hours, "delete hour");
71
}
72
73
void AuctionHandler::cancel(const int auctionId) const
74
{
75
    createOutPacket(CMSG_AUCTION_CANCEL);
76
    outMsg.writeInt32(auctionId, "auction id");
77
}
78
79
void AuctionHandler::close(const int auctionId) const
80
{
81
    createOutPacket(CMSG_AUCTION_CLOSE);
82
    outMsg.writeInt32(auctionId, "auction id");
83
}
84
85
void AuctionHandler::bid(const int auctionId,
86
                         const int money) const
87
{
88
    createOutPacket(CMSG_AUCTION_BID);
89
    outMsg.writeInt32(auctionId, "auction id");
90
    outMsg.writeInt32(money, "money");
91
}
92
93
void AuctionHandler::search(const AuctionSearchTypeT type,
94
                            const int auctionId,
95
                            const std::string &text,
96
                            const int page) const
97
{
98
    createOutPacket(CMSG_AUCTION_SEARCH);
99
    outMsg.writeInt16(CAST_S16(type), "search type");
100
    outMsg.writeInt32(auctionId, "auction id");
101
    outMsg.writeString(text, 24, "search text");
102
    outMsg.writeInt16(CAST_S16(page), "page");
103
}
104
105
void AuctionHandler::buy() const
106
{
107
    createOutPacket(CMSG_AUCTION_BUY_SELL);
108
    outMsg.writeInt16(1, "buy/sell type");
109
}
110
111
void AuctionHandler::sell() const
112
{
113
    createOutPacket(CMSG_AUCTION_BUY_SELL);
114
    outMsg.writeInt16(0, "buy/sell type");
115
}
116
117
}  // namespace EAthena