complexitem.cpp

main 116 lines · 2.7 KB Raw
Alex Alex Commit Map Editor 18/10/2026 23:40
1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#include "main.h"
19
20#include "complexitem.h"
21
22#include "iomap.h"
23
24// Container
25Container::Container(const uint16_t type) :
26 Item(type, 0) {
27 ////
28}
29
30Container::~Container() {
31 for (Item* item : contents) {
32 delete item;
33 }
34}
35
36Item* Container::deepCopy() const {
37 Item* copy = Item::deepCopy();
38 Container* copyContainer = dynamic_cast<Container*>(copy);
39 if (copyContainer) {
40 for (Item* item : contents) {
41 copyContainer->contents.push_back(item->deepCopy());
42 }
43 }
44 return copy;
45}
46
47Item* Container::getItem(size_t index) const {
48 if (index < contents.size()) {
49 return contents[index];
50 }
51 return nullptr;
52}
53
54double Container::getWeight() {
55 return g_items[id].weight;
56}
57
58// Teleport
59Teleport::Teleport(const uint16_t type) :
60 Item(type, 0),
61 destination(0, 0, 0) {
62 ////
63}
64
65Item* Teleport::deepCopy() const {
66 Teleport* copy = static_cast<Teleport*>(Item::deepCopy());
67 copy->destination = destination;
68 return copy;
69}
70
71// Door
72Door::Door(const uint16_t type) :
73 Item(type, 0),
74 doorId(0) {
75 ////
76}
77
78Item* Door::deepCopy() const {
79 Door* copy = static_cast<Door*>(Item::deepCopy());
80 copy->doorId = doorId;
81 return copy;
82}
83
84// Depot
85Depot::Depot(const uint16_t type) :
86 Item(type, 0),
87 depotId(0) {
88 ////
89}
90
91Item* Depot::deepCopy() const {
92 Item* copy = Item::deepCopy();
93 Depot* copy_depot = dynamic_cast<Depot*>(copy);
94 if (copy_depot) {
95 copy_depot->depotId = depotId;
96 }
97 return copy;
98}
99
100// Podium
101Podium::Podium(const uint16_t type) :
102 Item(type, 0),
103 outfit(Outfit()), showOutfit(true), showMount(true), showPlatform(true), direction(0) {
104 ////
105}
106
107Item* Podium::deepCopy() const {
108 Podium* copy = static_cast<Podium*>(Item::deepCopy());
109 copy->outfit = outfit;
110 copy->showOutfit = showOutfit;
111 copy->showMount = showMount;
112 copy->showPlatform = showPlatform;
113 copy->direction = direction;
114 return copy;
115}
116
Top