浏览代码

Fix sonar warnings, convert spaces -> tabs

Ivan Savenko 3 月之前
父节点
当前提交
e12765dca0
共有 45 个文件被更改,包括 478 次插入491 次删除
  1. 46 46
      client/UIHelper.cpp
  2. 3 3
      client/eventsSDL/InputSourceTouch.cpp
  3. 2 2
      client/mainmenu/CreditsScreen.cpp
  4. 1 1
      client/mapView/MapRenderer.cpp
  5. 1 1
      client/mapView/MapRenderer.h
  6. 1 1
      client/mapView/MapRendererContext.cpp
  7. 7 7
      client/renderSDL/SDLRWwrapper.cpp
  8. 176 176
      client/windows/CHeroOverview.cpp
  9. 1 1
      client/windows/CHeroWindow.cpp
  10. 3 3
      client/windows/CSpellWindow.cpp
  11. 2 2
      client/windows/CSpellWindow.h
  12. 4 4
      launcher/modManager/chroniclesextractor.cpp
  13. 1 1
      launcher/modManager/modstatecontroller.cpp
  14. 2 2
      lib/CConsoleHandler.cpp
  15. 4 4
      lib/CCreatureHandler.cpp
  16. 1 1
      lib/ScriptHandler.cpp
  17. 1 1
      lib/VCMIDirs.cpp
  18. 1 1
      lib/battle/CBattleInfoEssentials.cpp
  19. 3 3
      lib/battle/CObstacleInstance.cpp
  20. 6 6
      lib/battle/DamageCalculator.cpp
  21. 2 2
      lib/battle/Unit.cpp
  22. 1 1
      lib/callback/CGameInfoCallback.cpp
  23. 1 1
      lib/callback/CGameInfoCallback.h
  24. 3 3
      lib/callback/EditorCallback.cpp
  25. 1 1
      lib/callback/EditorCallback.h
  26. 1 1
      lib/callback/IGameInfoCallback.h
  27. 2 2
      lib/filesystem/MinizipExtensions.cpp
  28. 5 9
      lib/mapObjects/army/CCreatureSet.cpp
  29. 2 2
      lib/mapObjects/army/CStackInstance.cpp
  30. 14 14
      lib/rmg/RmgPath.cpp
  31. 3 3
      lib/rmg/modificators/PrisonHeroPlacer.cpp
  32. 0 10
      lib/serializer/RegisterTypes.h
  33. 2 2
      lib/spells/ISpellMechanics.cpp
  34. 2 2
      lib/spells/effects/Sacrifice.cpp
  35. 2 2
      mapeditor/helper.cpp
  36. 107 105
      mapeditor/templateeditor/GeometryAlgorithm.cpp
  37. 16 15
      mapeditor/templateeditor/GeometryAlgorithm.h
  38. 3 3
      mapeditor/templateeditor/factionselector.cpp
  39. 5 5
      mapeditor/templateeditor/graphicelements/CardItem.cpp
  40. 6 6
      mapeditor/templateeditor/mineselector.cpp
  41. 4 4
      mapeditor/templateeditor/templateeditor.cpp
  42. 3 3
      mapeditor/templateeditor/terrainselector.cpp
  43. 9 9
      mapeditor/templateeditor/treasureselector.cpp
  44. 17 19
      scripting/lua/api/BonusSystem.cpp
  45. 1 1
      test/mock/mock_IGameInfoCallback.h

+ 46 - 46
client/UIHelper.cpp

@@ -19,72 +19,72 @@
 
 std::vector<Component> UIHelper::getArtifactsComponents(const CArtifactSet & artSet, const std::vector<MoveArtifactInfo> & movedPack)
 {
-    std::vector<Component> components;
-    for(const auto & artMoveInfo : movedPack)
-    {
-        const auto art = artSet.getArt(artMoveInfo.dstPos);
-        assert(art);
+	std::vector<Component> components;
+	for(const auto & artMoveInfo : movedPack)
+	{
+		const auto art = artSet.getArt(artMoveInfo.dstPos);
+		assert(art);
 
-        if(art->isScroll())
-            components.emplace_back(ComponentType::SPELL_SCROLL, art->getScrollSpellID());
-        else
-            components.emplace_back(ComponentType::ARTIFACT, art->getTypeId());
-    }
-    return components;
+		if(art->isScroll())
+			components.emplace_back(ComponentType::SPELL_SCROLL, art->getScrollSpellID());
+		else
+			components.emplace_back(ComponentType::ARTIFACT, art->getTypeId());
+	}
+	return components;
 }
 
 std::vector<Component> UIHelper::getSpellsComponents(const std::set<SpellID> & spells)
 {
-    std::vector<Component> components;
-    for(const auto & spell : spells)
-        components.emplace_back(ComponentType::SPELL, spell);
-    return components;
+	std::vector<Component> components;
+	for(const auto & spell : spells)
+		components.emplace_back(ComponentType::SPELL, spell);
+	return components;
 }
 
 soundBase::soundID UIHelper::getNecromancyInfoWindowSound()
 {
-    return soundBase::soundID(soundBase::pickup01 + CRandomGenerator::getDefault().nextInt(6));
+	return soundBase::soundID(soundBase::pickup01 + CRandomGenerator::getDefault().nextInt(6));
 }
 
 std::string UIHelper::getNecromancyInfoWindowText(const CStackBasicDescriptor & stack)
 {
-    MetaString text;
-    if(stack.getCount() > 1) // Practicing the dark arts of necromancy, ... (plural)
-    {
-        text.appendLocalString(EMetaText::GENERAL_TXT, 145);
-        text.replaceNumber(stack.getCount());
-    }
-    else // Practicing the dark arts of necromancy, ... (singular)
-    {
-        text.appendLocalString(EMetaText::GENERAL_TXT, 146);
-    }
-    text.replaceName(stack);
-    return text.toString();
+	MetaString text;
+	if(stack.getCount() > 1) // Practicing the dark arts of necromancy, ... (plural)
+	{
+		text.appendLocalString(EMetaText::GENERAL_TXT, 145);
+		text.replaceNumber(stack.getCount());
+	}
+	else // Practicing the dark arts of necromancy, ... (singular)
+	{
+		text.appendLocalString(EMetaText::GENERAL_TXT, 146);
+	}
+	text.replaceName(stack);
+	return text.toString();
 }
 
 std::string UIHelper::getArtifactsInfoWindowText()
 {
-    MetaString text;
-    text.appendLocalString(EMetaText::GENERAL_TXT, 30);
-    return text.toString();
+	MetaString text;
+	text.appendLocalString(EMetaText::GENERAL_TXT, 30);
+	return text.toString();
 }
 
 std::string UIHelper::getEagleEyeInfoWindowText(const CGHeroInstance & hero, const std::set<SpellID> & spells)
 {
-    MetaString text;
-    text.appendLocalString(EMetaText::GENERAL_TXT, 221); // Through eagle-eyed observation, %s is able to learn %s
-    text.replaceRawString(hero.getNameTranslated());
+	MetaString text;
+	text.appendLocalString(EMetaText::GENERAL_TXT, 221); // Through eagle-eyed observation, %s is able to learn %s
+	text.replaceRawString(hero.getNameTranslated());
 
-    auto curSpell = spells.begin();
-    text.replaceName(*curSpell++);
-    for(int i = 1; i < spells.size(); i++, curSpell++)
-    {
-        if(i + 1 == spells.size())
-            text.appendLocalString(EMetaText::GENERAL_TXT, 141); // " and "
-        else
-            text.appendRawString(", ");
-        text.appendName(*curSpell);
-    }
-    text.appendRawString(".");
-    return text.toString();
+	auto curSpell = spells.begin();
+	text.replaceName(*curSpell++);
+	for(int i = 1; i < spells.size(); i++, curSpell++)
+	{
+		if(i + 1 == spells.size())
+			text.appendLocalString(EMetaText::GENERAL_TXT, 141); // " and "
+		else
+			text.appendRawString(", ");
+		text.appendName(*curSpell);
+	}
+	text.appendRawString(".");
+	return text.toString();
 }

+ 3 - 3
client/eventsSDL/InputSourceTouch.cpp

@@ -366,10 +366,10 @@ void InputSourceTouch::emitPinchEvent(const SDL_TouchFingerEvent & tfinger)
 void InputSourceTouch::hapticFeedback() {
 	if(params.hapticFeedbackEnabled) {
 #if defined(VCMI_ANDROID)
-        CAndroidVMHelper vmHelper;
-        vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "hapticFeedback");
+		CAndroidVMHelper vmHelper;
+		vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "hapticFeedback");
 #elif defined(VCMI_IOS)
-    	iOS_utils::hapticFeedback();
+		iOS_utils::hapticFeedback();
 #endif
 	}
 }

+ 2 - 2
client/mainmenu/CreditsScreen.cpp

@@ -48,8 +48,8 @@ CreditsScreen::CreditsScreen(Rect rect)
 	size_t firstQuote = text.find('\"') + 1;
 	text = text.substr(firstQuote, text.find('\"', firstQuote) - firstQuote);
 
