summaryrefslogtreecommitdiff
path: root/src/shopitem.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-03 21:58:08 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-04 03:06:57 +0300
commit866a71ffd576fd10c4e309195016d86f0c8ed635 (patch)
tree21bbec175afc181cada529598267d62f12fcb671 /src/shopitem.cpp
parentebecb0cf42f2066943908fa158ac91527e0e6629 (diff)
downloadplus-866a71ffd576fd10c4e309195016d86f0c8ed635.tar.gz
plus-866a71ffd576fd10c4e309195016d86f0c8ed635.tar.bz2
plus-866a71ffd576fd10c4e309195016d86f0c8ed635.tar.xz
plus-866a71ffd576fd10c4e309195016d86f0c8ed635.zip
Add const to more classes.
Diffstat (limited to 'src/shopitem.cpp')
-rw-r--r--src/shopitem.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index a9068bacb..8d91c6ca0 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -29,8 +29,9 @@
#include "debug.h"
-ShopItem::ShopItem(int inventoryIndex, int id, unsigned char color,
- int quantity, int price) :
+ShopItem::ShopItem(const int inventoryIndex, const int id,
+ const unsigned char color,
+ const int quantity, const int price) :
Item(id, 0, 0, color),
mPrice(price),
mShowQuantity(true)
@@ -52,7 +53,7 @@ ShopItem::ShopItem(int inventoryIndex, int id, unsigned char color,
addDuplicate(inventoryIndex, quantity);
}
-ShopItem::ShopItem (int id, unsigned char color, int price) :
+ShopItem::ShopItem (const int id, const unsigned char color, const int price) :
Item (id, 0, 0, color),
mPrice(price),
mShowQuantity(false)
@@ -100,9 +101,9 @@ void ShopItem::update()
}
}
-void ShopItem::addDuplicate(int inventoryIndex, int quantity)
+void ShopItem::addDuplicate(const int inventoryIndex, const int quantity)
{
- DuplicateItem* di = new DuplicateItem;
+ DuplicateItem *const di = new DuplicateItem;
di->inventoryIndex = inventoryIndex;
di->quantity = quantity;
mDuplicates.push(di);
@@ -111,19 +112,20 @@ void ShopItem::addDuplicate(int inventoryIndex, int quantity)
void ShopItem::addDuplicate()
{
- DuplicateItem* di = new DuplicateItem;
+ DuplicateItem *const di = new DuplicateItem;
di->inventoryIndex = -1;
di->quantity = 0;
mDuplicates.push(di);
}
-int ShopItem::sellCurrentDuplicate(int quantity)
+int ShopItem::sellCurrentDuplicate(const int quantity)
{
DuplicateItem* dupl = mDuplicates.top();
if (!dupl)
return 0;
- int sellCount = quantity <= dupl->quantity ? quantity : dupl->quantity;
+ const int sellCount = quantity <= dupl->quantity
+ ? quantity : dupl->quantity;
dupl->quantity -= sellCount;
mQuantity -= sellCount;
if (dupl->quantity == 0)