summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-23 22:02:17 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-23 22:02:17 +0200
commit768f3d93019b262ce6aa9f913aed0f45d5e4c929 (patch)
tree0eee9d83a498b1f18def288848f54551881b778d
parentcc2cd67e1c3c3f95485ae4477b6a2f0d255e9163 (diff)
parentfbbd4c406bf95ef8591f7368baacfad6f4d3f30f (diff)
downloadmana-768f3d93019b262ce6aa9f913aed0f45d5e4c929.tar.gz
mana-768f3d93019b262ce6aa9f913aed0f45d5e4c929.tar.bz2
mana-768f3d93019b262ce6aa9f913aed0f45d5e4c929.tar.xz
mana-768f3d93019b262ce6aa9f913aed0f45d5e4c929.zip
Merge branch '0.0.29'
Conflicts: src/gui/widgets/chattab.cpp
-rw-r--r--src/gui/inventorywindow.cpp5
-rw-r--r--src/gui/widgets/chattab.cpp22
-rw-r--r--src/resources/itemdb.cpp26
-rw-r--r--src/resources/iteminfo.h7
4 files changed, 28 insertions, 32 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index c44ae9e7..06e43eac 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -245,11 +245,12 @@ void InventoryWindow::keyReleased(gcn::KeyEvent &event)
void InventoryWindow::valueChanged(const gcn::SelectionEvent &event)
{
- if (mSplit)
+ if (mSplit && Net::getInventoryHandler()->canSplit(mItems->getSelectedItem()))
{
Item *item = mItems->getSelectedItem();
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item,
+ if (item)
+ ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item,
(item->getQuantity() - 1));
}
}
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 85353bf7..ad0911c9 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -215,7 +215,7 @@ void ChatTab::chatInput(std::string &msg)
while (start != std::string::npos && msg[start+1] != '@')
{
std::string::size_type end = msg.find(']', start);
- if (start+1 != end && end != std::string::npos)
+ if (start + 1 != end && end != std::string::npos)
{
// Catch multiple embeds and ignore them
// so it doesn't crash the client.
@@ -227,22 +227,16 @@ void ChatTab::chatInput(std::string &msg)
std::string temp = msg.substr(start + 1, end - start - 1);
- // Do not parse an empty string (it crashes the client)
- if (!temp.empty())
+ const ItemInfo itemInfo = ItemDB::get(temp);
+ if (itemInfo.getId() != 0)
{
- toLower(trim(temp));
-
- const ItemInfo itemInfo = ItemDB::get(temp);
- if (itemInfo.getName() != _("Unknown item"))
- {
- msg.insert(end, "@@");
- msg.insert(start+1, "|");
- msg.insert(start+1, toString(itemInfo.getId()));
- msg.insert(start+1, "@@");
- }
+ msg.insert(end, "@@");
+ msg.insert(start + 1, "|");
+ msg.insert(start + 1, toString(itemInfo.getId()));
+ msg.insert(start + 1, "@@");
}
}
- start = msg.find('[', start + 1);
+ start = msg.find('[', start + 1);
}
// Prepare ordinary message
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 899dd977..62bf0700 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -247,7 +247,7 @@ void ItemDB::unload()
mLoaded = false;
}
-const ItemInfo& ItemDB::get(int id)
+const ItemInfo &ItemDB::get(int id)
{
assert(mLoaded);
@@ -255,30 +255,30 @@ const ItemInfo& ItemDB::get(int id)
if (i == mItemInfos.end())
{
- logger->log("ItemDB: Error, unknown item ID# %d", id);
+ logger->log("ItemDB: Warning, unknown item ID# %d", id);
return *mUnknown;
}
- else
- {
- return *(i->second);
- }
+
+ return *(i->second);
}
-const ItemInfo& ItemDB::get(const std::string &name)
+const ItemInfo &ItemDB::get(const std::string &name)
{
- assert(mLoaded && !name.empty());
+ assert(mLoaded);
NamedItemInfos::const_iterator i = mNamedItemInfos.find(name);
if (i == mNamedItemInfos.end())
{
- logger->log("ItemDB: Error, unknown item name %s", name.c_str());
+ if (!name.empty())
+ {
+ logger->log("ItemDB: Warning, unknown item name \"%s\"",
+ name.c_str());
+ }
return *mUnknown;
}
- else
- {
- return *(i->second);
- }
+
+ return *(i->second);
}
void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node)
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 3329d95b..0c87b585 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -118,6 +118,7 @@ class ItemInfo
mType(ITEM_UNUSABLE),
mWeight(0),
mView(0),
+ mId(0),
mAttackType(ACTION_DEFAULT)
{
}
@@ -162,10 +163,10 @@ class ItemInfo
ItemType getType() const
{ return mType; }
- void setWeight(short weight)
+ void setWeight(int weight)
{ mWeight = weight; }
- short getWeight() const
+ int getWeight() const
{ return mWeight; }
void setView(int view)
@@ -198,7 +199,7 @@ class ItemInfo
std::string mEffect; /**< Description of effects. */
ItemType mType; /**< Item type. */
std::string mParticle; /**< Particle effect used with this item */
- short mWeight; /**< Weight in grams. */
+ int mWeight; /**< Weight in grams. */
int mView; /**< Item ID of how this item looks. */
int mId; /**< Item ID */