1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Start integration of map format into engine

This commit is contained in:
AlexVinS
2016-02-09 20:20:03 +03:00
parent 6db94ab74c
commit 0c21efb202
9 changed files with 59 additions and 30 deletions

View File

@ -68,21 +68,32 @@ std::unique_ptr<IMapLoader> CMapService::getMapLoader(std::unique_ptr<CInputStre
ui32 header = reader.readUInt32();
reader.getStream()->seek(0);
// Check which map format is used
// gzip header is 3 bytes only in size
switch(header & 0xffffff)
//check for ZIP magic. Zip files are VCMI maps
switch(header)
{
// gzip header magic number, reversed for LE
case 0x00088B1F:
stream = std::unique_ptr<CInputStream>(new CCompressedStream(std::move(stream), true));
return std::unique_ptr<IMapLoader>(new CMapLoaderH3M(stream.get()));
case EMapFormat::WOG :
case EMapFormat::AB :
case EMapFormat::ROE :
case EMapFormat::SOD :
return std::unique_ptr<IMapLoader>(new CMapLoaderH3M(stream.get()));
default :
throw std::runtime_error("Unknown map format");
case 0x06054b50:
case 0x04034b50:
case 0x02014b50:
//return std::unique_ptr<IMapLoader>(new CMapLoaderJson(stream.get()));
throw std::runtime_error("Not implemented map format");
break;
default:
// Check which map format is used
// gzip header is 3 bytes only in size
switch(header & 0xffffff)
{
// gzip header magic number, reversed for LE
case 0x00088B1F:
stream = std::unique_ptr<CInputStream>(new CCompressedStream(std::move(stream), true));
return std::unique_ptr<IMapLoader>(new CMapLoaderH3M(stream.get()));
case EMapFormat::WOG :
case EMapFormat::AB :
case EMapFormat::ROE :
case EMapFormat::SOD :
return std::unique_ptr<IMapLoader>(new CMapLoaderH3M(stream.get()));
default :
throw std::runtime_error("Unknown map format");
}
}
}