diff --git a/converter/DeNotchConverter.sln b/converter/DeNotchConverter.sln
deleted file mode 100644
index c90aaa4fc..000000000
--- a/converter/DeNotchConverter.sln
+++ /dev/null
@@ -1,34 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeNotchConverter", "DeNotchConverter.vcxproj", "{A6F31DB3-6F2F-413B-ACAC-8E24A6C8B38A}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZLib", "..\VC2010\ZLib.vcxproj", "{F6F43A78-816D-4C37-A07B-68BED529273A}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {A6F31DB3-6F2F-413B-ACAC-8E24A6C8B38A}.Debug|Win32.ActiveCfg = Debug|Win32
- {A6F31DB3-6F2F-413B-ACAC-8E24A6C8B38A}.Debug|Win32.Build.0 = Debug|Win32
- {A6F31DB3-6F2F-413B-ACAC-8E24A6C8B38A}.Debug|x64.ActiveCfg = Debug|Win32
- {A6F31DB3-6F2F-413B-ACAC-8E24A6C8B38A}.Release|Win32.ActiveCfg = Release|Win32
- {A6F31DB3-6F2F-413B-ACAC-8E24A6C8B38A}.Release|Win32.Build.0 = Release|Win32
- {A6F31DB3-6F2F-413B-ACAC-8E24A6C8B38A}.Release|x64.ActiveCfg = Release|Win32
- {F6F43A78-816D-4C37-A07B-68BED529273A}.Debug|Win32.ActiveCfg = Debug|Win32
- {F6F43A78-816D-4C37-A07B-68BED529273A}.Debug|Win32.Build.0 = Debug|Win32
- {F6F43A78-816D-4C37-A07B-68BED529273A}.Debug|x64.ActiveCfg = Debug|x64
- {F6F43A78-816D-4C37-A07B-68BED529273A}.Debug|x64.Build.0 = Debug|x64
- {F6F43A78-816D-4C37-A07B-68BED529273A}.Release|Win32.ActiveCfg = Release|Win32
- {F6F43A78-816D-4C37-A07B-68BED529273A}.Release|Win32.Build.0 = Release|Win32
- {F6F43A78-816D-4C37-A07B-68BED529273A}.Release|x64.ActiveCfg = Release|x64
- {F6F43A78-816D-4C37-A07B-68BED529273A}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/converter/DeNotchConverter.vcxproj b/converter/DeNotchConverter.vcxproj
deleted file mode 100644
index b0e6656b0..000000000
--- a/converter/DeNotchConverter.vcxproj
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {A6F31DB3-6F2F-413B-ACAC-8E24A6C8B38A}
- DeNotchConverter
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Level3
- Disabled
- ../zlib-1.2.5
- _DEBUG;%(PreprocessorDefinitions)
-
-
- true
- ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- ../zlib-1.2.5
- MultiThreaded
-
-
- true
- true
- true
- ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {f6f43a78-816d-4c37-a07b-68bed529273a}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/converter/DeNotchConverter.vcxproj.filters b/converter/DeNotchConverter.vcxproj.filters
deleted file mode 100644
index 5aad6fe3a..000000000
--- a/converter/DeNotchConverter.vcxproj.filters
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
\ No newline at end of file
diff --git a/converter/DeNotchConverter.vcxproj.user b/converter/DeNotchConverter.vcxproj.user
deleted file mode 100644
index de7919d96..000000000
--- a/converter/DeNotchConverter.vcxproj.user
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- $(ProjectDir)/region
- WindowsLocalDebugger
-
-
- $(ProjectDir)/region
- WindowsLocalDebugger
-
-
\ No newline at end of file
diff --git a/converter/clean.bat b/converter/clean.bat
deleted file mode 100644
index bfcd0af7e..000000000
--- a/converter/clean.bat
+++ /dev/null
@@ -1,24 +0,0 @@
-del *.ncb
-del *.ilk
-del *.lib
-del *.exp
-del *.map
-del *.pdb
-del *.bsc
-del *.sdf
-del *.opensdf /AH
-del *.insprc
-del *.aps
-del applog.txt
-del *.suo /AH
-del debug\*.* /Q
-del release\*.* /Q
-del x64\*.* /Q
-del "My Inspector Results"\*.* /Q
-del ipch\*.* /Q
-del build\*.* /Q
-rd release /S /Q
-rd debug /S /Q
-rd ipch /S /Q
-rd x64 /Q
-rd "My Inspector Results" /Q
\ No newline at end of file
diff --git a/converter/makefile b/converter/makefile
deleted file mode 100644
index e5fd9e628..000000000
--- a/converter/makefile
+++ /dev/null
@@ -1,178 +0,0 @@
-CC = /usr/bin/g++
-CC_OPTIONS = -O2 -s
-CCE_OPTIONS = -O2 -s -x c
-
-
-INCLUDE = -I.\
- -I../zlib-1.2.5\
- -Isource
-
-denotch: \
- build/main.o\
- build/cDeNotch.o\
- build/cNBTData.o\
- build/cTimer.o\
- build/cQuicksort.o\
- build/cMakeDir.o\
- build/adler32.o\
- build/compress.o\
- build/crc32.o\
- build/deflate.o\
- build/gzclose.o\
- build/gzlib.o\
- build/gzread.o\
- build/gzwrite.o\
- build/infback.o\
- build/inffast.o\
- build/inflate.o\
- build/inftrees.o\
- build/trees.o\
- build/uncompr.o\
- build/zutil.o
-
- $(CC) $(LNK_OPTIONS) \
- build/main.o\
- build/cDeNotch.o\
- build/cNBTData.o\
- build/cTimer.o\
- build/cQuicksort.o\
- build/cMakeDir.o\
- build/adler32.o\
- build/compress.o\
- build/crc32.o\
- build/deflate.o\
- build/gzclose.o\
- build/gzlib.o\
- build/gzread.o\
- build/gzwrite.o\
- build/infback.o\
- build/inffast.o\
- build/inflate.o\
- build/inftrees.o\
- build/trees.o\
- build/uncompr.o\
- build/zutil.o\
- -o denotch
-
-clean:
- rm \
- build/main.o\
- build/cDeNotch.o\
- build/cNBTData.o\
- build/cTimer.o\
- build/cQuicksort.o\
- build/cMakeDir.o\
- build/adler32.o\
- build/compress.o\
- build/crc32.o\
- build/deflate.o\
- build/gzclose.o\
- build/gzlib.o\
- build/gzread.o\
- build/gzwrite.o\
- build/infback.o\
- build/inffast.o\
- build/inflate.o\
- build/inftrees.o\
- build/trees.o\
- build/uncompr.o\
- build/zutil.o\
-
-install : denotch
- cp denotch denotch
-
-build/main.o : source/main.cpp
- $(CC) $(CC_OPTIONS) source/main.cpp -c $(INCLUDE) -o build/main.o
-
-
-build/cDeNotch.o : source/cDeNotch.cpp
- $(CC) $(CC_OPTIONS) source/cDeNotch.cpp -c $(INCLUDE) -o build/cDeNotch.o
-
-
-build/cNBTData.o : source/cNBTData.cpp
- $(CC) $(CC_OPTIONS) source/cNBTData.cpp -c $(INCLUDE) -o build/cNBTData.o
-
-
-build/cTimer.o : source/cTimer.cpp
- $(CC) $(CC_OPTIONS) source/cTimer.cpp -c $(INCLUDE) -o build/cTimer.o
-
-
-build/cQuicksort.o : source/cQuicksort.cpp
- $(CC) $(CC_OPTIONS) source/cQuicksort.cpp -c $(INCLUDE) -o build/cQuicksort.o
-
-build/cMakeDir.o : source/cMakeDir.cpp
- $(CC) $(CC_OPTIONS) source/cMakeDir.cpp -c $(INCLUDE) -o build/cMakeDir.o
-
-# Item # 104 -- adler32 --
-build/adler32.o : ../zlib-1.2.5/adler32.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/adler32.c -c $(INCLUDE) -o build/adler32.o
-
-
-# Item # 105 -- compress --
-build/compress.o : ../zlib-1.2.5/compress.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/compress.c -c $(INCLUDE) -o build/compress.o
-
-
-# Item # 106 -- crc32 --
-build/crc32.o : ../zlib-1.2.5/crc32.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/crc32.c -c $(INCLUDE) -o build/crc32.o
-
-
-# Item # 107 -- deflate --
-build/deflate.o : ../zlib-1.2.5/deflate.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/deflate.c -c $(INCLUDE) -o build/deflate.o
-
-
-# Item # 108 -- gzclose --
-build/gzclose.o : ../zlib-1.2.5/gzclose.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/gzclose.c -c $(INCLUDE) -o build/gzclose.o
-
-
-# Item # 109 -- gzlib --
-build/gzlib.o : ../zlib-1.2.5/gzlib.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/gzlib.c -c $(INCLUDE) -o build/gzlib.o
-
-
-# Item # 110 -- gzread --
-build/gzread.o : ../zlib-1.2.5/gzread.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/gzread.c -c $(INCLUDE) -o build/gzread.o
-
-
-# Item # 111 -- gzwrite --
-build/gzwrite.o : ../zlib-1.2.5/gzwrite.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/gzwrite.c -c $(INCLUDE) -o build/gzwrite.o
-
-
-# Item # 112 -- infback --
-build/infback.o : ../zlib-1.2.5/infback.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/infback.c -c $(INCLUDE) -o build/infback.o
-
-
-# Item # 113 -- inffast --
-build/inffast.o : ../zlib-1.2.5/inffast.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/inffast.c -c $(INCLUDE) -o build/inffast.o
-
-
-# Item # 114 -- inflate --
-build/inflate.o : ../zlib-1.2.5/inflate.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/inflate.c -c $(INCLUDE) -o build/inflate.o
-
-
-# Item # 115 -- inftrees --
-build/inftrees.o : ../zlib-1.2.5/inftrees.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/inftrees.c -c $(INCLUDE) -o build/inftrees.o
-
-
-# Item # 116 -- trees --
-build/trees.o : ../zlib-1.2.5/trees.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/trees.c -c $(INCLUDE) -o build/trees.o
-
-
-# Item # 117 -- uncompr --
-build/uncompr.o : ../zlib-1.2.5/uncompr.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/uncompr.c -c $(INCLUDE) -o build/uncompr.o
-
-
-# Item # 118 -- zutil --
-build/zutil.o : ../zlib-1.2.5/zutil.c
- $(CC) $(CCE_OPTIONS) ../zlib-1.2.5/zutil.c -c $(INCLUDE) -o build/zutil.o
diff --git a/converter/region/r.0.0.mcr b/converter/region/r.0.0.mcr
deleted file mode 100755
index 47ff73161..000000000
Binary files a/converter/region/r.0.0.mcr and /dev/null differ
diff --git a/converter/source/MemoryLeak.h b/converter/source/MemoryLeak.h
deleted file mode 100644
index 2d62f2a4b..000000000
--- a/converter/source/MemoryLeak.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-#ifdef _WIN32
-
-#ifdef _DEBUG
-
-#define _CRTDBG_MAP_ALLOC
-#include
-#include
-
-#ifndef DEBUG_NEW
-#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
-#define new DEBUG_NEW
-#endif
-
-#endif
-
-#endif
diff --git a/converter/source/cDeNotch.cpp b/converter/source/cDeNotch.cpp
deleted file mode 100644
index 75d4ffa9d..000000000
--- a/converter/source/cDeNotch.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-#include "MemoryLeak.h"
-
-#include "cDeNotch.h"
-#include
-#include
-#include
-#include
-#include
-#include "zlib.h"
-#include "cNBTData.h"
-#include "cTimer.h"
-#include "cQuicksort.h"
-#include "cDeNotch.h"
-#include "cMakeDir.h"
-
-#ifdef _WIN32
-#include "wdirent.h"
-#else
-#include
-#endif
-
-#ifndef _WIN32
-#define sprintf_s(target, size, ... ) printf(target, __VA_ARGS__ )
-#endif
-
-inline bool fOpenFile( FILE*& a_hFile, const char* a_FileName, const char* a_Mode )
-{
-#ifdef _WIN32
- return fopen_s(&a_hFile, a_FileName, a_Mode ) == 0;
-#else
- return (a_hFile = fopen(a_FileName, a_Mode )) != 0;
-#endif
-}
-
-cDeNotch::cDeNotch ( )
-{
-
-}
-
-int cDeNotch:: Converter ( std::string mcrSource, std::string pakOutput )
-{
- std::string OutDir = "world/";
-
- FILE* f = 0;
- FILE* wf = 0;
-
- std::string SourceFileName = mcrSource;
- std::string OutFileName = OutDir + pakOutput;
-
- cMakeDir::MakeDir( OutDir.c_str() );
- if( !fOpenFile(wf, OutFileName.c_str(), "wb") )
- {
- printf("Could not open/create file %s\n", OutFileName.c_str() );
- }
-
- printf ("Now Converting %s to %s\n", SourceFileName.c_str(), OutFileName.c_str() );
- if( fOpenFile(f, SourceFileName.c_str(), "rb") )
- {
- char* t_FakeHeader = new char[1*1024*1024]; //1MB Temp FakeHeader array
- int t_FakeHeaderSz = -1; //Size of data in array
-
- char* t_CompChunk = new char[5*1024*1024]; //5MB Temp Compressed Chunk Data array
- int t_CompChunkSz = -1; //Size of data in array
-
- char PakVersion = 1;
- char ChunkVersion = 1;
- short NumChunks = 0;
-
- unsigned char byte1 = 0;
- unsigned char byte2 = 0;
- unsigned char byte3 = 0;
- unsigned char byte4 = 0;
- unsigned char byte5 = 0;
- unsigned char trash = 0;
- unsigned int frloc = 0;
-
- int toffset = 0;
- int compdlength = 0;
-
- int toffarr[1024];
-
- //loop through notch's header
- for( short i = 0; i < 1024 ; ++i )
- { //loop through first 4096 bytes of data, 4 bytes at a time
- //Region files begin with an 8kiB header containing information about which chunks are present in the region file, when they were last updated, and where they can be found. The location in the region file of a chunk at (x, z) (in chunk coordinates) can be found at byte offset 4 * ((x mod 32) + (z mod 32) * 32) in its region file. Its timestamp can be found 4096 bytes later in the file. The remainder of the file consists of data for up to 1024 chunks, interspersed with an arbitrary amount of unused space.
- //we are only using the first 4096 bytes. We don't need the timestamps right now.
- if( fread( &byte1, sizeof(byte1), 1, f) != 1 ) { std::cout << "ERROR 21hs READING FROM FILE " << SourceFileName; fclose(f); return false; }
- if( fread( &byte2, sizeof(byte2), 1, f) != 1 ) { std::cout << "ERROR ks93 READING FROM FILE " << SourceFileName; fclose(f); return false; }
- if( fread( &byte3, sizeof(byte3), 1, f) != 1 ) { std::cout << "ERROR 2s5f READING FROM FILE " << SourceFileName; fclose(f); return false; }//first three bytes area big-endian representation of the chunk offsets in no particular order.
- if( fread( &byte4, sizeof(byte4), 1, f) != 1 ) { std::cout << "ERROR dhj3 READING FROM FILE " << SourceFileName; fclose(f); return false; }//we don't need to use this byte right now.
- toffset = 4096 * ((byte1*256*256) + (byte2*256) + byte3);//find the chunk offsets using the first three bytes of each long;
- toffarr[i] = toffset;//array of chunk offset locations in the file.
- }
- for ( short i = 0; i < 4096; i++ )
- { //loop through next 4096 bytes of the header.
- //keeping this code here in case we need it later. not using it right now.
- if( fread( &trash, sizeof(byte4), 1, f) != 1 ) { std::cout << "ERROR 2jkd READING FROM FILE " << SourceFileName; fclose(f); return false; }
- }
- frloc = 8192; //current location of fread is at 4096+ 4096 since we read through and collected important info from the header.
-
- cQuicksort Quick;
- Quick.quicksort(toffarr, 0, 1023); //sort the array from smallest to largest offset locations so we only have to read through the file once.
-
- for ( short ia = 0; ia < 1024; ia++ )
- { //a region file can hold a maximum of 1024 chunks (32*32)
- if (ia < 3500 )
- { //only run chunk # 3
- if (toffarr[ia] < 8192)
- { //offsets of less than 8192 are impossible. 0 means there is no chunk in a particular location.
- if (toffarr[ia] > 0) { std::cout << "ERROR 2s31 IN COLLECTED CHUNK OFFSETS " << toffarr[ia]; fclose(f); return false; } //values between 0 and 8192 should be impossible.
- //This file does not contain the max 1024 chunks, skip until we get to the first
- }
- else
- { // found a chunk offset value
- //Chunk data begins with a (big-endian) four-byte length field which indicates the exact length of the remaining chunk data in bytes. The following byte indicates the compression scheme used for chunk data, and the remaining (length-1) bytes are the compressed chunk data.
- //printf("Working on chunk %i :: %i\n", ia, toffarr[ia]);
- if( fread( &byte1, sizeof(byte1), 1, f) != 1 ) { std::cout << "ERROR 2t32 READING FROM FILE " << SourceFileName; fclose(f); return false; }
- if( fread( &byte2, sizeof(byte2), 1, f) != 1 ) { std::cout << "ERROR 2y51 READING FROM FILE " << SourceFileName; fclose(f); return false; }
- if( fread( &byte3, sizeof(byte3), 1, f) != 1 ) { std::cout << "ERROR 3424 READING FROM FILE " << SourceFileName; fclose(f); return false; }
- if( fread( &byte4, sizeof(byte4), 1, f) != 1 ) { std::cout << "ERROR sd22 READING FROM FILE " << SourceFileName; fclose(f); return false; }
- compdlength = ((byte1*256*256*256) + (byte2*256*256) + (byte3*256) + byte4 - 0); //length of compressed chunk data
- if( fread( &byte5, sizeof(byte5), 1, f) != 1 ) { std::cout << "ERROR 2341 READING FROM FILE " << SourceFileName; fclose(f); return false; } //compression type, 1 = GZip (RFC1952) (unused in practice) , 2 = Zlib (RFC1950)
-
- frloc += 5; //moved ahead 5 bytes while reading data.
-
- char* compBlockData = new char[compdlength];
- if( fread( compBlockData, compdlength, 1, f) != 1 ) { std::cout << "ERROR rf22 READING FROM FILE " << SourceFileName; fclose(f); return false; }
- frloc = frloc + compdlength;
-
- uLongf DestSize = 128576;// uncompressed chunks should never be larger than this
-
- char* BlockData = new char[ DestSize ];
-
- int errorcode = uncompress( (Bytef*)BlockData, &DestSize, (Bytef*)compBlockData, compdlength ); //DestSize will update to the actual uncompressed data size after this opperation.
- int testr = (int)DestSize; //testing something, can't remember what.
- if( errorcode != Z_OK ){
- printf("ERROR: Decompressing chunk data! %i", errorcode );
- switch( errorcode )
- {
- case Z_MEM_ERROR:
- printf("Not enough memory");
- break;
- case Z_BUF_ERROR:
- printf("Not enough room in output buffer");
- break;
- case Z_DATA_ERROR:
- printf("Input data corrupted or incomplete");
- break;
- default:
- break;
- };
- }
-
- NumChunks++;
- cNBTData* NBTData = new cNBTData(BlockData, (int)DestSize);
- NBTData->ParseData();
- //NBTData->PrintData();
- NBTData->OpenCompound("");
- NBTData->OpenCompound("Level"); // You need to open the right compounds before you can access the data in it
-
- //NBT Data for blocks should look something like this:
- //==== STRUCTURED NBT DATA ====
- // COMPOUND ( )
- // COMPOUND
- // COMPOUND (Level)
- // LIST (Entities)
- // LIST (TileEntities)
- // INTEGER LastUpdate (0)
- // INTEGER xPos (0)
- // INTEGER zPos (0)
- // BYTE TerrainPopulated (1)
- // BYTE ARRAY BlockLight (length: 16384)
- // BYTE ARRAY Blocks (length: 32768)
- // BYTE ARRAY Data (length: 16384)
- // BYTE ARRAY HeightMap (length: 256)
- // BYTE ARRAY SkyLight (length: 16384)
- //=============================
-
- int UncompressedChunkSz = (32768+16384+16384+16384);
- char* UncompressedChunk = new char[ UncompressedChunkSz ];
- uLongf CompressedSize = compressBound( UncompressedChunkSz );
- char* CompressedChunk = new char[ CompressedSize ];
- int UnChunkArrLoc = 0;
- int xPos = NBTData->GetInteger("xPos");
- int zPos = NBTData->GetInteger("zPos");
- //printf("Chunk [%i, %i]\n", xPos, zPos );
-
- memcpy( t_FakeHeader + t_FakeHeaderSz + 1, &xPos, sizeof(int) );t_FakeHeaderSz += sizeof(int);
- memcpy( t_FakeHeader + t_FakeHeaderSz + 1, &zPos, sizeof(int) );t_FakeHeaderSz += sizeof(int);
-
-
- //TODO: insert json code and add it to chunk data
-
- memcpy( UncompressedChunk + UnChunkArrLoc, NBTData->GetByteArray("Blocks"), 32768 );UnChunkArrLoc += 32768;
- memcpy( UncompressedChunk + UnChunkArrLoc, NBTData->GetByteArray("Data"), 16384 );UnChunkArrLoc += 16384;
- memcpy( UncompressedChunk + UnChunkArrLoc, NBTData->GetByteArray("BlockLight"), 16384 );UnChunkArrLoc += 16384;
- memcpy( UncompressedChunk + UnChunkArrLoc, NBTData->GetByteArray("SkyLight"), 16384 );UnChunkArrLoc += 16384;
-
- errorcode = compress2( (Bytef*)CompressedChunk, &CompressedSize, (const Bytef*)UncompressedChunk, UncompressedChunkSz, Z_DEFAULT_COMPRESSION);
- if( errorcode != Z_OK )
- {
- printf("Error compressing data (%i)", errorcode );
- break;
- }
-
- memcpy( t_FakeHeader + t_FakeHeaderSz + 1, &CompressedSize, sizeof(int) );t_FakeHeaderSz += sizeof(int);
- memcpy( t_FakeHeader + t_FakeHeaderSz + 1, &UncompressedChunkSz, sizeof(int) );t_FakeHeaderSz += sizeof(int);
- memcpy( t_CompChunk + t_CompChunkSz + 1, CompressedChunk, CompressedSize );t_CompChunkSz += CompressedSize;
-
- NBTData->CloseCompound();// Close the compounds after you're done
- NBTData->CloseCompound();
-
- delete [] UncompressedChunk;
- delete [] CompressedChunk;
- delete [] compBlockData;
- delete [] BlockData;
-
- while ( (frloc < toffarr[ia+1]) && (ia<1023) )
- { //loop through Notch's junk data until we get to another chunk offset possition to start the loop again
- if( fread( &trash, sizeof(byte4), 1, f) != 1 ) { std::cout << "ERROR 2nkd READING FROM FILE " << SourceFileName; fclose(f); return false; }
- frloc ++;
- }
-
-
- delete NBTData;
- }
- } //only run chunk # 3
- }
-
- fwrite( &PakVersion, sizeof(PakVersion), 1, wf );
- fwrite( &ChunkVersion, sizeof(ChunkVersion), 1, wf );
- fwrite( &NumChunks, sizeof(NumChunks), 1, wf );
- fwrite( t_FakeHeader, t_FakeHeaderSz+1, 1, wf );
- fwrite( t_CompChunk, t_CompChunkSz+1, 1, wf );
- delete [] t_FakeHeader;
- delete [] t_CompChunk;
-
- fclose(wf); //close file.
- fclose(f); //close file.
- }
- return true;
-};
diff --git a/converter/source/cDeNotch.h b/converter/source/cDeNotch.h
deleted file mode 100644
index 7701718a6..000000000
--- a/converter/source/cDeNotch.h
+++ /dev/null
@@ -1,264 +0,0 @@
-#pragma once
-
-#include
-
-class cDeNotch
-{
-public:
-
-
-cDeNotch();
-
-int Converter ( std::string, std::string );
-
-std::string mcrSource;
-std::string pakOutput;
-
-
-};
-
-/*
-using namespace std;
-
-
-int main () {
-
- string dir;
- DIR* dp;
- struct dirent *entry;
- int found;
- string entrys;
- string str2;
- string str3;
- string filexPos;
- string filezPos;
- string pak_name;
- //string* dir_array;
- int dir_num_files = 0;
- int ctr = 0;
-
- if(dp = opendir("region/")){
- while(entry = readdir(dp)){
- entrys = entry->d_name;
- found = entrys.find(".mcr");
- if ( (found!=string::npos) && (entry->d_type==8) ) {
- str2 = entrys.substr (2,sizeof(entrys));
- filexPos = str2.substr (0,(int)str2.find("."));
- str3 = str2.substr ((int)str2.find(".")+1, sizeof(str2));
- filezPos = str3.substr (0,(int)str3.find("."));
- pak_name = "X" + filexPos + "_Z" + filezPos + ".pak";
-
- clock_t begin=clock(); //start execution timer
-
- cDeNotch ( entrys, pak_name );
-
- clock_t end=clock();
- cout << "Time to convert chunk: " << double(diffclock(end,begin)) << " Seconds"<< endl;
- }
- }
- closedir(dp);
- }
-
- return 0;
-};
-
-
-
-int cDeNotch ( std::string mcrSource, std::string pakOutput ) {
- char SourceFile[128];
- char OutputFile[128];
-
-
- FILE* f = 0;
- FILE* wf = 0;
- #ifdef _WIN32
- sprintf_s(SourceFile, 128, "region/%s", mcrSource.c_str() ); //replace hard coded file with file array variable
- sprintf_s(OutputFile, 128, "world/%s", pakOutput.c_str() ); //parce x and z from file array variable and place into pak file format
- if( fopen_s(&wf, OutputFile, "wb" ) == 0 ) {} else { cout << "uhoh!" << endl; return false; } //open new pak file for writing
- #else
- sprintf(SourceFile, "region/%s", mcrSource.c_str() ); //same as above but for linux
- sprintf(OutputFile, "world/%s", pakOutput.c_str() );
- if( (wf = fopen(OutputFile, "wb" )) != 0 ) {} else { cout << "uhoh!" << endl; return false; }
- #endif
-
-
- printf ("Now Converting %s to %s\n", mcrSource.c_str(), pakOutput.c_str() );
- if( (f = fopen(SourceFile, "rb" )) != 0 ) { // no error
-
- char* t_FakeHeader;
- t_FakeHeader = new char[1*1024*1024]; //1MB Temp FakeHeader array
- int t_FakeHeaderSz = -1; //Size of data in array
-
- char* t_CompChunk;
- t_CompChunk = new char[5*1024*1024]; //5MB Temp Compressed Chunk Data array
- int t_CompChunkSz = -1; //Size of data in array
-
- char PakVersion = 1;
- char ChunkVersion = 1;
- short NumChunks = 0;
-
- unsigned char byte1 = 0;
- unsigned char byte2 = 0;
- unsigned char byte3 = 0;
- unsigned char byte4 = 0;
- unsigned char byte5 = 0;
- unsigned char trash = 0;
- unsigned int frloc = 0;
-
- int toffset = 0;
- int compdlength = 0;
-
- int toffarr[1024];
-
- //loop through notch's header
- for( short i = 0; i < 1024 ; ++i ) {//loop through first 4096 bytes of data, 4 bytes at a time
- //Region files begin with an 8kiB header containing information about which chunks are present in the region file, when they were last updated, and where they can be found. The location in the region file of a chunk at (x, z) (in chunk coordinates) can be found at byte offset 4 * ((x mod 32) + (z mod 32) * 32) in its region file. Its timestamp can be found 4096 bytes later in the file. The remainder of the file consists of data for up to 1024 chunks, interspersed with an arbitrary amount of unused space.
- //we are only using the first 4096 bytes. We don't need the timestamps right now.
- if( fread( &byte1, sizeof(byte1), 1, f) != 1 ) { cout << "ERROR 21hs READING FROM FILE " << SourceFile; fclose(f); return false; }
- if( fread( &byte2, sizeof(byte2), 1, f) != 1 ) { cout << "ERROR ks93 READING FROM FILE " << SourceFile; fclose(f); return false; }
- if( fread( &byte3, sizeof(byte3), 1, f) != 1 ) { cout << "ERROR 2s5f READING FROM FILE " << SourceFile; fclose(f); return false; }//first three bytes area big-endian representation of the chunk offsets in no particular order.
- if( fread( &byte4, sizeof(byte4), 1, f) != 1 ) { cout << "ERROR dhj3 READING FROM FILE " << SourceFile; fclose(f); return false; }//we don't need to use this byte right now.
- toffset = 4096 * ((byte1*256*256) + (byte2*256) + byte3);//find the chunk offsets using the first three bytes of each long;
- toffarr[i] = toffset;//array of chunk offset locatiosn in the fle.
- }
- for ( short i = 0; i < 4096; i++ ) {//loop through next 4096 bytes of the header.
- //keeping this code here in case we need it later. not using it right now.
- if( fread( &trash, sizeof(byte4), 1, f) != 1 ) { cout << "ERROR 2jkd READING FROM FILE " << SourceFile; fclose(f); return false; }
- }
- frloc = 8192; //current location of fread is at 4096+ 4096 since we read through and collected important info from the header.
-
- cQuicksort Quick;
- Quick.quicksort(toffarr, 0, 1023); //sort the array from smallest to larget offset locations so we only have to read through the file once.
-
- for ( short ia = 0; ia < 1024; ia++ ) {//a region file can hold a maximum of 1024 chunks (32*32)
- if (ia < 3500 ) { //only run chunk # 3
- if (toffarr[ia] < 8192) { //offsets of less than 8192 are impossible. 0 means there is no chunk in a particular location.
- if (toffarr[ia] > 0) { cout << "ERROR 2s31 IN COLLECTED CHUNK OFFSETS " << toffarr[ia]; fclose(f); return false; } //values between 0 and 8192 should be impossible.
- //This file does not contain the max 1024 chunks, skip until we get to the first
- } else { // found a chunk offset value
- //Chunk data begins with a (big-endian) four-byte length field which indicates the exact length of the remaining chunk data in bytes. The following byte indicates the compression scheme used for chunk data, and the remaining (length-1) bytes are the compressed chunk data.
- //printf("Working on chunk %i :: %i\n", ia, toffarr[ia]);
- if( fread( &byte1, sizeof(byte1), 1, f) != 1 ) { cout << "ERROR 2t32 READING FROM FILE " << SourceFile; fclose(f); return false; }
- if( fread( &byte2, sizeof(byte2), 1, f) != 1 ) { cout << "ERROR 2y51 READING FROM FILE " << SourceFile; fclose(f); return false; }
- if( fread( &byte3, sizeof(byte3), 1, f) != 1 ) { cout << "ERROR 3424 READING FROM FILE " << SourceFile; fclose(f); return false; }
- if( fread( &byte4, sizeof(byte4), 1, f) != 1 ) { cout << "ERROR sd22 READING FROM FILE " << SourceFile; fclose(f); return false; }
- compdlength = ((byte1*256*256*256) + (byte2*256*256) + (byte3*256) + byte4 - 0); //length of compressed chunk data
- if( fread( &byte5, sizeof(byte5), 1, f) != 1 ) { cout << "ERROR 2341 READING FROM FILE " << SourceFile; fclose(f); return false; } //compression type, 1 = GZip (RFC1952) (unused in practice) , 2 = Zlib (RFC1950)
-
- frloc += 5; //moved ahead 5 bytes while reading data.
-
- char* compBlockData = new char[compdlength];
- if( fread( compBlockData, compdlength, 1, f) != 1 ) { cout << "ERROR rf22 READING FROM FILE " << SourceFile; fclose(f); return false; }
- frloc = frloc + compdlength;
-
- uLongf DestSize = 128576;// uncompressed chunks should never be larger than this
-
- char* BlockData = new char[ DestSize ];
-
- int errorcode = uncompress( (Bytef*)BlockData, &DestSize, (Bytef*)compBlockData, compdlength ); //DestSize will update to the actual uncompressed data size after this opperation.
- int testr = (int)DestSize; //testing something, can't remember what.
- if( errorcode != Z_OK ){
- printf("ERROR: Decompressing chunk data! %i", errorcode );
- switch( errorcode )
- {
- case Z_MEM_ERROR:
- printf("Not enough memory");
- break;
- case Z_BUF_ERROR:
- printf("Not enough room in output buffer");
- break;
- case Z_DATA_ERROR:
- printf("Input data corrupted or incomplete");
- break;
- default:
- break;
- };
- }
-
- NumChunks++;
- cNBTData* NBTData = new cNBTData(BlockData, (int)DestSize);
- NBTData->ParseData();
- //NBTData->PrintData();
- NBTData->OpenCompound("");
- NBTData->OpenCompound("Level"); // You need to open the right compounds before you can access the data in it
-
- //NBT Data for blocks should look something like this:
- //==== STRUCTURED NBT DATA ====
- // COMPOUND ( )
- // COMPOUND
- // COMPOUND (Level)
- // LIST (Entities)
- // LIST (TileEntities)
- // INTEGER LastUpdate (0)
- // INTEGER xPos (0)
- // INTEGER zPos (0)
- // BYTE TerrainPopulated (1)
- // BYTE ARRAY BlockLight (length: 16384)
- // BYTE ARRAY Blocks (length: 32768)
- // BYTE ARRAY Data (length: 16384)
- // BYTE ARRAY HeightMap (length: 256)
- // BYTE ARRAY SkyLight (length: 16384)
- //=============================
-
- int UncompressedChunkSz = (32768+16384+16384+16384);
- char* UncompressedChunk = new char[ UncompressedChunkSz ];
- uLongf CompressedSize = compressBound( UncompressedChunkSz );
- char* CompressedChunk = new char[ CompressedSize ];
- int UnChunkArrLoc = 0;
- int xPos = NBTData->GetInteger("xPos");
- int zPos = NBTData->GetInteger("zPos");
-
- memcpy( t_FakeHeader + t_FakeHeaderSz + 1, &xPos, sizeof(int) );t_FakeHeaderSz += sizeof(int);
- memcpy( t_FakeHeader + t_FakeHeaderSz + 1, &zPos, sizeof(int) );t_FakeHeaderSz += sizeof(int);
-
-
- //todo: inserert json code and add it to chunk data
-
- memcpy( UncompressedChunk + UnChunkArrLoc, NBTData->GetByteArray("Blocks"), 32768 );UnChunkArrLoc += 32768;
- memcpy( UncompressedChunk + UnChunkArrLoc, NBTData->GetByteArray("Data"), 16384 );UnChunkArrLoc += 16384;
- memcpy( UncompressedChunk + UnChunkArrLoc, NBTData->GetByteArray("BlockLight"), 16384 );UnChunkArrLoc += 16384;
- memcpy( UncompressedChunk + UnChunkArrLoc, NBTData->GetByteArray("SkyLight"), 16384 );UnChunkArrLoc += 16384;
-
- errorcode = compress2( (Bytef*)CompressedChunk, &CompressedSize, (const Bytef*)UncompressedChunk, UncompressedChunkSz, Z_DEFAULT_COMPRESSION);
- if( errorcode != Z_OK )
- {
- printf("Error compressing data (%i)", errorcode );
- break;
- }
-
- memcpy( t_FakeHeader + t_FakeHeaderSz + 1, &CompressedSize, sizeof(int) );t_FakeHeaderSz += sizeof(int);
- memcpy( t_FakeHeader + t_FakeHeaderSz + 1, &UncompressedChunkSz, sizeof(int) );t_FakeHeaderSz += sizeof(int);
- memcpy( t_CompChunk + t_CompChunkSz + 1, CompressedChunk, CompressedSize );t_CompChunkSz += CompressedSize;
-
- NBTData->CloseCompound();// Close the compounds after you're done
- NBTData->CloseCompound();
-
- delete [] UncompressedChunk;
- delete [] CompressedChunk;
- delete [] compBlockData;
- delete [] BlockData;
- //delete [] NBTData;
-
- while ( (frloc < toffarr[ia+1]) && (ia<1023) ) { //loop through Notch's junk data until we get to another chunk offset possition to start the loop again
- if( fread( &trash, sizeof(byte4), 1, f) != 1 ) { cout << "ERROR 2nkd READING FROM FILE " << SourceFile; fclose(f); return false; }
- frloc ++;
- }
-
- }
- } //only run chunk # 3
-
- }
- fwrite( &PakVersion, sizeof(PakVersion), 1, wf );
- fwrite( &ChunkVersion, sizeof(ChunkVersion), 1, wf );
- fwrite( &NumChunks, sizeof(NumChunks), 1, wf );
- fwrite( t_FakeHeader, t_FakeHeaderSz+1, 1, wf );
- fwrite( t_CompChunk, t_CompChunkSz+1, 1, wf );
- delete [] t_FakeHeader;
- delete [] t_CompChunk;
-
- fclose(wf); //close file.
- fclose(f); //close file.
- }
- return true;
-};
-*/
diff --git a/converter/source/cMakeDir.cpp b/converter/source/cMakeDir.cpp
deleted file mode 100644
index 579d39359..000000000
--- a/converter/source/cMakeDir.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "cMakeDir.h"
-
-#ifndef _WIN32
-//#include // If something is missing, uncomment some of these!
-//#include
-//#include
-#include // for mkdir
-//#include
-#else
-#include
-#endif
-
-void cMakeDir::MakeDir( const char* a_Directory )
-{
-#ifdef _WIN32
- SECURITY_ATTRIBUTES Attrib;
- Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
- Attrib.lpSecurityDescriptor = NULL;
- Attrib.bInheritHandle = false;
- ::CreateDirectory(a_Directory, &Attrib);
-#else
- mkdir(a_Directory, S_IRWXU | S_IRWXG | S_IRWXO);
-#endif
-}
\ No newline at end of file
diff --git a/converter/source/cMakeDir.h b/converter/source/cMakeDir.h
deleted file mode 100644
index 240b76507..000000000
--- a/converter/source/cMakeDir.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma once
-
-class cMakeDir
-{
-public:
- static void MakeDir( const char* a_Directory );
-};
\ No newline at end of file
diff --git a/converter/source/cNBTData.cpp b/converter/source/cNBTData.cpp
deleted file mode 100644
index cdd88a0c0..000000000
--- a/converter/source/cNBTData.cpp
+++ /dev/null
@@ -1,945 +0,0 @@
-#include "MemoryLeak.h"
-
-#include "cNBTData.h"
-#include // memcpy
-#include
-#include "zlib.h"
-#include
-#include
-
-#ifndef _WIN32
-#include
-#include
-#endif
-
-#ifdef _WIN32
-#include
-#endif
-
-cNBTData::~cNBTData()
-{
- // TODO: Delete all compounds and stuff in it
- Clear();
-}
-
-cNBTData::cNBTData( char* a_Buffer, unsigned int a_BufferSize )
- : cNBTCompound( 0 )
-{
- m_NumUnnamedElements = 0;
- for(int i = 0; i < TAG_NumTags; i++)
- {
- m_ParseFunctions[i] = 0;
- }
- m_ParseFunctions[TAG_Byte] = &cNBTData::ParseByte;
- m_ParseFunctions[TAG_Short] = &cNBTData::ParseShort;
- m_ParseFunctions[TAG_Int] = &cNBTData::ParseInt;
- m_ParseFunctions[TAG_Long] = &cNBTData::ParseLong;
- m_ParseFunctions[TAG_Double] = &cNBTData::ParseDouble;
- m_ParseFunctions[TAG_Float] = &cNBTData::ParseFloat;
- m_ParseFunctions[TAG_String] = &cNBTData::ParseString;
- m_ParseFunctions[TAG_List] = &cNBTData::ParseList;
- m_ParseFunctions[TAG_Compound] = &cNBTData::ParseCompound;
- m_ParseFunctions[TAG_ByteArray] = &cNBTData::ParseByteArray;
-
-
- m_BufferSize = a_BufferSize;
- m_Buffer = new char[m_BufferSize]; // Make a copy of the buffer
- memcpy( m_Buffer, a_Buffer, m_BufferSize );
-
- m_Index = 0;
-
- tm = false; //tm to true will print more information for test mode
- if (m_BufferSize == 82659) {
-// tm = true;
- }
-
- m_CurrentCompound = this;
-
- m_bDecompressed = true;
-}
-
-bool cNBTData::OpenCompound( std::string a_Name )
-{
- cNBTCompound* Compound = GetCompound( a_Name );
- if( Compound )
- {
- m_CurrentCompound = Compound;
- return true;
- }
- printf("WARNING: Could not open NBT Compound %s\n", a_Name.c_str() );
- return false;
-}
-
-bool cNBTData::CloseCompound()
-{
- if( m_CurrentCompound->GetParentCompound() )
- {
- m_CurrentCompound = m_CurrentCompound->GetParentCompound();
- return true;
- }
- printf("WARNING: Could not close NBT Compound, already at root!\n" );
- return false;
-}
-
-bool cNBTCompound::OpenList( std::string a_Name )
-{
- if( GetList( a_Name ) )
- {
- m_CurrentList = GetList( a_Name );
- return true;
- }
- printf("WARNING: Could not open NBT List %s\n", a_Name.c_str() );
- return false;
-}
-
-bool cNBTCompound::CloseList()
-{
- if( m_CurrentList )
- {
- m_CurrentList = m_CurrentList->GetParentList();
- return true;
- }
- printf("WARNING: Could not close NBT List, no list open!\n" );
- return false;
-}
-
-bool cNBTData::OpenList( std::string a_Name )
-{
- return m_CurrentCompound->OpenList( a_Name );
-}
-
-bool cNBTData::CloseList()
-{
- return m_CurrentCompound->CloseList();
-}
-
-void cNBTData::Compress()
-{
- //printf("Before Compress size: %i\n", m_BufferSize );//re
- const int MAXNBTSIZE = 1024 * 1024 * 120;
-
- int ret;
- unsigned have;
- z_stream strm;
- unsigned char* Compressed = new unsigned char[MAXNBTSIZE];
-
- /* allocate deflate state */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = m_BufferSize;
- strm.avail_out = MAXNBTSIZE;
- strm.next_in =(Bytef*)m_Buffer;
- strm.next_out = Compressed;
- strm.total_in = 0;
- strm.total_out = 0;
- ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15+MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
- if (ret != Z_OK)
- {
- printf("deflateInit2 returned NOT OK\n");
- return;
- }
-
-
-
- /* run deflate() on input until output buffer not full, finish
- compression if all of source has been read in */
-
- ret = deflate(&strm, Z_FULL_FLUSH); /* no bad return value */
- if( ret != Z_OK )
- {
- printf("WARNING: deflate returned NOT OK\n");
- }
- assert(ret != Z_STREAM_ERROR); /* state not clobbered */
- have = strm.total_out;
-
- assert(strm.avail_in == 0); /* all input will be used */
-
- if( ret != Z_STREAM_END )
- {
- //printf("WARNING: Compressing didn't go to end of stream\n");//re
- }
-
- if(m_Buffer)
- {
- delete [] m_Buffer;
- m_Buffer = 0;
- }
-
- //printf("Compressed size: %i\n", have );//re
-
- m_BufferSize = have;
- m_Buffer = new char[ m_BufferSize ];
- memcpy( m_Buffer, Compressed, m_BufferSize );
- delete Compressed;
-
- /* clean up and return */
- deflateEnd(&strm);
- m_bDecompressed = false;
- return;
-}
-
-bool cNBTData::Decompress()
-{
- if( m_bDecompressed )
- {
- printf("WARNING: Decompress called, while it has already been decompressed\n");
- return false;
- }
- if( m_BufferSize == 0 )
- {
- printf("WARNING: Decompress called, with m_BufferSize of 0\n");
- return false;
- }
-
- //printf("Before Decompress size: %i\n", m_BufferSize );//re
-
- const int MAXNBTSIZE = 1024 * 1024 * 120 ;
-
- int ret;
- z_stream strm;
- unsigned char* out = new unsigned char[MAXNBTSIZE];
-
- /* allocate inflate state */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = Z_NULL;
- strm.next_in = Z_NULL;
- strm.avail_in = m_BufferSize;
- strm.avail_out = Z_NULL;
- strm.next_in = (Bytef*)m_Buffer;
- strm.next_out = Z_NULL;
- strm.avail_out = MAXNBTSIZE;
- strm.next_out = out;
- strm.total_in = 0;
- strm.total_out = 0;
-
- ret = inflateInit2(&strm, 16+MAX_WBITS);
- if (ret != Z_OK)
- {
- printf("inflateInit2 returned NOT OK\n");
- delete out;
- return false;
- }
-
- if( (ret = inflate(&strm, Z_NO_FLUSH)) != Z_STREAM_END)
- {
- assert(ret != Z_STREAM_ERROR); /* state not clobbered */
- printf("ret != Z_STREAM_END\n");
- }
- unsigned UncompressedSize = strm.total_out; //MAXNBTSIZE - strm.avail_out;
-
- m_Buffer = new char[ UncompressedSize ];
- memcpy( m_Buffer, out, UncompressedSize );
- m_BufferSize = UncompressedSize;
-
- inflateEnd(&strm);
- delete [] out;
-
- if( ret != Z_STREAM_END )
- {
- printf("WARNING: NBT Data received was too big! (More than %i bytes)\n", MAXNBTSIZE);
- }
-
- //printf("Decompressed Size: %i\n", UncompressedSize );//re
- m_bDecompressed = true;
- return (ret == Z_STREAM_END) ? true : false;
-}
-
-void cNBTCompound::AppendShort( std::string & a_Buffer, short a_Value )
-{
- a_Buffer.push_back( (char)((a_Value>>8)&0xff) );
- a_Buffer.push_back( (char)((a_Value)&0xff) );
-}
-
-void cNBTCompound::AppendInteger( std::string & a_Buffer, int a_Value )
-{
- int NetVal = htonl( a_Value );
- a_Buffer.append( (char*)&NetVal, sizeof( int ) );
-}
-
-void cNBTCompound::Serialize(std::string & a_Buffer)
-{
- //printf("cNBTCompound::Serialize()\n");//re
- for( CompoundMap::iterator itr = m_Compounds.begin(); itr != m_Compounds.end(); itr++ )
- {
- if( itr->second == 0 ) continue;
- a_Buffer.push_back( TAG_Compound );
- AppendShort( a_Buffer, (short)itr->first.size() );
- if( itr->first.size() > 0 )
- {
- a_Buffer.append( itr->first.c_str(), itr->first.size() );
- }
- itr->second->Serialize( a_Buffer );
- a_Buffer.push_back( TAG_End );
- }
-
- for( ListMap::iterator itr = m_Lists.begin(); itr != m_Lists.end(); itr++ )
- {
- if( itr->second == 0 ) continue;
- a_Buffer.push_back( TAG_List );
- AppendShort( a_Buffer, (short)itr->first.size() );
- if( itr->first.size() > 0 )
- {
- a_Buffer.append( itr->first.c_str(), itr->first.size() );
- }
- a_Buffer.push_back( (char)itr->second->GetType() );
- AppendInteger( a_Buffer, itr->second->GetSize() );
- itr->second->Serialize( a_Buffer );
- }
-
- for( IntegerMap::iterator itr = m_Integers.begin(); itr != m_Integers.end(); itr++ )
- {
- a_Buffer.push_back( TAG_Int );
- AppendShort( a_Buffer, (short)itr->first.size() );
- if( itr->first.size() > 0 )
- {
- a_Buffer.append( itr->first.c_str(), itr->first.size() );
- }
- AppendInteger( a_Buffer, itr->second );
- }
-
- for( ShortMap::iterator itr = m_Shorts.begin(); itr != m_Shorts.end(); itr++ )
- {
- a_Buffer.push_back( TAG_Short );
- AppendShort( a_Buffer, (short)itr->first.size() );
- if( itr->first.size() > 0 )
- {
- a_Buffer.append( itr->first.c_str(), itr->first.size() );
- }
- AppendShort( a_Buffer, itr->second );
- }
-
- for( ByteMap::iterator itr = m_Bytes.begin(); itr != m_Bytes.end(); itr++ )
- {
- a_Buffer.push_back( TAG_Byte );
- AppendShort( a_Buffer, (short)itr->first.size() );
- if( itr->first.size() > 0 )
- {
- a_Buffer.append( itr->first.c_str(), itr->first.size() );
- }
- a_Buffer.push_back( itr->second );
- }
-
- for( DoubleMap::iterator itr = m_Doubles.begin(); itr != m_Doubles.end(); itr++ )
- {
- a_Buffer.push_back( TAG_Double );
- AppendShort( a_Buffer, (short)itr->first.size() );
- if( itr->first.size() > 0 )
- {
- a_Buffer.append( itr->first.c_str(), itr->first.size() );
- }
- a_Buffer.push_back( itr->second );
- }
-
- for( FloatMap::iterator itr = m_Floats.begin(); itr != m_Floats.end(); itr++ )
- {
- a_Buffer.push_back( TAG_Float );
- AppendShort( a_Buffer, (short)itr->first.size() );
- if( itr->first.size() > 0 )
- {
- a_Buffer.append( itr->first.c_str(), itr->first.size() );
- }
- a_Buffer.push_back( itr->second );
- }
-
- for( LongMap::iterator itr = m_Longs.begin(); itr != m_Longs.end(); itr++ )
- {
- a_Buffer.push_back( TAG_Long );
- AppendShort( a_Buffer, (short)itr->first.size() );
- if( itr->first.size() > 0 )
- {
- a_Buffer.append( itr->first.c_str(), itr->first.size() );
- }
- a_Buffer.push_back( itr->second );
- }
-
-
-}
-
-void cNBTCompound::PrintData( int a_Depth, std::string a_Name )
-{
- char* Prefix = new char[a_Depth*4+1];
- for(int i = 0; i < a_Depth*4; i++)
- Prefix[i] = ' ';
- Prefix[ a_Depth*4 ] = 0;
-
- if( a_Name.size() > 0 )
- printf("%sCOMPOUND (%s)\n", Prefix, a_Name.c_str() );
- else
- printf("%sCOMPOUND (...)\n", Prefix );
-
- delete Prefix;
- a_Depth++;
- Prefix = new char[a_Depth*4];
- for(int i = 0; i < a_Depth*4; i++)
- Prefix[i] = ' ';
- Prefix[ a_Depth*4-1 ] = 0;
-
- for( CompoundMap::iterator itr = m_Compounds.begin(); itr != m_Compounds.end(); itr++ )
- {
- if( itr->second == 0 ) continue;
- itr->second->PrintData( a_Depth, itr->first );
- }
-
- for( ListMap::iterator itr = m_Lists.begin(); itr != m_Lists.end(); itr++)
- {
- if( itr->second == 0 ) continue;
- itr->second->PrintData( a_Depth, itr->first );
- }
-
- for( StringMap::iterator itr = m_Strings.begin(); itr != m_Strings.end(); itr++ )
- {
- printf("%s STRING %s (%s)\n", Prefix, itr->first.c_str(), itr->second.c_str() );
- }
-
- for( IntegerMap::iterator itr = m_Integers.begin(); itr != m_Integers.end(); itr++ )
- {
- printf("%s INTEGER %s (%i)\n", Prefix, itr->first.c_str(), itr->second );
- }
-
- for( ShortMap::iterator itr = m_Shorts.begin(); itr != m_Shorts.end(); itr++ )
- {
- printf("%s SHORT %s (%i)\n", Prefix, itr->first.c_str(), itr->second );
- }
-
- for( FloatMap::iterator itr = m_Floats.begin(); itr != m_Floats.end(); itr++ )
- {
- printf("%s FLOAT %s (%f)\n", Prefix, itr->first.c_str(), itr->second );
- }
-
- for( LongMap::iterator itr = m_Longs.begin(); itr != m_Longs.end(); itr++ )
- {
- printf("%s LONG %s (%lli)\n", Prefix, itr->first.c_str(), itr->second );
- }
-
- for( DoubleMap::iterator itr = m_Doubles.begin(); itr != m_Doubles.end(); itr++ )
- {
- printf("%s Double %s (%f)\n", Prefix, itr->first.c_str(), itr->second );
- }
-
- for( ByteMap::iterator itr = m_Bytes.begin(); itr != m_Bytes.end(); itr++ )
- {
- printf("%s BYTE %s (%i)\n", Prefix, itr->first.c_str(), itr->second );
- }
-
- for( ByteArrayMap::iterator itr = m_ByteArrays.begin(); itr != m_ByteArrays.end(); itr++ )
- {
- printf("%s BYTE ARRAY %s (length: %li)\n", Prefix, itr->first.c_str(), sizeof(itr->second) );
- }
-
- delete Prefix;
-}
-
-void cNBTData::PrintData()
-{
- printf("==== STRUCTURED NBT DATA ====\n");
- m_CurrentCompound->PrintData( 0, " " );
- printf("=============================\n");
-}
-
-void cNBTData::Serialize()
-{
- std::string Buffer;
- m_CurrentCompound->Serialize( Buffer );
-
- if( m_Buffer )
- delete m_Buffer;
- m_Buffer = new char[Buffer.size()];
- memcpy( m_Buffer, Buffer.c_str(), Buffer.size() );
- m_BufferSize = Buffer.size();
-
- //printf("m_BufferSize1: %i\n", m_BufferSize);//re
-
- //for(unsigned int i = 0; i < m_BufferSize; i++)//re
- //{//re
- // printf("%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );//re
- //}//re
-}
-
-void cNBTData::ParseData()
-{
- if(!m_bDecompressed)
- {
- printf("WARNING: ParseData() called while data was not decompressed\n");
- return;
- }
-
- m_Index = 0;
- //printf("m_BufferSize2: %i\n", m_BufferSize);//re
- //printf("cNBTData::ParseData()\n");//re
- //for(unsigned int i = 0; i < m_BufferSize; i++)//re
- //for(unsigned int i = 0; i < 70; i++)//re
- //{//re
- // printf("echo%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );//re
- //}//re
-
- while( m_Index < m_BufferSize )
- {
- if (tm) {
- printf("m_BufferSize3: %i\n", m_BufferSize);
- printf("m_Index: %i\n", m_Index);
- }
- ParseTags();
- }
-
-
- delete [] m_Buffer;
- m_Buffer = 0; m_BufferSize = 0;
-}
-
-void cNBTData::ParseTags()
-{
- if( m_Index < m_BufferSize )
- {
- //printf("ParseTags idx:%02i %02x %3i %c\n", m_Index, (unsigned char)m_Buffer[m_Index], (unsigned char)m_Buffer[m_Index], m_Buffer[m_Index] );//re
- ENUM_TAG Tag = (ENUM_TAG)m_Buffer[m_Index];
- if( Tag > 0 && m_ParseFunctions[ Tag ] )
- {
- //printf("m_BufferSize4: %i\n", m_BufferSize);
- //printf("m_Index1: %i\n\n\n\n", m_Index);
-
- m_Index++;
- if (tm) {
- printf("Tag: %i\n", Tag);
- }
- (*this.*m_ParseFunctions[ Tag ])(true);
- }
- else if( Tag == TAG_End )
- {
- if (tm) {
- printf("Tag End\n");
- int n;
- std::cin >> n;
- }
- m_Index++;
- }
- else
- {
- printf("UNKNOWN TAG %x\n", m_Buffer[m_Index] );
- for(unsigned int i = (m_Index-10 > 0)?m_Index-10:0 ; i < m_Index+10 && i < m_BufferSize; i++)
- {
- printf("%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );
- }
- m_Index = m_BufferSize;
- return;
- }
- }
-}
-
-void cNBTData::ParseCompound( bool a_bNamed )
-{
- std::string Name;
- if( a_bNamed ) Name = ReadName();
- //printf("OPEN COMPOUND: %s\n", Name.c_str() );//re
-
- PutCompound( Name );
- OpenCompound( Name );
- while( m_Index < m_BufferSize && m_Buffer[ m_Index ] != TAG_End )
- {
- ParseTags();
- }
- CloseCompound();
- m_Index++;
- //printf("CLOSE COMPOUND\n");//re
-}
-
-void cNBTData::ParseList( bool a_bNamed )
-{
- std::string Name;
- if( a_bNamed ) Name = ReadName();
- ENUM_TAG TagType = (ENUM_TAG)ReadByte();
- int Length = ReadInt();
- //printf("LIST: %s Type: %02x Length: %i\n", Name.c_str(), TagType, Length );//re
-
- //for(unsigned int i = (m_Index-10 > 0)?m_Index-10:0 ; i < m_Index+10 && i < m_BufferSize; i++)//re
- //{//re
- //printf("%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );//re
- //}//re
-
- if (tm) {
- printf("List Name, tag, length: %s, %i, %i\n", Name.c_str(), (int)TagType, Length);
- }
-
- PutList( Name, TagType );
- OpenList( Name );
- for(int i = 0; i < Length && m_Index < m_BufferSize; i++)
- {
- if( m_ParseFunctions[ TagType ] )
- {
- (*this.*m_ParseFunctions[ TagType ] )(false);
- }
- }
- if (tm) {
- printf("List Done Name, tag, length: %s, %i, %i\n", Name.c_str(), (int)TagType, Length);
- }
-
- CloseList();
-
-}
-
-void cNBTData::ParseByte( bool a_bNamed )
-{
- std::string Name;
- if( a_bNamed ) Name = ReadName();
- char Value = ReadByte();
-
- PutByte( Name, Value );
- if (tm) {
- printf("BYTE: %s %i\n", Name.c_str(), Value );//re
- }
-}
-
-void cNBTData::ParseShort( bool a_bNamed )
-{
- std::string Name;
- if( a_bNamed ) Name = ReadName();
- short Value = ReadShort();
-
- PutShort( Name, Value );
- if (tm) {
- printf("SHORT: %s %i\n", Name.c_str(), Value );//re
- }
-}
-
-void cNBTData::ParseInt( bool a_bNamed )
-{
- std::string Name;
- if( a_bNamed ) Name = ReadName();
- int Value = ReadInt();
-
- PutInteger( Name, Value );
- if (tm) {
- printf("INT: %s %i\n", Name.c_str(), Value );//re
- }
-}
-
-void cNBTData::ParseLong( bool a_bNamed )
-{
- if (tm) {
- for(unsigned int i = (m_Index-10 > 0)?m_Index-10:0 ; i < m_Index+30 && i < m_BufferSize; i++) {
- printf("%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );
- }
- }
- std::string Name;
- if( a_bNamed ) Name = ReadName();
- long long Value = ReadLong();
-
- //PutInteger( Name, (int)Value );
- PutLong( Name, Value );
- if (tm) {
- printf("LONG: %s %lli\n", Name.c_str(), Value );//re
- }
-}
-
-void cNBTData::ParseDouble( bool a_bNamed )
-{
- if (tm) {
- for(unsigned int i = (m_Index-10 > 0)?m_Index-10:0 ; i < m_Index+30 && i < m_BufferSize; i++) {
- printf("%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );
- }
- }
- std::string Name;
- if( a_bNamed ) Name = ReadName();
- double Value = ReadDouble();
-
- //PutInteger( Name, (int)Value );
- PutDouble( Name, Value );
- if (tm) {
- printf("Double: %s %f\n", Name.c_str(), Value );//re
- }
-}
-
-void cNBTData::ParseFloat( bool a_bNamed )
-{
- if (tm) {
- for(unsigned int i = (m_Index-10 > 0)?m_Index-10:0 ; i < m_Index+30 && i < m_BufferSize; i++) {
- printf("%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );
- }
- }
- std::string Name;
- if( a_bNamed ) Name = ReadName();
- float Value = ReadFloat();
-
- //PutInteger( Name, (int)Value );
- PutFloat( Name, Value );
- if (tm) {
- printf("Float: %s %f\n", Name.c_str(), Value );//re
- }
-}
-
-void cNBTData::ParseString( bool a_bNamed )
-{
- std::string Name;
- if( a_bNamed ) Name = ReadName();
- std::string String = ReadName();
-
- PutString( Name, String );
- if (tm) {
- printf("STRING: %s (%s)\n", Name.c_str(), String.c_str() );//re
- }
-}
-
-void cNBTData::ParseByteArray( bool a_bNamed )
-{
-
- std::string Name;
- if( a_bNamed ) Name = ReadName();
-
- int Length = ReadInt();
- std::string String;
-
- char* ByteArray = 0;
- if( Length > 0 )
- {
- ByteArray = new char[ Length ];
- memcpy( ByteArray, &m_Buffer[ m_Index ], Length );
- m_Index += Length;
- }
-
- PutByteArray( Name, ByteArray );
-
- if (tm) {
- for(unsigned int i = (m_Index-10 > 0)?m_Index-10:0 ; i < m_Index+10 && i < m_BufferSize; i++) {
- printf("%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );
- }
- }
-}
-
-std::string cNBTData::ReadName()
-{
- //printf("crui1 \n");
- short Length = ReadShort();
-
- //printf("crui Length: %i\n", Length);
- std::string Name;
- if( Length > 0 )
- {
- for(int i = 0; i < Length; i++, m_Index++)
- {
- Name.push_back( m_Buffer[m_Index] );
- }
- }
- return Name;
-}
-
-char cNBTData::ReadByte()
-{
- unsigned char Byte = m_Buffer[ m_Index ]; m_Index++;
- return Byte;
-}
-
-short cNBTData::ReadShort()
-{
- short Length = 0;
- Length |= m_Buffer[ m_Index ] << 8; m_Index++;
- Length |= m_Buffer[ m_Index ]; m_Index++;
- return Length;
-}
-
-int cNBTData::ReadInt()
-{
- int Value = 0;
- memcpy( &Value, m_Buffer+m_Index, sizeof(int) );
- m_Index+=sizeof(int);
-
- return ntohl( Value );
-}
-
-long long cNBTData::ReadLong()
-{
- if (tm) {
- printf( "here1 : %i, m_Index: %i\n", (int)sizeof(long long), (int)m_Index );
- }
- long long Value = 0;
- memcpy( &Value, m_Buffer+m_Index, sizeof(long long) );
- m_Index+=sizeof(long long);
- if (tm) {
- printf( "here2 : %i, m_Index: %i\n", (int)sizeof(long long), (int)m_Index );
- }
- return Value;
-}
-
-double cNBTData::ReadDouble()
-{
- double Value = 0;
- memcpy( &Value, m_Buffer+m_Index, sizeof(double) );
- m_Index+=sizeof(double);
-
- return Value;
-}
-
-float cNBTData::ReadFloat()
-{
- float Value = 0;
- memcpy( &Value, m_Buffer+m_Index, sizeof(float) );
- m_Index+=sizeof(float);
-
- return Value;
-}
-
-void cNBTCompound::PutList( std::string Name, ENUM_TAG Type )
-{
- m_Lists[Name] = new cNBTList( m_CurrentList, Type );
-}
-
-void cNBTCompound::PutCompound( std::string Name )
-{
- if( m_CurrentList )
- {
- m_CurrentList->AddToList( new cNBTCompound( this ) );
- }
- else
- {
- m_Compounds[Name] = new cNBTCompound( this );
- }
-}
-
-void cNBTCompound::PutFloat( std::string Name, float Value )
-{
- if( m_CurrentList )
- m_CurrentList->AddToList( (void*)((unsigned int*)&Value) );
- else
- m_Floats[Name] = Value;
-}
-
-cNBTCompound* cNBTCompound::GetCompound( std::string Name )
-{
- if( m_CurrentList )
- {
- if( m_CurrentList->GetType() != TAG_Compound )
- return 0;
-
- return (cNBTCompound*)m_CurrentList->GetLastElement();
- }
- return m_Compounds[Name];
-}
-
-void cNBTList::PrintData(int a_Depth, std::string a_Name)
-{
- char* Prefix = new char[a_Depth*4];
- for(int i = 0; i < a_Depth*4; i++)
- Prefix[i] = ' ';
- Prefix[ a_Depth*4-1 ] = 0;
-
- if( a_Name.size() > 0 )
- printf("%s LIST (%s)\n", Prefix, a_Name.c_str() );
- else
- printf("%s LIST\n", Prefix );
-
- delete [] Prefix;
-
- for( VoidList::iterator itr = m_List.begin(); itr != m_List.end(); itr++)
- {
- switch( m_Type )
- {
- case cNBTCompound::TAG_Compound:
- {
- ((cNBTCompound*)*itr)->PrintData(a_Depth+1, "...");
- }
- break;
- default:
- break;
- }
- }
-}
-
-void cNBTList::Serialize(std::string & a_Buffer)
-{
- for( VoidList::iterator itr = m_List.begin(); itr != m_List.end(); itr++ )
- {
- switch( m_Type )
- {
- case cNBTCompound::TAG_Compound:
- {
- ((cNBTCompound*)(*itr))->Serialize( a_Buffer );
- a_Buffer.push_back( cNBTCompound::TAG_End );
- }
- break;
- default:
- break;
- }
- }
-}
-
-void cNBTData::Clear()
-{
- while( m_CurrentCompound != this ) CloseCompound(); // Close ALL the compounds!!
-
- m_CurrentCompound->Clear(); // This recursively clears all compounds
-
- if( m_Buffer )
- {
- delete m_Buffer;
- m_Buffer = 0;
- }
- m_BufferSize = 0;
-}
-
-void cNBTCompound::Clear()
-{
- for( CompoundMap::iterator itr = m_Compounds.begin(); itr != m_Compounds.end(); itr++ )
- {
- if( itr->second == 0 ) continue;
- itr->second->Clear();
- delete itr->second;
- itr->second = 0;
- }
- m_Compounds.clear();
-
- for( ListMap::iterator itr = m_Lists.begin(); itr != m_Lists.end(); itr++ )
- {
- if( itr->second == 0 ) continue;
- itr->second->Clear();
- delete itr->second;
- itr->second = 0;
- }
- m_Lists.clear();
-
- for( ByteArrayMap::iterator itr = m_ByteArrays.begin(); itr != m_ByteArrays.end(); itr++ )
- {
- if( itr->second == 0 ) continue;
- delete [] itr->second;
- itr->second = 0;
- }
- m_ByteArrays.clear();
-
- // Don't really have to do this, but meh
- m_Bytes.clear();
- m_Shorts.clear();
- m_Integers.clear();
- m_Longs.clear();
- m_Doubles.clear();
- m_Floats.clear();
- m_Strings.clear();
-}
-
-void cNBTList::Clear()
-{
- for( VoidList::iterator itr = m_List.begin(); itr != m_List.end(); itr++)
- {
- switch( m_Type )
- {
- case cNBTCompound::TAG_Compound:
- {
- cNBTCompound* Compound = (cNBTCompound*)(*itr);
- Compound->Clear();
- delete Compound;
- *itr = 0;
- }
- break;
- case cNBTCompound::TAG_List:
- {
- cNBTList* List = (cNBTList*)(*itr);
- List->Clear();
- delete List;
- *itr = 0;
- }
- break;
- default:
- break;
- }
- }
- m_List.clear();
-}
diff --git a/converter/source/cNBTData.h b/converter/source/cNBTData.h
deleted file mode 100644
index 7d80aacb9..000000000
--- a/converter/source/cNBTData.h
+++ /dev/null
@@ -1,198 +0,0 @@
-#pragma once
-
-#include