1
0

Compounds are not closed double anymore

Float values are actually added to 'lists' now (should do the same for the rest)
Indenting while printing NBT data aligns slightly better now


git-svn-id: http://mc-server.googlecode.com/svn/trunk@32 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth 2011-10-31 05:12:21 +00:00
parent 20d391764c
commit 35c44ede5a
2 changed files with 19 additions and 16 deletions

View File

@ -362,9 +362,9 @@ void cNBTCompound::PrintData( int a_Depth, std::string a_Name )
Prefix[ a_Depth*4 ] = 0;
if( a_Name.size() > 0 )
printf("%s COMPOUND (%s)\n", Prefix, a_Name.c_str() );
printf("%sCOMPOUND (%s)\n", Prefix, a_Name.c_str() );
else
printf("%s COMPOUND\n", Prefix );
printf("%sCOMPOUND (...)\n", Prefix );
delete Prefix;
a_Depth++;
@ -385,6 +385,11 @@ void cNBTCompound::PrintData( int a_Depth, std::string a_Name )
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 );
@ -481,7 +486,7 @@ 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
unsigned char Tag = m_Buffer[m_Index];
ENUM_TAG Tag = (ENUM_TAG)m_Buffer[m_Index];
if( Tag > 0 && m_ParseFunctions[ Tag ] )
{
//printf("m_BufferSize4: %i\n", m_BufferSize);
@ -528,6 +533,7 @@ void cNBTData::ParseCompound( bool a_bNamed )
ParseTags();
}
CloseCompound();
m_Index++;
//printf("CLOSE COMPOUND\n");//re
}
@ -552,20 +558,9 @@ void cNBTData::ParseList( bool a_bNamed )
OpenList( Name );
for(int i = 0; i < Length && m_Index < m_BufferSize; i++)
{
if( (int)TagType == 6 ) {
cNBTData::ParseDouble( false );
} else if( (int)TagType == 5 ) {
cNBTData::ParseFloat( false );
} else
if( m_ParseFunctions[ TagType ] )
{
(*this.*m_ParseFunctions[ TagType ] )(false);
m_Index++;
}
}
if (tm) {
@ -772,7 +767,7 @@ float cNBTData::ReadFloat()
memcpy( &Value, m_Buffer+m_Index, sizeof(float) );
m_Index+=sizeof(float);
return Value;
return Value;
}
void cNBTCompound::PutList( std::string Name, ENUM_TAG Type )
@ -792,6 +787,14 @@ void cNBTCompound::PutCompound( std::string Name )
}
}
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 )

View File

@ -40,7 +40,7 @@ public:
void PutInteger( std::string Name, int Value ) { m_Integers[Name] = Value; }
void PutLong( std::string Name, long long Value ) { m_Longs[Name] = Value; }
void PutDouble( std::string Name, double Value ) { m_Doubles[Name] = Value; }
void PutFloat( std::string Name, float Value ) { m_Floats[Name] = Value; }
void PutFloat( std::string Name, float Value );
void PutString( std::string Name, std::string Value ) { m_Strings[Name] = Value; }
void PutByteArray( std::string Name, char* ByteArray ) { m_ByteArrays[Name] = ByteArray; }
void PutCompound( std::string Name );