-	auto translateCredits = [&text](std::map<std::string, std::string> replacements){
-		for(auto & item : replacements)
+	const auto & translateCredits = [&text](const std::map<std::string, std::string> & replacements){
+		for(const auto & item : replacements)
 			boost::replace_first(text, "{" + item.second + ":}", "{" + LIBRARY->generaltexth->translate(item.first) + ":}");
 	};
 	translateCredits({

+ 1 - 1
client/mapView/MapRenderer.cpp

@@ -470,7 +470,7 @@ std::shared_ptr<CAnimation> MapRendererObjects::getOverlayAnimation(const CGObje
 	return nullptr;
 }
 
-std::shared_ptr<IImage> MapRendererObjects::getImageToRender(IMapRendererContext & context, const CGObjectInstance * obj, const std::shared_ptr<CAnimation>& animation) const
+std::shared_ptr<IImage> MapRendererObjects::getImageToRender(const IMapRendererContext & context, const CGObjectInstance * obj, const std::shared_ptr<CAnimation>& animation) const
 {
 	if(!animation)
 		return nullptr;

+ 1 - 1
client/mapView/MapRenderer.h

@@ -82,7 +82,7 @@ class MapRendererObjects
 	std::shared_ptr<CAnimation> getAnimation(const AnimationPath & filename, bool generateMovementGroups, bool enableOverlay);
 	std::shared_ptr<IImage> getImage(const ImagePath & filename) const;
 
-	std::shared_ptr<IImage> getImageToRender(IMapRendererContext & context, const CGObjectInstance * obj, const std::shared_ptr<CAnimation> & animation) const;
+	std::shared_ptr<IImage> getImageToRender(const IMapRendererContext & context, const CGObjectInstance * obj, const std::shared_ptr<CAnimation> & animation) const;
 
 	void renderImage(IMapRendererContext & context, Canvas & target, const int3 & coordinates, const CGObjectInstance * object, const std::shared_ptr<IImage> & image);
 	void renderObject(IMapRendererContext & context, Canvas & target, const int3 & coordinates, const CGObjectInstance * obj);

+ 1 - 1
client/mapView/MapRendererContext.cpp

@@ -92,7 +92,7 @@ int MapRendererBaseContext::attackedMonsterDirection(const CGObjectInstance * wa
 	if(wanderingMonster->ID != Obj::MONSTER)
 		return -1;
 		
-	for(auto & battle : GAME->interface()->cb->getActiveBattles())
+	for(const auto & battle : GAME->interface()->cb->getActiveBattles())
 		if(wanderingMonster->pos == battle.second->getBattle()->getLocation())
 			return battle.second->getBattle()->getSideHero(BattleSide::ATTACKER)->moveDir;
 

+ 7 - 7
client/renderSDL/SDLRWwrapper.cpp

@@ -47,10 +47,10 @@ static Sint64 impl_seek(SDL_RWops* context, Sint64 offset, int whence)
 
 static std::size_t impl_read(SDL_RWops* context, void *ptr, size_t size, size_t maxnum)
 {
-    auto stream = get_stream(context);
-    auto oldpos = stream->tell();
+	auto stream = get_stream(context);
+	auto oldpos = stream->tell();
 
-    auto count = stream->read(static_cast<ui8*>(ptr), size*maxnum);
+	auto count = stream->read(static_cast<ui8*>(ptr), size*maxnum);
 
 	if (count != 0 && count != size*maxnum)
 	{
@@ -58,7 +58,7 @@ static std::size_t impl_read(SDL_RWops* context, void *ptr, size_t size, size_t
 		stream->seek(oldpos + size * (count / size));
 	}
 
-    return count / size;
+	return count / size;
 }
 
 static std::size_t impl_write(SDL_RWops* context, const void *ptr, size_t size, size_t num)
@@ -72,9 +72,9 @@ static int impl_close(SDL_RWops* context)
 	if (context == nullptr)
 		return 0;
 
-    delete get_stream(context);
-    SDL_FreeRW(context);
-    return 0;
+	delete get_stream(context);
+	SDL_FreeRW(context);
+	return 0;
 }
 
 

+ 176 - 176
client/windows/CHeroOverview.cpp

@@ -38,12 +38,12 @@ CHeroOverview::CHeroOverview(const HeroTypeID & h)
 {
 	OBJECT_CONSTRUCTION;
 
-    heroIdx = hero.getNum();
+	heroIdx = hero.getNum();
 
 	pos = Rect(0, 0, 600, 485);
 
 	genBackground();
-    genControls();
+	genControls();
 
 	center();
 }
@@ -56,191 +56,191 @@ void CHeroOverview::genBackground()
 
 void CHeroOverview::genControls()
 {
-    Rect r = Rect();
+	Rect r = Rect();
 
 	labelTitle = std::make_shared<CLabel>(pos.w / 2 + 8, 21, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, LIBRARY->generaltexth->allTexts[77]);
 
-    // hero image
-    r = Rect(borderOffset, borderOffset + yOffset, 58, 64);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	// hero image
+	r = Rect(borderOffset, borderOffset + yOffset, 58, 64);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
 	imageHero = std::make_shared<CAnimImage>(AnimationPath::builtin("PortraitsLarge"), (*LIBRARY->heroh)[heroIdx]->imageIndex, 0, r.x, r.y);
 
-    // hero name
-    r = Rect(64 + borderOffset, borderOffset + yOffset, 220, 64);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	// hero name
+	r = Rect(64 + borderOffset, borderOffset + yOffset, 220, 64);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
 	labelHeroName = std::make_shared<CLabel>(r.x + 110, r.y + 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, (*LIBRARY->heroh)[heroIdx]->getNameTranslated());
 	labelHeroClass = std::make_shared<CLabel>(r.x + 110, r.y + 45, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, (*LIBRARY->heroh)[heroIdx]->heroClass->getNameTranslated());
 
-    // vertical line
-    backgroundLines.push_back(std::make_shared<SimpleLine>(Point(295, borderOffset + yOffset - 1), Point(295, borderOffset + yOffset - 2 + 439), borderColor));
-    
-    // skills header
-    r = Rect(borderOffset, 2 * borderOffset + yOffset + 64, 284, 20);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    for(int i = 0; i < 4; i++)
-        labelSkillHeader.push_back(std::make_shared<CLabel>((r.w / 4) * i + 42, r.y + 10, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, LIBRARY->generaltexth->jktexts[1 + i]));
-
-    // skill
-    const int tmp[] = {0, 1, 2, 5};
-    for(int i = 0; i < 4; i++)
-    {
-        r = Rect((284 / 4) * i + 21, 3 * borderOffset + yOffset + 85, 42, 42);
-        backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-        imageSkill.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), tmp[i], 0, r.x, r.y));
-    }
-
-    // skills footer
-    r = Rect(borderOffset, 4 * borderOffset + yOffset + 128, 284, 20);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    for(int i = 0; i < 4; i++)
-    {
-        r = Rect((284 / 4) * i + 42, r.y, r.w, r.h);
-        labelSkillFooter.push_back(std::make_shared<CLabel>(r.x, r.y + 10, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, std::to_string((*LIBRARY->heroh)[heroIdx]->heroClass->primarySkillInitial[i])));
-    } 
-
-    // hero biography
-    r = Rect(borderOffset, 5 * borderOffset + yOffset + 148, 284, 130);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    labelHeroBiography = std::make_shared<CTextBox>((*LIBRARY->heroh)[heroIdx]->getBiographyTranslated(), r.resize(-borderOffset), CSlider::EStyle::BROWN, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
-    if(labelHeroBiography->slider && ENGINE->input().getCurrentInputMode() != InputMode::TOUCH)
-        labelHeroBiography->slider->clearScrollBounds();
-
-    // speciality name
-    r = Rect(2 * borderOffset + 44, 6 * borderOffset + yOffset + 278, 235, 44);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	// vertical line
+	backgroundLines.push_back(std::make_shared<SimpleLine>(Point(295, borderOffset + yOffset - 1), Point(295, borderOffset + yOffset - 2 + 439), borderColor));
+
+	// skills header
+	r = Rect(borderOffset, 2 * borderOffset + yOffset + 64, 284, 20);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	for(int i = 0; i < 4; i++)
+		labelSkillHeader.push_back(std::make_shared<CLabel>((r.w / 4) * i + 42, r.y + 10, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, LIBRARY->generaltexth->jktexts[1 + i]));
+
+	// skill
+	const int tmp[] = {0, 1, 2, 5};
+	for(int i = 0; i < 4; i++)
+	{
+		r = Rect((284 / 4) * i + 21, 3 * borderOffset + yOffset + 85, 42, 42);
+		backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+		imageSkill.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), tmp[i], 0, r.x, r.y));
+	}
+
+	// skills footer
+	r = Rect(borderOffset, 4 * borderOffset + yOffset + 128, 284, 20);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	for(int i = 0; i < 4; i++)
+	{
+		r = Rect((284 / 4) * i + 42, r.y, r.w, r.h);
+		labelSkillFooter.push_back(std::make_shared<CLabel>(r.x, r.y + 10, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, std::to_string((*LIBRARY->heroh)[heroIdx]->heroClass->primarySkillInitial[i])));
+	}
+
+	// hero biography
+	r = Rect(borderOffset, 5 * borderOffset + yOffset + 148, 284, 130);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	labelHeroBiography = std::make_shared<CTextBox>((*LIBRARY->heroh)[heroIdx]->getBiographyTranslated(), r.resize(-borderOffset), CSlider::EStyle::BROWN, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
+	if(labelHeroBiography->slider && ENGINE->input().getCurrentInputMode() != InputMode::TOUCH)
+		labelHeroBiography->slider->clearScrollBounds();
+
+	// speciality name
+	r = Rect(2 * borderOffset + 44, 6 * borderOffset + yOffset + 278, 235, 44);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
 	labelHeroSpeciality = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->allTexts[78]);
 	labelSpecialityName = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 20, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*LIBRARY->heroh)[heroIdx]->getSpecialtyNameTranslated());
 
