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
|
2014-03-10 22:46:28 +01: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
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:46:28 +01:00
|
|
|
Container::~Container()
|
|
|
|
|
{
|
2015-12-06 11:42:37 -03:00
|
|
|
for(Item* item : contents) {
|
2014-03-10 22:46:28 +01:00
|
|
|
delete item;
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:46:28 +01:00
|
|
|
Item* Container::deepCopy() const
|
|
|
|
|
{
|
2012-07-03 21:59:51 +02:00
|
|
|
Item* copy = Item::deepCopy();
|
2014-03-10 22:46:28 +01:00
|
|
|
Container* copyContainer = dynamic_cast<Container*>(copy);
|
2015-12-06 11:42:37 -03:00
|
|
|
if(copyContainer) {
|
|
|
|
|
for(Item* item : contents) {
|
2014-03-10 22:46:28 +01:00
|
|
|
copyContainer->contents.push_back(item->deepCopy());
|
2012-07-03 21:59:51 +02:00
|
|
|
}
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:46:28 +01:00
|
|
|
Item* Container::getItem(size_t index) const
|
|
|
|
|
{
|
2015-12-06 11:42:37 -03:00
|
|
|
if(index < contents.size()) {
|
2014-03-10 22:46:28 +01:00
|
|
|
return contents[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
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:46:28 +01:00
|
|
|
double Container::getWeight()
|
|
|
|
|
{
|
2016-10-25 09:47:00 -03:00
|
|
|
return g_items[id].weight;
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Teleport
|
2014-03-10 22:46:28 +01:00
|
|
|
Teleport::Teleport(const uint16_t type) : Item(type, 0),
|
|
|
|
|
destination(0, 0, 0)
|
2012-06-29 16:44:26 +02:00
|
|
|
{
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:46:28 +01:00
|
|
|
Item* Teleport::deepCopy() const
|
|
|
|
|
{
|
2012-06-29 16:44:26 +02:00
|
|
|
Teleport* copy = static_cast<Teleport*>(Item::deepCopy());
|
|
|
|
|
copy->destination = destination;
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Door
|
2014-03-10 22:46:28 +01:00
|
|
|
Door::Door(const uint16_t type) : Item(type, 0),
|
|
|
|
|
doorId(0)
|
2012-06-29 16:44:26 +02:00
|
|
|
{
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:46:28 +01:00
|
|
|
Item* Door::deepCopy() const
|
|
|
|
|
{
|
2012-06-29 16:44:26 +02:00
|
|
|
Door* copy = static_cast<Door*>(Item::deepCopy());
|
2014-03-10 22:46:28 +01:00
|
|
|
copy->doorId = doorId;
|
2012-06-29 16:44:26 +02:00
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Depot
|
2014-03-10 22:46:28 +01:00
|
|
|
Depot::Depot(const uint16_t type) : Item(type, 0),
|
|
|
|
|
depotId(0)
|
2012-06-29 16:44:26 +02:00
|
|
|
{
|
2015-12-06 11:42:37 -03:00
|
|
|
////
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:46:28 +01:00
|
|
|
Item* Depot::deepCopy() const
|
|
|
|
|
{
|
2012-07-03 21:59:51 +02:00
|
|
|
Item* copy = Item::deepCopy();
|
|
|
|
|
Depot* copy_depot = dynamic_cast<Depot*>(copy);
|
2015-12-06 11:42:37 -03:00
|
|
|
if(copy_depot) {
|
2014-03-10 22:46:28 +01:00
|
|
|
copy_depot->depotId = depotId;
|
|
|
|
|
}
|
2012-06-29 16:44:26 +02:00
|
|
|
return copy;
|
|
|
|
|
}
|