From c4dec67acc3113430f462d7b41664a549036b919 Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sun, 19 Jun 2022 10:33:24 +0300 Subject: [PATCH] Fix movement freeze after battle in teleport --- client/CPlayerInterface.cpp | 3 ++- lib/serializer/CTypeList.cpp | 15 +++++++++++++++ lib/serializer/CTypeList.h | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 4dedf1296..d826f88f6 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -2771,7 +2771,8 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path) destinationTeleport = destTeleportObj->id; destinationTeleportPos = nextCoord; doMovement(h->pos, false); - if (path.nodes[i-1].action == CGPathNode::TELEPORT_BLOCKING_VISIT) + if (path.nodes[i-1].action == CGPathNode::TELEPORT_BLOCKING_VISIT + || path.nodes[i-1].action == CGPathNode::TELEPORT_BATTLE) { destinationTeleport = ObjectInstanceID(); destinationTeleportPos = int3(-1); diff --git a/lib/serializer/CTypeList.cpp b/lib/serializer/CTypeList.cpp index 37740bfe5..8ff73749d 100644 --- a/lib/serializer/CTypeList.cpp +++ b/lib/serializer/CTypeList.cpp @@ -45,6 +45,21 @@ ui16 CTypeList::getTypeID(const std::type_info *type, bool throws) const return descriptor->typeID; } +CTypeList::TypeInfoPtr CTypeList::getTypeDescriptor(ui16 typeID) const +{ + auto found = std::find_if(typeInfos.begin(), typeInfos.end(), [typeID](const std::pair & p) -> bool + { + return p.second->typeID == typeID; + }); + + if(found != typeInfos.end()) + { + return found->second; + } + + return TypeInfoPtr(); +} + std::vector CTypeList::castSequence(TypeInfoPtr from, TypeInfoPtr to) const { if(!strcmp(from->name, to->name)) diff --git a/lib/serializer/CTypeList.h b/lib/serializer/CTypeList.h index 640e643f3..951df3ec0 100644 --- a/lib/serializer/CTypeList.h +++ b/lib/serializer/CTypeList.h @@ -148,6 +148,8 @@ public: return getTypeID(getTypeInfo(t), throws); } + TypeInfoPtr getTypeDescriptor(ui16 typeID) const; + template void * castToMostDerived(const TInput * inputPtr) const {