-    // speciality image
-    r = Rect(borderOffset, 6 * borderOffset + yOffset + 278, 44, 44);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    imageSpeciality = std::make_shared<CAnimImage>(AnimationPath::builtin("UN44"), (*LIBRARY->heroh)[heroIdx]->imageIndex, 0, r.x, r.y);
+	// speciality image
+	r = Rect(borderOffset, 6 * borderOffset + yOffset + 278, 44, 44);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	imageSpeciality = std::make_shared<CAnimImage>(AnimationPath::builtin("UN44"), (*LIBRARY->heroh)[heroIdx]->imageIndex, 0, r.x, r.y);
 
-    // speciality description
-    r = Rect(borderOffset, 7 * borderOffset + yOffset + 322, 284, 85);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	// speciality description
+	r = Rect(borderOffset, 7 * borderOffset + yOffset + 322, 284, 85);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
 	labelSpecialityDescription = std::make_shared<CTextBox>((*LIBRARY->heroh)[heroIdx]->getSpecialtyDescriptionTranslated(), r.resize(-borderOffset), CSlider::EStyle::BROWN, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
-    if(labelSpecialityDescription->slider && ENGINE->input().getCurrentInputMode() != InputMode::TOUCH)
-        labelSpecialityDescription->slider->clearScrollBounds();
-
-    // army title
-    r = Rect(302, borderOffset + yOffset, 292, 30);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    labelArmyTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.heroOverview.startingArmy"));
-
-    // army numbers
-    r = Rect(302, 3 * borderOffset + yOffset + 62, 292, 32);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-
-    auto stacksCountChances = LIBRARY->engineSettings()->getVector(EGameSettings::HEROES_STARTING_STACKS_CHANCES);
-
-    // army
-    int space = (260 - 7 * 32) / 6;
-    for(int i = 0; i < 7; i++)
-    {
-        r = Rect(318 + i * (32 + space), 2 * borderOffset + yOffset + 30, 32, 32);
-        backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    }
-    int i = 0;
-    int iStack = 0;
-    for(auto & army : (*LIBRARY->heroh)[heroIdx]->initialArmy)
-    {
-        if((*LIBRARY->creh)[army.creature]->warMachine == ArtifactID::NONE)
-        {
-            imageArmy.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), (*LIBRARY->creh)[army.creature]->getIconIndex(), 0, 302 + i * (32 + space) + 16, 2 * borderOffset + yOffset + 30));
-            labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 32, 3 * borderOffset + yOffset + 72, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, (army.minAmount == army.maxAmount) ? std::to_string(army.minAmount) : std::to_string(army.minAmount) + "-" + std::to_string(army.maxAmount)));
-            if(iStack<stacksCountChances.size())
-                labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 32, 3 * borderOffset + yOffset + 86, FONT_SMALL, ETextAlignment::CENTER, grayedColor, std::to_string(stacksCountChances[iStack]) + "%"));
-            i++;
-        }
-        iStack++;
-    }
-
-    // war machine title
-    r = Rect(302, 4 * borderOffset + yOffset + 94, 292, 30);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    labelWarMachineTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.heroOverview.warMachine"));
-
-    // war machine
-    space = (260 - 4 * 32) / 3;
-    for(int i = 0; i < 4; i++)
-    {
-        r = Rect(318 + i * (32 + space), 5 * borderOffset + yOffset + 124, 32, 32);
-        backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    }
-    i = 0;
-    iStack = 0;
-    for(auto & army : (*LIBRARY->heroh)[heroIdx]->initialArmy)
-    {
-        if(i == 0)
-        {
-            imageWarMachine.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), (*LIBRARY->creh)[army.creature.CATAPULT]->getIconIndex(), 0, 302 + i * (32 + space) + 16, 5 * borderOffset + yOffset + 124));
-            labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 51, 5 * borderOffset + yOffset + 144, FONT_SMALL, ETextAlignment::TOPLEFT, grayedColor, "100%"));
-            i++;
-        }
-        if((*LIBRARY->creh)[army.creature]->warMachine != ArtifactID::NONE)
-        {
-            imageWarMachine.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), (*LIBRARY->creh)[army.creature]->getIconIndex(), 0, 302 + i * (32 + space) + 16, 5 * borderOffset + yOffset + 124));
-            if(iStack<stacksCountChances.size())
-                labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 51, 5 * borderOffset + yOffset + 144, FONT_SMALL, ETextAlignment::TOPLEFT, grayedColor, std::to_string(stacksCountChances[iStack]) + "%"));
-            i++;
-        }
-        iStack++;
-    }
-
-    // secskill title
-    r = Rect(302, 6 * borderOffset + yOffset + 156, (292 / 2) - 2 * borderOffset, 30);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    labelSecSkillTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.heroOverview.secondarySkills"));
-
-    // vertical line
-    backgroundLines.push_back(std::make_shared<SimpleLine>(Point(302 + (292 / 2), 6 * borderOffset + yOffset + 156 - 1), Point(302 + (292 / 2), 6 * borderOffset + yOffset + 156 - 2 + 254), borderColor));
-
-    // spell title
-    r = Rect(302 + (292 / 2) + 2 * borderOffset, 6 * borderOffset + yOffset + 156, (292 / 2) - 2 * borderOffset, 30);
-    backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    labelSpellTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.heroOverview.spells"));
-
-    // secskill
-    for(int i = 0; i < 6; i++)
-    {
-        r = Rect(302, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32);
-        backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-        r = Rect(r.x + 32 + borderOffset, r.y, (292 / 2) - 32 - 3 * borderOffset, r.h);
-        backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    }
-    i = 0;
-    for(auto & skill : (*LIBRARY->heroh)[heroIdx]->secSkillsInit)
-    {
-        secSkills.push_back(std::make_shared<CSecSkillPlace>(Point(302, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset)),
-            CSecSkillPlace::ImageSize::SMALL, skill.first, skill.second));
-        labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) - 5, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, LIBRARY->generaltexth->levels[skill.second - 1]));
-        labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) + 10, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*LIBRARY->skillh)[skill.first]->getNameTranslated()));
-        i++;
-    }
-
-    // spell
-    for(int i = 0; i < 6; i++)
-    {
-        r = Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32);
-        backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-        r = Rect(r.x + 32 + borderOffset, r.y, (292 / 2) - 32 - 3 * borderOffset, r.h);
-        backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
-    }
-    i = 0;
-    for(auto & spell : (*LIBRARY->heroh)[heroIdx]->spells)
-    {
-        if(i == 0)
-        {
-            if((*LIBRARY->heroh)[heroIdx]->haveSpellBook)
-            {
-                imageSpells.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("ARTIFACT"), 0, Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
-            }
-            i++;
-        }
-
-        imageSpells.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SPELLBON"), (*LIBRARY->spellh)[spell]->getIconIndex(), Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
-        labelSpellsNames.push_back(std::make_shared<CLabel>(302 + (292 / 2) + 3 * borderOffset + 32 + borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) + 3, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*LIBRARY->spellh)[spell]->getNameTranslated()));
-        i++;
-    }
+	if(labelSpecialityDescription->slider && ENGINE->input().getCurrentInputMode() != InputMode::TOUCH)
+		labelSpecialityDescription->slider->clearScrollBounds();
+
+	// army title
+	r = Rect(302, borderOffset + yOffset, 292, 30);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	labelArmyTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.heroOverview.startingArmy"));
+
+	// army numbers
+	r = Rect(302, 3 * borderOffset + yOffset + 62, 292, 32);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+
+	auto stacksCountChances = LIBRARY->engineSettings()->getVector(EGameSettings::HEROES_STARTING_STACKS_CHANCES);
+
+	// army
+	int space = (260 - 7 * 32) / 6;
+	for(int i = 0; i < 7; i++)
+	{
+		r = Rect(318 + i * (32 + space), 2 * borderOffset + yOffset + 30, 32, 32);
+		backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	}
+	int i = 0;
+	int iStack = 0;
+	for(auto & army : (*LIBRARY->heroh)[heroIdx]->initialArmy)
+	{
+		if((*LIBRARY->creh)[army.creature]->warMachine == ArtifactID::NONE)
+		{
+			imageArmy.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), (*LIBRARY->creh)[army.creature]->getIconIndex(), 0, 302 + i * (32 + space) + 16, 2 * borderOffset + yOffset + 30));
+			labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 32, 3 * borderOffset + yOffset + 72, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, (army.minAmount == army.maxAmount) ? std::to_string(army.minAmount) : std::to_string(army.minAmount) + "-" + std::to_string(army.maxAmount)));
+			if(iStack<stacksCountChances.size())
+				labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 32, 3 * borderOffset + yOffset + 86, FONT_SMALL, ETextAlignment::CENTER, grayedColor, std::to_string(stacksCountChances[iStack]) + "%"));
+			i++;
+		}
+		iStack++;
+	}
+
+	// war machine title
+	r = Rect(302, 4 * borderOffset + yOffset + 94, 292, 30);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	labelWarMachineTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.heroOverview.warMachine"));
+
+	// war machine
+	space = (260 - 4 * 32) / 3;
+	for(int i = 0; i < 4; i++)
+	{
+		r = Rect(318 + i * (32 + space), 5 * borderOffset + yOffset + 124, 32, 32);
+		backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	}
+	i = 0;
+	iStack = 0;
+	for(auto & army : (*LIBRARY->heroh)[heroIdx]->initialArmy)
+	{
+		if(i == 0)
+		{
+			imageWarMachine.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), (*LIBRARY->creh)[army.creature.CATAPULT]->getIconIndex(), 0, 302 + i * (32 + space) + 16, 5 * borderOffset + yOffset + 124));
+			labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 51, 5 * borderOffset + yOffset + 144, FONT_SMALL, ETextAlignment::TOPLEFT, grayedColor, "100%"));
+			i++;
+		}
+		if((*LIBRARY->creh)[army.creature]->warMachine != ArtifactID::NONE)
+		{
+			imageWarMachine.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), (*LIBRARY->creh)[army.creature]->getIconIndex(), 0, 302 + i * (32 + space) + 16, 5 * borderOffset + yOffset + 124));
+			if(iStack<stacksCountChances.size())
+				labelArmyCount.push_back(std::make_shared<CLabel>(302 + i * (32 + space) + 51, 5 * borderOffset + yOffset + 144, FONT_SMALL, ETextAlignment::TOPLEFT, grayedColor, std::to_string(stacksCountChances[iStack]) + "%"));
+			i++;
+		}
+		iStack++;
+	}
+
+	// secskill title
+	r = Rect(302, 6 * borderOffset + yOffset + 156, (292 / 2) - 2 * borderOffset, 30);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	labelSecSkillTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.heroOverview.secondarySkills"));
+
+	// vertical line
+	backgroundLines.push_back(std::make_shared<SimpleLine>(Point(302 + (292 / 2), 6 * borderOffset + yOffset + 156 - 1), Point(302 + (292 / 2), 6 * borderOffset + yOffset + 156 - 2 + 254), borderColor));
+
+	// spell title
+	r = Rect(302 + (292 / 2) + 2 * borderOffset, 6 * borderOffset + yOffset + 156, (292 / 2) - 2 * borderOffset, 30);
+	backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	labelSpellTitle = std::make_shared<CLabel>(r.x + borderOffset, r.y + borderOffset + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.heroOverview.spells"));
+
+	// secskill
+	for(int i = 0; i < 6; i++)
+	{
+		r = Rect(302, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32);
+		backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+		r = Rect(r.x + 32 + borderOffset, r.y, (292 / 2) - 32 - 3 * borderOffset, r.h);
+		backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	}
+	i = 0;
+	for(auto & skill : (*LIBRARY->heroh)[heroIdx]->secSkillsInit)
+	{
+		secSkills.push_back(std::make_shared<CSecSkillPlace>(Point(302, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset)),
+															 CSecSkillPlace::ImageSize::SMALL, skill.first, skill.second));
+		labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) - 5, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, LIBRARY->generaltexth->levels[skill.second - 1]));
+		labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) + 10, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*LIBRARY->skillh)[skill.first]->getNameTranslated()));
+		i++;
+	}
+
+	// spell
+	for(int i = 0; i < 6; i++)
+	{
+		r = Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32);
+		backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+		r = Rect(r.x + 32 + borderOffset, r.y, (292 / 2) - 32 - 3 * borderOffset, r.h);
+		backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
+	}
+	i = 0;
+	for(auto & spell : (*LIBRARY->heroh)[heroIdx]->spells)
+	{
+		if(i == 0)
+		{
+			if((*LIBRARY->heroh)[heroIdx]->haveSpellBook)
+			{
+				imageSpells.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("ARTIFACT"), 0, Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
+			}
+			i++;
+		}
+
+		imageSpells.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SPELLBON"), (*LIBRARY->spellh)[spell]->getIconIndex(), Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
+		labelSpellsNames.push_back(std::make_shared<CLabel>(302 + (292 / 2) + 3 * borderOffset + 32 + borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) + 3, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*LIBRARY->spellh)[spell]->getNameTranslated()));
+		i++;
+	}
 }

