summaryrefslogtreecommitdiff
path: root/src/being/playerinfo.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-09 00:26:41 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-09 00:26:41 +0300
commit9c46394f54db8c1b9e357ad555f3db96251a616d (patch)
treeb1ab9e8ebec6d9b4d91a9b705b6cc0c3682a5fac /src/being/playerinfo.cpp
parente0d14cf8d3c809a0a5291823d3a962a4835a8f6e (diff)
downloadmv-9c46394f54db8c1b9e357ad555f3db96251a616d.tar.gz
mv-9c46394f54db8c1b9e357ad555f3db96251a616d.tar.bz2
mv-9c46394f54db8c1b9e357ad555f3db96251a616d.tar.xz
mv-9c46394f54db8c1b9e357ad555f3db96251a616d.zip
Add some missing checks to being found by paranucker.
Diffstat (limited to 'src/being/playerinfo.cpp')
-rw-r--r--src/being/playerinfo.cpp48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 8c7b55639..b3c3f5bb4 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -209,7 +209,9 @@ Inventory *getInventory()
Inventory *getStorageInventory()
{
- return inventoryHandler->getStorage();
+ if (inventoryHandler)
+ return inventoryHandler->getStorage();
+ return nullptr;
}
#ifdef EATHENA_SUPPORT
@@ -250,21 +252,24 @@ void equipItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- inventoryHandler->equipItem(item);
+ if (inventoryHandler)
+ inventoryHandler->equipItem(item);
}
void unequipItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- inventoryHandler->unequipItem(item);
+ if (inventoryHandler)
+ inventoryHandler->unequipItem(item);
}
void useItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
- inventoryHandler->useItem(item);
+ if (inventoryHandler)
+ inventoryHandler->useItem(item);
}
void useEquipItem(const Item *const item, const Sfx sfx)
@@ -276,7 +281,8 @@ void useEquipItem(const Item *const item, const Sfx sfx)
{
if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
- inventoryHandler->useCard(item);
+ if (inventoryHandler)
+ inventoryHandler->useCard(item);
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USECARD);
}
@@ -289,20 +295,23 @@ void useEquipItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- inventoryHandler->unequipItem(item);
+ if (inventoryHandler)
+ inventoryHandler->unequipItem(item);
}
else
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- inventoryHandler->equipItem(item);
+ if (inventoryHandler)
+ inventoryHandler->equipItem(item);
}
}
else
{
if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
- inventoryHandler->useItem(item);
+ if (inventoryHandler)
+ inventoryHandler->useItem(item);
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
}
@@ -320,13 +329,15 @@ void useEquipItem2(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- inventoryHandler->unequipItem(item);
+ if (inventoryHandler)
+ inventoryHandler->unequipItem(item);
}
else
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- inventoryHandler->equipItem(item);
+ if (inventoryHandler)
+ inventoryHandler->equipItem(item);
}
}
else
@@ -335,7 +346,8 @@ void useEquipItem2(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
- inventoryHandler->useItem(item);
+ if (inventoryHandler)
+ inventoryHandler->useItem(item);
}
}
}
@@ -347,7 +359,8 @@ void dropItem(const Item *const item, const int amount, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::DROP);
- inventoryHandler->dropItem(item, amount);
+ if (inventoryHandler)
+ inventoryHandler->dropItem(item, amount);
}
}
@@ -355,7 +368,8 @@ void pickUpItem(const FloorItem *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::PICKUP);
- playerHandler->pickUp(item);
+ if (playerHandler)
+ playerHandler->pickUp(item);
}
// --- Misc -------------------------------------------------------------------
@@ -582,18 +596,18 @@ BeingId getMercenaryId()
void updateMoveAI()
{
- if (mMercenary)
+ if (mMercenary && mercenaryHandler)
mercenaryHandler->moveToMaster();
- if (mHomunculus)
+ if (mHomunculus && homunculusHandler)
homunculusHandler->moveToMaster();
}
void updateAttackAi(const BeingId targetId,
const Keep keep)
{
- if (mMercenary)
+ if (mMercenary && mercenaryHandler)
mercenaryHandler->attack(targetId, keep);
- if (mHomunculus)
+ if (mHomunculus && homunculusHandler)
homunculusHandler->attack(targetId, keep);
}