From 5134805bd749e927afa2da16a98ddfb837477b92 Mon Sep 17 00:00:00 2001 From: "admin@omencraft.com" Date: Sun, 30 Oct 2011 08:04:40 +0000 Subject: More changes to the denotch map converter git-svn-id: http://mc-server.googlecode.com/svn/trunk@25 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- converter/cConvert.cpp | 6 ++++++ converter/cNBTData.cpp | 48 +++++++++++++++++++++++++----------------------- converter/cNBTData.h | 22 +++++++++++----------- converter/denotch | Bin 154788 -> 165208 bytes 4 files changed, 42 insertions(+), 34 deletions(-) (limited to 'converter') diff --git a/converter/cConvert.cpp b/converter/cConvert.cpp index 876d1a009..1ee923a31 100644 --- a/converter/cConvert.cpp +++ b/converter/cConvert.cpp @@ -177,6 +177,12 @@ int main () { //NBTData->m_bDecompressed = true; NBTData->ParseData(); NBTData->PrintData(); + + //Char* Blocks = + //NBTData->GetByteArray("Blocks"); + //for(unsigned int i = 0; i < 111; i++) {//re + //printf("Blocks?: %i\n", NBTData->cNBTCompound::GetByteArray("Blocks")[0]); + //} return 1; fwrite( BlockData, DestSize, 1, wf ); //write contents of uncompressed block data to file to check to see if it's valid... It is! :D //fwrite( &temparr, compdlength, sizeof(unsigned char), wf ); diff --git a/converter/cNBTData.cpp b/converter/cNBTData.cpp index 845e8382b..5bc6e3ddf 100644 --- a/converter/cNBTData.cpp +++ b/converter/cNBTData.cpp @@ -112,15 +112,15 @@ void cNBTData::Compress() 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.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; + 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) { @@ -189,19 +189,19 @@ bool cNBTData::Decompress() 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.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.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; + 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) @@ -551,18 +551,20 @@ void cNBTData::ParseByteArray( bool a_bNamed ) int Length = ReadInt(); std::string String; - + char* ByteArray = new char[ Length ]; if( Length > 0 ) { for(int i = 0; i < Length; i++, m_Index++) { - String.push_back( m_Buffer[m_Index] ); + ByteArray[i] = m_Buffer[ m_Index ]; + //ByteArray[i].push_back( m_Buffer[m_Index] ); + //String.push_back( m_Buffer[m_Index] ); } } - PutByteArray( Name, String ); + PutByteArray( Name, ByteArray ); - printf("VALUE: %s (%s)\n", Name.c_str(), String.c_str() );//re + printf("VALUE: %s First 5 Chars: (%i,%i,%i,%i,%i)\n", Name.c_str(), ByteArray[0],ByteArray[1],ByteArray[2],ByteArray[3],ByteArray[4] );//re } std::string cNBTData::ReadName() diff --git a/converter/cNBTData.h b/converter/cNBTData.h index 4de9822d3..a0a40e68b 100644 --- a/converter/cNBTData.h +++ b/converter/cNBTData.h @@ -38,18 +38,18 @@ public: void PutInteger( std::string Name, int Value ) { m_Integers[Name] = Value; } void PutLong( std::string Name, long Value ) { m_Longs[Name] = Value; } void PutString( std::string Name, std::string Value ) { m_Strings[Name] = Value; } - void PutByteArray( std::string Name, std::string Value ) { m_ByteArrays[Name] = Value; } + void PutByteArray( std::string Name, char* ByteArray ) { m_ByteArrays[Name] = ByteArray; } void PutCompound( std::string Name ); void PutList( std::string Name, ENUM_TAG Type ); - char GetByte( std::string Name ) { return m_Bytes[Name]; } - short GetShort( std::string Name ) { return m_Shorts[Name]; } - int GetInteger( std::string Name ) { return m_Integers[Name]; } - long GetLong( std::string Name ) { return m_Longs[Name]; } - std::string GetString( std::string Name ) { return m_Strings[Name]; } - std::string GetByteArray( std::string Name ) { return m_ByteArrays[Name]; } + char GetByte( std::string Name ) { return m_Bytes[Name]; } + short GetShort( std::string Name ) { return m_Shorts[Name]; } + int GetInteger( std::string Name ) { return m_Integers[Name]; } + long GetLong( std::string Name ) { return m_Longs[Name]; } + std::string GetString( std::string Name ) { return m_Strings[Name]; } + char* GetByteArray( std::string Name ) { return m_ByteArrays[Name]; } cNBTCompound* GetCompound( std::string Name ); - cNBTList* GetList( std::string Name ) { return m_Lists[Name]; } + cNBTList* GetList( std::string Name ) { return m_Lists[Name]; } cNBTList* GetCurrentList() { return m_CurrentList; } cNBTCompound* GetParentCompound() { return m_ParentCompound; } @@ -72,7 +72,7 @@ private: typedef std::map IntegerMap; typedef std::map LongMap; typedef std::map StringMap; - typedef std::map ByteArrayMap; + typedef std::map ByteArrayMap; typedef std::map CompoundMap; typedef std::map ListMap; ByteMap m_Bytes; @@ -131,14 +131,14 @@ public: void PutInteger( std::string Name, int Value ) { m_CurrentCompound->PutInteger( Name, Value ); } void PutLong( std::string Name, long Value ) { m_CurrentCompound->PutLong( Name, Value ); } void PutString( std::string Name, std::string Value ) { m_CurrentCompound->PutString(Name, Value); } - void PutByteArray( std::string Name, std::string Value ) { m_CurrentCompound->PutByteArray( Name, Value ); } + void PutByteArray( std::string Name, char* ByteArray ) { m_CurrentCompound->PutByteArray( Name, ByteArray ); } void PutCompound( std::string Name ) { m_CurrentCompound->PutCompound( Name ); } void PutList( std::string Name, ENUM_TAG Type ) { m_CurrentCompound->PutList( Name, Type ); } int GetInteger( std::string Name ) { return m_CurrentCompound->GetInteger(Name); } long GetLong( std::string Name ) { return m_CurrentCompound->GetLong(Name); } std::string GetString( std::string Name ) { return m_CurrentCompound->GetString(Name); } - std::string GetByteArray( std::string Name ) { return m_CurrentCompound->GetByteArray(Name); } + char* GetByteArray( std::string Name ) { return m_CurrentCompound->GetByteArray(Name); } cNBTCompound* GetCompound( std::string Name ) { return m_CurrentCompound->GetCompound(Name); } cNBTList* GetList( std::string Name ) { return m_CurrentCompound->GetList(Name); } diff --git a/converter/denotch b/converter/denotch index 840178cc1..dfc191c69 100755 Binary files a/converter/denotch and b/converter/denotch differ -- cgit v1.2.3