+ 1 - 1
client/windows/CHeroWindow.cpp

@@ -161,7 +161,7 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
 	for(int i = 0; i < std::min<size_t>(hero->secSkills.size(), 8u); ++i)
 	{
 		bool isSmallBox = (secSkillSlider && i%2 == 1);
-		Rect r = Rect(i%2 == 0  ?  18  :  162,  276 + 48 * (i/2), isSmallBox ? 120 : 136,  42);
+		Rect r(i%2 == 0  ?  18  :  162,  276 + 48 * (i/2), isSmallBox ? 120 : 136,  42);
 		secSkills.emplace_back(std::make_shared<CSecSkillPlace>(r.topLeft(), CSecSkillPlace::ImageSize::MEDIUM));
 
 		int x = (i % 2) ? 212 : 68;

+ 3 - 3
client/windows/CSpellWindow.cpp

@@ -72,7 +72,7 @@ bool isLegacySpellSchool(SpellSchool school)
 	return getAnimFrameFromSchool(school) != -1;
 }
 
-CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner)
+CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, const std::function<void()> & funcL, int helpTextId, CSpellWindow * _owner)
 {
 	addUsedEvents(LCLICK | SHOW_POPUP | HOVER);
 	pos = myRect;
@@ -82,7 +82,7 @@ CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, std::functio
 	owner = _owner;
 }
 
-CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, std::function<void()> funcL, std::string textId, CSpellWindow * _owner)
+CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, const std::function<void()> & funcL, std::string textId, CSpellWindow * _owner)
 {
 	addUsedEvents(LCLICK | SHOW_POPUP | HOVER);
 	pos = myRect;
@@ -632,7 +632,7 @@ void CSpellWindow::keyPressed(EShortcut key)
 		case EShortcut::MOVE_DOWN:
 		{
 			bool down = key == EShortcut::MOVE_DOWN;
-			static const SpellSchool schoolsOrder[] = { SpellSchool::AIR, SpellSchool::EARTH, SpellSchool::FIRE, SpellSchool::WATER, SpellSchool::ANY };
+			static const std::array schoolsOrder = { SpellSchool::AIR, SpellSchool::EARTH, SpellSchool::FIRE, SpellSchool::WATER, SpellSchool::ANY };
 			int index = -1;
 			while(schoolsOrder[++index] != selectedTab);
 			index += (down ? 1 : -1);

+ 2 - 2
client/windows/CSpellWindow.h

@@ -66,8 +66,8 @@ class CSpellWindow : public CWindowObject, public IVideoHolder
 		void showPopupWindow(const Point & cursorPosition) override;
 		void hover(bool on) override;
 
-		InteractiveArea(const Rect &myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner);
-		InteractiveArea(const Rect &myRect, std::function<void()> funcL, std::string textId, CSpellWindow * _owner);
+		InteractiveArea(const Rect &myRect, const std::function<void()> & funcL, int helpTextId, CSpellWindow * _owner);
+		InteractiveArea(const Rect &myRect, const std::function<void()> & funcL, std::string textId, CSpellWindow * _owner);
 	};
 
 	std::shared_ptr<CPicture> leftCorner;

+ 4 - 4
launcher/modManager/chroniclesextractor.cpp

@@ -121,8 +121,8 @@ void ChroniclesExtractor::createBaseMod() const
 	};
 
 	QFile jsonFile(dir.filePath("mod.json"));
-    jsonFile.open(QFile::WriteOnly);
-    jsonFile.write(QJsonDocument(mod).toJson());
+	jsonFile.open(QFile::WriteOnly);
+	jsonFile.write(QJsonDocument(mod).toJson());
 
 	for(auto & dataPath : VCMIDirs::get().dataPaths())
 	{
@@ -157,8 +157,8 @@ void ChroniclesExtractor::createChronicleMod(int no)
 	};
 	
 	QFile jsonFile(dir.filePath("mod.json"));
-    jsonFile.open(QFile::WriteOnly);
-    jsonFile.write(QJsonDocument(mod).toJson());
+	jsonFile.open(QFile::WriteOnly);
+	jsonFile.write(QJsonDocument(mod).toJson());
 
 	dir.cd("content");
 	

+ 1 - 1
launcher/modManager/modstatecontroller.cpp

@@ -236,7 +236,7 @@ bool ModStateController::doInstallMod(QString modname, QString archivePath)
 	// Remove .github folder from installed mod
 	QDir githubDir(extractedDir.filePath(".github"));
 	if (githubDir.exists())
-	    githubDir.removeRecursively();
+		githubDir.removeRecursively();
 	
 	//there are possible excessive files - remove them
 	QString upperLevel = modDirName.section('/', 0, 0);

+ 2 - 2
lib/CConsoleHandler.cpp

@@ -222,12 +222,12 @@ void CConsoleHandler::setColor(EConsoleTextColor color)
 		break;
 	}
 #ifdef VCMI_WINDOWS
-    SetConsoleTextAttribute(handleOut, colorCode);
+	SetConsoleTextAttribute(handleOut, colorCode);
 	if (color == EConsoleTextColor::DEFAULT)
 		colorCode = defErrColor;
 	SetConsoleTextAttribute(handleErr, colorCode);
 #else
-    std::cout << colorCode;
+	std::cout << colorCode;
 #endif
 }
 

+ 4 - 4
lib/CCreatureHandler.cpp

@@ -504,10 +504,10 @@ void CCreatureHandler::loadCommanders()
 		++level;
 	}
 
