Forráskód Böngészése

Merge branch 'develop' into battleonly

Laserlicht 1 hónapja
szülő
commit
c202d44179

+ 1 - 1
.github/workflows/aab-from-build.yml

@@ -42,7 +42,7 @@ jobs:
         echo "ANDROID_AAB_PATH=$ANDROID_AAB_PATH" >> $GITHUB_ENV
 
     - name: Artifact
-      uses: actions/upload-artifact@v4
+      uses: actions/upload-artifact@v5
       with:
         name: aab
         compression-level: 0

+ 10 - 10
.github/workflows/github.yml

@@ -332,7 +332,7 @@ jobs:
 
     - name: Upload Artifact
       id: upload_artifact
-      uses: actions/upload-artifact@v4
+      uses: actions/upload-artifact@v5
       with:
         name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
         compression-level: 9
@@ -342,7 +342,7 @@ jobs:
     - name: Upload AAB Artifact
       id: upload_aab
       if: ${{ startsWith(matrix.platform, 'android') && github.ref == 'refs/heads/master' }}
-      uses: actions/upload-artifact@v4
+      uses: actions/upload-artifact@v5
       with:
         name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - aab
         compression-level: 9
@@ -352,7 +352,7 @@ jobs:
     - name: Upload debug symbols
       id: upload_symbols
       if: ${{ startsWith(matrix.platform, 'msvc') }}
-      uses: actions/upload-artifact@v4
+      uses: actions/upload-artifact@v5
       with:
         name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - symbols
         compression-level: 9
@@ -381,7 +381,7 @@ jobs:
         python3 CI/emit_partial.py
 
     - name: Upload partial JSON with build informations
-      uses: actions/upload-artifact@v4
+      uses: actions/upload-artifact@v5
       with:
         name: partial-json-${{ matrix.platform }}
         path: .summary/${{ matrix.platform }}.json
@@ -412,7 +412,7 @@ jobs:
 
         - name: Upload source code archive
           id: upload_source
-          uses: actions/upload-artifact@v4
+          uses: actions/upload-artifact@v5
           with:
             name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
             compression-level: 9
@@ -428,7 +428,7 @@ jobs:
             JSON
 
         - name: Upload partial JSON with source informations
-          uses: actions/upload-artifact@v4
+          uses: actions/upload-artifact@v5
           with:
             name: partial-json-source
             path: .summary/source.json
@@ -615,7 +615,7 @@ jobs:
         PULL_REQUEST: ${{ github.event.pull_request.number }}
 
     - name: Download Artifact
-      uses: actions/download-artifact@v5
+      uses: actions/download-artifact@v6
       with:
         name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
         path: ${{github.workspace}}/artifact
@@ -645,7 +645,7 @@ jobs:
 
     - name: Upload VCMI Installer Artifacts
       id: upload_installer
-      uses: actions/upload-artifact@v4
+      uses: actions/upload-artifact@v5
       with:
         name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - installer
         compression-level: 9
@@ -673,7 +673,7 @@ jobs:
         JSON
 
     - name: Upload partial JSON with installer informations
-      uses: actions/upload-artifact@v4
+      uses: actions/upload-artifact@v5
       with:
         name: partial-json-${{ matrix.platform }}-installer
         path: .summary/installer-${{ matrix.platform }}.json
@@ -720,7 +720,7 @@ jobs:
 
       - name: Download all partial JSON artifacts
         continue-on-error: true
-        uses: actions/download-artifact@v5
+        uses: actions/download-artifact@v6
         with:
           pattern: partial-json-*
           merge-multiple: true

+ 19 - 3
CI/wininstaller/installer.iss

@@ -166,12 +166,12 @@ Source: "{#UCRTFilesPath}\{#InstallerArch}\*"; DestDir: "{app}"; Flags: ignoreve
 
 
 [Icons]
-Name: "{group}\{cm:ShortcutLauncher}"; Filename: "{app}\VCMI_launcher.exe"; Comment: "{cm:ShortcutLauncherComment}";  Tasks: startmenu
-Name: "{group}\{cm:ShortcutMapEditor}"; Filename: "{app}\VCMI_mapeditor.exe"; Comment: "{cm:ShortcutMapEditorComment}";  Tasks: startmenu
+Name: "{group}\{cm:ShortcutLauncher}{code:GetBranchSuffix}"; Filename: "{app}\VCMI_launcher.exe"; Comment: "{cm:ShortcutLauncherComment}{code:GetBranchSuffix}";  Tasks: startmenu
+Name: "{group}\{cm:ShortcutMapEditor}{code:GetBranchSuffix}"; Filename: "{app}\VCMI_mapeditor.exe"; Comment: "{cm:ShortcutMapEditorComment}{code:GetBranchSuffix}";  Tasks: startmenu
 Name: "{group}\{cm:ShortcutWebPage}"; Filename: "{#VCMIHome}"; Comment: "{cm:ShortcutWebPageComment}";  Tasks: startmenu
 Name: "{group}\{cm:ShortcutDiscord}"; Filename: "{#VCMIContact}"; Comment: "{cm:ShortcutDiscordComment}";  Tasks: startmenu
 
