diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a2bcaa32..67cf9bf8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/client/BattleInterface/CBattleInterface.cpp b/client/BattleInterface/CBattleInterface.cpp index e6a52383a..35537e792 100644 --- a/client/BattleInterface/CBattleInterface.cpp +++ b/client/BattleInterface/CBattleInterface.cpp @@ -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; } } diff --git a/lib/CGeneralTextHandler.cpp b/lib/CGeneralTextHandler.cpp index 5298621d7..1aa162eb0 100644 --- a/lib/CGeneralTextHandler.cpp +++ b/lib/CGeneralTextHandler.cpp @@ -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()); diff --git a/lib/Filesystem/CFilesystemLoader.cpp b/lib/Filesystem/CFilesystemLoader.cpp index c5cdbfa5c..87cada10b 100644 --- a/lib/Filesystem/CFilesystemLoader.cpp +++ b/lib/Filesystem/CFilesystemLoader.cpp @@ -52,6 +52,13 @@ bool CFilesystemLoader::createEntry(std::string filename) boost::unordered_map CFilesystemLoader::listFiles(size_t depth, bool initial) const { + std::set 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 fileList; @@ -75,7 +82,7 @@ boost::unordered_map 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; diff --git a/lib/Filesystem/CResourceLoader.cpp b/lib/Filesystem/CResourceLoader.cpp index 64274e8d6..ccc45f3cb 100644 --- a/lib/Filesystem/CResourceLoader.cpp +++ b/lib/Filesystem/CResourceLoader.cpp @@ -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(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(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(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(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"; diff --git a/lib/Filesystem/CResourceLoader.h b/lib/Filesystem/CResourceLoader.h index c9f88e255..fc159d7de 100644 --- a/lib/Filesystem/CResourceLoader.h +++ b/lib/Filesystem/CResourceLoader.h @@ -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(resourceIdent.getType())); } -// namespace std -// { -// /** -// * Template specialization for std::hash. -// */ -// template <> -// class hash -// { -// 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()(resourceIdent.getName()) ^ hash()(static_cast(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 diff --git a/vcmimanual.tex b/vcmimanual.tex index 22102847c..7a8f40541 100644 --- a/vcmimanual.tex +++ b/vcmimanual.tex @@ -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}