-	for (auto ability : config["abilityRequirements"].Vector())
+	for (const auto & abilityRequirements : config["abilityRequirements"].Vector())
 	{
 		std::pair <std::vector<std::shared_ptr<Bonus> >, std::pair <ui8, ui8> > a;
-		JsonNode & abilities = ability["ability"];
+		const JsonNode & abilities = abilityRequirements["ability"];
 
 		if (abilities[0].isString()) // old format with single bonus
 		{
@@ -519,8 +519,8 @@ void CCreatureHandler::loadCommanders()
 				a.first.push_back(parseBonusWithCompatibility(ability));
 		}
 
-		a.second.first =  static_cast<ui8>(ability["skills"][0].Float());
-		a.second.second = static_cast<ui8>(ability["skills"][1].Float());
+		a.second.first =  static_cast<ui8>(abilityRequirements["skills"][0].Float());
+		a.second.second = static_cast<ui8>(abilityRequirements["skills"][1].Float());
 		skillRequirements.push_back (a);
 	}
 }

+ 1 - 1
lib/ScriptHandler.cpp

@@ -166,7 +166,7 @@ void PoolImpl::serializeState(const bool saving, JsonNode & data)
 {
 	if(saving)
 	{
-        for(auto & scriptAndContext : cache)
+		for(auto & scriptAndContext : cache)
 		{
 			const auto * script = scriptAndContext.first;
 			auto context = scriptAndContext.second;

+ 1 - 1
lib/VCMIDirs.cpp

@@ -66,7 +66,7 @@ void IVCMIDirs::init()
 #ifdef VCMI_WINDOWS
 
 #ifdef __MINGW32__
-    #define _WIN32_IE 0x0500
+	#define _WIN32_IE 0x0500
 
 	#ifndef CSIDL_MYDOCUMENTS
 	#define CSIDL_MYDOCUMENTS CSIDL_PERSONAL

+ 1 - 1
lib/battle/CBattleInfoEssentials.cpp

@@ -313,7 +313,7 @@ BattleSide CBattleInfoEssentials::playerToSide(const PlayerColor & player) const
 PlayerColor CBattleInfoEssentials::sideToPlayer(BattleSide side) const
 {
 	RETURN_IF_NOT_BATTLE(PlayerColor::CANNOT_DETERMINE);
-    return getBattle()->getSidePlayer(side);
+	return getBattle()->getSidePlayer(side);
 }
 
 BattleSide CBattleInfoEssentials::otherSide(BattleSide side)

+ 3 - 3
lib/battle/CObstacleInstance.cpp

@@ -183,8 +183,8 @@ void SpellCreatedObstacle::fromInfo(const ObstacleChanges & info)
 	if(info.operation != ObstacleChanges::EOperation::ADD && info.operation != ObstacleChanges::EOperation::UPDATE)
 		logGlobal->error("ADD or UPDATE operation expected");
 
-    JsonDeserializer deser(nullptr, info.data);
-    deser.serializeStruct("obstacle", *this);
+	JsonDeserializer deser(nullptr, info.data);
+	deser.serializeStruct("obstacle", *this);
 }
 
 void SpellCreatedObstacle::serializeJson(JsonSerializeFormat & handler)
@@ -266,4 +266,4 @@ int SpellCreatedObstacle::getAnimationYOffset(int imageHeight) const
 	return offset;
 }
 
-VCMI_LIB_NAMESPACE_END
+VCMI_LIB_NAMESPACE_END

+ 6 - 6
lib/battle/DamageCalculator.cpp

@@ -32,14 +32,14 @@ DamageRange DamageCalculator::getBaseDamageSingle() const
 	minDmg = info.attacker->getMinDamage(info.shooting);
 	maxDmg = info.attacker->getMaxDamage(info.shooting);
 
-    if(minDmg > maxDmg)
-    {
+	if(minDmg > maxDmg)
+	{
 	const auto & creatureName = info.attacker->creatureId().toEntity(LIBRARY)->getNamePluralTranslated();
 	logGlobal->error("Creature %s: min damage %lld exceeds max damage %lld.", creatureName, minDmg, maxDmg);
-        logGlobal->error("This may lead to unexpected results, please report it to the mod's creator.");
-        // to avoid an RNG crash and make bless and curse spells work as expected
-        std::swap(minDmg, maxDmg);
-    }
+		logGlobal->error("This may lead to unexpected results, please report it to the mod's creator.");
+		// to avoid an RNG crash and make bless and curse spells work as expected
+		std::swap(minDmg, maxDmg);
+	}
 
 	if(info.attacker->creatureIndex() == CreatureID::ARROW_TOWERS)
 	{

+ 2 - 2
lib/battle/Unit.cpp

@@ -243,8 +243,8 @@ void UnitInfo::save(JsonNode & data)
 void UnitInfo::load(uint32_t id_, const JsonNode & data)
 {
 	id = id_;
-    JsonDeserializer deser(nullptr, data);
-    deser.serializeStruct("newUnitInfo", *this);
+	JsonDeserializer deser(nullptr, data);
+	deser.serializeStruct("newUnitInfo", *this);
 }
 
 }

+ 1 - 1
lib/callback/CGameInfoCallback.cpp

@@ -851,7 +851,7 @@ void CGameInfoCallback::getTilesInRange(std::unordered_set<int3> & tiles,
 	}
 }
 
-void CGameInfoCallback::getAllTiles(std::unordered_set<int3> & tiles, std::optional<PlayerColor> Player, int level, std::function<bool(const TerrainTile *)> filter) const
+void CGameInfoCallback::getAllTiles(std::unordered_set<int3> & tiles, std::optional<PlayerColor> Player, int level, const std::function<bool(const TerrainTile *)> & filter) const
 {
 	if(Player.has_value() && !Player->isValidPlayer())
 	{

+ 1 - 1
lib/callback/CGameInfoCallback.h

@@ -104,7 +104,7 @@ public:
 	//used for random spawns
 	void getFreeTiles(std::vector<int3> &tiles) const;
 	void getTilesInRange(std::unordered_set<int3> & tiles, const int3 & pos, int radius, ETileVisibility mode, std::optional<PlayerColor> player = std::optional<PlayerColor>(), int3::EDistanceFormula formula = int3::DIST_2D) const override;
-	void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter) const override;
+	void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, const std::function<bool(const TerrainTile *)> & filter) const override;
 
 	void getAllowedSpells(std::vector<SpellID> &out, std::optional<ui16> level = std::nullopt) const;
 

+ 3 - 3
lib/callback/EditorCallback.cpp

@@ -27,9 +27,9 @@ EditorCallback::EditorCallback(const CMap * map)
 	: map(map)
 {}
 
-void EditorCallback::setMap(const CMap * map)
+void EditorCallback::setMap(const CMap * newMap)
 {
-	this->map = map;
+	map = newMap;
 }
 
 CGameState & EditorCallback::gameState()
@@ -97,7 +97,7 @@ void EditorCallback::getTilesInRange(std::unordered_set<int3> &, const int3 &, i
 	THROW_EDITOR_UNSUPPORTED;
 }
 
-void EditorCallback::getAllTiles(std::unordered_set<int3> &, std::optional<PlayerColor>, int, std::function<bool(const TerrainTile *)>) const
+void EditorCallback::getAllTiles(std::unordered_set<int3> &, std::optional<PlayerColor>, int, const std::function<bool(const TerrainTile *)> &) const
 {
 	THROW_EDITOR_UNSUPPORTED;
 }

+ 1 - 1
lib/callback/EditorCallback.h

@@ -40,7 +40,7 @@ public:
 	std::vector<const CGObjectInstance*> getGuardingCreatures(int3 pos) const override;
 
 	void getTilesInRange(std::unordered_set<int3> & tiles, const int3 & pos, int radius, ETileVisibility mode, std::optional<PlayerColor> player, int3::EDistanceFormula formula) const override;
-	void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter) const override;
+	void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, const std::function<bool(const TerrainTile *)> & filter) const override;
 
 	std::vector<ObjectInstanceID> getVisibleTeleportObjects(std::vector<ObjectInstanceID> ids, PlayerColor player) const override;
 	std::vector<ObjectInstanceID> getTeleportChannelEntrances(TeleportChannelID id, PlayerColor player) const override;

+ 1 - 1
lib/callback/IGameInfoCallback.h

@@ -152,7 +152,7 @@ public:
 	virtual void getTilesInRange(std::unordered_set<int3> & tiles, const int3 & pos, int radius, ETileVisibility mode, std::optional<PlayerColor> player = std::optional<PlayerColor>(), int3::EDistanceFormula formula = int3::DIST_2D) const = 0;
 
 	/// returns all tiles on given level (-1 - both levels, otherwise number of level)
-	virtual void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter) const = 0;
+	virtual void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, const std::function<bool(const TerrainTile *)> & filter) const = 0;
 
 	virtual std::vector<ObjectInstanceID> getVisibleTeleportObjects(std::vector<ObjectInstanceID> ids, PlayerColor player)  const  = 0;
 	virtual std::vector<ObjectInstanceID> getTeleportChannelEntrances(TeleportChannelID id, PlayerColor Player = PlayerColor::UNFLAGGABLE) const  = 0;

+ 2 - 2
lib/filesystem/MinizipExtensions.cpp

@@ -83,7 +83,7 @@ inline int streamProxyClose(voidpf opaque, voidpf stream)
 
 	actualStream->seek(0);
 
-    return 0;
+	return 0;
 }
 
 ///CDefaultIOApi
