summaryrefslogtreecommitdiffstats
path: root/converter
diff options
context:
space:
mode:
Diffstat (limited to 'converter')
-rw-r--r--converter/cConvert.cpp11
-rw-r--r--converter/cNBTData.cpp28
-rw-r--r--converter/cNBTData.h42
-rwxr-xr-xconverter/denotchbin143870 -> 143873 bytes
4 files changed, 55 insertions, 26 deletions
diff --git a/converter/cConvert.cpp b/converter/cConvert.cpp
index 788399dcf..8554687ca 100644
--- a/converter/cConvert.cpp
+++ b/converter/cConvert.cpp
@@ -109,6 +109,9 @@ int main () {
char temparr[compdlength]; //can't get fread to read more than one char at a time into a char array... so that's what I'll do. :( At least it works.
+ if( fread( temparr, compdlength, 1, f) != 1 ) { cout << "ERROR rf22 READING FROM FILE " << SourceFile; fclose(f); return false; }
+ frloc = frloc + compdlength;
+ /*
int re = 0;
char tempbyte = 0;
while (re < compdlength) { //loop through file and read contents into char array a byte at a time.
@@ -118,7 +121,7 @@ int main () {
frloc++;
}
-
+ */
//if( fread( comp_data, compdlength, sizeof(unsigned char), f) != 1 ) { cout << "ERROR 1234 READING FROM FILE " << SourceFile <<endl; fclose(f); return false; } //actual compressed chunk data
//frloc += compdlength;
@@ -169,6 +172,12 @@ int main () {
//cout << BlockDataString << endl;
+ //testing of nbtparser.
+ cNBTData* NBTData = new cNBTData::cNBTData(BlockData, testr);
+ //NBTData->m_bDecompressed = true;
+ NBTData->ParseData();
+ 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 );
//cin >> n; //just to see screen output
diff --git a/converter/cNBTData.cpp b/converter/cNBTData.cpp
index 9bc25b789..03e88b3ce 100644
--- a/converter/cNBTData.cpp
+++ b/converter/cNBTData.cpp
@@ -27,12 +27,13 @@ cNBTData::cNBTData( char* a_Buffer, unsigned int a_BufferSize )
{
m_ParseFunctions[i] = 0;
}
- m_ParseFunctions[TAG_Byte] = &cNBTData::ParseByte;
- m_ParseFunctions[TAG_Short] = &cNBTData::ParseShort;
- m_ParseFunctions[TAG_Int] = &cNBTData::ParseInt;
+ m_ParseFunctions[TAG_Byte] = &cNBTData::ParseByte;
+ m_ParseFunctions[TAG_Short] = &cNBTData::ParseShort;
+ m_ParseFunctions[TAG_Int] = &cNBTData::ParseInt;
m_ParseFunctions[TAG_String] = &cNBTData::ParseString;
- m_ParseFunctions[TAG_List] = &cNBTData::ParseList;
- m_ParseFunctions[TAG_Compound] = &cNBTData::ParseCompound;
+ m_ParseFunctions[TAG_List] = &cNBTData::ParseList;
+ m_ParseFunctions[TAG_Compound] = &cNBTData::ParseCompound;
+ m_ParseFunctions[TAG_ByteArray] = &cNBTData::ParseByteArray;
m_Buffer = a_Buffer;
@@ -41,7 +42,7 @@ cNBTData::cNBTData( char* a_Buffer, unsigned int a_BufferSize )
m_CurrentCompound = this;
- m_bDecompressed = false;
+ m_bDecompressed = true;
}
bool cNBTData::OpenCompound( std::string a_Name )
@@ -102,7 +103,7 @@ bool cNBTData::CloseList()
void cNBTData::Compress()
{
//printf("Before Compress size: %i\n", m_BufferSize );
- const int MAXNBTSIZE = 1024 * 2;
+ const int MAXNBTSIZE = 1024 * 1024 * 120;
int ret;
unsigned have;
@@ -180,7 +181,7 @@ bool cNBTData::Decompress()
//printf("Before Decompress size: %i\n", m_BufferSize );
- const int MAXNBTSIZE = 1024 * 2;
+ const int MAXNBTSIZE = 1024 * 1024 * 120 ;
int ret;
z_stream strm;
@@ -518,6 +519,17 @@ void cNBTData::ParseString( bool a_bNamed )
//printf("STRING: %s (%s)\n", Name.c_str(), String.c_str() );
}
+void cNBTData::ParseByteArray( bool a_bNamed )
+{
+ std::string Name;
+ if( a_bNamed ) Name = ReadName();
+ std::string String = ReadName();
+
+ PutString( Name, String );
+
+ //printf("STRING: %s (%s)\n", Name.c_str(), String.c_str() );
+}
+
std::string cNBTData::ReadName()
{
short Length = ReadShort();
diff --git a/converter/cNBTData.h b/converter/cNBTData.h
index cb4918fcb..46a020d0a 100644
--- a/converter/cNBTData.h
+++ b/converter/cNBTData.h
@@ -24,6 +24,7 @@ public:
TAG_Short,
TAG_Int,
TAG_String = 8,
+ TAG_ByteArray,
TAG_List,
TAG_Compound,
TAG_NumTags // Not a real tag, but contains number of tags
@@ -35,13 +36,15 @@ public:
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 PutByteArray( std::string Name, char Value ) { m_ByteArrays[Name] = Value; }
void PutCompound( std::string Name );
void PutList( std::string Name, ENUM_TAG Type );
- char GetByte( std::string Name ) { return m_Bytes[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]; }
- std::string GetString( std::string Name ) { return m_Strings[Name]; }
+ int GetInteger( std::string Name ) { return m_Integers[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]; }
@@ -61,16 +64,18 @@ private:
cNBTCompound* m_ParentCompound;
cNBTList* m_CurrentList;
- typedef std::map<std::string, char> ByteMap;
+ 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, std::string> StringMap;
+ typedef std::map<std::string, int> IntegerMap;
+ typedef std::map<std::string, std::string> StringMap;
+ typedef std::map<std::string, char> ByteArrayMap;
typedef std::map<std::string, cNBTCompound*> CompoundMap;
typedef std::map<std::string, cNBTList*> ListMap;
ByteMap m_Bytes;
- ShortMap m_Shorts;
- IntegerMap m_Integers;
- StringMap m_Strings;
+ ShortMap m_Shorts;
+ IntegerMap m_Integers;
+ StringMap m_Strings;
+ ByteArrayMap m_ByteArrays;
CompoundMap m_Compounds;
ListMap m_Lists;
};
@@ -117,16 +122,18 @@ public:
bool CloseList();
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 PutString( std::string Name, std::string Value ) { m_CurrentCompound->PutString(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 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 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); }
- std::string GetString( std::string Name ) { return m_CurrentCompound->GetString(Name); }
- cNBTCompound* GetCompound( std::string Name ) { return m_CurrentCompound->GetCompound(Name); }
- cNBTList* GetList( std::string Name ) { return m_CurrentCompound->GetList(Name); }
+ int GetInteger( std::string Name ) { return m_CurrentCompound->GetInteger(Name); }
+ std::string GetString( std::string Name ) { return m_CurrentCompound->GetString(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); }
char* GetBuffer() { return m_Buffer; }
unsigned int GetBufferSize() { return m_BufferSize; }
@@ -144,6 +151,7 @@ private:
void ParseList( bool a_bNamed );
void ParseString( bool a_bNamed );
void ParseByte( bool a_bNamed );
+ void ParseByteArray( bool a_bNamed );
void ParseInt( bool a_bNamed );
void ParseShort( bool a_bNamed );
diff --git a/converter/denotch b/converter/denotch
index 363de19b8..6be4bc7a5 100755
--- a/converter/denotch
+++ b/converter/denotch
Binary files differ