From 7c0be7520ac70ceed378856aa95a062935d80442 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 1 Jun 2013 07:54:04 +0000 Subject: cItem constructor changed to create single-piece items when not given count http://forum.mc-server.org/showthread.php?tid=1150 git-svn-id: http://mc-server.googlecode.com/svn/trunk@1536 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Item.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'source/Item.h') diff --git a/source/Item.h b/source/Item.h index 9e37ce3bc..45b124e67 100644 --- a/source/Item.h +++ b/source/Item.h @@ -16,14 +16,29 @@ namespace Json class cItem { public: - cItem(short a_ItemType = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemDamage = 0) - : m_ItemType (a_ItemType) - , m_ItemCount (a_ItemCount) - , m_ItemDamage(a_ItemDamage) + /// Creates an empty item + cItem(void) : + m_ItemType(E_ITEM_EMPTY), + m_ItemCount(0), + m_ItemDamage(0) + { + } + + + /// Creates an item of the specified type, by default 1 piece with no damage + cItem( + short a_ItemType, + char a_ItemCount = 1, + short a_ItemDamage = 0 + ) : + m_ItemType (a_ItemType), + m_ItemCount (a_ItemCount), + m_ItemDamage(a_ItemDamage) { if (!IsValidItem(m_ItemType)) { - m_ItemType = E_ITEM_EMPTY; + LOGWARNING("%s: creating an invalid item type (%d), resetting to empty.", __FUNCTION__, a_ItemType); + Empty(); } } -- cgit v1.2.3