summaryrefslogtreecommitdiff
path: root/src/resources/item
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-10-10 22:14:45 +0300
committerAndrei Karas <akaras@inbox.ru>2017-10-10 22:15:57 +0300
commitaa3f63fd497558a02feb3ddbc44f31eac091f39b (patch)
tree0e28b9b1f0501dd8be9e1a38db4ec1777fa3fbfa /src/resources/item
parent7c10a6b61e9d06a4ae9cc9f942dfacb6fcfd9d3d (diff)
downloadplus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.gz
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.bz2
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.xz
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.zip
Remove most unused files.
Diffstat (limited to 'src/resources/item')
-rw-r--r--src/resources/item/cardslist.cpp25
-rw-r--r--src/resources/item/cardslist.h72
-rw-r--r--src/resources/item/complexitem.cpp96
-rw-r--r--src/resources/item/complexitem.h65
-rw-r--r--src/resources/item/item.cpp198
-rw-r--r--src/resources/item/item.h267
-rw-r--r--src/resources/item/itemfieldtype.h45
-rw-r--r--src/resources/item/itemoption.h39
-rw-r--r--src/resources/item/itemoptionslist.h102
-rw-r--r--src/resources/item/shopitem.cpp174
-rw-r--r--src/resources/item/shopitem.h181
11 files changed, 0 insertions, 1264 deletions
diff --git a/src/resources/item/cardslist.cpp b/src/resources/item/cardslist.cpp
deleted file mode 100644
index d4e26466f..000000000
--- a/src/resources/item/cardslist.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/item/cardslist.h"
-
-#include "debug.h"
-
-CardsList zeroCards(0, 0, 0, 0);
diff --git a/src/resources/item/cardslist.h b/src/resources/item/cardslist.h
deleted file mode 100644
index 6bc1f5e22..000000000
--- a/src/resources/item/cardslist.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_CARDSLIST_H
-#define RESOURCES_ITEM_CARDSLIST_H
-
-#include "const/resources/item/cards.h"
-
-#include "localconsts.h"
-
-struct CardsList final
-{
- CardsList(const int card0,
- const int card1,
- const int card2,
- const int card3)
- {
- cards[0] = card0;
- cards[1] = card1;
- cards[2] = card2;
- cards[3] = card3;
- }
-
- explicit CardsList(const int *const cards0)
- {
- if (cards0 != nullptr)
- {
- for (int f = 0; f < maxCards; f ++)
- cards[f] = cards0[f];
- }
- else
- {
- for (int f = 0; f < maxCards; f ++)
- cards[f] = 0;
- }
- }
-
- A_DEFAULT_COPY(CardsList)
-
- bool isEmpty() const noexcept2 A_WARN_UNUSED
- {
- return cards[0] == 0 &&
- cards[1] == 0 &&
- cards[2] == 0 &&
- cards[3] == 0;
- }
-
- int cards[maxCards];
-};
-
-extern CardsList zeroCards;
-
-#endif // RESOURCES_ITEM_CARDSLIST_H
diff --git a/src/resources/item/complexitem.cpp b/src/resources/item/complexitem.cpp
deleted file mode 100644
index 1fd703f8c..000000000
--- a/src/resources/item/complexitem.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/item/complexitem.h"
-
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-ComplexItem::ComplexItem(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped) :
- Item(id,
- type,
- quantity,
- refine,
- color,
- identified,
- damaged,
- favorite,
- equipment,
- equipped),
- mChildItems()
-{
-}
-
-ComplexItem::~ComplexItem()
-{
- delete_all(mChildItems);
- mChildItems.clear();
-}
-
-void ComplexItem::addChild(const Item *const item,
- const int amount)
-{
- if (item == nullptr)
- return;
- increaseQuantity(amount);
- Item *child = nullptr;
- FOR_EACH (STD_VECTOR<Item*>::iterator, it, mChildItems)
- {
- Item *const item1 = *it;
- if (item1->getId() == item->getId() &&
- item1->getInvIndex() == item->getInvIndex() &&
- item1->getTag() == item->getTag())
- {
- child = item1;
- break;
- }
- }
- if (child != nullptr)
- {
- child->increaseQuantity(amount);
- }
- else
- {
- child = new ComplexItem(item->getId(),
- item->getType(),
- amount,
- item->getRefine(),
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- Equipm_false,
- Equipped_false);
- child->setTag(item->getTag());
- child->setInvIndex(item->getInvIndex());
- mChildItems.push_back(child);
- }
-}
diff --git a/src/resources/item/complexitem.h b/src/resources/item/complexitem.h
deleted file mode 100644
index aa41fb3fd..000000000
--- a/src/resources/item/complexitem.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_COMPLEXITEM_H
-#define RESOURCES_ITEM_COMPLEXITEM_H
-
-#include "resources/item/item.h"
-
-#include "localconsts.h"
-
-/**
- * Represents one or more instances of a certain item type.
- */
-class ComplexItem final : public Item
-{
- public:
- /**
- * Constructor.
- */
- ComplexItem(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped);
-
- A_DELETE_COPY(ComplexItem)
-
- /**
- * Destructor.
- */
- virtual ~ComplexItem();
-
- void addChild(const Item *const item,
- const int amount);
-
- const STD_VECTOR<Item*> &getChilds() const noexcept2 A_WARN_UNUSED
- { return mChildItems; }
-
- protected:
- STD_VECTOR<Item*> mChildItems;
-};
-
-#endif // RESOURCES_ITEM_COMPLEXITEM_H
diff --git a/src/resources/item/item.cpp b/src/resources/item/item.cpp
deleted file mode 100644
index a9a2c89df..000000000
--- a/src/resources/item/item.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/item/item.h"
-
-#include "configuration.h"
-#include "dragdrop.h"
-#include "itemcolormanager.h"
-
-#include "gui/theme.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/item/itemoptionslist.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "net/net.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-DragDrop dragDrop(nullptr, DragDropSource::Empty);
-
-Item::Item(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped) :
- mId(0),
- mColor(ItemColor_zero),
- mQuantity(quantity),
- mTag(0),
- mImage(nullptr),
- mDescription(),
- mTags(),
- mCards(),
- mOptions(nullptr),
- mRefine(refine),
- mInvIndex(0),
- mType(type),
- mEquipment(equipment),
- mEquipped(equipped),
- mInEquipment(false),
- mIdentified(identified),
- mDamaged(damaged),
- mFavorite(favorite)
-{
- setId(id, color);
- for (int f = 0; f < maxCards; f ++)
- mCards[f] = 0;
-}
-
-Item::~Item()
-{
- if (mImage != nullptr)
- {
- mImage->decRef();
- mImage = nullptr;
- }
- delete2(mOptions);
- dragDrop.clearItem(this);
-}
-
-void Item::setId(const int id,
- const ItemColor color)
-{
- mId = id;
- mColor = color;
-
- // Types 0 and 1 are not equippable items.
- mEquipment = fromBool(id && CAST_S32(getInfo().getType())
- >= 2, Equipm);
-
- if (mImage != nullptr)
- mImage->decRef();
-
- const ItemInfo &info = getInfo();
- mTags = info.getTags();
-
- const std::string dye = combineDye2(pathJoin(
- paths.getStringValue("itemIcons"), info.getDisplay().image),
- info.getDyeIconColorsString(color));
- mImage = Loader::getImage(dye);
-
- if (mImage == nullptr)
- {
- mImage = Theme::getImageFromTheme(paths.getValue("unknownItemFile",
- "unknown-item.png"));
- }
-}
-
-bool Item::isHaveTag(const int tagId) const
-{
- const std::map <int, int>::const_iterator it = mTags.find(tagId);
- if (it == mTags.end())
- return false;
- return (*it).second > 0;
-}
-
-Image *Item::getImage(const int id,
- const ItemColor color)
-{
- const ItemInfo &info = ItemDB::get(id);
- Image *image = Loader::getImage(combineDye2(pathJoin(paths.getStringValue(
- "itemIcons"), info.getDisplay().image),
- info.getDyeIconColorsString(color)));
-
- if (image == nullptr)
- image = Theme::getImageFromTheme("unknown-item.png");
- return image;
-}
-
-std::string Item::getName() const
-{
- const ItemInfo &info = ItemDB::get(mId);
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- {
- return info.getName();
- }
-#endif // TWMA_SUPPORT
- return info.getName(mColor);
-}
-
-void Item::setCard(const int index, const int id)
-{
- if (index < 0 || index >= maxCards)
- return;
- mCards[index] = id;
-}
-
-int Item::getCard(const int index) const
-{
- if (index < 0 || index >= maxCards)
- return 0;
- return mCards[index];
-}
-
-void Item::setCards(const int *const cards, const int size)
-{
- if (size < 0 || (cards == nullptr))
- return;
- int sz = size;
- if (sz > maxCards)
- sz = maxCards;
- for (int f = 0; f < sz; f ++)
- mCards[f] = cards[f];
-}
-
-void Item::addCard(const int card)
-{
- for (int f = 0; f < maxCards; f ++)
- {
- if (mCards[f] == 0)
- {
- mCards[f] = card;
- return;
- }
- }
-}
-
-void Item::setOptions(const ItemOptionsList *const options)
-{
- delete2(mOptions);
- mOptions = ItemOptionsList::copy(options);
-}
-
-void Item::updateColor()
-{
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- setId(mId, ItemColorManager::getColorFromCards(&mCards[0]));
-}
diff --git a/src/resources/item/item.h b/src/resources/item/item.h
deleted file mode 100644
index f1712d26a..000000000
--- a/src/resources/item/item.h
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_ITEM_H
-#define RESOURCES_ITEM_ITEM_H
-
-#include "const/resources/item/cards.h"
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/damaged.h"
-#include "enums/simpletypes/equipm.h"
-#include "enums/simpletypes/equipped.h"
-#include "enums/simpletypes/favorite.h"
-#include "enums/simpletypes/identified.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "resources/db/itemdb.h"
-
-#include "localconsts.h"
-
-class Image;
-
-struct ItemOptionsList;
-
-/**
- * Represents one or more instances of a certain item type.
- */
-class Item notfinal
-{
- public:
- /**
- * Constructor.
- */
- Item(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped);
-
- A_DELETE_COPY(Item)
-
- /**
- * Destructor.
- */
- virtual ~Item();
-
- /**
- * Sets the item id, color the item type.
- */
- void setId(const int id, const ItemColor color);
-
- /**
- * Returns the item id.
- */
- int getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- /**
- * Returns the item image.
- */
- Image *getImage() const noexcept2 A_WARN_UNUSED
- { return mImage; }
-
- /**
- * Sets the number of items.
- */
- void setQuantity(const int quantity) noexcept2
- { mQuantity = quantity; }
-
- /**
- * Increases the number of items by the given amount.
- */
- void increaseQuantity(const int amount) noexcept2
- { mQuantity += amount; }
-
- /**
- * Returns the number of items.
- */
- int getQuantity() const noexcept2 A_WARN_UNUSED
- { return mQuantity; }
-
- /**
- * Sets whether this item is considered equipment.
- */
- void setEquipment(const Equipm equipment) noexcept2
- { mEquipment = equipment; }
-
- /**
- * Returns whether this item is considered equipment.
- */
- Equipm isEquipment() const noexcept2 A_WARN_UNUSED
- { return mEquipment; }
-
- /**
- * Sets whether this item is equipped.
- */
- void setEquipped(const Equipped equipped) noexcept2
- { mEquipped = equipped; }
-
- /**
- * Returns whether this item is equipped.
- */
- Equipped isEquipped() const noexcept2 A_WARN_UNUSED
- { return mEquipped; }
-
- /**
- * Sets this item refine level.
- */
- void setRefine(const uint8_t refine) noexcept2
- { mRefine = refine; }
-
- /**
- * Returns this item refine level.
- */
- uint8_t getRefine() const noexcept2 A_WARN_UNUSED
- { return mRefine; }
-
- /**
- * Sets whether this item is in equipment.
- */
- void setInEquipment(const bool inEquipment) noexcept2
- { mInEquipment = inEquipment; }
-
- /**
- * Returns whether this item is in equipment.
- */
- bool isInEquipment() const noexcept2 A_WARN_UNUSED
- { return mInEquipment; }
-
- /**
- * Sets the inventory index of this item.
- */
- void setInvIndex(const int index) noexcept2
- { mInvIndex = index; }
-
- /**
- * Returns the inventory index of this item.
- */
- int getInvIndex() const noexcept2 A_WARN_UNUSED
- { return mInvIndex; }
-
- /**
- * Returns information about this item type.
- */
- const ItemInfo &getInfo() const A_WARN_UNUSED
- { return ItemDB::get(mId); }
-
- std::string getName() const A_WARN_UNUSED;
-
- static Image *getImage(const int id,
- const ItemColor color) A_WARN_UNUSED;
-
- bool isHaveTag(const int tagId) const A_WARN_UNUSED;
-
- ItemColor getColor() const noexcept2 A_WARN_UNUSED
- { return mColor; }
-
- void setColor(const ItemColor color) noexcept2
- { mColor = color; }
-
- const std::string &getDescription() const noexcept2 A_WARN_UNUSED
- { return mDescription; }
-
- void setIdentified(const Identified b) noexcept2
- { mIdentified = b; }
-
- Identified getIdentified() const noexcept2 A_WARN_UNUSED
- { return mIdentified; }
-
- void setDamaged(const Damaged b) noexcept2
- { mDamaged = b; }
-
- Damaged getDamaged() const noexcept2 A_WARN_UNUSED
- { return mDamaged; }
-
- void setFavorite(const Favorite b) noexcept2
- { mFavorite = b; }
-
- Favorite getFavorite() const noexcept2 A_WARN_UNUSED
- { return mFavorite; }
-
- void setCard(const int index, const int id);
-
- int getCard(const int index) const;
-
- void setCards(const int *const cards, const int size);
-
- const int *getCards() const noexcept2 A_WARN_UNUSED
- { return mCards; }
-
- void setOptions(const ItemOptionsList *const options);
-
- const ItemOptionsList *getOptions() const noexcept2 A_WARN_UNUSED
- { return mOptions; }
-
- void setType(const ItemTypeT type) noexcept2
- { mType = type; }
-
- ItemTypeT getType() const noexcept2 A_WARN_UNUSED
- { return mType; }
-
- void setTag(const int tag) noexcept2
- { mTag = tag; }
-
- int getTag() const noexcept2 A_WARN_UNUSED
- { return mTag; }
-
- void addCard(const int card);
-
- void updateColor();
-
- static constexpr bool isItem(const int id) noexcept2 A_WARN_UNUSED
- {
- return id != 0 &&
- id != CARD0_FORGE &&
- id != CARD0_CREATE &&
- id != CARD0_PET;
- }
-
- int mId; /**< Item id. */
- ItemColor mColor;
- int mQuantity; /**< Number of items. */
- int mTag;
-
- protected:
- Image *mImage; /**< Item image. */
- std::string mDescription;
- std::map <int, int> mTags;
- int mCards[maxCards];
- const ItemOptionsList *mOptions;
- uint8_t mRefine; /**< Item refine level. */
- int mInvIndex; /**< Inventory index. */
- ItemTypeT mType; /**< Item type. */
- Equipm mEquipment; /**< Item is equipment. */
- Equipped mEquipped; /**< Item is equipped. */
- bool mInEquipment; /**< Item is in equipment */
- Identified mIdentified;
- Damaged mDamaged;
- Favorite mFavorite;
-};
-
-#endif // RESOURCES_ITEM_ITEM_H
diff --git a/src/resources/item/itemfieldtype.h b/src/resources/item/itemfieldtype.h
deleted file mode 100644
index e7a6424b9..000000000
--- a/src/resources/item/itemfieldtype.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_ITEMFIELDTYPE_H
-#define RESOURCES_ITEM_ITEMFIELDTYPE_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct ItemFieldType final
-{
- ItemFieldType(const std::string &name0,
- const std::string &description0,
- const bool sign0) :
- name(name0),
- description(description0),
- sign(sign0)
- { }
-
- A_DELETE_COPY(ItemFieldType)
-
- const std::string name;
- const std::string description;
- const bool sign;
-};
-
-#endif // RESOURCES_ITEM_ITEMFIELDTYPE_H
diff --git a/src/resources/item/itemoption.h b/src/resources/item/itemoption.h
deleted file mode 100644
index c4327622a..000000000
--- a/src/resources/item/itemoption.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_ITEMOPTION_H
-#define RESOURCES_ITEM_ITEMOPTION_H
-
-#include "localconsts.h"
-
-struct ItemOption final
-{
- ItemOption() :
- index(0U),
- value(0)
- { }
-
- A_DELETE_COPY(ItemOption)
-
- uint16_t index;
- int16_t value;
-};
-
-#endif // RESOURCES_ITEM_ITEMOPTION_H
diff --git a/src/resources/item/itemoptionslist.h b/src/resources/item/itemoptionslist.h
deleted file mode 100644
index f5b3365f5..000000000
--- a/src/resources/item/itemoptionslist.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_ITEMOPTIONSLIST_H
-#define RESOURCES_ITEM_ITEMOPTIONSLIST_H
-
-#include "const/resources/item/itemoptions.h"
-
-#include "resources/item/itemoption.h"
-
-#include "localconsts.h"
-
-struct ItemOptionsList final
-{
- explicit ItemOptionsList(const size_t amount0) :
- options(nullptr),
- amount(amount0),
- pointer(0U)
- {
- options = new ItemOption[amount];
- }
-
- ItemOptionsList() :
- options(nullptr),
- amount(maxItemOptions),
- pointer(0U)
- {
- options = new ItemOption[amount];
- }
-
- A_DELETE_COPY(ItemOptionsList)
-
- ~ItemOptionsList()
- {
- delete [] options;
- options = nullptr;
- }
-
- void add(const uint16_t index,
- const uint16_t value)
- {
- if (pointer >= amount)
- return;
- options[pointer].index = index;
- options[pointer].value = value;
- pointer ++;
- }
-
- static ItemOptionsList *copy(const ItemOptionsList *const options0)
- {
- if (options0 == nullptr)
- return nullptr;
-
- const size_t amount0 = options0->amount;
- ItemOptionsList *const obj = new ItemOptionsList(amount0);
- for (size_t f = 0; f < amount0; f ++)
- {
- obj->options[f].index = options0->options[f].index;
- obj->options[f].value = options0->options[f].value;
- }
- obj->amount = options0->amount;
- obj->pointer = options0->pointer;
- return obj;
- }
-
- size_t size() const
- {
- if (pointer < amount)
- return pointer;
- return amount;
- }
-
- const ItemOption &get(const size_t index) const
- {
- return options[index];
- }
-
- ItemOption *options;
- size_t amount;
- size_t pointer;
-};
-
-#endif // RESOURCES_ITEM_ITEMOPTIONSLIST_H
diff --git a/src/resources/item/shopitem.cpp b/src/resources/item/shopitem.cpp
deleted file mode 100644
index 76b269cca..000000000
--- a/src/resources/item/shopitem.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/item/shopitem.h"
-
-#include "resources/iteminfo.h"
-
-#include "utils/stringutils.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-#endif // TMWA_SUPPORT
-
-#include "resources/db/unitsdb.h"
-
-#include "debug.h"
-
-ShopItem::ShopItem(const int inventoryIndex,
- const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int quantity,
- const int price,
- const std::string &currency) :
- Item(id, type, 0, 0, color,
- Identified_true,
- Damaged_false,
- Favorite_false,
- Equipm_false,
- Equipped_false),
- mDisplayName(),
- mCurrency(currency),
- mDuplicates(),
- mPrice(price),
- mUsedQuantity(0),
- mShowQuantity(true),
- mVisible(true),
- mDisabled(false)
-{
- updateDisplayName(quantity);
- setInvIndex(inventoryIndex);
- addDuplicate(inventoryIndex, quantity);
-}
-
-ShopItem::ShopItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int price,
- const std::string &currency) :
- Item(id, type, 0, 0, color,
- Identified_true,
- Damaged_false,
- Favorite_false,
- Equipm_false,
- Equipped_false),
- mDisplayName(),
- mCurrency(currency),
- mDuplicates(),
- mPrice(price),
- mUsedQuantity(0),
- mShowQuantity(false),
- mVisible(true),
- mDisabled(false)
-{
- updateDisplayName(0);
- setInvIndex(-1);
- addDuplicate(-1, 0);
-}
-
-ShopItem::~ShopItem()
-{
- /** Clear all remaining duplicates on Object destruction. */
- while (!mDuplicates.empty())
- {
- delete mDuplicates.top();
- mDuplicates.pop();
- }
-}
-
-void ShopItem::updateDisplayName(const int quantity)
-{
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- mDisplayName = std::string(getInfo().getName());
- else
-#endif // TMWA_SUPPORT
- mDisplayName = std::string(getInfo().getName(mColor));
- if (mPrice != 0)
- {
- mDisplayName.append(" (").append(
- UnitsDb::formatCurrency(mCurrency, mPrice)).append(") ");
- }
- if (mShowQuantity && quantity > 1)
- mDisplayName.append("[").append(toString(quantity)).append("]");
- if (mUsedQuantity > 0)
- mDisplayName.append(" +").append(toString(mUsedQuantity));
-}
-
-void ShopItem::update()
-{
- updateDisplayName(mQuantity);
-}
-
-void ShopItem::addDuplicate(const int inventoryIndex, const int quantity)
-{
- DuplicateItem *const di = new DuplicateItem;
- di->inventoryIndex = inventoryIndex;
- di->quantity = quantity;
- mDuplicates.push(di);
- mQuantity += quantity;
-}
-
-void ShopItem::addDuplicate()
-{
- DuplicateItem *const di = new DuplicateItem;
- di->inventoryIndex = -1;
- di->quantity = 0;
- mDuplicates.push(di);
-}
-
-int ShopItem::sellCurrentDuplicate(const int quantity)
-{
- DuplicateItem* dupl = mDuplicates.top();
- if (dupl == nullptr)
- return 0;
-
- const int sellCount = quantity <= dupl->quantity
- ? quantity : dupl->quantity;
- dupl->quantity -= sellCount;
- mQuantity -= sellCount;
- if (dupl->quantity == 0)
- {
- delete dupl;
- mDuplicates.pop();
- }
- return sellCount;
-}
-
-void ShopItem::increaseUsedQuantity(const int amount)
-{
- if (mShowQuantity && (mQuantity != 0))
- {
- if (mQuantity < mUsedQuantity + amount ||
- mUsedQuantity + amount < 0)
- {
- return;
- }
- }
- else if (mUsedQuantity + amount < 0)
- {
- return;
- }
-
- mUsedQuantity += amount;
-}
diff --git a/src/resources/item/shopitem.h b/src/resources/item/shopitem.h
deleted file mode 100644
index 7596d0269..000000000
--- a/src/resources/item/shopitem.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_SHOPITEM_H
-#define RESOURCES_ITEM_SHOPITEM_H
-
-#include "resources/item/item.h"
-
-#include <stack>
-
-#include "localconsts.h"
-
-/**
- * Represents an item in a shop inventory. It can store quantity and inventory
- * indices of duplicate entries in the shop as well.
- */
-class ShopItem final : public Item
-{
- public:
- /**
- * Constructor. Creates a new ShopItem.
- *
- * @param inventoryIndex the inventory index of the item
- * @param id the id of the item
- * @param quantity number of available copies of the item
- * @param price price of the item
- */
- ShopItem(const int inventoryIndex,
- const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int quantity,
- const int price,
- const std::string &currency);
-
- /**
- * Constructor. Creates a new ShopItem. Inventory index will be set to
- * -1 and quantity to 0.
- *
- * @param id the id of the item
- * @param price price of the item
- */
- ShopItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int price,
- const std::string &currency);
-
- A_DELETE_COPY(ShopItem)
-
- /**
- * Destructor.
- */
- ~ShopItem();
-
- /**
- * Add a duplicate. Id and price will be taken from this item.
- *
- * @param inventoryIndex the inventory index of the item
- * @param quantity number of available copies of the item
- */
- void addDuplicate(const int inventoryIndex, const int quantity);
-
- /**
- * Add a duplicate. Id and price will be taken from this item.
- * Needed for compatibility with ShopDuplicateItems (see) class
- * documentation).
- */
- void addDuplicate();
-
- void update();
-
- /**
- * Gets the quantity of the currently topmost duplicate.
- *
- * @return the quantity of the currently topmost duplicate
- */
- int getCurrentQuantity() const A_WARN_UNUSED
- {
- return mDuplicates.empty() ? 0 : mDuplicates.top()->quantity;
- }
-
- /**
- * Gets the inventory index of the currently topmost duplicate.
- *
- * @return the inventory index of the currently topmost duplicate
- */
- int getCurrentInvIndex() const A_WARN_UNUSED
- {
- return mDuplicates.empty() ? mInvIndex :
- mDuplicates.top()->inventoryIndex;
- }
-
- /**
- * Reduces the quantity of the topmost duplicate by the specified
- * amount. Also reduces the total quantity of this DuplicateItem.
- * Empty duplicates are automatically removed.
- *
- * If the amount is bigger than the quantity of the current topmost,
- * only sell as much as possible. Returns the amount actually sold (do
- * not ignore the return value!)
- *
- * @return the amount, that actually was sold.
- */
- int sellCurrentDuplicate(const int quantity);
-
- /**
- * Gets the price of the item.
- *
- * @return the price of the item
- */
- int getPrice() const noexcept2 A_WARN_UNUSED
- { return mPrice; }
-
- /**
- * Gets the display name for the item in the shop list.
- *
- * @return the display name for the item in the shop list
- */
- const std::string &getDisplayName() const noexcept2 A_WARN_UNUSED
- { return mDisplayName; }
-
- void setVisible(const bool b) noexcept2
- { mVisible = b; }
-
- bool isVisible() const noexcept2 A_WARN_UNUSED
- { return mVisible; }
-
- void increaseUsedQuantity(const int amount);
-
- int getUsedQuantity() const noexcept2 A_WARN_UNUSED
- { return mUsedQuantity; }
-
- void setDisabled(const bool b) noexcept2
- { mDisabled = b; }
-
- bool getDisabled() const noexcept2 A_WARN_UNUSED
- { return mDisabled; }
-
- protected:
- void updateDisplayName(const int quantity);
-
- std::string mDisplayName;
- std::string mCurrency;
-
- /**
- * Struct to keep track of duplicates.
- */
- typedef struct
- {
- int inventoryIndex;
- int quantity;
- } DuplicateItem;
- std::stack<DuplicateItem*> mDuplicates; /** <-- Stores duplicates */
- int mPrice;
- int mUsedQuantity;
- bool mShowQuantity;
- bool mVisible;
- bool mDisabled;
-};
-
-#endif // RESOURCES_ITEM_SHOPITEM_H