From 1407a08f0087905edae30ac3793e83757ff56d4c Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Sat, 23 May 2009 05:53:31 -0400 Subject: Fixes a segmentfault and disables shift split for eA --- src/gui/inventorywindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index d6cd3a84..47f66e76 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -233,11 +233,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)); } } -- cgit v1.2.3-70-g09d2 From 4deff8569279d5cf23a73fdc1c986592ca4f7ed2 Mon Sep 17 00:00:00 2001 From: Kess Vargavind Date: Thu, 21 May 2009 00:00:24 +0200 Subject: Fix a segmentation fault The client crashed when entering [] inside an item link, for example the string [[]]. (cherry picked from commit 86a055d46df5a262fce0f76697cc3d54e75b19e1) --- src/gui/widgets/chattab.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 711680d1..85353bf7 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -227,15 +227,19 @@ void ChatTab::chatInput(std::string &msg) std::string temp = msg.substr(start + 1, end - start - 1); - toLower(trim(temp)); - - const ItemInfo itemInfo = ItemDB::get(temp); - if (itemInfo.getName() != _("Unknown item")) + // Do not parse an empty string (it crashes the client) + if (!temp.empty()) { - msg.insert(end, "@@"); - msg.insert(start+1, "|"); - msg.insert(start+1, toString(itemInfo.getId())); - msg.insert(start+1, "@@"); + 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, "@@"); + } } } start = msg.find('[', start + 1); -- cgit v1.2.3-70-g09d2 From 2a9f8e05312c210ec204e09861f47c3d017706eb Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 23 May 2009 13:11:40 +0200 Subject: Fixed the empty item link crash differently The crash was due to an assertion which shouldn't have been there, so I removed the assertion instead. I've also made sure the unknown item has its id initialized to 0, so that it can be used to check against instead of the item name. Normalization of item names was moved within the item database. --- src/gui/widgets/chattab.cpp | 22 ++++++++-------------- src/resources/itemdb.cpp | 26 +++++++++++++------------- src/resources/iteminfo.h | 7 ++++--- 3 files changed, 25 insertions(+), 30 deletions(-) (limited to 'src') 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 99907ca7..5dda2bfd 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -243,7 +243,7 @@ void ItemDB::unload() mLoaded = false; } -const ItemInfo& ItemDB::get(int id) +const ItemInfo &ItemDB::get(int id) { assert(mLoaded); @@ -251,30 +251,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 */ -- cgit v1.2.3-70-g09d2 From 0507f575f2d9abe953e53822a52e66677cd8775c Mon Sep 17 00:00:00 2001 From: Fate Date: Tue, 19 May 2009 14:00:01 +0000 Subject: Default port consistently uses 6901 on eAthena. branding.xml also defaults to 6901 now since most players play on eAthena, so the -P client parameter finally works out of the box again. (cherry picked from commit 3dd404ee8a02958089bf2c6901fb877d2fae760e) --- data/branding.xml | 2 +- src/main.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/data/branding.xml b/data/branding.xml index 29974ab4..fd5779f6 100644 --- a/data/branding.xml +++ b/data/branding.xml @@ -15,7 +15,7 @@ writing a branding.xml for their forks.