summaryrefslogtreecommitdiffstats
path: root/source/BlockArea.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-07 10:15:55 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-07 10:15:55 +0100
commite0535ca6dfee3e5680d591e5764529596d4d412d (patch)
tree1cbbc76193f67b9f78c52149afeddaccaf791256 /source/BlockArea.cpp
parentcBlockArea can now be loaded from a .schematic file. (diff)
downloadcuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.gz
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.bz2
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.lz
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.xz
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.zst
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.zip
Diffstat (limited to '')
-rw-r--r--source/BlockArea.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/source/BlockArea.cpp b/source/BlockArea.cpp
index cdabf0378..6a973efe6 100644
--- a/source/BlockArea.cpp
+++ b/source/BlockArea.cpp
@@ -7,7 +7,7 @@
#include "Globals.h"
#include "BlockArea.h"
#include "World.h"
-#include "zlib.h"
+#include "OSSupport/GZipFile.h"
#include "WorldStorage/FastNBT.h"
@@ -194,28 +194,21 @@ bool cBlockArea::LoadFromSchematicFile(const AString & a_FileName)
{
// Un-GZip the contents:
AString Contents;
- gzFile File = gzopen(a_FileName.c_str(), "rb");
- if (File == NULL)
+ cGZipFile File;
+ if (!File.Open(a_FileName, cGZipFile::fmRead))
{
LOG("Cannot open the schematic file \"%s\".", a_FileName.c_str());
return false;
}
- // Since the gzip format doesn't really support getting the uncompressed length, we need to read incrementally. Yuck!
- int NumBytesRead = 0;
- char Buffer[32 KiB];
- while ((NumBytesRead = gzread(File, Buffer, sizeof(Buffer))) > 0)
- {
- Contents.append(Buffer, NumBytesRead);
- }
+ int NumBytesRead = File.ReadRestOfFile(Contents);
if (NumBytesRead < 0)
{
LOG("Cannot read GZipped data in the schematic file \"%s\", error %d", a_FileName.c_str(), NumBytesRead);
- gzclose(File);
return false;
}
- gzclose(File);
+ File.Close();
- // TODO: Parse the NBT:
+ // Parse the NBT:
cParsedNBT NBT(Contents.data(), Contents.size());
if (!NBT.IsValid())
{