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
This commit is contained in:
parent
aead2e43c2
commit
87a7bfa9aa
@ -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 );
|
||||
|
@ -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 );
|
||||
|
@ -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<std::string, char> ByteMap;
|
||||
typedef std::map<std::string, short> ShortMap;
|
||||
typedef std::map<std::string, int> IntegerMap;
|
||||
typedef std::map<std::string, long> LongMap;
|
||||
typedef std::map<std::string, std::string> StringMap;
|
||||
typedef std::map<std::string, std::string> ByteArrayMap;
|
||||
typedef std::map<std::string, cNBTCompound*> 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;
|
||||
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user