mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	- fixed seer hut issue (#1073)
- separate archive types in filesystem for lod\vid\snd
This commit is contained in:
		| @@ -36,7 +36,7 @@ if(CMAKE_CXX_COMPILER MATCHES ".*clang") | ||||
| endif() | ||||
|  | ||||
| if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) | ||||
|     set(CMAKE_CXX_FLAGS "-std=c++0x -Wall -Wextra -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wno-overloaded-virtual") | ||||
|     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wno-overloaded-virtual") | ||||
| endif() | ||||
|  | ||||
| #define required constants | ||||
|   | ||||
| @@ -3411,11 +3411,10 @@ SDL_Surface * CBattleInterface::imageOfObstacle(const CObstacleInstance &oi) con | ||||
| 				return vstd::circularAt(smallForceField[forceField.casterSide]->ourImages, frameIndex).bitmap; | ||||
| 		} | ||||
|  | ||||
| 	case CObstacleInstance::MOAT: | ||||
| 		//moat is blitted by SiegeHelper, this shouldn't be called | ||||
| 		assert(0); | ||||
| 	case CObstacleInstance::MOAT://moat is blitted by SiegeHelper, this shouldn't be called | ||||
| 	default: | ||||
| 		assert(0); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -338,8 +338,7 @@ void CGeneralTextHandler::load() | ||||
|  | ||||
| 		//skip header | ||||
| 		parser.endLine(); | ||||
|  | ||||
| 		while (parser.endLine()); | ||||
| 		parser.endLine(); | ||||
|  | ||||
| 		for (int i = 0; i < 6; ++i) | ||||
| 			seerEmpty.push_back(parser.readString()); | ||||
|   | ||||
| @@ -52,6 +52,13 @@ bool CFilesystemLoader::createEntry(std::string filename) | ||||
|  | ||||
| boost::unordered_map<ResourceID, std::string> CFilesystemLoader::listFiles(size_t depth, bool initial) const | ||||
| { | ||||
| 	std::set<EResType::Type> initialTypes; | ||||
| 	initialTypes.insert(EResType::DIRECTORY); | ||||
| 	initialTypes.insert(EResType::TEXT); | ||||
| 	initialTypes.insert(EResType::ARCHIVE_LOD); | ||||
| 	initialTypes.insert(EResType::ARCHIVE_VID); | ||||
| 	initialTypes.insert(EResType::ARCHIVE_SND); | ||||
|  | ||||
| 	assert(boost::filesystem::is_directory(baseDirectory)); | ||||
| 	boost::unordered_map<ResourceID, std::string> fileList; | ||||
|  | ||||
| @@ -75,7 +82,7 @@ boost::unordered_map<ResourceID, std::string> CFilesystemLoader::listFiles(size_ | ||||
| 		else | ||||
| 			type = EResTypeHelper::getTypeFromExtension(boost::filesystem::extension(*it)); | ||||
|  | ||||
| 		if (!initial || type == EResType::DIRECTORY || type == EResType::ARCHIVE || type == EResType::TEXT) | ||||
| 		if (!initial || vstd::contains(initialTypes, type)) | ||||
| 		{ | ||||
| 			//reconstruct relative filename (not possible via boost AFAIK) | ||||
| 			std::string filename; | ||||
|   | ||||
| @@ -244,10 +244,10 @@ EResType::Type EResTypeHelper::getTypeFromExtension(std::string extension) | ||||
| 			(".MPG",   EResType::VIDEO) | ||||
| 	        (".MP3",   EResType::MUSIC) | ||||
| 	        (".OGG",   EResType::MUSIC) | ||||
| 	        (".LOD",   EResType::ARCHIVE) | ||||
| 	        (".PAC",   EResType::ARCHIVE) | ||||
| 	        (".VID",   EResType::ARCHIVE) | ||||
| 	        (".SND",   EResType::ARCHIVE) | ||||
| 	        (".LOD",   EResType::ARCHIVE_LOD) | ||||
| 	        (".PAC",   EResType::ARCHIVE_LOD) | ||||
| 	        (".VID",   EResType::ARCHIVE_VID) | ||||
| 	        (".SND",   EResType::ARCHIVE_SND) | ||||
| 	        (".PAL",   EResType::PALETTE) | ||||
| 	        (".VCGM1", EResType::CLIENT_SAVEGAME) | ||||
| 	        (".VLGM1", EResType::LIB_SAVEGAME) | ||||
| @@ -274,7 +274,9 @@ std::string EResTypeHelper::getEResTypeAsString(EResType::Type type) | ||||
| 		MAP_ENUM(VIDEO) | ||||
| 		MAP_ENUM(SOUND) | ||||
| 		MAP_ENUM(MUSIC) | ||||
| 		MAP_ENUM(ARCHIVE) | ||||
| 		MAP_ENUM(ARCHIVE_LOD) | ||||
| 		MAP_ENUM(ARCHIVE_SND) | ||||
| 		MAP_ENUM(ARCHIVE_VID) | ||||
| 		MAP_ENUM(PALETTE) | ||||
| 		MAP_ENUM(CLIENT_SAVEGAME) | ||||
| 		MAP_ENUM(LIB_SAVEGAME) | ||||
| @@ -333,6 +335,33 @@ void CResourceHandler::initialize() | ||||
| 	recurseInDir("ALL/MODS", 2); // look for mods. Depth 2 is required for now but won't cause issues if no mods present | ||||
| } | ||||
|  | ||||
| void CResourceHandler::loadDirectory(const std::string mountPoint, const JsonNode & config) | ||||
| { | ||||
| 	std::string URI = config["path"].String(); | ||||
| 	bool writeable = config["writeable"].Bool(); | ||||
| 	int depth = 16; | ||||
| 	if (!config["depth"].isNull()) | ||||
| 		depth = config["depth"].Float(); | ||||
|  | ||||
| 	auto resources = initialLoader->getResourcesWithName(ResourceID(URI, EResType::DIRECTORY)); | ||||
|  | ||||
| 	BOOST_FOREACH(const ResourceLocator & entry, resources) | ||||
| 	{ | ||||
| 		std::string filename = entry.getLoader()->getOrigin() + '/' + entry.getResourceName(); | ||||
| 		resourceLoader->addLoader(mountPoint, | ||||
| 		    shared_ptr<ISimpleResourceLoader>(new CFilesystemLoader(filename, depth)), writeable); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CResourceHandler::loadArchive(const std::string mountPoint, const JsonNode & config, EResType::Type archiveType) | ||||
| { | ||||
| 	std::string URI = config["path"].String(); | ||||
| 	std::string filename = initialLoader->getResourceName(ResourceID(URI, archiveType)); | ||||
| 	if (!filename.empty()) | ||||
| 		resourceLoader->addLoader(mountPoint, | ||||
| 		    shared_ptr<ISimpleResourceLoader>(new CLodArchiveLoader(filename)), false); | ||||
| } | ||||
|  | ||||
| void CResourceHandler::loadFileSystem(const std::string fsConfigURI) | ||||
| { | ||||
| 	auto fsConfigData = initialLoader->loadData(ResourceID(fsConfigURI, EResType::TEXT)); | ||||
| @@ -346,30 +375,20 @@ void CResourceHandler::loadFileSystem(const std::string fsConfigURI) | ||||
| 			CStopWatch timer; | ||||
| 			tlog5 << "\t\tLoading resource at " << entry["path"].String(); | ||||
|  | ||||
| 			std::string URI = entry["path"].String(); | ||||
| 			if (entry["type"].String() == "dir") | ||||
| 				loadDirectory(mountPoint.first, entry); | ||||
| 			if (entry["type"].String() == "lod") | ||||
| 				loadArchive(mountPoint.first, entry, EResType::ARCHIVE_LOD); | ||||
| 			if (entry["type"].String() == "snd") | ||||
| 				loadArchive(mountPoint.first, entry, EResType::ARCHIVE_SND); | ||||
| 			if (entry["type"].String() == "vid") | ||||
| 				loadArchive(mountPoint.first, entry, EResType::ARCHIVE_VID); | ||||
|  | ||||
| 			if (entry["type"].String() == "file") // for some compatibility, will be removed for 0.90 | ||||
| 			{ | ||||
| 				bool writeable = entry["writeable"].Bool(); | ||||
| 				int depth = 16; | ||||
| 				if (!entry["depth"].isNull()) | ||||
| 					depth = entry["depth"].Float(); | ||||
|  | ||||
| 				auto resources = initialLoader->getResourcesWithName(ResourceID(URI, EResType::DIRECTORY)); | ||||
|  | ||||
| 				BOOST_FOREACH(const ResourceLocator & entry, resources) | ||||
| 				{ | ||||
| 					std::string filename = entry.getLoader()->getOrigin() + '/' + entry.getResourceName(); | ||||
| 					resourceLoader->addLoader(mountPoint.first, | ||||
| 					    shared_ptr<ISimpleResourceLoader>(new CFilesystemLoader(filename, depth)), writeable); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if (entry["type"].String() == "file") | ||||
| 			{ | ||||
| 				std::string filename = initialLoader->getResourceName(ResourceID(URI, EResType::ARCHIVE)); | ||||
| 				if (!filename.empty()) | ||||
| 					resourceLoader->addLoader(mountPoint.first, | ||||
| 					    shared_ptr<ISimpleResourceLoader>(new CLodArchiveLoader(filename)), false); | ||||
| 				loadArchive(mountPoint.first, entry, EResType::ARCHIVE_LOD); | ||||
| 				loadArchive(mountPoint.first, entry, EResType::ARCHIVE_SND); | ||||
| 				loadArchive(mountPoint.first, entry, EResType::ARCHIVE_VID); | ||||
| 			} | ||||
|  | ||||
| 			tlog5 << " took " << timer.getDiff() << " ms.\n"; | ||||
|   | ||||
| @@ -16,6 +16,7 @@ | ||||
| class CResourceLoader; | ||||
| class ResourceLocator; | ||||
| class ISimpleResourceLoader; | ||||
| class JsonNode; | ||||
|  | ||||
| /** | ||||
|  * Specifies the resource type. | ||||
| @@ -50,7 +51,9 @@ namespace EResType | ||||
| 		VIDEO, | ||||
| 		SOUND, | ||||
| 		MUSIC, | ||||
| 		ARCHIVE, | ||||
| 		ARCHIVE_VID, | ||||
| 		ARCHIVE_SND, | ||||
| 		ARCHIVE_LOD, | ||||
| 		PALETTE, | ||||
| 		CLIENT_SAVEGAME, | ||||
| 		LIB_SAVEGAME, | ||||
| @@ -187,28 +190,6 @@ inline size_t hash_value(const ResourceID & resourceIdent) | ||||
| 	return stringHasher(resourceIdent.getName()) ^ intHasher(static_cast<int>(resourceIdent.getType())); | ||||
| } | ||||
|  | ||||
| // namespace std | ||||
| // { | ||||
| // 	/** | ||||
| // 	 * Template specialization for std::hash. | ||||
| // 	 */ | ||||
| // 	template <> | ||||
| // 	class hash<ResourceID> | ||||
| // 	{ | ||||
| // public: | ||||
| // 		/** | ||||
| // 		 * Generates a hash value for the resource identifier object. | ||||
| // 		 * | ||||
| // 		 * @param resourceIdent The object from which a hash value should be generated. | ||||
| // 		 * @return the generated hash value | ||||
| // 		 */ | ||||
| // 		size_t operator()(const ResourceID & resourceIdent) const | ||||
| // 		{ | ||||
| // 			return hash<string>()(resourceIdent.getName()) ^ hash<int>()(static_cast<int>(resourceIdent.getType())); | ||||
| // 		} | ||||
| // 	}; | ||||
| // }; | ||||
|  | ||||
| /** | ||||
|  * This class manages the loading of resources whether standard | ||||
|  * or derived from several container formats and the file system. | ||||
| @@ -396,6 +377,8 @@ public: | ||||
| 	 * Will load all filesystem data from Json data at this path (config/filesystem.json) | ||||
| 	 */ | ||||
| 	static void loadFileSystem(const std::string fsConfigURI); | ||||
| 	static void loadDirectory(const std::string mountPoint, const JsonNode & config); | ||||
| 	static void loadArchive(const std::string mountPoint, const JsonNode & config, EResType::Type archiveType); | ||||
|  | ||||
| 	/** | ||||
| 	 * Experimental. Checks all subfolders of MODS directory for presence of ERA-style mods | ||||
|   | ||||
| @@ -48,7 +48,7 @@ VCMI supports resolutions higher than original 800x600. Namely these are: | ||||
| \item 1920x1080 | ||||
| \end{itemize} | ||||
| Switching resolution may not only change visible area of map, but also alters some interface features such as \hyperref[Stack_Queue]{Stack Queue.}\\ | ||||
| To change resolution or full screen mode use interactive "settings" menu when in game. Changes in resolution will take place when you restart VCMI. \\ | ||||
| To change resolution or full screen mode use System Options menu when in game. Changes in resolution will take place when you restart VCMI. \\ | ||||
| Fullscreen mode can be toggled anytime using F4 hotkey. | ||||
| \end{itemize} | ||||
| \label{Mods} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user