Core/Cleanup: remove C-style cast to (Bag*):

* add ToBag() methods for Item class;
* add GetBagByPos() method for Player class.
This commit is contained in:
Azazel
2011-03-18 15:58:08 +06:00
parent 90a3fee232
commit e49b5b44d6
9 changed files with 156 additions and 183 deletions
+4
View File
@@ -253,8 +253,12 @@ class Item : public Object
void SaveRefundDataToDB();
void DeleteRefundDataFromDB();
Bag* ToBag() { if (IsBag()) return reinterpret_cast<Bag*>(this); else return NULL; }
const Bag* ToBag() const { if (IsBag()) return reinterpret_cast<const Bag*>(this); else return NULL; }
bool IsLocked() const { return !HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_UNLOCKED); }
bool IsBag() const { return GetProto()->InventoryType == INVTYPE_BAG; }
bool IsNotEmptyBag() const;
bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; }
bool CanBeTraded(bool mail = false, bool trade = false) const;
void SetInTrade(bool b = true) { mb_in_trade = b; }