From 12482925037825c7b83e901726031651d17928c9 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 2 Dec 2022 21:37:58 +0200 Subject: [PATCH 1/2] Fixed access violation - do NOT return address to temporary created on stack --- lib/CArtHandler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index 5a50c227d..fd6637560 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -1547,16 +1547,18 @@ DLL_LINKAGE ArtifactPosition ArtifactUtils::getArtifactDstPosition( const CArtif DLL_LINKAGE const std::vector & ArtifactUtils::unmovableSlots() { - return + static const std::vector positions = { ArtifactPosition::SPELLBOOK, ArtifactPosition::MACH4 }; + + return positions; } DLL_LINKAGE const std::vector & ArtifactUtils::constituentWornSlots() { - return + static const std::vector positions = { ArtifactPosition::HEAD, ArtifactPosition::SHOULDERS, @@ -1573,6 +1575,8 @@ DLL_LINKAGE const std::vector & ArtifactUti ArtifactPosition::MISC4, ArtifactPosition::MISC5, }; + + return positions; } DLL_LINKAGE bool ArtifactUtils::isArtRemovable(const std::pair & slot) From 848454d48aa01e7c316d3687be24ac4311b49084 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 2 Dec 2022 21:38:59 +0200 Subject: [PATCH 2/2] Check for end-of-battle after opening spells are cast, fixes potentially infinite battle --- server/CGameHandler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 473ad5ae6..40e684973 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -6642,6 +6642,8 @@ void CGameHandler::runBattle() } } } + // it is possible that due to opening spells one side was eliminated -> check for end of battle + checkBattleStateChanges(); bool firstRound = true;//FIXME: why first round is -1?