inbox.cpp

main 73 lines · 2 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1/**
2 * The Forgotten Server - a free and open-source MMORPG server emulator
3 * Copyright (C) 2019 Mark Samman <mark.samman@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#include "otpch.h"
21
22#include "inbox.h"
23#include "tools.h"
24
25Inbox::Inbox(uint16_t type) : Container(type, 30, false, true) {}
26
27ReturnValue Inbox::queryAdd(int32_t, const Thing& thing, uint32_t,
28 uint32_t flags, Creature*) const
29{
30 if (!hasBitSet(FLAG_NOLIMIT, flags)) {
31 return RETURNVALUE_CONTAINERNOTENOUGHROOM;
32 }
33
34 const Item* item = thing.getItem();
35 if (!item) {
36 return RETURNVALUE_NOTPOSSIBLE;
37 }
38
39 if (item == this) {
40 return RETURNVALUE_THISISIMPOSSIBLE;
41 }
42
43 if (!item->isPickupable()) {
44 return RETURNVALUE_CANNOTPICKUP;
45 }
46
47 return RETURNVALUE_NOERROR;
48}
49
50void Inbox::postAddNotification(Thing* thing, const Cylinder* oldParent, int32_t index, cylinderlink_t)
51{
52 Cylinder* parent = getParent();
53 if (parent != nullptr) {
54 parent->postAddNotification(thing, oldParent, index, LINK_PARENT);
55 }
56}
57
58void Inbox::postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, cylinderlink_t)
59{
60 Cylinder* parent = getParent();
61 if (parent != nullptr) {
62 parent->postRemoveNotification(thing, newParent, index, LINK_PARENT);
63 }
64}
65
66Cylinder* Inbox::getParent() const
67{
68 if (parent) {
69 return parent->getParent();
70 }
71 return nullptr;
72}
73
Top