More changes to the denotch map converter

git-svn-id: http://mc-server.googlecode.com/svn/trunk@25 0a769ca7-a7f5-676a-18bf-c427514a06d6
master
admin@omencraft.com 2011-10-30 08:04:40 +00:00
parent 87a7bfa9aa
commit 5134805bd7
4 changed files with 42 additions and 34 deletions

View File

@ -177,6 +177,12 @@ int main () {
//NBTData->m_bDecompressed = true;
NBTData->ParseData();
NBTData->PrintData();
//Char* Blocks =
//NBTData->GetByteArray("Blocks");
//for(unsigned int i = 0; i < 111; i++) {//re
//printf("Blocks?: %i\n", NBTData->cNBTCompound::GetByteArray("Blocks")[0]);
//}
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 );

View File

@ -112,15 +112,15 @@ void cNBTData::Compress()
unsigned char* Compressed = new unsigned char[MAXNBTSIZE];
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = m_BufferSize;
strm.avail_out = MAXNBTSIZE;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = m_BufferSize;
strm.avail_out = MAXNBTSIZE;
strm.next_in =(Bytef*)m_Buffer;
strm.next_out = Compressed;
strm.total_in = 0;
strm.total_out = 0;
strm.next_out = Compressed;
strm.total_in = 0;
strm.total_out = 0;
ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15+MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
if (ret != Z_OK)
{
@ -189,19 +189,19 @@ bool cNBTData::Decompress()
unsigned char* out = new unsigned char[MAXNBTSIZE];
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = Z_NULL;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = Z_NULL;
strm.next_in = Z_NULL;
strm.avail_in = m_BufferSize;
strm.avail_out = Z_NULL;
strm.avail_in = m_BufferSize;
strm.avail_out = Z_NULL;
strm.next_in = (Bytef*)m_Buffer;
strm.next_out = Z_NULL;
strm.avail_out = MAXNBTSIZE;
strm.next_out = out;
strm.total_in = 0;
strm.total_out = 0;
strm.next_out = Z_NULL;
strm.avail_out = MAXNBTSIZE;
strm.next_out = out;
strm.total_in = 0;
strm.total_out = 0;
ret = inflateInit2(&strm, 16+MAX_WBITS);
if (ret != Z_OK)
@ -551,18 +551,20 @@ void cNBTData::ParseByteArray( bool a_bNamed )
int Length = ReadInt();
std::string String;
char* ByteArray = new char[ Length ];
if( Length > 0 )
{
for(int i = 0; i < Length; i++, m_Index++)
{
String.push_back( m_Buffer[m_Index] );
ByteArray[i] = m_Buffer[ m_Index ];
//ByteArray[i].push_back( m_Buffer[m_Index] );
//String.push_back( m_Buffer[m_Index] );
}
}
PutByteArray( Name, String );
PutByteArray( Name, ByteArray );
printf("VALUE: %s (%s)\n", Name.c_str(), String.c_str() );//re
printf("VALUE: %s First 5 Chars: (%i,%i,%i,%i,%i)\n", Name.c_str(), ByteArray[0],ByteArray[1],ByteArray[2],ByteArray[3],ByteArray[4] );//re
}
std::string cNBTData::ReadName()

View File

@ -38,18 +38,18 @@ public:
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 PutByteArray( std::string Name, char* ByteArray ) { m_ByteArrays[Name] = ByteArray; }
void PutCompound( std::string Name );
void PutList( std::string Name, ENUM_TAG Type );
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]; }
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]; }
char* GetByteArray( std::string Name ) { return m_ByteArrays[Name]; }
cNBTCompound* GetCompound( std::string Name );
cNBTList* GetList( std::string Name ) { return m_Lists[Name]; }
cNBTList* GetList( std::string Name ) { return m_Lists[Name]; }
cNBTList* GetCurrentList() { return m_CurrentList; }
cNBTCompound* GetParentCompound() { return m_ParentCompound; }
@ -72,7 +72,7 @@ private:
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, char*> ByteArrayMap;
typedef std::map<std::string, cNBTCompound*> CompoundMap;
typedef std::map<std::string, cNBTList*> ListMap;
ByteMap m_Bytes;
@ -131,14 +131,14 @@ public:
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 PutByteArray( std::string Name, char* ByteArray ) { m_CurrentCompound->PutByteArray( Name, ByteArray ); }
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); }
char* GetByteArray( std::string Name ) { return m_CurrentCompound->GetByteArray(Name); }
cNBTCompound* GetCompound( std::string Name ) { return m_CurrentCompound->GetCompound(Name); }
cNBTList* GetList( std::string Name ) { return m_CurrentCompound->GetList(Name); }

Binary file not shown.