1
0

I think I got Tag 7 working, now I need to add tag 4 for the deNotch map converter.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@23 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
admin@omencraft.com 2011-10-30 06:48:10 +00:00
parent 07ac0492d0
commit aead2e43c2
4 changed files with 52 additions and 27 deletions

View File

@ -173,7 +173,7 @@ int main () {
//testing of nbtparser. //testing of nbtparser.
cNBTData* NBTData = new cNBTData::cNBTData(BlockData, testr*2); cNBTData* NBTData = new cNBTData::cNBTData(BlockData, (testr));
//NBTData->m_bDecompressed = true; //NBTData->m_bDecompressed = true;
NBTData->ParseData(); NBTData->ParseData();
//NBTData->PrintData(); //NBTData->PrintData();

View File

@ -102,7 +102,7 @@ bool cNBTData::CloseList()
void cNBTData::Compress() void cNBTData::Compress()
{ {
printf("Before Compress size: %i\n", m_BufferSize );//re //printf("Before Compress size: %i\n", m_BufferSize );//re
const int MAXNBTSIZE = 1024 * 1024 * 120; const int MAXNBTSIZE = 1024 * 1024 * 120;
int ret; int ret;
@ -153,7 +153,7 @@ void cNBTData::Compress()
m_Buffer = 0; m_Buffer = 0;
} }
printf("Compressed size: %i\n", have );//re //printf("Compressed size: %i\n", have );//re
m_BufferSize = have; m_BufferSize = have;
m_Buffer = new char[ m_BufferSize ]; m_Buffer = new char[ m_BufferSize ];
@ -179,7 +179,7 @@ bool cNBTData::Decompress()
return false; return false;
} }
printf("Before Decompress size: %i\n", m_BufferSize );//re //printf("Before Decompress size: %i\n", m_BufferSize );//re
const int MAXNBTSIZE = 1024 * 1024 * 120 ; const int MAXNBTSIZE = 1024 * 1024 * 120 ;
@ -229,7 +229,7 @@ bool cNBTData::Decompress()
printf("WARNING: NBT Data received was too big! (More than %i bytes)\n", MAXNBTSIZE); printf("WARNING: NBT Data received was too big! (More than %i bytes)\n", MAXNBTSIZE);
} }
printf("Decompressed Size: %i\n", UncompressedSize );//re //printf("Decompressed Size: %i\n", UncompressedSize );//re
m_bDecompressed = true; m_bDecompressed = true;
return (ret == Z_STREAM_END) ? true : false; return (ret == Z_STREAM_END) ? true : false;
} }
@ -377,10 +377,12 @@ void cNBTData::Serialize()
memcpy( m_Buffer, Buffer.c_str(), Buffer.size() ); memcpy( m_Buffer, Buffer.c_str(), Buffer.size() );
m_BufferSize = Buffer.size(); m_BufferSize = Buffer.size();
for(unsigned int i = 0; i < m_BufferSize; i++)//re printf("m_BufferSize1: %i\n", m_BufferSize);//re
{//re
printf("%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );//re //for(unsigned int i = 0; i < m_BufferSize; i++)//re
}//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() void cNBTData::ParseData()
@ -392,14 +394,18 @@ void cNBTData::ParseData()
} }
m_Index = 0; m_Index = 0;
printf("m_BufferSize2: %i\n", m_BufferSize);//re
printf("cNBTData::ParseData()\n");//re printf("cNBTData::ParseData()\n");//re
for(unsigned int i = 0; i < m_BufferSize; i++)//re //for(unsigned int i = 0; i < m_BufferSize; i++)//re
for(unsigned int i = 0; i < 70; i++)//re
{//re {//re
printf("%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );//re printf("echo%02i %02x %3i %c\n", i, (unsigned char)m_Buffer[i], (unsigned char)m_Buffer[i], m_Buffer[i] );//re
}//re }//re
while( m_Index < m_BufferSize ) while( m_Index < m_BufferSize )
{ {
printf("m_BufferSize3: %i\n", m_BufferSize);
printf("m_Index: %i\n", m_Index);
ParseTags(); ParseTags();
} }
} }
@ -412,11 +418,16 @@ void cNBTData::ParseTags()
unsigned char Tag = m_Buffer[m_Index]; unsigned char Tag = m_Buffer[m_Index];
if( Tag > 0 && m_ParseFunctions[ Tag ] ) 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++; m_Index++;
printf("Tag: %i\n", Tag);
(*this.*m_ParseFunctions[ Tag ])(true); (*this.*m_ParseFunctions[ Tag ])(true);
} }
else if( Tag == TAG_End ) else if( Tag == TAG_End )
{ {
printf("Tag End");
m_Index++; m_Index++;
} }
else else
@ -521,19 +532,33 @@ void cNBTData::ParseString( bool a_bNamed )
void cNBTData::ParseByteArray( bool a_bNamed ) void cNBTData::ParseByteArray( bool a_bNamed )
{ {
std::string Name; std::string Name;
if( a_bNamed ) Name = ReadName(); if( a_bNamed ) Name = ReadName();
std::string String = ReadName();
PutString( Name, String ); int Length = ReadInt();
std::string String;
printf("STRING: %s (%s)\n", Name.c_str(), String.c_str() );//re
if( Length > 0 )
{
for(int i = 0; i < Length; i++, m_Index++)
{
String.push_back( m_Buffer[m_Index] );
}
}
PutByteArray( Name, String );
printf("VALUE: %s (%s)\n", Name.c_str(), String.c_str() );//re
} }
std::string cNBTData::ReadName() std::string cNBTData::ReadName()
{ {
printf("crui1 \n");
short Length = ReadShort(); short Length = ReadShort();
printf("crui Length: %i\n", Length);
std::string Name; std::string Name;
if( Length > 0 ) if( Length > 0 )
{ {

View File

@ -36,7 +36,7 @@ public:
void PutShort( std::string Name, short Value ) { m_Shorts[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 PutInteger( std::string Name, int Value ) { m_Integers[Name] = Value; }
void PutString( std::string Name, std::string Value ) { m_Strings[Name] = Value; } void PutString( std::string Name, std::string Value ) { m_Strings[Name] = Value; }
void PutByteArray( std::string Name, char Value ) { m_ByteArrays[Name] = Value; } void PutByteArray( std::string Name, std::string Value ) { m_ByteArrays[Name] = Value; }
void PutCompound( std::string Name ); void PutCompound( std::string Name );
void PutList( std::string Name, ENUM_TAG Type ); void PutList( std::string Name, ENUM_TAG Type );
@ -44,7 +44,7 @@ public:
short GetShort( std::string Name ) { return m_Shorts[Name]; } short GetShort( std::string Name ) { return m_Shorts[Name]; }
int GetInteger( std::string Name ) { return m_Integers[Name]; } int GetInteger( std::string Name ) { return m_Integers[Name]; }
std::string GetString( std::string Name ) { return m_Strings[Name]; } std::string GetString( std::string Name ) { return m_Strings[Name]; }
char GetByteArray( std::string Name ) { return m_ByteArrays[Name]; } std::string GetByteArray( std::string Name ) { return m_ByteArrays[Name]; }
cNBTCompound* GetCompound( std::string Name ); cNBTCompound* GetCompound( std::string Name );
cNBTList* GetList( std::string Name ) { return m_Lists[Name]; } cNBTList* GetList( std::string Name ) { return m_Lists[Name]; }
@ -68,7 +68,7 @@ private:
typedef std::map<std::string, short> ShortMap; typedef std::map<std::string, short> ShortMap;
typedef std::map<std::string, int> IntegerMap; typedef std::map<std::string, int> IntegerMap;
typedef std::map<std::string, std::string> StringMap; typedef std::map<std::string, std::string> StringMap;
typedef std::map<std::string, char> ByteArrayMap; typedef std::map<std::string, std::string> ByteArrayMap;
typedef std::map<std::string, cNBTCompound*> CompoundMap; typedef std::map<std::string, cNBTCompound*> CompoundMap;
typedef std::map<std::string, cNBTList*> ListMap; typedef std::map<std::string, cNBTList*> ListMap;
ByteMap m_Bytes; ByteMap m_Bytes;
@ -125,13 +125,13 @@ public:
void PutShort( std::string Name, short Value ) { m_CurrentCompound->PutShort( 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 PutInteger( std::string Name, int Value ) { m_CurrentCompound->PutInteger( Name, Value ); }
void PutString( std::string Name, std::string Value ) { m_CurrentCompound->PutString(Name, Value); } void PutString( std::string Name, std::string Value ) { m_CurrentCompound->PutString(Name, Value); }
void PutByteArray( std::string Name, char Value ) { m_CurrentCompound->PutByteArray( 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 PutCompound( std::string Name ) { m_CurrentCompound->PutCompound( Name ); }
void PutList( std::string Name, ENUM_TAG Type ) { m_CurrentCompound->PutList( Name, Type ); } void PutList( std::string Name, ENUM_TAG Type ) { m_CurrentCompound->PutList( Name, Type ); }
int GetInteger( std::string Name ) { return m_CurrentCompound->GetInteger(Name); } int GetInteger( std::string Name ) { return m_CurrentCompound->GetInteger(Name); }
std::string GetString( std::string Name ) { return m_CurrentCompound->GetString(Name); } std::string GetString( std::string Name ) { return m_CurrentCompound->GetString(Name); }
char GetByteArray( std::string Name ) { return m_CurrentCompound->GetByteArray(Name); } std::string GetByteArray( std::string Name ) { return m_CurrentCompound->GetByteArray(Name); }
cNBTCompound* GetCompound( std::string Name ) { return m_CurrentCompound->GetCompound(Name); } cNBTCompound* GetCompound( std::string Name ) { return m_CurrentCompound->GetCompound(Name); }
cNBTList* GetList( std::string Name ) { return m_CurrentCompound->GetList(Name); } cNBTList* GetList( std::string Name ) { return m_CurrentCompound->GetList(Name); }

Binary file not shown.