@@ -222,7 +222,7 @@ int ZCALLBACK CProxyIOApi::closeFileProxy(voidpf opaque, voidpf stream)
 
 int ZCALLBACK CProxyIOApi::errorFileProxy(voidpf opaque, voidpf stream)
 {
-    return 0;
+	return 0;
 }
 
 CInputOutputStream * CProxyIOApi::openFile(const boost::filesystem::path & filename, int mode)

+ 5 - 9
lib/mapObjects/army/CCreatureSet.cpp

@@ -332,14 +332,11 @@ ui64 CCreatureSet::getArmyStrength(int fortLevel) const
 	for(const auto & elem : stacks)
 	{
 		ui64 powerToAdd = elem.second->getPower();
-		if(fortLevel > 0)
+		if(fortLevel > 0 && !elem.second->hasBonusOfType(BonusType::FLYING))
 		{
-			if(!elem.second->hasBonusOfType(BonusType::FLYING))
-			{
+			powerToAdd /= fortLevel;
+			if(!elem.second->hasBonusOfType(BonusType::SHOOTER))
 				powerToAdd /= fortLevel;
-				if(!elem.second->hasBonusOfType(BonusType::SHOOTER))
-					powerToAdd /= fortLevel;
-			}
 		}
 		ret += powerToAdd;
 	}
@@ -365,12 +362,12 @@ std::string CCreatureSet::getRoughAmount(const SlotID & slot, int mode) const
 	/// "Pack" - 0, "A pack of" - 1, "a pack of" - 2
 	CCreature::CreatureQuantityId quantity = CCreature::getQuantityID(getStackCount(slot));
 
-	if((int)quantity)
+	if(static_cast<int>(quantity) != 0)
 	{
 		if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
 			return CCreature::getQuantityRangeStringForId(quantity);
 
-		return LIBRARY->generaltexth->arraytxt[(174 + mode) + 3 * (int)quantity];
+		return LIBRARY->generaltexth->arraytxt[(174 + mode) + 3 * static_cast<int>(quantity)];
 	}
 	return "";
 }
@@ -546,7 +543,6 @@ std::unique_ptr<CStackInstance> CCreatureSet::detachStack(const SlotID & slot)
 	assert(hasStackAtSlot(slot));
 	std::unique_ptr<CStackInstance> ret = std::move(stacks[slot]);
 
