diff --git a/client/widgets/Images.cpp b/client/widgets/Images.cpp index 197a45fa1..bd0253ad1 100644 --- a/client/widgets/Images.cpp +++ b/client/widgets/Images.cpp @@ -288,10 +288,18 @@ void CAnimImage::showAll(SDL_Surface * to) if(!visible) return; - if(flags & CShowableAnim::BASE && frame != 0) - if(auto img = anim->getImage(0, group)) + std::vector frames = {frame}; + + if((flags & CShowableAnim::BASE) && frame != 0) + { + frames.insert(frames.begin(), 0); + } + + for(auto targetFrame : frames) + { + if(auto img = anim->getImage(targetFrame, group)) { - if (isScaled()) + if(isScaled()) { auto scaled = img->scaleFast(float(scaledSize.x) / img->width()); scaled->draw(to, pos.x, pos.y); @@ -299,16 +307,6 @@ void CAnimImage::showAll(SDL_Surface * to) else img->draw(to, pos.x, pos.y); } - - if(auto img = anim->getImage(frame, group)) - { - if (isScaled()) - { - auto scaled = img->scaleFast(float(scaledSize.x) / img->width()); - scaled->draw(to, pos.x, pos.y); - } - else - img->draw(to, pos.x, pos.y); } } diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index f0ecd63d6..85741da51 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -812,25 +812,29 @@ std::function CExchangeController::onMoveArmyToRight() std::function CExchangeController::onSwapArmy() { - return [&]() { - auto cb = LOCPLINT->cb; + return [&]() + { + std::shared_ptr cb = LOCPLINT->cb; + const TSlots & leftSlots = left->Slots(); + const TSlots & rightSlots = right->Slots(); - for(SlotID i = SlotID(0); i.validSlot(); i.advance(1)) + for(auto i = leftSlots.begin(), j = rightSlots.begin(); i != leftSlots.end() && j != rightSlots.end(); i++, j++) { - if(left->hasStackAtSlot(i) || right->hasStackAtSlot(i)) - cb->swapCreatures(left, right, SlotID(i), SlotID(i)); + cb->swapCreatures(left, right, i->first, j->first); } }; } void CExchangeController::hdModQuickExchangeArmy(bool leftToRight) { - auto source = leftToRight ? left : right; - auto target = leftToRight ? right : left; - auto cb = LOCPLINT->cb; + const CGHeroInstance * source = leftToRight ? left : right; + const CGHeroInstance * target = leftToRight ? right : left; + std::shared_ptr cb = LOCPLINT->cb; boost::thread([=] { + boost::shared_lock gsLock(CGameState::mutex); + auto slots = source->Slots(); std::vector> stacks(slots.begin(), slots.end()); @@ -839,7 +843,11 @@ void CExchangeController::hdModQuickExchangeArmy(bool leftToRight) return a.second->type->level > b.second->type->level; }); + auto originalWaitTillRealize = cb->waitTillRealize; + auto originalUnlockGsWhenWating = cb->unlockGsWhenWaiting; + cb->waitTillRealize = true; + cb->unlockGsWhenWaiting = true; for(auto pair : stacks) { @@ -866,7 +874,8 @@ void CExchangeController::hdModQuickExchangeArmy(bool leftToRight) } } - cb->waitTillRealize = false; + cb->waitTillRealize = originalWaitTillRealize; + cb->unlockGsWhenWaiting = originalUnlockGsWhenWating; }); }