From c81d80b6cd18977f60f8ba19f898a583c055d117 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 23 Aug 2016 22:06:54 +0300 Subject: Add check for cards for existing item id. --- src/being/being.cpp | 6 ++++++ src/resources/item/item.cpp | 8 ++++++++ src/resources/item/item.h | 2 ++ 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/being/being.cpp b/src/being/being.cpp index 93222c846..bf082dd79 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -94,6 +94,8 @@ #include "resources/image/image.h" +#include "resources/item/item.h" + #include "resources/map/map.h" #include "resources/skill/skilldata.h" @@ -5101,6 +5103,8 @@ void Being::addItemParticlesCards(const int id, for (int f = 0; f < maxCards; f ++) { const int cardId = cards.cards[f]; + if (!Item::isItem(cardId)) + continue; const ItemInfo &info = ItemDB::get(cardId); const SpriteDisplay &restrict display2 = info.getDisplay(); FOR_EACH (StringVectCIter, itr, display2.particles) @@ -5121,6 +5125,8 @@ void Being::addItemParticlesCards(const int id, for (int f = 0; f < maxCards; f ++) { const int cardId = cards.cards[f]; + if (!Item::isItem(cardId)) + continue; const ItemInfo &info = ItemDB::get(cardId); const SpriteDisplay &restrict display2 = info.getDisplay(); FOR_EACH (StringVectCIter, itr, display2.particles) diff --git a/src/resources/item/item.cpp b/src/resources/item/item.cpp index 9d3a1b3f8..4627225f2 100644 --- a/src/resources/item/item.cpp +++ b/src/resources/item/item.cpp @@ -181,3 +181,11 @@ void Item::updateColor() if (serverFeatures && serverFeatures->haveItemColors()) setId(mId, ItemColorManager::getColorFromCards(&mCards[0])); } + +bool Item::isItem(const int id) +{ + return id != 0 && + id != CARD0_FORGE && + id != CARD0_CREATE && + id != CARD0_PET; +} diff --git a/src/resources/item/item.h b/src/resources/item/item.h index 5ae0cbc99..64e5fa063 100644 --- a/src/resources/item/item.h +++ b/src/resources/item/item.h @@ -227,6 +227,8 @@ class Item notfinal void updateColor(); + static bool isItem(const int id); + int mId; /**< Item id. */ ItemColor mColor; int mQuantity; /**< Number of items. */ -- cgit v1.2.3-70-g09d2