Changed cChunkMat.cpp back to normal. Made more changes to the denotch map converter. Testing cNBTData parser.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@21 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
625a4accda
commit
9f3b6fe838
@ -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.
|
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;
|
int re = 0;
|
||||||
char tempbyte = 0;
|
char tempbyte = 0;
|
||||||
while (re < compdlength) { //loop through file and read contents into char array a byte at a time.
|
while (re < compdlength) { //loop through file and read contents into char array a byte at a time.
|
||||||
@ -118,7 +121,7 @@ int main () {
|
|||||||
frloc++;
|
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
|
//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;
|
//frloc += compdlength;
|
||||||
@ -169,6 +172,12 @@ int main () {
|
|||||||
//cout << BlockDataString << endl;
|
//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( 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 );
|
//fwrite( &temparr, compdlength, sizeof(unsigned char), wf );
|
||||||
//cin >> n; //just to see screen output
|
//cin >> n; //just to see screen output
|
||||||
|
@ -27,12 +27,13 @@ cNBTData::cNBTData( char* a_Buffer, unsigned int a_BufferSize )
|
|||||||
{
|
{
|
||||||
m_ParseFunctions[i] = 0;
|
m_ParseFunctions[i] = 0;
|
||||||
}
|
}
|
||||||
m_ParseFunctions[TAG_Byte] = &cNBTData::ParseByte;
|
m_ParseFunctions[TAG_Byte] = &cNBTData::ParseByte;
|
||||||
m_ParseFunctions[TAG_Short] = &cNBTData::ParseShort;
|
m_ParseFunctions[TAG_Short] = &cNBTData::ParseShort;
|
||||||
m_ParseFunctions[TAG_Int] = &cNBTData::ParseInt;
|
m_ParseFunctions[TAG_Int] = &cNBTData::ParseInt;
|
||||||
m_ParseFunctions[TAG_String] = &cNBTData::ParseString;
|
m_ParseFunctions[TAG_String] = &cNBTData::ParseString;
|
||||||
m_ParseFunctions[TAG_List] = &cNBTData::ParseList;
|
m_ParseFunctions[TAG_List] = &cNBTData::ParseList;
|
||||||
m_ParseFunctions[TAG_Compound] = &cNBTData::ParseCompound;
|
m_ParseFunctions[TAG_Compound] = &cNBTData::ParseCompound;
|
||||||
|
m_ParseFunctions[TAG_ByteArray] = &cNBTData::ParseByteArray;
|
||||||
|
|
||||||
|
|
||||||
m_Buffer = a_Buffer;
|
m_Buffer = a_Buffer;
|
||||||
@ -41,7 +42,7 @@ cNBTData::cNBTData( char* a_Buffer, unsigned int a_BufferSize )
|
|||||||
|
|
||||||
m_CurrentCompound = this;
|
m_CurrentCompound = this;
|
||||||
|
|
||||||
m_bDecompressed = false;
|
m_bDecompressed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cNBTData::OpenCompound( std::string a_Name )
|
bool cNBTData::OpenCompound( std::string a_Name )
|
||||||
@ -102,7 +103,7 @@ bool cNBTData::CloseList()
|
|||||||
void cNBTData::Compress()
|
void cNBTData::Compress()
|
||||||
{
|
{
|
||||||
//printf("Before Compress size: %i\n", m_BufferSize );
|
//printf("Before Compress size: %i\n", m_BufferSize );
|
||||||
const int MAXNBTSIZE = 1024 * 2;
|
const int MAXNBTSIZE = 1024 * 1024 * 120;
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
unsigned have;
|
unsigned have;
|
||||||
@ -180,7 +181,7 @@ bool cNBTData::Decompress()
|
|||||||
|
|
||||||
//printf("Before Decompress size: %i\n", m_BufferSize );
|
//printf("Before Decompress size: %i\n", m_BufferSize );
|
||||||
|
|
||||||
const int MAXNBTSIZE = 1024 * 2;
|
const int MAXNBTSIZE = 1024 * 1024 * 120 ;
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
z_stream strm;
|
z_stream strm;
|
||||||
@ -518,6 +519,17 @@ void cNBTData::ParseString( bool a_bNamed )
|
|||||||
//printf("STRING: %s (%s)\n", Name.c_str(), String.c_str() );
|
//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()
|
std::string cNBTData::ReadName()
|
||||||
{
|
{
|
||||||
short Length = ReadShort();
|
short Length = ReadShort();
|
||||||
|
@ -24,6 +24,7 @@ public:
|
|||||||
TAG_Short,
|
TAG_Short,
|
||||||
TAG_Int,
|
TAG_Int,
|
||||||
TAG_String = 8,
|
TAG_String = 8,
|
||||||
|
TAG_ByteArray,
|
||||||
TAG_List,
|
TAG_List,
|
||||||
TAG_Compound,
|
TAG_Compound,
|
||||||
TAG_NumTags // Not a real tag, but contains number of tags
|
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 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 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 );
|
||||||
|
|
||||||
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]; }
|
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]; }
|
||||||
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]; }
|
||||||
|
|
||||||
@ -61,16 +64,18 @@ private:
|
|||||||
cNBTCompound* m_ParentCompound;
|
cNBTCompound* m_ParentCompound;
|
||||||
cNBTList* m_CurrentList;
|
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, 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, 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;
|
||||||
ShortMap m_Shorts;
|
ShortMap m_Shorts;
|
||||||
IntegerMap m_Integers;
|
IntegerMap m_Integers;
|
||||||
StringMap m_Strings;
|
StringMap m_Strings;
|
||||||
|
ByteArrayMap m_ByteArrays;
|
||||||
CompoundMap m_Compounds;
|
CompoundMap m_Compounds;
|
||||||
ListMap m_Lists;
|
ListMap m_Lists;
|
||||||
};
|
};
|
||||||
@ -117,16 +122,18 @@ public:
|
|||||||
bool CloseList();
|
bool CloseList();
|
||||||
|
|
||||||
void PutByte( std::string Name, char Value ) { m_CurrentCompound->PutByte( Name, Value ); }
|
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 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 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); }
|
||||||
cNBTCompound* GetCompound( std::string Name ) { return m_CurrentCompound->GetCompound(Name); }
|
char GetByteArray( std::string Name ) { return m_CurrentCompound->GetByteArray(Name); }
|
||||||
cNBTList* GetList( std::string Name ) { return m_CurrentCompound->GetList(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; }
|
char* GetBuffer() { return m_Buffer; }
|
||||||
unsigned int GetBufferSize() { return m_BufferSize; }
|
unsigned int GetBufferSize() { return m_BufferSize; }
|
||||||
@ -144,6 +151,7 @@ private:
|
|||||||
void ParseList( bool a_bNamed );
|
void ParseList( bool a_bNamed );
|
||||||
void ParseString( bool a_bNamed );
|
void ParseString( bool a_bNamed );
|
||||||
void ParseByte( bool a_bNamed );
|
void ParseByte( bool a_bNamed );
|
||||||
|
void ParseByteArray( bool a_bNamed );
|
||||||
void ParseInt( bool a_bNamed );
|
void ParseInt( bool a_bNamed );
|
||||||
void ParseShort( bool a_bNamed );
|
void ParseShort( bool a_bNamed );
|
||||||
|
|
||||||
|
Binary file not shown.
@ -12,8 +12,6 @@
|
|||||||
#include <stdio.h> // sprintf and stuff
|
#include <stdio.h> // sprintf and stuff
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
|
|
||||||
@ -365,7 +363,6 @@ cChunk* cChunkMap::GetChunk( int a_X, int a_Y, int a_Z )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cChunk* Chunk = new cChunk(a_X, a_Y, a_Z);
|
cChunk* Chunk = new cChunk(a_X, a_Y, a_Z);
|
||||||
//std::cout << BlockData;
|
|
||||||
memcpy( Chunk->m_BlockData, BlockData, cChunk::c_BlockDataSize );
|
memcpy( Chunk->m_BlockData, BlockData, cChunk::c_BlockDataSize );
|
||||||
Chunk->CalculateHeightmap();
|
Chunk->CalculateHeightmap();
|
||||||
Data->m_LiveChunk = Chunk;
|
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 );
|
sprintf_s(SourceFile, 128, "world/X%i_Z%i.pak", a_Layer->m_X, a_Layer->m_Z );
|
||||||
#else
|
#else
|
||||||
sprintf(SourceFile, "world/X%i_Z%i.pak", a_Layer->m_X, a_Layer->m_Z );
|
sprintf(SourceFile, "world/X%i_Z%i.pak", a_Layer->m_X, a_Layer->m_Z );
|
||||||
//std::cout << SourceFile << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -689,7 +685,6 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
|
|||||||
}
|
}
|
||||||
|
|
||||||
OrderedData[i] = Data;
|
OrderedData[i] = Data;
|
||||||
//std::cout << Data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop over chunks again, in the order they were loaded, and load their compressed data
|
// Loop over chunks again, in the order they were loaded, and load their compressed data
|
||||||
|
Loading…
Reference in New Issue
Block a user