summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-30 03:16:01 +0100
committeradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-30 03:16:01 +0100
commit9f3b6fe838b29fd178a7981b559ba56f7e2c34cd (patch)
tree77316b98bf6f6940ef90069083b7f281c2d6b886
parentAdded denotch map converter. Program currently reads the only mcr file in the region dir and writes the uncompressed chunk data in world/X0-Z0.pak. I compile in linux with "g++ cConvert.cpp -lz -o denotch" (diff)
downloadcuberite-9f3b6fe838b29fd178a7981b559ba56f7e2c34cd.tar
cuberite-9f3b6fe838b29fd178a7981b559ba56f7e2c34cd.tar.gz
cuberite-9f3b6fe838b29fd178a7981b559ba56f7e2c34cd.tar.bz2
cuberite-9f3b6fe838b29fd178a7981b559ba56f7e2c34cd.tar.lz
cuberite-9f3b6fe838b29fd178a7981b559ba56f7e2c34cd.tar.xz
cuberite-9f3b6fe838b29fd178a7981b559ba56f7e2c34cd.tar.zst
cuberite-9f3b6fe838b29fd178a7981b559ba56f7e2c34cd.zip
-rw-r--r--converter/cConvert.cpp11
-rw-r--r--converter/cNBTData.cpp28
-rw-r--r--converter/cNBTData.h42
-rwxr-xr-xconverter/denotchbin143870 -> 143873 bytes
-rw-r--r--source/cChunkMap.cpp5
5 files changed, 55 insertions, 31 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
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index 2f6818195..32bdf576a 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -12,8 +12,6 @@
#include <stdio.h> // sprintf and stuff
#endif
-#include <iostream>
-
#include "zlib.h"
#include <json/json.h>
@@ -365,7 +363,6 @@ cChunk* cChunkMap::GetChunk( int a_X, int a_Y, int a_Z )
else
{
cChunk* Chunk = new cChunk(a_X, a_Y, a_Z);
- //std::cout << BlockData;
memcpy( Chunk->m_BlockData, BlockData, cChunk::c_BlockDataSize );
Chunk->CalculateHeightmap();
Data->m_LiveChunk = Chunk;
@@ -559,7 +556,6 @@ void cChunkMap::SaveLayer( cChunkLayer* a_Layer )
sprintf_s(SourceFile, 128, "world/X%i_Z%i.pak", a_Layer->m_X, a_Layer->m_Z );
#else
sprintf(SourceFile, "world/X%i_Z%i.pak", a_Layer->m_X, a_Layer->m_Z );
- //std::cout << SourceFile << std::endl;
#endif
@@ -689,7 +685,6 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
}
OrderedData[i] = Data;
- //std::cout << Data;
}
// Loop over chunks again, in the order they were loaded, and load their compressed data