-Name: "{code:GetUserDesktopFolder}\{cm:ShortcutLauncher}"; Filename: "{app}\VCMI_launcher.exe"; Comment: "{cm:ShortcutLauncherComment}"; Tasks: desktop
+Name: "{code:GetUserDesktopFolder}\{cm:ShortcutLauncher}{code:GetBranchSuffix}"; Filename: "{app}\VCMI_launcher.exe"; Comment: "{cm:ShortcutLauncherComment}{code:GetBranchSuffix}"; Tasks: desktop
 
 
 [Tasks]
@@ -371,6 +371,22 @@ begin
 end;
 
 
+function GetBranchSuffix(Param: string): string;
+var
+  Branch: string;
+begin
+  Branch := UpperCase(ExpandConstant('{#VCMIFolder}'));
+
+  if Pos('(BRANCH BETA)', Branch) > 0 then
+    Result := ' (Beta)'
+  else
+  if Pos('(BRANCH DEVELOP)', Branch) > 0 then
+    Result := ' (Develop)'
+  else
+    Result := '';
+end;
+
+
 function GetCommonProgramFilesDir: String;
 begin
   if IsARM64 then

+ 22 - 22
CMakePresets.json

@@ -462,19 +462,19 @@
             "inherits": "default-release"
         },
         {
-        	"name": "windows-msvc-ninja-release",
-        	"configurePreset": "windows-msvc-ninja-release",
-        	"inherits": "default-release"
+            "name": "windows-msvc-ninja-release",
+            "configurePreset": "windows-msvc-ninja-release",
+            "inherits": "default-release"
         },
         {
-        	"name": "windows-msvc-ninja-release-x86",
-        	"configurePreset": "windows-msvc-ninja-release-x86",
-        	"inherits": "default-release"
+            "name": "windows-msvc-ninja-release-x86",
+            "configurePreset": "windows-msvc-ninja-release-x86",
+            "inherits": "default-release"
         },
         {
-        	"name": "windows-msvc-ninja-release-arm64",
-        	"configurePreset": "windows-msvc-ninja-release-arm64",
-        	"inherits": "default-release"
+            "name": "windows-msvc-ninja-release-arm64",
+            "configurePreset": "windows-msvc-ninja-release-arm64",
+            "inherits": "default-release"
         },
         {
             "name": "ios-release-conan",
@@ -518,34 +518,34 @@
             }
         },
         {
-          "name": "linux-clang-release",
-          "configurePreset": "linux-clang-release",
-          "inherits": "default-release"
+            "name": "linux-clang-debug",
+            "configurePreset": "linux-clang-debug",
+            "inherits": "default-release"
         },
         {
-            "name": "linux-gcc-release",
-            "configurePreset": "linux-gcc-release",
+            "name": "linux-clang-release",
+            "configurePreset": "linux-clang-release",
             "inherits": "default-release"
         },
         {
-            "name": "linux-clang-debug",
+            "name": "linux-clang-test",
             "configurePreset": "linux-clang-test",
             "inherits": "default-release"
         },
         {
             "name": "linux-gcc-debug",
-            "configurePreset": "linux-gcc-test",
+            "configurePreset": "linux-gcc-debug",
             "inherits": "default-release"
         },
         {
-          "name": "linux-gcc-test",
-          "configurePreset": "linux-gcc-test",
-          "inherits": "default-release"
+            "name": "linux-gcc-release",
+            "configurePreset": "linux-gcc-release",
+            "inherits": "default-release"
         },
         {
-          "name": "linux-clang-test",
-          "configurePreset": "linux-clang-test",
-          "inherits": "default-release"
+            "name": "linux-gcc-test",
+            "configurePreset": "linux-gcc-test",
+            "inherits": "default-release"
         },
         {
             "name": "macos-xcode-release",

+ 2 - 2
client/ClientCommandManager.cpp

@@ -239,7 +239,7 @@ void ClientCommandManager::handleTranslateMapsCommand()
 		try
 		{
 			// load and drop loaded map - we only need loader to run over all maps
-			loadedMaps.push_back(mapService.loadMap(mapName, nullptr));
+			loadedMaps.push_back(mapService.loadMap(mapName, GAME->interface()->cb.get()));
 		}
 		catch(std::exception & e)
 		{
@@ -260,7 +260,7 @@ void ClientCommandManager::handleTranslateMapsCommand()
 		{
 			loadedCampaigns.push_back(CampaignHandler::getCampaign(campaignName.getName()));
 			for (auto const & part : loadedCampaigns.back()->allScenarios())
-				loadedCampaigns.back()->getMap(part, nullptr);
+				loadedCampaigns.back()->getMap(part, GAME->interface()->cb.get());
 		}
 		catch(std::exception & e)
 		{

+ 1 - 0
client/mapView/IMapRendererContext.h

@@ -99,6 +99,7 @@ public:
 	virtual bool showGrid() const = 0;
 	virtual bool showVisitable() const = 0;
 	virtual bool showBlocked() const = 0;
+	virtual bool showInvisible() const = 0;
 
 	/// if true, spell range for teleport / scuttle boat will be visible
 	virtual bool showSpellRange(const int3 & position) const = 0;

+ 20 - 2
client/mapView/MapRenderer.cpp

@@ -14,6 +14,10 @@
 #include "IMapRendererContext.h"
 #include "mapHandler.h"
 
+#include "../CPlayerInterface.h"
+#include "../CServerHandler.h"
+#include "../GameInstance.h"
+#include "../Client.h"
 #include "../GameEngine.h"
 #include "../render/CAnimation.h"
 #include "../render/Canvas.h"
@@ -23,12 +27,15 @@
 #include "../render/Graphics.h"
 
 #include "../../lib/CConfigHandler.h"
+#include "../../lib/callback/CCallback.h"
+#include "../../lib/gameState/CGameState.h"
 #include "../../lib/RiverHandler.h"
 #include "../../lib/RoadHandler.h"
 #include "../../lib/TerrainHandler.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/MiscObjects.h"
 #include "../../lib/mapObjects/ObjectTemplate.h"
+#include "../../lib/mapping/CMap.h"
 #include "../../lib/mapping/TerrainTile.h"
 #include "../../lib/pathfinder/CGPathNode.h"
 
@@ -592,8 +599,10 @@ MapRendererOverlay::MapRendererOverlay()
 	, imageBlocked(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/blocked"), EImageBlitMode::COLORKEY))
 	, imageVisitable(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/visitable"), EImageBlitMode::COLORKEY))
 	, imageSpellRange(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/spellRange"), EImageBlitMode::COLORKEY))
+	, imageEvent(ENGINE->renderHandler().loadAnimation(AnimationPath::builtin("AVZevnt0"), EImageBlitMode::COLORKEY)->getImage(0))
+	, imageGrail(ENGINE->renderHandler().loadAnimation(AnimationPath::builtin("AVZgrail"), EImageBlitMode::COLORKEY)->getImage(0))
+	, grailPos(GAME->server().client->gameState().getMap().grailPos)
 {
-
 }
 
 void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & target, const int3 & coordinates)
@@ -601,7 +610,7 @@ void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & targ
 	if(context.showGrid())
 		target.draw(imageGrid, Point(0,0));
 
-	if(context.showVisitable() || context.showBlocked())
+	if(GAME->interface()->cb->getStartInfo()->extraOptionsInfo.cheatsAllowed && (context.showVisitable() || context.showBlocked() || context.showInvisible()))
 	{
 		bool blocking = false;
 		bool visitable = false;
@@ -610,6 +619,12 @@ void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & targ
 		{
 			const auto * object = context.getObject(objectID);
 
+			if(object->ID == Obj::EVENT && context.showInvisible())
+				target.draw(imageEvent, Point(0,0));
+			
+			if(grailPos == coordinates && context.showInvisible())
+				target.draw(imageGrail, Point(0,0));
+
 			if(context.objectTransparency(objectID, coordinates) > 0 && !context.isActiveHero(object))
 			{
 				visitable |= object->visitableAt(coordinates);
@@ -643,6 +658,9 @@ uint8_t MapRendererOverlay::checksum(IMapRendererContext & context, const int3 &
 	if (context.showSpellRange(coordinates))
 		result += 8;
 
+	if (context.showInvisible())
+		result += 16;
+
 	return result;
 }
 

+ 5 - 1
client/mapView/MapRenderer.h

@@ -9,11 +9,11 @@
  */
 #pragma once
 
+#include "../../lib/int3.h"
 #include "../../lib/filesystem/ResourcePath.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 
-class int3;
 class ObjectInstanceID;
 class CGObjectInstance;
 
@@ -139,6 +139,10 @@ class MapRendererOverlay
 	std::shared_ptr<IImage> imageVisitable;
 	std::shared_ptr<IImage> imageBlocked;
 	std::shared_ptr<IImage> imageSpellRange;
+	std::shared_ptr<IImage> imageEvent;
+	std::shared_ptr<IImage> imageGrail;
+
+	int3 grailPos;
 public:
 	MapRendererOverlay();
 

+ 10 - 0
client/mapView/MapRendererContext.cpp

@@ -232,6 +232,11 @@ bool MapRendererBaseContext::showBlocked() const
 	return false;
 }
 
+bool MapRendererBaseContext::showInvisible() const
+{
+	return false;
+}
+
 bool MapRendererBaseContext::showSpellRange(const int3 & position) const
 {
 	return false;
@@ -362,6 +367,11 @@ bool MapRendererAdventureContext::showBlocked() const
 	return settingShowBlocked;
 }
 
+bool MapRendererAdventureContext::showInvisible() const
+{
+	return settingShowInvisible;
+}
+
 bool MapRendererAdventureContext::showTextOverlay() const
 {
 	return settingTextOverlay;

+ 3 - 0
client/mapView/MapRendererContext.h

@@ -62,6 +62,7 @@ public:
 	bool showGrid() const override;
 	bool showVisitable() const override;
 	bool showBlocked() const override;
+	bool showInvisible() const override;
 	bool showSpellRange(const int3 & position) const override;
 };
 
@@ -72,6 +73,7 @@ public:
 	bool settingShowGrid = false;
 	bool settingShowVisitable = false;
 	bool settingShowBlocked = false;
+	bool settingShowInvisible = false;
 	bool settingTextOverlay = false;
 	bool settingsAdventureObjectAnimation = true;
 	bool settingsAdventureTerrainAnimation = true;
@@ -88,6 +90,7 @@ public:
 	bool showGrid() const override;
 	bool showVisitable() const override;
 	bool showBlocked() const override;
+	bool showInvisible() const override;
 	bool showTextOverlay() const override;
 
 	bool showSpellRange(const int3 & position) const override;

+ 1 - 0
client/mapView/MapViewController.cpp

@@ -233,6 +233,7 @@ void MapViewController::updateState()
 		adventureContext->settingShowGrid = settings["gameTweaks"]["showGrid"].Bool();
 		adventureContext->settingShowVisitable = settings["session"]["showVisitable"].Bool();
 		adventureContext->settingShowBlocked = settings["session"]["showBlocked"].Bool();
+		adventureContext->settingShowInvisible = settings["session"]["showInvisible"].Bool();
 		adventureContext->settingTextOverlay = (ENGINE->isKeyboardAltDown() || ENGINE->input().getNumTouchFingers() == 2) && settings["general"]["enableOverlay"].Bool();
 	}
 }

+ 14 - 19
client/windows/GUIClasses.cpp

@@ -1598,7 +1598,7 @@ CObjectListWindow::CObjectListWindow(const std::vector<int> & _items, std::share
 	for(int id : _items)
 	{
 		std::string objectName = GAME->interface()->cb->getObjInstance(ObjectInstanceID(id))->getObjectName();
-		trimTextIfTooWide(objectName);
+		trimTextIfTooWide(objectName, false);
 		items.emplace_back(id, objectName);
 	}
 	itemsVisible = items;
@@ -1622,7 +1622,7 @@ CObjectListWindow::CObjectListWindow(const std::vector<std::string> & _items, st
 	for(size_t i = 0; i < _items.size(); i++)
 	{
 		std::string objectName = _items[i];
-		trimTextIfTooWide(objectName);
+		trimTextIfTooWide(objectName, true);
 		items.emplace_back(static_cast<int>(i), objectName);
 	}
 	itemsVisible = items;
@@ -1666,29 +1666,24 @@ void CObjectListWindow::init(std::shared_ptr<CIntObject> titleWidget_, std::stri
 	searchBox->setCallback(std::bind(&CObjectListWindow::itemsSearchCallback, this, std::placeholders::_1));
 }
 
-void CObjectListWindow::trimTextIfTooWide(std::string & text) const
+void CObjectListWindow::trimTextIfTooWide(std::string & text, bool preserveCountSuffix) const
 {
+	std::string suffix = "...";
 	int maxWidth = pos.w - 60;	// 60 px for scrollbar and borders
-	auto posBrace = text.find('(');
-	auto posClosing = text.find(')');
 
-	std::string objCount;
-	if (posBrace != std::string::npos && posClosing != std::string::npos && posClosing > posBrace)
-	{
-		objCount = text.substr(posBrace, posClosing - posBrace) + ')';
-		if(text.size() > 0 && text[0] == '{')
-			objCount = '}' + objCount;
-	}
-	else
+	if(text[0] == '{')
+		suffix += "}";
+
+	if (preserveCountSuffix)
 	{
-		// fallback: if text starts with '{', keep a trailing '}' token, otherwise empty
-		if(text.size() > 0 && text[0] == '{')
-			objCount = "}";
-		else
-			objCount.clear();
+		auto posBrace = text.find_last_of("(");
+		auto posClosing = text.find_last_of(")");
+		std::string objCount = text.substr(posBrace, posClosing - posBrace) + ')';
+		suffix += " ";
+		suffix += objCount;
 	}
+
 	const auto & font = ENGINE->renderHandler().loadFont(FONT_SMALL);
-	std::string suffix = objCount.empty() ? "..." : std::string("... ") + objCount;
 
 	if(font->getStringWidth(text) >= maxWidth)
 	{

+ 1 - 1
client/windows/GUIClasses.h

@@ -206,7 +206,7 @@ class CObjectListWindow : public CWindowObject
 	std::vector< std::pair<int, std::string> > itemsVisible; //visible items present in list
 
 	void init(std::shared_ptr<CIntObject> titleWidget_, std::string _title, std::string _descr, bool searchBoxEnabled, bool blue);
-	void trimTextIfTooWide(std::string & text) const; // trim item's text to fit within window's width
+	void trimTextIfTooWide(std::string & text, bool preserveCountSuffix) const; // trim item's text to fit within window's width
 	void itemsSearchCallback(const std::string & text);
 	void exitPressed();
 public:

+ 12 - 1
docs/modders/Entities_Format/Hero_Type_Format.md

@@ -130,10 +130,21 @@ In order to make functional hero you also need:
 			"anotherOne" : {Bonus Format}
 		},
 		// Shortcut for defining creature specialty, using standard H3 rules
+		// Can be combined with bonuses-based specialty if desired
 		"creature" : "griffin",
 
 		// Shortcut for defining specialty in secondary skill, using standard H3 rules
-		"secondary" : "offence"
+		// Can be combined with bonuses-based specialty if desired
+		"secondary" : "offence",
+		
+		// Optional, only applicable to creature specialties
+		// Overrides creature level to specific value for purposes of computing growth of h3-like creature specialty
+		"creatureLevel" : 5
+		
+		// Optional, only applicable to creature and secondary skill specialties
+		// Overrides default (5% for vanilla H3 specialties) growth of specialties per level to a specified value
+		// Default value can be modified globally using specialtySecondarySkillGrowth and specialtyCreatureGrowth game settings
+		"stepSize" : 5
 	}
 }
 ```

+ 11 - 8
docs/players/Cheat_Codes.md

@@ -162,16 +162,19 @@ Below a list of supported commands, with their arguments wrapped in `<>`
 
 #### Settings
 
-- `set <command> <on/off>` - sets special temporary settings that reset on game quit. Below some of the most notable commands:  
-- `autoskip` - identical to `autoskip` option  
-- `onlyAI` - run without human player, all players will be *default AI*  
-- `headless` - run without GUI, implies `onlyAI` is set  
-- `showGrid` - display a square grid overlay on top of adventure map  
-- `showBlocked` - show blocked tiles on map  
-- `showVisitable` - show visitable tiles on map  
-- `hideSystemMessages` - suppress server messages in chat  
+- `set <command> <on/off>` - sets special temporary settings that reset on game quit. Below some of the most notable commands:
+- `autoskip` - identical to `autoskip` option
+- `onlyAI` - run without human player, all players will be *default AI*
+- `headless` - run without GUI, implies `onlyAI` is set
+- `showGrid` - display a square grid overlay on top of adventure map
+- `showBlocked` - show blocked tiles on map
+- `showVisitable` - show visitable tiles on map
+- `showInvisible` - show invisible tiles (events, grail) on map
+- `hideSystemMessages` - suppress server messages in chat
 - `antilag` - toggles network lag compensation in multiplayer on or off
 
+`showBlocked`, `showVisitable` and `showInvisible` only works if cheats are enabled.
+
 #### Developer Commands
 
 - `crash` - force a game crash. It is sometimes useful to generate memory dump file in certain situations, for example game freeze  

+ 1 - 1
lib/mapObjects/ObjectTemplate.cpp

@@ -66,7 +66,7 @@ void ObjectTemplate::afterLoadFixup()
 	if(id == Obj::EVENT)
 	{
 		setSize(1,1);
-		usedTiles[0][0] = VISITABLE;
+		usedTiles[0][0] = VISITABLE | VISIBLE;
 		visitDir = 0xFF;
 	}
 }

+ 1 - 1
lib/mapping/CMapOperation.cpp

@@ -311,7 +311,7 @@ void CDrawTerrainOperation::updateTerrainViews()
 		if(!pattern.diffImages)
 		{
 			tile.terView = gen->nextInt(mapping.first, mapping.second);
-			tile.extTileFlags = valRslt.flip;
+			tile.extTileFlags = (tile.extTileFlags & 0b11111100) | valRslt.flip;
 		}
 		else
 		{

+ 6 - 0
lib/mapping/MapFormatH3M.cpp

@@ -1100,6 +1100,8 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
 			SpellID scrollSpell = reader->readSpell16();
 			if (grantedArtifact == ArtifactID::SPELL_SCROLL)
 				reward.grantedScrolls.push_back(scrollSpell);
+			else
+				reward.grantedArtifacts.push_back(grantedArtifact);
 		}
 		else
 			reward.grantedArtifacts.push_back(grantedArtifact);
@@ -2306,6 +2308,8 @@ void CMapLoaderH3M::readSeerHutQuest(CGSeerHut * hut, const int3 & position, con
 					SpellID scrollSpell = reader->readSpell16();
 					if (grantedArtifact == ArtifactID::SPELL_SCROLL)
 						reward.grantedScrolls.push_back(scrollSpell);
+					else
+						reward.grantedArtifacts.push_back(grantedArtifact);
 				}
 				else
 					reward.grantedArtifacts.push_back(grantedArtifact);
@@ -2381,6 +2385,8 @@ EQuestMission CMapLoaderH3M::readQuest(IQuestObject * guard, const int3 & positi
 					SpellID scrollSpell = reader->readSpell16();
 					if (requiredArtifact == ArtifactID::SPELL_SCROLL)
 						guard->getQuest().mission.scrolls.push_back(scrollSpell);
+					else
+						guard->getQuest().mission.artifacts.push_back(requiredArtifact);
 				}
 				else
 					guard->getQuest().mission.artifacts.push_back(requiredArtifact);

+ 2 - 2
lib/spells/adventure/TownPortalEffect.cpp

@@ -140,7 +140,7 @@ void TownPortalEffect::endCast(SpellCastEnvironment * env, const AdventureSpellC
 {
 	const CGTownInstance * destination = nullptr;
 
-	if(parameters.caster->getSpellSchoolLevel(owner) < 2)
+	if(!allowTownSelection)
 	{
 		std::vector<const CGTownInstance *> pool = getPossibleTowns(env, parameters);
 		destination = findNearestTown(env, parameters, pool);
@@ -194,7 +194,7 @@ ESpellCastResult TownPortalEffect::beginCast(SpellCastEnvironment * env, const A
 		return ESpellCastResult::CANCEL;
 	}
 
-	if(!parameters.pos.isValid() && parameters.caster->getSpellSchoolLevel(owner) >= 2)
+	if(!parameters.pos.isValid() && allowTownSelection)
 	{
 		auto queryCallback = [&mechanics, env, parameters](std::optional<int32_t> reply) -> void
 		{

+ 8 - 2
server/CGameHandler.cpp

@@ -3894,8 +3894,14 @@ void CGameHandler::castSpell(const spells::Caster * caster, SpellID spellID, con
 	const CSpell * s = spellID.toSpell();
 	s->adventureCast(spellEnv.get(), p);
 
-	if(const auto * hero = caster->getHeroCaster())
-		useChargeBasedSpell(hero->id, spellID);
+	// FIXME: hack to avoid attempts to use charges when spell is casted externally
+	// For example, town gates map object in hota/wog
+	// Proper fix would be to instead spend charges similar to existing caster::spendMana call
+	if (dynamic_cast<const spells::ExternalCaster*>(caster) == nullptr)
+	{
+		if(const auto * hero = caster->getHeroCaster())
+			useChargeBasedSpell(hero->id, spellID);
+	}
 }
 
 bool CGameHandler::swapStacks(const StackLocation & sl1, const StackLocation & sl2)

+ 4 - 0
test/bonus/BonusSystemTest.cpp

@@ -189,6 +189,8 @@ TEST_F(BonusSystemTest, battlewidePropagationToAll)
 
 	EXPECT_TRUE(heroAine.hasBonusOfType(BonusType::BLOCK_ALL_MAGIC));
 	EXPECT_TRUE(heroBron.hasBonusOfType(BonusType::BLOCK_ALL_MAGIC));
+
+	heroAine.detachFromSource(orb);
 }
 
 TEST_F(BonusSystemTest, battlewidePropagationToEnemies)
@@ -297,6 +299,8 @@ TEST_F(BonusSystemTest, legionPieces)
 
 	heroAine.detachFrom(townAndVisitor);
 	EXPECT_EQ(town.valOfBonuses(BonusType::CREATURE_GROWTH, BonusCustomSubtype::creatureLevel(3)), 0);
+
+	heroAine.detachFromSource(legion);
 }
 
 }

+ 6 - 4
test/events/ApplyDamageTest.cpp

@@ -22,9 +22,11 @@ namespace test
 using namespace ::testing;
 using namespace ::events;
 
-class ListenerMock
+class ApplyDamageListenerMock
 {
 public:
+	virtual ~ApplyDamageListenerMock() = default;
+
 	MOCK_METHOD1(beforeEvent, void(ApplyDamage &));
 	MOCK_METHOD1(afterEvent, void(const ApplyDamage &));
 };
@@ -33,7 +35,7 @@ class ApplyDamageTest : public Test
 {
 public:
 	EventBus eventBus;
-	ListenerMock listener;
+	ApplyDamageListenerMock listener;
 	StrictMock<EnvironmentMock> environmentMock;
 
 	std::shared_ptr<StrictMock<UnitMock>> targetMock;
@@ -47,8 +49,8 @@ protected:
 //this should be the only subscription test for events, just in case cross-binary subscription breaks
 TEST_F(ApplyDamageTest, Subscription)
 {
-	auto subscription1 = eventBus.subscribeBefore<ApplyDamage>(std::bind(&ListenerMock::beforeEvent, &listener, _1));
-	auto subscription2 = eventBus.subscribeAfter<ApplyDamage>(std::bind(&ListenerMock::afterEvent, &listener, _1));
+	auto subscription1 = eventBus.subscribeBefore<ApplyDamage>(std::bind(&ApplyDamageListenerMock::beforeEvent, &listener, _1));
+	auto subscription2 = eventBus.subscribeAfter<ApplyDamage>(std::bind(&ApplyDamageListenerMock::afterEvent, &listener, _1));
 
 	EXPECT_CALL(listener, beforeEvent(_)).Times(1);
 	EXPECT_CALL(listener, afterEvent(_)).Times(1);

+ 23 - 21
test/events/EventBusTest.cpp

@@ -35,9 +35,11 @@ public:
 	friend class SubscriptionRegistry<EventExample>;
 };
 
-class ListenerMock
+class EventBusListenerMock
 {
 public:
+	virtual ~EventBusListenerMock() = default;
+
 	MOCK_METHOD1(beforeEvent, void(EventExample &));
 	MOCK_METHOD1(onEvent, void(EventExample &));
 	MOCK_METHOD1(afterEvent, void(const EventExample &));
@@ -51,9 +53,9 @@ public:
 	EventBus subject1;
 	EventBus subject2;
 
-	StrictMock<ListenerMock> listener;
-	StrictMock<ListenerMock> listener1;
-	StrictMock<ListenerMock> listener2;
+	StrictMock<EventBusListenerMock> listener;
+	StrictMock<EventBusListenerMock> listener1;
+	StrictMock<EventBusListenerMock> listener2;
 };
 
 TEST_F(EventBusTest, ExecuteNoListeners)
@@ -67,15 +69,15 @@ TEST_F(EventBusTest, ExecuteNoListenersWithHandler)
 	EXPECT_CALL(event1, isEnabled()).WillRepeatedly(Return(true));
 	EXPECT_CALL(listener, onEvent(Ref(event1))).Times(1);
 
-	subject1.executeEvent(event1, std::bind(&ListenerMock::onEvent, &listener, _1));
+	subject1.executeEvent(event1, std::bind(&EventBusListenerMock::onEvent, &listener, _1));
 }
 
 TEST_F(EventBusTest, ExecuteIgnoredSubscription)
 {
 	EXPECT_CALL(event1, isEnabled()).WillRepeatedly(Return(true));
 
-	subject1.subscribeBefore<EventExample>(std::bind(&ListenerMock::beforeEvent, &listener, _1));
-	subject1.subscribeAfter<EventExample>(std::bind(&ListenerMock::afterEvent, &listener, _1));
+	subject1.subscribeBefore<EventExample>(std::bind(&EventBusListenerMock::beforeEvent, &listener, _1));
+	subject1.subscribeAfter<EventExample>(std::bind(&EventBusListenerMock::afterEvent, &listener, _1));
 
 	EXPECT_CALL(listener, beforeEvent(_)).Times(0);
 	EXPECT_CALL(listener, afterEvent(_)).Times(0);
@@ -87,10 +89,10 @@ TEST_F(EventBusTest, ExecuteSequence)
 {
 	EXPECT_CALL(event1, isEnabled()).WillRepeatedly(Return(true));
 
-	auto subscription1 = subject1.subscribeBefore<EventExample>(std::bind(&ListenerMock::beforeEvent, &listener1, _1));
-	auto subscription2 = subject1.subscribeAfter<EventExample>(std::bind(&ListenerMock::afterEvent, &listener1, _1));
-	auto subscription3 = subject1.subscribeBefore<EventExample>(std::bind(&ListenerMock::beforeEvent, &listener2, _1));
-	auto subscription4 = subject1.subscribeAfter<EventExample>(std::bind(&ListenerMock::afterEvent, &listener2, _1));
+	auto subscription1 = subject1.subscribeBefore<EventExample>(std::bind(&EventBusListenerMock::beforeEvent, &listener1, _1));
+	auto subscription2 = subject1.subscribeAfter<EventExample>(std::bind(&EventBusListenerMock::afterEvent, &listener1, _1));
+	auto subscription3 = subject1.subscribeBefore<EventExample>(std::bind(&EventBusListenerMock::beforeEvent, &listener2, _1));
+	auto subscription4 = subject1.subscribeAfter<EventExample>(std::bind(&EventBusListenerMock::afterEvent, &listener2, _1));
 
 	{
 		InSequence sequence;
@@ -101,17 +103,17 @@ TEST_F(EventBusTest, ExecuteSequence)
 		EXPECT_CALL(listener2, afterEvent(Ref(event1))).Times(1);
 	}
 
-	subject1.executeEvent(event1, std::bind(&ListenerMock::onEvent, &listener, _1));
+	subject1.executeEvent(event1, std::bind(&EventBusListenerMock::onEvent, &listener, _1));
 }
 
 TEST_F(EventBusTest, BusesAreIndependent)
 {
 	EXPECT_CALL(event1, isEnabled()).WillRepeatedly(Return(true));
 
-	auto subscription1 = subject1.subscribeBefore<EventExample>(std::bind(&ListenerMock::beforeEvent, &listener1, _1));
-	auto subscription2 = subject1.subscribeAfter<EventExample>(std::bind(&ListenerMock::afterEvent, &listener1, _1));
-	auto subscription3 = subject2.subscribeBefore<EventExample>(std::bind(&ListenerMock::beforeEvent, &listener2, _1));
-	auto subscription4 = subject2.subscribeAfter<EventExample>(std::bind(&ListenerMock::afterEvent, &listener2, _1));
+	auto subscription1 = subject1.subscribeBefore<EventExample>(std::bind(&EventBusListenerMock::beforeEvent, &listener1, _1));
+	auto subscription2 = subject1.subscribeAfter<EventExample>(std::bind(&EventBusListenerMock::afterEvent, &listener1, _1));
+	auto subscription3 = subject2.subscribeBefore<EventExample>(std::bind(&EventBusListenerMock::beforeEvent, &listener2, _1));
+	auto subscription4 = subject2.subscribeAfter<EventExample>(std::bind(&EventBusListenerMock::afterEvent, &listener2, _1));
 
 	EXPECT_CALL(listener1, beforeEvent(_)).Times(1);
 	EXPECT_CALL(listener2, beforeEvent(_)).Times(0);
@@ -125,7 +127,7 @@ TEST_F(EventBusTest, DisabledTestDontExecute)
 {
 	EXPECT_CALL(event1, isEnabled()).Times(AtLeast(1)).WillRepeatedly(Return(false));
 	EXPECT_CALL(listener, onEvent(Ref(event1))).Times(0);
-	subject1.executeEvent(event1, std::bind(&ListenerMock::onEvent, &listener, _1));
+	subject1.executeEvent(event1, std::bind(&EventBusListenerMock::onEvent, &listener, _1));
 }
 
 TEST_F(EventBusTest, DisabledTestDontExecutePostHandler)
@@ -134,10 +136,10 @@ TEST_F(EventBusTest, DisabledTestDontExecutePostHandler)
 	EXPECT_CALL(listener, onEvent(Ref(event1))).WillRepeatedly(Return());
 	EXPECT_CALL(listener1, afterEvent(Ref(event1))).Times(0);
 
-	auto subscription1 = subject1.subscribeAfter<EventExample>(std::bind(&ListenerMock::afterEvent, &listener1, _1));
+	auto subscription1 = subject1.subscribeAfter<EventExample>(std::bind(&EventBusListenerMock::afterEvent, &listener1, _1));
 
 
-	subject1.executeEvent(event1, std::bind(&ListenerMock::onEvent, &listener, _1));
+	subject1.executeEvent(event1, std::bind(&EventBusListenerMock::onEvent, &listener, _1));
 }
 
 TEST_F(EventBusTest, DisabledTestExecutePreHandler)
@@ -146,9 +148,9 @@ TEST_F(EventBusTest, DisabledTestExecutePreHandler)
 	EXPECT_CALL(listener, onEvent(Ref(event1))).WillRepeatedly(Return());
 	EXPECT_CALL(listener1, beforeEvent(Ref(event1))).Times(1);
 
-	auto subscription1 = subject1.subscribeBefore<EventExample>(std::bind(&ListenerMock::beforeEvent, &listener1, _1));
+	auto subscription1 = subject1.subscribeBefore<EventExample>(std::bind(&EventBusListenerMock::beforeEvent, &listener1, _1));
 
-	subject1.executeEvent(event1, std::bind(&ListenerMock::onEvent, &listener, _1));
+	subject1.executeEvent(event1, std::bind(&EventBusListenerMock::onEvent, &listener, _1));
 }