summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-18 19:02:45 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-18 19:02:45 +0300
commitf1812857720449697c9106a7a3776b7202258cb3 (patch)
treeeb100f3d713c3faeebd057c6c3d572e17295d345 /src
parent33b6e130de855dd3a81e739168a668d898f78e9e (diff)
downloadplus-f1812857720449697c9106a7a3776b7202258cb3.tar.gz
plus-f1812857720449697c9106a7a3776b7202258cb3.tar.bz2
plus-f1812857720449697c9106a7a3776b7202258cb3.tar.xz
plus-f1812857720449697c9106a7a3776b7202258cb3.zip
Fix code style in beingequipbackend and add some consts to it.
Diffstat (limited to 'src')
-rw-r--r--src/being/playerinfo.cpp2
-rw-r--r--src/being/playerinfo.h2
-rw-r--r--src/beingequipbackend.cpp10
-rw-r--r--src/beingequipbackend.h8
-rw-r--r--src/equipment.h6
-rw-r--r--src/gui/popups/popupmenu.cpp4
-rw-r--r--src/gui/popups/popupmenu.h6
-rw-r--r--src/gui/windows/equipmentwindow.cpp4
-rw-r--r--src/gui/windows/equipmentwindow.h2
9 files changed, 25 insertions, 19 deletions
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index a374d8b5b..0f9eb6b6c 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -234,7 +234,7 @@ Equipment *getEquipment()
return mEquipment;
}
-Item *getEquipment(const unsigned int slot)
+const Item *getEquipment(const unsigned int slot)
{
if (mEquipment)
return mEquipment->getEquipment(slot);
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
index c45ba8a06..fbd8d4109 100644
--- a/src/being/playerinfo.h
+++ b/src/being/playerinfo.h
@@ -183,7 +183,7 @@ namespace PlayerInfo
/**
* Returns the player's equipment at the given slot.
*/
- Item *getEquipment(const unsigned int slot) A_WARN_UNUSED;
+ const Item *getEquipment(const unsigned int slot) A_WARN_UNUSED;
// --- Misc -------------------------------------------------------------------
diff --git a/src/beingequipbackend.cpp b/src/beingequipbackend.cpp
index 051afcfe2..e732e72c4 100644
--- a/src/beingequipbackend.cpp
+++ b/src/beingequipbackend.cpp
@@ -44,7 +44,10 @@ BeingEquipBackend::BeingEquipBackend(Being *const being)
const int id = being->mSpriteIDs[f];
if (id > 0 && idx >= 0 && idx < EQUIPMENT_SIZE)
{
- mEquipment[idx] = new Item(id, 0, 1, 0,
+ mEquipment[idx] = new Item(id,
+ 0,
+ 1,
+ 0,
being->mSpriteColorsIds[f],
Identified_true,
Damaged_false,
@@ -68,12 +71,13 @@ void BeingEquipBackend::clear()
delete2(mEquipment[i])
}
-void BeingEquipBackend::setEquipment(const int index, Item *const item)
+void BeingEquipBackend::setEquipment(const int index,
+ const Item *const item)
{
mEquipment[index] = item;
}
-Item *BeingEquipBackend::getEquipment(const int index) const
+const Item *BeingEquipBackend::getEquipment(const int index) const
{
if (index < 0 || index >= EQUIPMENT_SIZE)
return nullptr;
diff --git a/src/beingequipbackend.h b/src/beingequipbackend.h
index a1d2119ae..b4941d018 100644
--- a/src/beingequipbackend.h
+++ b/src/beingequipbackend.h
@@ -36,14 +36,16 @@ class BeingEquipBackend final : public Equipment::Backend
~BeingEquipBackend();
- Item *getEquipment(const int index) const override final A_WARN_UNUSED;
+ const Item *getEquipment(const int index) const override final
+ A_WARN_UNUSED;
void clear() override final;
- void setEquipment(const int index, Item *const item);
+ void setEquipment(const int index,
+ const Item *const item);
private:
- Item *mEquipment[EQUIPMENT_SIZE];
+ const Item *mEquipment[EQUIPMENT_SIZE];
};
#endif // BEINGEQUIPBACKEND_H
diff --git a/src/equipment.h b/src/equipment.h
index 2de7ba33a..149b1b340 100644
--- a/src/equipment.h
+++ b/src/equipment.h
@@ -50,8 +50,8 @@ class Equipment final
class Backend notfinal
{
public:
- virtual Item *getEquipment(const int index)
- const A_WARN_UNUSED = 0;
+ virtual const Item *getEquipment(const int index)
+ const A_WARN_UNUSED = 0;
virtual void clear() = 0;
@@ -62,7 +62,7 @@ class Equipment final
/**
* Get equipment at the given slot.
*/
- Item *getEquipment(const int index) const A_WARN_UNUSED
+ const Item *getEquipment(const int index) const A_WARN_UNUSED
{ return mBackend ? mBackend->getEquipment(index) : nullptr; }
/**
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index f55d8cb22..5f0676741 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1624,7 +1624,7 @@ void PopupMenu::handleLink(const std::string &link,
void PopupMenu::showPopup(Window *const parent,
const int x, const int y,
- Item *const item,
+ const Item *const item,
const InventoryTypeT type)
{
if (!item)
@@ -2120,7 +2120,7 @@ void PopupMenu::showPickupItemPopup(const int x, const int y,
void PopupMenu::showUndressPopup(const int x, const int y,
const Being *const being,
- Item *const item)
+ const Item *const item)
{
if (!being || !item)
return;
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index d37a29f56..0a83c5dd7 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -95,7 +95,7 @@ class PopupMenu final : public Popup, public LinkHandler
*/
void showPopup(Window *const parent,
const int x, const int y,
- Item *const item,
+ const Item *const item,
const InventoryTypeT type);
void showPopup(const int x, const int y, Button *const button);
@@ -125,7 +125,7 @@ class PopupMenu final : public Popup, public LinkHandler
void showUndressPopup(const int x, const int y,
const Being *const being,
- Item *const item);
+ const Item *const item);
void showMapPopup(const int x, const int y,
const int x2, const int y2,
@@ -209,7 +209,7 @@ class PopupMenu final : public Popup, public LinkHandler
BeingId mBeingId;
BeingId mFloorItemId;
- Item *mItem;
+ const Item *mItem;
int mItemId;
ItemColor mItemColor;
MapItem *mMapItem;
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 54b3f2f7c..c8a8da5ab 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -397,7 +397,7 @@ void EquipmentWindow::updatePage()
mRedraw = true;
}
-Item *EquipmentWindow::getItem(const int x, const int y) const
+const Item *EquipmentWindow::getItem(const int x, const int y) const
{
if (!mEquipment)
return nullptr;
@@ -469,7 +469,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
}
else if (event.getButton() == MouseButton::RIGHT)
{
- if (Item *const item = getItem(x, y))
+ if (const Item *const item = getItem(x, y))
{
if (itemPopup)
itemPopup->setVisible(Visible_false);
diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h
index 2e901fd0e..5836b0986 100644
--- a/src/gui/windows/equipmentwindow.h
+++ b/src/gui/windows/equipmentwindow.h
@@ -98,7 +98,7 @@ class EquipmentWindow final : public Window,
static void prepareSlotNames();
private:
- Item *getItem(const int x, const int y) const A_WARN_UNUSED;
+ const Item *getItem(const int x, const int y) const A_WARN_UNUSED;
void setSelected(const int index);