From ca1d98a7baf7d650c02e027c6c15dfc8eeeb171d Mon Sep 17 00:00:00 2001 From: faketruth Date: Sun, 30 Oct 2011 11:41:18 +0000 Subject: Changed long to long long so it works fine on 32bit systems Added printing for Byte array tags (the length is incorrect though) Structured the tags enums a bit more In cConvert.cpp the correct compounds are opened before accessing data Added VS2010 project so the converter can be compiled through VS2010 git-svn-id: http://mc-server.googlecode.com/svn/trunk@27 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- converter/cNBTData.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'converter/cNBTData.cpp') diff --git a/converter/cNBTData.cpp b/converter/cNBTData.cpp index 5bc6e3ddf..fc0dd628e 100644 --- a/converter/cNBTData.cpp +++ b/converter/cNBTData.cpp @@ -357,6 +357,11 @@ void cNBTCompound::PrintData( int a_Depth, std::string a_Name ) 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: %i)\n", Prefix, itr->first.c_str(), sizeof(itr->second) ); + } + delete Prefix; } @@ -524,9 +529,9 @@ void cNBTData::ParseLong( bool a_bNamed ) { std::string Name; if( a_bNamed ) Name = ReadName(); - long Value = ReadLong(); + long long Value = ReadLong(); - PutInteger( Name, Value ); + PutInteger( Name, (int)Value ); printf("LONG: %s %li\n", Name.c_str(), Value );//re } @@ -554,12 +559,8 @@ void cNBTData::ParseByteArray( bool a_bNamed ) char* ByteArray = new char[ Length ]; if( Length > 0 ) { - for(int i = 0; i < Length; i++, m_Index++) - { - ByteArray[i] = m_Buffer[ m_Index ]; - //ByteArray[i].push_back( m_Buffer[m_Index] ); - //String.push_back( m_Buffer[m_Index] ); - } + memcpy( ByteArray, &m_Buffer[ m_Index ], Length ); + m_Index += Length; } PutByteArray( Name, ByteArray ); @@ -607,11 +608,11 @@ int cNBTData::ReadInt() return ntohl( Value ); } -long cNBTData::ReadLong() +long long cNBTData::ReadLong() { - long Value = 0; - memcpy( &Value, m_Buffer+m_Index, sizeof(long) ); - m_Index+=sizeof(long); + long long Value = 0; + memcpy( &Value, m_Buffer+m_Index, sizeof(long long) ); + m_Index+=sizeof(long long); return ntohl( Value ); } @@ -757,4 +758,4 @@ void cNBTList::Clear() } } m_List.clear(); -} +} \ No newline at end of file -- cgit v1.2.3