-	//if(CArmedInstance *armedObj = castToArmyObj())
 	if(ret)
 	{
 		ret->setArmy(nullptr); //detaches from current armyobj

+ 2 - 2
lib/mapObjects/army/CStackInstance.cpp

@@ -202,12 +202,12 @@ std::string CStackInstance::getQuantityTXT(bool capitalized) const
 {
 	CCreature::CreatureQuantityId quantity = getQuantityID();
 
-	if((int)quantity)
+	if(static_cast<int>(quantity))
 	{
 		if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
 			return CCreature::getQuantityRangeStringForId(quantity);
 
-		return LIBRARY->generaltexth->arraytxt[174 + (int)quantity * 3 - 1 - capitalized];
+		return LIBRARY->generaltexth->arraytxt[174 + static_cast<int>(quantity) * 3 - 1 - capitalized];
 	}
 	else
 		return "";

+ 14 - 14
lib/rmg/RmgPath.cpp

@@ -196,20 +196,20 @@ float Path::nonEuclideanCostFunction(const int3& src, const int3& dst, const int
 	float W = 10.0f;// width of the transition area
 	float A = 0.7f; // sine bias
 
-    // Euclidean distance:
-    float d = src.dist2d(dst);
-    
-    // Distance from dst to the zone center:
-    float r = dst.dist2d(center);
-    
-    // Compute normalized offset inside the zone:
-    // (R - W) is the inner edge, R is the outer edge.
-    float t = std::clamp((r - (R - W)) / W, 0.0f, 1.0f);
-    
-    // Use sine bias: lowest cost in the middle (t=0.5), higher near edges.
-    float bias = 1.0f + A * std::sin(M_PI * t);
-    
-    return d * bias;
+	// Euclidean distance:
+	float d = src.dist2d(dst);
+
+	// Distance from dst to the zone center:
+	float r = dst.dist2d(center);
+
+	// Compute normalized offset inside the zone:
+	// (R - W) is the inner edge, R is the outer edge.
+	float t = std::clamp((r - (R - W)) / W, 0.0f, 1.0f);
+
+	// Use sine bias: lowest cost in the middle (t=0.5), higher near edges.
+	float bias = 1.0f + A * std::sin(M_PI * t);
+
+	return d * bias;
 }
 
 Path::MoveCostFunction Path::createCurvedCostFunction(const Area & border)

+ 3 - 3
lib/rmg/modificators/PrisonHeroPlacer.cpp

@@ -41,7 +41,7 @@ void PrisonHeroPlacer::getAllowedHeroes()
 	// Call that only once
 	if (allowedHeroes.empty())
 	{
-    	allowedHeroes = generator.getAllPossibleHeroes();
+		allowedHeroes = generator.getAllPossibleHeroes();
 	}
 }
 
@@ -56,8 +56,8 @@ HeroTypeID PrisonHeroPlacer::drawRandomHero()
 	if (getPrisonsRemaining() > 0)
 	{
 		RandomGeneratorUtil::randomShuffle(allowedHeroes, zone.getRand());
-        HeroTypeID ret = allowedHeroes.back();
-        allowedHeroes.pop_back();
+		HeroTypeID ret = allowedHeroes.back();
+		allowedHeroes.pop_back();
 		return ret;
 	}
 	else

+ 0 - 10
lib/serializer/RegisterTypes.h

@@ -55,15 +55,6 @@ VCMI_LIB_NAMESPACE_BEGIN
 template<typename Serializer>
 void registerTypes(Serializer &s)
 {
-	static_assert(std::is_abstract_v<IObjectInterface>, "If this type is no longer abstract consider registering it for serialization with ID 1");
-	static_assert(std::is_abstract_v<CGTeleport>, "If this type is no longer abstract consider registering it for serialization with ID 3");
-	static_assert(std::is_abstract_v<IQuestObject>, "If this type is no longer abstract consider registering it for serialization with ID 11");
-	static_assert(std::is_abstract_v<CArtifactSet>, "If this type is no longer abstract consider registering it for serialization with ID 29");
-//	static_assert(std::is_abstract_v<CPackForClient>, "If this type is no longer abstract consider registering it for serialization with ID 83");
-//	static_assert(std::is_abstract_v<Query>, "If this type is no longer abstract consider registering it for serialization with ID 153");
-//	static_assert(std::is_abstract_v<CGarrisonOperationPack>, "If this type is no longer abstract consider registering it for serialization with ID 161");
-//	static_assert(std::is_abstract_v<CArtifactOperationPack>, "If this type is no longer abstract consider registering it for serialization with ID 168");
-
 	s.template registerType<CGObjectInstance>(2);
 	s.template registerType<CGMonolith>(4);
 	s.template registerType<CGSubterraneanGate>(5);
@@ -86,7 +77,6 @@ void registerTypes(Serializer &s)
 	s.template registerType<CGUniversity>(23);
 	s.template registerType<CGHeroPlaceholder>(24);
 	s.template registerType<CArmedInstance>(25);
-//	s.template registerType<CBonusSystemNode>(26);
 	s.template registerType<CCreatureSet>(27);
 	s.template registerType<CGHeroInstance>(28);
 	s.template registerType<CGDwelling>(30);

+ 2 - 2
lib/spells/ISpellMechanics.cpp

@@ -615,12 +615,12 @@ int64_t BaseMechanics::calculateRawEffectValue(int32_t basePowerMultiplier, int3
 
 bool BaseMechanics::ownerMatches(const battle::Unit * unit) const
 {
-    return ownerMatches(unit, owner->getPositiveness());
+	return ownerMatches(unit, owner->getPositiveness());
 }
 
 bool BaseMechanics::ownerMatches(const battle::Unit * unit, const boost::logic::tribool positivness) const
 {
-    return cb->battleMatchOwner(caster->getCasterOwner(), unit, positivness);
+	return cb->battleMatchOwner(caster->getCasterOwner(), unit, positivness);
 }
 
 IBattleCast::Value BaseMechanics::getEffectLevel() const

+ 2 - 2
lib/spells/effects/Sacrifice.cpp

@@ -109,9 +109,9 @@ void Sacrifice::apply(ServerCallback * server, const Mechanics * m, const Effect
 		return;
 	}
 
-    const battle::Unit * victim = target.back().unitValue;
+	const battle::Unit * victim = target.back().unitValue;
 
-    if(!victim)
+	if(!victim)
 	{
 		logGlobal->error("No unit to Sacrifice");
 		return;

+ 2 - 2
mapeditor/helper.cpp

@@ -145,9 +145,9 @@ void Helper::saveTemplate(std::map<std::string, std::shared_ptr<CRmgTemplate>> t
 	}
 	
 	auto byteData = JsonNode(data).toBytes();
-	QByteArray byteDataArray = QByteArray(reinterpret_cast<const char*>(byteData.data()), static_cast<int>(byteData.size()));
+	QByteArray byteDataArray(reinterpret_cast<const char*>(byteData.data()), static_cast<int>(byteData.size()));
 	QFile file(filename);
 
 	if(file.open(QIODevice::WriteOnly))
-    	file.write(byteDataArray);
+		file.write(byteDataArray);
 }

+ 107 - 105
mapeditor/templateeditor/GeometryAlgorithm.cpp

@@ -13,121 +13,123 @@
 
 double GeometryAlgorithm::distance(double x1, double y1, double x2, double y2)
 {
-    return std::sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)) + 1e-9;
+	return std::sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)) + 1e-9;
 }
 
 bool GeometryAlgorithm::edgesIntersect(const Node& a, const Node& b, const Node& c, const Node& d)
 {
-    auto cross = [](double x1, double y1, double x2, double y2) {
-        return x1 * y2 - y1 * x2;
-    };
+	auto cross = [](double x1, double y1, double x2, double y2) {
+		return x1 * y2 - y1 * x2;
+	};
 
-    double dx1 = b.x - a.x, dy1 = b.y - a.y;
-    double dx2 = d.x - c.x, dy2 = d.y - c.y;
+	double dx1 = b.x - a.x;
+	double dy1 = b.y - a.y;
+	double dx2 = d.x - c.x;
+	double dy2 = d.y - c.y;
 
-    double delta = cross(dx1, dy1, dx2, dy2);
-    if (std::abs(delta) < 1e-10) return false; // Parallel
+	double delta = cross(dx1, dy1, dx2, dy2);
+	if (std::abs(delta) < 1e-10) return false; // Parallel
 
-    // Compute intersection
-    double s = cross(c.x - a.x, c.y - a.y, dx2, dy2) / delta;
-    double t = cross(c.x - a.x, c.y - a.y, dx1, dy1) / delta;
+	// Compute intersection
+	double s = cross(c.x - a.x, c.y - a.y, dx2, dy2) / delta;
+	double t = cross(c.x - a.x, c.y - a.y, dx1, dy1) / delta;
 
-    return s > 0 && s < 1 && t > 0 && t < 1;
+	return s > 0 && s < 1 && t > 0 && t < 1;
 }
 
 void GeometryAlgorithm::forceDirectedLayout(std::vector<Node> & nodes, const std::vector<Edge> & edges, int iterations, double width, double height)
 {
-    const double area = width * height;
-    const double k = std::sqrt(area / nodes.size());
-
-    for (int it = 0; it < iterations; ++it)
-    {
-        // Reset forces
-        for (auto& node : nodes)
-            node.dx = node.dy = 0;
-
-        // Repulsive forces
-        for (size_t i = 0; i < nodes.size(); ++i)
-        {
-            for (size_t j = i + 1; j < nodes.size(); ++j)
-            {
-                double dx = nodes[i].x - nodes[j].x;
-                double dy = nodes[i].y - nodes[j].y;
-                double dist = distance(nodes[i].x, nodes[i].y, nodes[j].x, nodes[j].y);
-                double force = (k * k) / dist;
-
-                nodes[i].dx += (dx / dist) * force;
-                nodes[i].dy += (dy / dist) * force;
-                nodes[j].dx -= (dx / dist) * force;
-                nodes[j].dy -= (dy / dist) * force;
-            }
-        }
-
-        // Attractive forces
-        for (const auto& edge : edges)
-        {
-            Node& u = nodes[edge.from];
-            Node& v = nodes[edge.to];
-            double dx = u.x - v.x;
-            double dy = u.y - v.y;
-            double dist = distance(u.x, u.y, v.x, v.y);
-            double force = (dist * dist) / k;
-
-            double fx = (dx / dist) * force;
-            double fy = (dy / dist) * force;
-
-            u.dx -= fx;
-            u.dy -= fy;
-            v.dx += fx;
-            v.dy += fy;
-        }
-
-        // Edge crossing penalty
-        for (size_t i = 0; i < edges.size(); ++i) {
-            for (size_t j = i + 1; j < edges.size(); ++j) {
-                const Edge& e1 = edges[i];
-                const Edge& e2 = edges[j];
-
-                if (e1.from == e2.from || e1.from == e2.to ||
-                    e1.to == e2.from || e1.to == e2.to)
-                    continue; // Skip if they share nodes
-
-                Node& a = nodes[e1.from];
-                Node& b = nodes[e1.to];
-                Node& c = nodes[e2.from];
-                Node& d = nodes[e2.to];
-
-                if (edgesIntersect(a, b, c, d)) {
-                    double strength = 0.05;
-
-                    a.dx += strength * (a.x - c.x);
-                    a.dy += strength * (a.y - c.y);
-                    b.dx += strength * (b.x - d.x);
-                    b.dy += strength * (b.y - d.y);
-                    c.dx += strength * (c.x - a.x);
-                    c.dy += strength * (c.y - a.y);
-                    d.dx += strength * (d.x - b.x);
-                    d.dy += strength * (d.y - b.y);
-                }
-            }
-        }
-
-        // Apply displacement
-        for (auto& node : nodes)
-        {
-            node.x += std::max(-5.0, std::min(5.0, node.dx));
-            node.y += std::max(-5.0, std::min(5.0, node.dy));
-
-            // Keep within bounds
-            node.x = std::min(width, std::max(0.0, node.x));
-            node.y = std::min(height, std::max(0.0, node.y));
-        }
-    }
-
-    for (auto& node : nodes)
-    {
-        // Center around 0
-        node.x -= width / 2;
-        node.y -= height / 2;
-    }
+	const double area = width * height;
+	const double k = std::sqrt(area / nodes.size());
+
+	for (int it = 0; it < iterations; ++it)
+	{
+		// Reset forces
+		for (auto& node : nodes)
+			node.dx = node.dy = 0;
+
+		// Repulsive forces
+		for (size_t i = 0; i < nodes.size(); ++i)
+		{
+			for (size_t j = i + 1; j < nodes.size(); ++j)
+			{
+				double dx = nodes[i].x - nodes[j].x;
+				double dy = nodes[i].y - nodes[j].y;
+				double dist = distance(nodes[i].x, nodes[i].y, nodes[j].x, nodes[j].y);
+				double force = (k * k) / dist;
+
+				nodes[i].dx += (dx / dist) * force;
+				nodes[i].dy += (dy / dist) * force;
+				nodes[j].dx -= (dx / dist) * force;
+				nodes[j].dy -= (dy / dist) * force;
+			}
+		}
+
+		// Attractive forces
+		for (const auto& edge : edges)
+		{
+			Node& u = nodes[edge.from];
+			Node& v = nodes[edge.to];
+			double dx = u.x - v.x;
+			double dy = u.y - v.y;
+			double dist = distance(u.x, u.y, v.x, v.y);
+			double force = (dist * dist) / k;
+
+			double fx = (dx / dist) * force;
+			double fy = (dy / dist) * force;
+
+			u.dx -= fx;
+			u.dy -= fy;
+			v.dx += fx;
+			v.dy += fy;
+		}
+
+		// Edge crossing penalty
+		for (size_t i = 0; i < edges.size(); ++i) {
+			for (size_t j = i + 1; j < edges.size(); ++j) {
+				const Edge& e1 = edges[i];
+				const Edge& e2 = edges[j];
+
+				if (e1.from == e2.from || e1.from == e2.to ||
+				   e1.to == e2.from || e1.to == e2.to)
+					continue; // Skip if they share nodes
+
+				Node& a = nodes[e1.from];
+				Node& b = nodes[e1.to];
+				Node& c = nodes[e2.from];
+				Node& d = nodes[e2.to];
+
+				if (edgesIntersect(a, b, c, d)) {
+					double strength = 0.05;
+
+					a.dx += strength * (a.x - c.x);
+					a.dy += strength * (a.y - c.y);
+					b.dx += strength * (b.x - d.x);
+					b.dy += strength * (b.y - d.y);
+					c.dx += strength * (c.x - a.x);
+					c.dy += strength * (c.y - a.y);
+					d.dx += strength * (d.x - b.x);
+					d.dy += strength * (d.y - b.y);
+				}
+			}
+		}
+
+		// Apply displacement
+		for (auto& node : nodes)
+		{
+			node.x += std::max(-5.0, std::min(5.0, node.dx));
+			node.y += std::max(-5.0, std::min(5.0, node.dy));
+
+			// Keep within bounds
+			node.x = std::min(width, std::max(0.0, node.x));
+			node.y = std::min(height, std::max(0.0, node.y));
+		}
+	}
+
+	for (auto& node : nodes)
+	{
+		// Center around 0
+		node.x -= width / 2;
+		node.y -= height / 2;
+	}
 }

+ 16 - 15
mapeditor/templateeditor/GeometryAlgorithm.h

@@ -9,24 +9,25 @@
  */
 #pragma once
 
-#include "../StdInc.h"
-
 class GeometryAlgorithm
 {
 public:
-    struct Node
-    {
-        double x, y;
-        double dx = 0, dy = 0;
-        int id;
-    };
+	struct Node
+	{
+		double x;
+		double y;
+		double dx = 0;
+		double dy = 0;
+		int id;
+	};
 
-    struct Edge
-    {
-        int from, to;
-    };
+	struct Edge
+	{
+		int from;
+		int to;
+	};
 
-    static double distance(double x1, double y1, double x2, double y2);
-    static bool edgesIntersect(const Node& a, const Node& b, const Node& c, const Node& d);
-    static void forceDirectedLayout(std::vector<Node>& nodes, const std::vector<Edge>& edges, int iterations, double width, double height);
+	static double distance(double x1, double y1, double x2, double y2);
+	static bool edgesIntersect(const Node& a, const Node& b, const Node& c, const Node& d);
+	static void forceDirectedLayout(std::vector<Node>& nodes, const std::vector<Edge>& edges, int iterations, double width, double height);
 };

