diff --git a/lib/CArtHandler.h b/lib/CArtHandler.h index 38266a81f..0efb2f4be 100644 --- a/lib/CArtHandler.h +++ b/lib/CArtHandler.h @@ -80,7 +80,7 @@ public: h & static_cast(*this); h & name & description & eventText & image & large & advMapDef & iconIndex & price & possibleSlots & constituents & constituentOf & aClass & id; - if(version>=756) + if(version>=759) { h & identifier; } diff --git a/lib/CCreatureHandler.h b/lib/CCreatureHandler.h index b97878a1c..acec549fe 100644 --- a/lib/CCreatureHandler.h +++ b/lib/CCreatureHandler.h @@ -138,7 +138,7 @@ public: h & idNumber & faction & sounds & animation; h & doubleWide & special; - if(version>=756) + if(version>=759) { h & identifier; } diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index ef037e9fd..9adf94ba4 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -92,10 +92,10 @@ public: h & ID & imageIndex & initialArmy & heroClass & secSkillsInit & spec & specialty & spells & haveSpellBook & sex & special; h & name & biography & specName & specDescr & specTooltip; h & iconSpecSmall & iconSpecLarge & portraitSmall & portraitLarge; - if(version>=756) + if(version>=759) { h & identifier; - } + } } }; diff --git a/lib/Connection.h b/lib/Connection.h index 11ff7fede..dedc6dc69 100644 --- a/lib/Connection.h +++ b/lib/Connection.h @@ -27,7 +27,7 @@ #include "mapping/CCampaignHandler.h" //for CCampaignState #include "rmg/CMapGenerator.h" // for CMapGenOptions -const ui32 version = 758; +const ui32 version = 759; const ui32 minSupportedVersion = 753; class CISer; diff --git a/lib/filesystem/CFileInputStream.cpp b/lib/filesystem/CFileInputStream.cpp index dcec9e76a..b95fe4f51 100644 --- a/lib/filesystem/CFileInputStream.cpp +++ b/lib/filesystem/CFileInputStream.cpp @@ -21,7 +21,21 @@ CFileInputStream::CFileInputStream(const boost::filesystem::path & file, si64 st } CFileInputStream::CFileInputStream(const CFileInfo & file, si64 start, si64 size) - : CFileInputStream{file.getName(), start, size} {} + : dataStart{start}, + dataSize{size}, + fileStream{file.getName(), std::ios::in | std::ios::binary} +{ + if (fileStream.fail()) + throw std::runtime_error("File " + file.getName() + " isn't available."); + + if (dataSize == 0) + { + fileStream.seekg(0, std::ios::end); + dataSize = tell(); + } + + fileStream.seekg(dataStart, std::ios::beg); +} si64 CFileInputStream::read(ui8 * data, si64 size) { diff --git a/lib/filesystem/CZipLoader.cpp b/lib/filesystem/CZipLoader.cpp index d95b8f99b..86e6cacdb 100644 --- a/lib/filesystem/CZipLoader.cpp +++ b/lib/filesystem/CZipLoader.cpp @@ -14,12 +14,12 @@ * */ -CZipStream::CZipStream(const boost::filesystem::path & archive, unz64_file_pos filepos) +CZipStream::CZipStream(std::shared_ptr api, const boost::filesystem::path & archive, unz64_file_pos filepos) { zlib_filefunc64_def zlibApi; - + zlibApi = api->getApiStructure(); - + file = unzOpen2_64(archive.c_str(), &zlibApi); unzGoToFilePos64(file, &filepos); unzOpenCurrentFile(file); @@ -53,7 +53,7 @@ ui32 CZipStream::calculateCRC32() ///CZipLoader CZipLoader::CZipLoader(const std::string & mountPoint, const boost::filesystem::path & archive, std::shared_ptr api): ioApi(api), - zlibApi(ioApi->getApiStructure()), + zlibApi(ioApi->getApiStructure()), archiveName(archive), mountPoint(mountPoint), files(listFiles(mountPoint, archive)) @@ -66,7 +66,7 @@ std::unordered_map CZipLoader::listFiles(const std:: std::unordered_map ret; unzFile file = unzOpen2_64(archive.c_str(), &zlibApi); - + if(file == nullptr) logGlobal->errorStream() << archive << " failed to open"; @@ -95,7 +95,7 @@ std::unordered_map CZipLoader::listFiles(const std:: std::unique_ptr CZipLoader::load(const ResourceID & resourceName) const { - return std::unique_ptr(new CZipStream(ioApi, archiveName, files.at(resourceName))); + return std::unique_ptr(new CZipStream(ioApi, archiveName, files.at(resourceName))); } bool CZipLoader::existsResource(const ResourceID & resourceName) const diff --git a/lib/filesystem/CZipLoader.h b/lib/filesystem/CZipLoader.h index 372a99e1d..a81745a47 100644 --- a/lib/filesystem/CZipLoader.h +++ b/lib/filesystem/CZipLoader.h @@ -28,7 +28,7 @@ public: * @param archive path to archive to open * @param filepos position of file to open */ - CZipStream(std::shared_ptr api, const boost::filesystem::path & archive, unz_file_pos filepos); + CZipStream(std::shared_ptr api, const boost::filesystem::path & archive, unz64_file_pos filepos); ~CZipStream(); si64 getSize() override; diff --git a/lib/mapObjects/CObjectClassesHandler.h b/lib/mapObjects/CObjectClassesHandler.h index 6e88fdb7c..9c7279b2f 100644 --- a/lib/mapObjects/CObjectClassesHandler.h +++ b/lib/mapObjects/CObjectClassesHandler.h @@ -159,7 +159,7 @@ public: template void serialize(Handler &h, const int version) { h & type & subtype & templates & rmgInfo & objectName; - if(version >= 756) + if(version >= 759) { h & typeName & subTypeName; } @@ -186,7 +186,7 @@ class DLL_LINKAGE CObjectClassesHandler : public IHandlerBase template void serialize(Handler &h, const int version) { h & name & handlerName & base & subObjects; - if(version >= 756) + if(version >= 759) { h & identifier & subIds; } diff --git a/lib/mapObjects/CObjectHandler.h b/lib/mapObjects/CObjectHandler.h index 4c350f9f4..12fe7eda6 100644 --- a/lib/mapObjects/CObjectHandler.h +++ b/lib/mapObjects/CObjectHandler.h @@ -179,7 +179,7 @@ public: h & pos & ID & subID & id & tempOwner & blockVisit & appearance; //definfo is handled by map serializer - if(version >= 756) + if(version >= 759) { h & typeName & subTypeName; } diff --git a/lib/mapping/MapFormatJson.cpp b/lib/mapping/MapFormatJson.cpp index eb8d5c2e2..cbad11899 100644 --- a/lib/mapping/MapFormatJson.cpp +++ b/lib/mapping/MapFormatJson.cpp @@ -598,7 +598,7 @@ void CMapLoaderJson::MapObjectLoader::construct() pos.x = configuration["x"].Float(); pos.y = configuration["y"].Float(); pos.z = configuration["l"].Float(); - owner->map->grailRadious = configuration["options"]["grailRadius"].Float(); + owner->map->grailRadius = configuration["options"]["grailRadius"].Float(); } handler = VLC->objtypeh->getHandlerFor(typeName, subTypeName); @@ -879,7 +879,7 @@ void CMapSaverJson::writeObjects() grail["y"].Float() = map->grailPos.y; grail["l"].Float() = map->grailPos.z; - grail["options"]["radius"].Float() = map->grailRadious; + grail["options"]["radius"].Float() = map->grailRadius; std::string grailId = boost::str(boost::format("grail_%d") % map->objects.size());