From 87a7bfa9aa1edd0d4ba467b341147fcaab3be7cf Mon Sep 17 00:00:00 2001 From: "admin@omencraft.com" Date: Sun, 30 Oct 2011 07:10:22 +0000 Subject: Added Long Tag. It'll now go through the entire NBT data without erroring out. I'm not sure that it's actually saving all tag 7 data though. git-svn-id: http://mc-server.googlecode.com/svn/trunk@24 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- converter/cConvert.cpp | 2 +- converter/cNBTData.cpp | 21 +++++++++++++++++++++ converter/cNBTData.h | 17 +++++++++++++---- converter/denotch | Bin 148086 -> 154788 bytes 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/converter/cConvert.cpp b/converter/cConvert.cpp index 0906a646e..876d1a009 100644 --- a/converter/cConvert.cpp +++ b/converter/cConvert.cpp @@ -176,7 +176,7 @@ int main () { cNBTData* NBTData = new cNBTData::cNBTData(BlockData, (testr)); //NBTData->m_bDecompressed = true; NBTData->ParseData(); - //NBTData->PrintData(); + NBTData->PrintData(); 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 a492f847c..845e8382b 100644 --- a/converter/cNBTData.cpp +++ b/converter/cNBTData.cpp @@ -30,6 +30,7 @@ cNBTData::cNBTData( char* a_Buffer, unsigned int a_BufferSize ) 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_String] = &cNBTData::ParseString; m_ParseFunctions[TAG_List] = &cNBTData::ParseList; m_ParseFunctions[TAG_Compound] = &cNBTData::ParseCompound; @@ -519,6 +520,17 @@ void cNBTData::ParseInt( bool a_bNamed ) printf("INT: %s %i\n", Name.c_str(), Value );//re } +void cNBTData::ParseLong( bool a_bNamed ) +{ + std::string Name; + if( a_bNamed ) Name = ReadName(); + long Value = ReadLong(); + + PutInteger( Name, Value ); + + printf("LONG: %s %li\n", Name.c_str(), Value );//re +} + void cNBTData::ParseString( bool a_bNamed ) { std::string Name; @@ -593,6 +605,15 @@ int cNBTData::ReadInt() return ntohl( Value ); } +long cNBTData::ReadLong() +{ + long Value = 0; + memcpy( &Value, m_Buffer+m_Index, sizeof(long) ); + m_Index+=sizeof(long); + + return ntohl( Value ); +} + void cNBTCompound::PutList( std::string Name, ENUM_TAG Type ) { m_Lists[Name] = new cNBTList( m_CurrentList, Type ); diff --git a/converter/cNBTData.h b/converter/cNBTData.h index 77d0ff256..4de9822d3 100644 --- a/converter/cNBTData.h +++ b/converter/cNBTData.h @@ -23,6 +23,7 @@ public: TAG_Byte, TAG_Short, TAG_Int, + TAG_Long, TAG_ByteArray = 7, TAG_String, TAG_List, @@ -32,10 +33,11 @@ public: void Clear(); - void PutByte( std::string Name, char Value ) { m_Bytes[Name] = Value; } - void PutShort( std::string Name, short Value ) { m_Shorts[Name] = Value; } - void PutInteger( std::string Name, int Value ) { m_Integers[Name] = Value; } - void PutString( std::string Name, std::string Value ) { m_Strings[Name] = Value; } + void PutByte( std::string Name, char Value ) { m_Bytes[Name] = Value; } + void PutShort( std::string Name, short Value ) { m_Shorts[Name] = Value; } + 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 PutCompound( std::string Name ); void PutList( std::string Name, ENUM_TAG Type ); @@ -43,6 +45,7 @@ public: 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]; } cNBTCompound* GetCompound( std::string Name ); @@ -67,6 +70,7 @@ private: typedef std::map ByteMap; typedef std::map ShortMap; typedef std::map IntegerMap; + typedef std::map LongMap; typedef std::map StringMap; typedef std::map ByteArrayMap; typedef std::map CompoundMap; @@ -74,6 +78,7 @@ private: ByteMap m_Bytes; ShortMap m_Shorts; IntegerMap m_Integers; + LongMap m_Longs; StringMap m_Strings; ByteArrayMap m_ByteArrays; CompoundMap m_Compounds; @@ -124,12 +129,14 @@ public: void PutByte( std::string Name, char Value ) { m_CurrentCompound->PutByte( Name, Value ); } void PutShort( std::string Name, short Value ) { m_CurrentCompound->PutShort( Name, Value ); } 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 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); } cNBTCompound* GetCompound( std::string Name ) { return m_CurrentCompound->GetCompound(Name); } @@ -153,12 +160,14 @@ private: void ParseByte( bool a_bNamed ); void ParseByteArray( bool a_bNamed ); void ParseInt( bool a_bNamed ); + void ParseLong( bool a_bNamed ); void ParseShort( bool a_bNamed ); short ReadShort(); std::string ReadName(); char ReadByte(); int ReadInt(); + long ReadLong(); cNBTCompound* m_CurrentCompound; diff --git a/converter/denotch b/converter/denotch index 82715249d..840178cc1 100755 Binary files a/converter/denotch and b/converter/denotch differ -- cgit v1.2.3