+ 3 - 3
mapeditor/templateeditor/factionselector.cpp

@@ -55,10 +55,10 @@ void FactionSelector::on_buttonBoxResult_accepted()
 			factionsSelected.insert(FactionID(item->data(Qt::UserRole).toInt()));
 	}
 
-    close();
+	close();
 }
 
 void FactionSelector::on_buttonBoxResult_rejected()
 {
-    close();
-}
+	close();
+}

+ 5 - 5
mapeditor/templateeditor/graphicelements/CardItem.cpp

@@ -41,12 +41,12 @@ QDomElement CardItem::getElementById(const QDomDocument& doc, const QString& id)
 
 bool isBlackTextNeeded(const QColor& bg)
 {
-    int r = bg.red();
-    int g = bg.green();
-    int b = bg.blue();
+	int r = bg.red();
+	int g = bg.green();
+	int b = bg.blue();
 
-    double luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
-    return luminance > 0.5;
+	double luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
+	return luminance > 0.5;
 }
 
 CardItem::CardItem():

+ 6 - 6
mapeditor/templateeditor/mineselector.cpp

@@ -35,12 +35,12 @@ MineSelector::MineSelector(std::map<TResource, ui16> & mines) :
 	{
 		auto name = LIBRARY->generaltexth->translate(TextIdentifier("core.restypes", resources[row].getNum()).get());
 		auto label = new QLabel(QString::fromStdString(name));
-        label->setAlignment(Qt::AlignCenter);
+		label->setAlignment(Qt::AlignCenter);
 		ui->tableWidgetMines->setCellWidget(row, 0, label);
 
 		auto spinBox = new QSpinBox();
-        spinBox->setRange(0, 100);
-        spinBox->setValue(mines[resources[row]]);
+		spinBox->setRange(0, 100);
+		spinBox->setValue(mines[resources[row]]);
 		ui->tableWidgetMines->setCellWidget(row, 1, spinBox);
 	}
 	ui->tableWidgetMines->resizeColumnsToContents();
@@ -60,10 +60,10 @@ void MineSelector::on_buttonBoxResult_accepted()
 	for (int row = 0; row < resources.size(); ++row)
 		minesSelected[resources[row]] = static_cast<QSpinBox *>(ui->tableWidgetMines->cellWidget(row, 1))->value();
 
-    close();
+	close();
 }
 
 void MineSelector::on_buttonBoxResult_rejected()
 {
-    close();
-}
+	close();
+}

+ 4 - 4
mapeditor/templateeditor/templateeditor.cpp

@@ -339,8 +339,8 @@ void TemplateEditor::loadZoneMenuContent(bool onlyPosition)
 	ui->comboBoxZoneType->addItem(tr("Water"), QVariant(static_cast<int>(ETemplateZoneType::WATER)));
 	ui->comboBoxZoneType->addItem(tr("Sealed"), QVariant(static_cast<int>(ETemplateZoneType::SEALED)));
 	for (int i = 0; i < ui->comboBoxZoneType->count(); ++i)
-    	if (ui->comboBoxZoneType->itemData(i).toInt() == static_cast<int>(zone->getType()))
-        	ui->comboBoxZoneType->setCurrentIndex(i);
+		if (ui->comboBoxZoneType->itemData(i).toInt() == static_cast<int>(zone->getType()))
+			ui->comboBoxZoneType->setCurrentIndex(i);
 
 	ui->comboBoxZoneOwner->clear();
 	auto type = static_cast<ETemplateZoneType>(ui->comboBoxZoneType->currentData().toInt());
@@ -370,8 +370,8 @@ void TemplateEditor::loadZoneMenuContent(bool onlyPosition)
 	ui->comboBoxMonsterStrength->addItem(tr("Normal"), QVariant(static_cast<int>(EMonsterStrength::EMonsterStrength::ZONE_NORMAL)));
 	ui->comboBoxMonsterStrength->addItem(tr("Strong"), QVariant(static_cast<int>(EMonsterStrength::EMonsterStrength::ZONE_STRONG)));
 	for (int i = 0; i < ui->comboBoxMonsterStrength->count(); ++i)
-    	if (ui->comboBoxMonsterStrength->itemData(i).toInt() == static_cast<int>(zone->monsterStrength))
-        	ui->comboBoxMonsterStrength->setCurrentIndex(i);
+		if (ui->comboBoxMonsterStrength->itemData(i).toInt() == static_cast<int>(zone->monsterStrength))
+			ui->comboBoxMonsterStrength->setCurrentIndex(i);
 }
 
 void TemplateEditor::loadZoneConnectionMenuContent()

+ 3 - 3
mapeditor/templateeditor/terrainselector.cpp

@@ -55,10 +55,10 @@ void TerrainSelector::on_buttonBoxResult_accepted()
 			terrainsSelected.insert(item->data(Qt::UserRole).toInt());
 	}
 
-    close();
+	close();
 }
 
 void TerrainSelector::on_buttonBoxResult_rejected()
 {
-    close();
-}
+	close();
+}

+ 9 - 9
mapeditor/templateeditor/treasureselector.cpp

@@ -33,18 +33,18 @@ TreasureSelector::TreasureSelector(std::vector<CTreasureInfo> & treasures) :
 
 	auto addRow = [this](int min, int max, int density, int row){
 		auto spinBoxMin = new QSpinBox();
-        spinBoxMin->setRange(0, 1000000);
-        spinBoxMin->setValue(min);
+		spinBoxMin->setRange(0, 1000000);
+		spinBoxMin->setValue(min);
 		ui->tableWidgetTreasures->setCellWidget(row, 0, spinBoxMin);
 
 		auto spinBoxMax = new QSpinBox();
-        spinBoxMax->setRange(0, 1000000);
-        spinBoxMax->setValue(max);
+		spinBoxMax->setRange(0, 1000000);
+		spinBoxMax->setValue(max);
 		ui->tableWidgetTreasures->setCellWidget(row, 1, spinBoxMax);
 
 		auto spinBoxDensity = new QSpinBox();
-        spinBoxDensity->setRange(0, 1000);
-        spinBoxDensity->setValue(density);
+		spinBoxDensity->setRange(0, 1000);
+		spinBoxDensity->setValue(density);
 		ui->tableWidgetTreasures->setCellWidget(row, 2, spinBoxDensity);
 
 		auto deleteButton = new QPushButton("Delete");
@@ -93,10 +93,10 @@ void TreasureSelector::on_buttonBoxResult_accepted()
 		treasures.push_back(info);
 	}
 
-    close();
+	close();
 }
 
 void TreasureSelector::on_buttonBoxResult_rejected()
 {
-    close();
-}
+	close();
+}

+ 17 - 19
scripting/lua/api/BonusSystem.cpp

@@ -235,29 +235,27 @@ int BonusBearerProxy::getBonuses(lua_State * L)
 	TConstBonusListPtr ret;
 
 	const bool hasSelector = S.isFunction(2);
-	const bool hasRangeSelector = S.isFunction(3);
+	//const bool hasRangeSelector = S.isFunction(3);
 
 	if(hasSelector)
 	{
-		auto selector = [](const Bonus * b)
-		{
-			return false; //TODO: BonusBearerProxy::getBonuses selector
-		};
-
-		if(hasRangeSelector)
-		{
-			//TODO: BonusBearerProxy::getBonuses rangeSelector
-			//auto rangeSelector = [](const Bonus * b)
-			//{
-			//	return false;
-			//};
-
-			ret = object->getBonuses(selector);
-		}
-		else
-		{
+		//if(hasRangeSelector)
+		//{
+		//	//TODO: BonusBearerProxy::getBonuses rangeSelector
+		//	auto rangeSelector = [](const Bonus * b)
+		//	{
+		//		return false;
+		//	};
+		//	ret = object->getBonuses(rangeSelector);
+		//}
+		//else
+		//{
+			auto selector = [](const Bonus * b)
+			{
+				return false; //TODO: BonusBearerProxy::getBonuses selector
+			};
 			ret = object->getBonuses(selector);
-		}
+		//}
 	}
 	else
 	{

+ 1 - 1
test/mock/mock_IGameInfoCallback.h

@@ -67,7 +67,7 @@ public:
 	MOCK_CONST_METHOD2(getTileDigStatus, EDiggingStatus(int3 tile, bool verbose));
 	MOCK_CONST_METHOD1(calculatePaths, void(const std::shared_ptr<PathfinderConfig> & config));
 	MOCK_CONST_METHOD6(getTilesInRange, void( std::unordered_set<int3> & tiles, const int3 & pos, int radius, ETileVisibility mode, std::optional<PlayerColor> player, int3::EDistanceFormula formula));
-	MOCK_CONST_METHOD4(getAllTiles, void(std::unordered_set<int3> & tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter));
+	MOCK_CONST_METHOD4(getAllTiles, void(std::unordered_set<int3> & tiles, std::optional<PlayerColor> player, int level, const std::function<bool(const TerrainTile *)> & filter));
 	MOCK_CONST_METHOD2(getVisibleTeleportObjects, std::vector<ObjectInstanceID>(std::vector<ObjectInstanceID> ids, PlayerColor player));
 	MOCK_CONST_METHOD2(getTeleportChannelEntrances, std::vector<ObjectInstanceID>(TeleportChannelID id, PlayerColor Player));
 	MOCK_CONST_METHOD2(getTeleportChannelExits, std::vector<ObjectInstanceID>(TeleportChannelID id, PlayerColor Player));