mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
lib/mapObjects/IMarket.cpp: Show error message about failed dynamic_cast() even if cast object is nullptr
This commit is contained in:
@@ -157,8 +157,14 @@ std::vector<int> IMarket::availableItemsIds(EMarketMode mode) const
|
||||
const IMarket * IMarket::castFrom(const CGObjectInstance *obj, bool verbose)
|
||||
{
|
||||
auto * imarket = dynamic_cast<const IMarket *>(obj);
|
||||
if(verbose && !imarket && obj)
|
||||
logGlobal->error("Cannot cast to IMarket object type %s", obj->typeName);
|
||||
if(verbose && !imarket)
|
||||
{
|
||||
logGlobal->error("Cannot cast to IMarket");
|
||||
if(obj)
|
||||
{
|
||||
logGlobal->error("Object type %s", obj->typeName);
|
||||
}
|
||||
}
|
||||
return imarket;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user