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

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