2012-06-29 16:44:26 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// This file is part of Remere's Map Editor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2020-07-30 11:42:28 -03:00
|
|
|
// Remere's Map Editor is free software: you can redistribute it and/or modify
|
2012-06-29 16:44:26 +02:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
2016-09-29 19:24:45 -03:00
|
|
|
//
|
2020-07-30 11:42:28 -03:00
|
|
|
// Remere's Map Editor is distributed in the hope that it will be useful,
|
2012-06-29 16:44:26 +02:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2020-07-30 11:42:28 -03:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-06-29 16:44:26 +02:00
|
|
|
// GNU General Public License for more details.
|
2016-09-29 19:24:45 -03:00
|
|
|
//
|
2012-06-29 16:44:26 +02:00
|
|
|
// You should have received a copy of the GNU General Public License
|
2020-07-30 11:42:28 -03:00
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2012-06-29 16:44:26 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
|
|
#include "complexitem.h"
|
|
|
|
|
|
|
|
|
|
#include "iomap.h"
|
|
|
|
|
|
|
|
|
|
// Container
|
2023-10-09 19:12:16 -07:00
|
|
|
Container::Container(const uint16_t type) :
|
|
|
|
|
Item(type, 0) {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
Container::~Container() {
|
|
|
|
|
for (Item* item : contents) {
|
2014-03-10 22:46:28 +01:00
|
|
|
delete item;
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
2023-10-09 23:02:37 -03:00
|
|
|
contents.clear();
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
Item* Container::deepCopy() const {
|
2012-07-03 21:59:51 +02:00
|
|
|
Item* copy = Item::deepCopy();
|
2023-10-09 19:12:16 -07:00
|
|
|
if (Container* container = copy->getContainer()) {
|
|
|
|
|
for (const Item* item : contents) {
|
2023-10-09 23:02:37 -03:00
|
|
|
container->contents.push_back(item->deepCopy());
|
2012-07-03 21:59:51 +02:00
|
|
|
}
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
Item* Container::getItem(size_t index) const {
|
|
|
|
|
if (index >= 0 && index < contents.size()) {
|
2023-10-09 23:02:37 -03:00
|
|
|
return contents.at(index);
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
2014-03-10 22:46:28 +01:00
|
|
|
return nullptr;
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Teleport
|
2023-10-09 19:12:16 -07:00
|
|
|
Teleport::Teleport(const uint16_t type) :
|
|
|
|
|
Item(type, 0),
|
|
|
|
|
destination(0, 0, 0) {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
Item* Teleport::deepCopy() const {
|
2023-10-09 23:02:37 -03:00
|
|
|
Item* copy = Item::deepCopy();
|
2023-10-09 19:12:16 -07:00
|
|
|
if (Teleport* teleport = copy->getTeleport()) {
|
2023-10-09 23:02:37 -03:00
|
|
|
teleport->setDestination(destination);
|
|
|
|
|
}
|
2012-06-29 16:44:26 +02:00
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Door
|
2023-10-09 19:12:16 -07:00
|
|
|
Door::Door(const uint16_t type) :
|
|
|
|
|
Item(type, 0),
|
|
|
|
|
doorId(0) {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
Item* Door::deepCopy() const {
|
2023-10-09 23:02:37 -03:00
|
|
|
Item* copy = Item::deepCopy();
|
2023-10-09 19:12:16 -07:00
|
|
|
if (Door* door = copy->getDoor()) {
|
2023-10-09 23:02:37 -03:00
|
|
|
door->doorId = doorId;
|
|
|
|
|
}
|
2012-06-29 16:44:26 +02:00
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Depot
|
2023-10-09 19:12:16 -07:00
|
|
|
Depot::Depot(const uint16_t type) :
|
|
|
|
|
Item(type, 0),
|
|
|
|
|
depotId(0) {
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
Item* Depot::deepCopy() const {
|
2012-07-03 21:59:51 +02:00
|
|
|
Item* copy = Item::deepCopy();
|
2023-10-09 19:12:16 -07:00
|
|
|
if (Depot* depot = copy->getDepot()) {
|
2023-10-09 23:02:37 -03:00
|
|
|
depot->depotId = depotId;
|
2014-03-10 22:46:28 +01:00
|
|
|
}
|
2012-06-29 16:44:26 +02:00
|
|
|
return copy;
|
|
|
|
|
}
|