From 703ab677ba0b3628d4ecf68e615ab4be29291e0a Mon Sep 17 00:00:00 2001 From: Alexander Wilms Date: Fri, 27 Oct 2023 22:47:56 +0000 Subject: [PATCH] lib/mapObjects/IMarket.cpp: Show error message about failed dynamic_cast() even if cast object is nullptr --- lib/mapObjects/IMarket.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/mapObjects/IMarket.cpp b/lib/mapObjects/IMarket.cpp index f4dd54a12..d37662028 100644 --- a/lib/mapObjects/IMarket.cpp +++ b/lib/mapObjects/IMarket.cpp @@ -157,8 +157,14 @@ std::vector IMarket::availableItemsIds(EMarketMode mode) const const IMarket * IMarket::castFrom(const CGObjectInstance *obj, bool verbose) { auto * imarket = dynamic_cast(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; }