diff --git a/VC2010/Converter.vcxproj b/VC2010/Converter.vcxproj
new file mode 100644
index 000000000..a9a40457f
--- /dev/null
+++ b/VC2010/Converter.vcxproj
@@ -0,0 +1,83 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+
+
+
+
+
+
+
+ {9AB1FB82-2148-40E4-919F-3B184B4593C8}
+ Converter
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+ ../converter/
+
+
+ ../converter/
+
+
+
+ Level3
+ Disabled
+ ../zlib-1.2.5
+
+
+ true
+ ./Debug/
+ ws2_32.lib;ZLib.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ ../zlib-1.2.5
+
+
+ true
+ true
+ true
+ ./Release/
+ ws2_32.lib;ZLib.lib;%(AdditionalDependencies)
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VC2010/Converter.vcxproj.filters b/VC2010/Converter.vcxproj.filters
new file mode 100644
index 000000000..dbe3b1c28
--- /dev/null
+++ b/VC2010/Converter.vcxproj.filters
@@ -0,0 +1,30 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+
\ No newline at end of file
diff --git a/VC2010/Converter.vcxproj.user b/VC2010/Converter.vcxproj.user
new file mode 100644
index 000000000..90d00fb58
--- /dev/null
+++ b/VC2010/Converter.vcxproj.user
@@ -0,0 +1,11 @@
+
+
+
+ $(TargetDir)
+ WindowsLocalDebugger
+
+
+ $(TargetDir)
+ WindowsLocalDebugger
+
+
\ No newline at end of file
diff --git a/VC2010/MCServer.sln b/VC2010/MCServer.sln
index 14e0e8457..322046d33 100644
--- a/VC2010/MCServer.sln
+++ b/VC2010/MCServer.sln
@@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebServer", "WebServer.vcxp
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JsonCpp", "JsonCpp.vcxproj", "{ADBF25B9-7192-4E54-B35E-8EC47CA5EF86}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Converter", "Converter.vcxproj", "{9AB1FB82-2148-40E4-919F-3B184B4593C8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -71,6 +73,12 @@ Global
{ADBF25B9-7192-4E54-B35E-8EC47CA5EF86}.Release|Win32.ActiveCfg = Release|Win32
{ADBF25B9-7192-4E54-B35E-8EC47CA5EF86}.Release|Win32.Build.0 = Release|Win32
{ADBF25B9-7192-4E54-B35E-8EC47CA5EF86}.Release|x64.ActiveCfg = Release|Win32
+ {9AB1FB82-2148-40E4-919F-3B184B4593C8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9AB1FB82-2148-40E4-919F-3B184B4593C8}.Debug|Win32.Build.0 = Debug|Win32
+ {9AB1FB82-2148-40E4-919F-3B184B4593C8}.Debug|x64.ActiveCfg = Debug|Win32
+ {9AB1FB82-2148-40E4-919F-3B184B4593C8}.Release|Win32.ActiveCfg = Release|Win32
+ {9AB1FB82-2148-40E4-919F-3B184B4593C8}.Release|Win32.Build.0 = Release|Win32
+ {9AB1FB82-2148-40E4-919F-3B184B4593C8}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/converter/cConvert.cpp b/converter/cConvert.cpp
index 565a6bd6a..e31730bf3 100644
--- a/converter/cConvert.cpp
+++ b/converter/cConvert.cpp
@@ -7,7 +7,7 @@
#include
#include "zlib.h"
#include
-#include "cNBTData.cpp"
+#include "cNBTData.h"
void quicksort(int*, int, int);
int partition(int*, int, int, int);
@@ -32,7 +32,7 @@ int main () {
FILE* wf = 0;
#ifdef _WIN32
sprintf_s(SourceFile, 128, "region/%s","r.0.0.mcr"); //replace hard coded file with file array variable
- sprintf_s(OutputFile, 128, "world/%s","X0_Z0.pak"); //parce x and z from file array variable and place into pak file format
+ sprintf_s(OutputFile, 128, "world/%s","X0_Z0.pak"); //parce x and z from file array variable and place into pak file format
if( fopen_s(&wf, OutputFile, "wb" ) == 0 ) {} else { cout << "uhoh!" << endl; return 0; } //open new pak file for writing
#else
sprintf(SourceFile, "region/%s","r.0.0.mcr"); //same as above but for linux
@@ -48,9 +48,9 @@ int main () {
unsigned char byte1 = 0;
unsigned char byte2 = 0;
unsigned char byte3 = 0;
- unsigned char byte4 = 0;
- unsigned char byte5 = 0;
- unsigned char trash = 0;
+ unsigned char byte4 = 0;
+ unsigned char byte5 = 0;
+ unsigned char trash = 0;
unsigned int frloc = 0;
int toffset = 0;
int compdlength = 0;
@@ -107,8 +107,8 @@ int main () {
//cout << "frloc: " << frloc << endl;
-
- 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.
+ // TODO - delete [] temparr after you're done with it, now it's a memory leak
+ char* temparr = new char[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;
/*
@@ -173,7 +173,7 @@ int main () {
//testing of nbtparser.
- cNBTData* NBTData = new cNBTData::cNBTData(BlockData, (testr));
+ cNBTData* NBTData = new cNBTData(BlockData, (testr));
//NBTData->m_bDecompressed = true;
NBTData->ParseData();
NBTData->PrintData();
@@ -181,10 +181,14 @@ int main () {
//NBTData->GetByteArray("Blocks");
//for(unsigned int i = 0; i < 111; i++) {//re
//printf("Blocks?: %i\n", NBTData->cNBTCompound::GetByteArray("Blocks")[0]);
+ NBTData->OpenCompound("");
+ NBTData->OpenCompound("Level"); // You need to open the right compounds before you can access the data in it
printf("xPos: %i\n", NBTData->GetInteger("xPos") );
//will print
//xPos: 0
- printf("test: %i\n", NBTData->cNBTCompound::GetByteArray("Blocks")[0] );
+ printf("test: %i\n", NBTData->GetByteArray("Blocks")[0] );
+ NBTData->CloseCompound();// Close the compounds after you're done
+ NBTData->CloseCompound();
//}
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
diff --git a/converter/cNBTData.cpp b/converter/cNBTData.cpp
index 5bc6e3ddf..fc0dd628e 100644
--- a/converter/cNBTData.cpp
+++ b/converter/cNBTData.cpp
@@ -357,6 +357,11 @@ void cNBTCompound::PrintData( int a_Depth, std::string a_Name )
printf("%s BYTE %s (%i)\n", Prefix, itr->first.c_str(), itr->second );
}
+ for( ByteArrayMap::iterator itr = m_ByteArrays.begin(); itr != m_ByteArrays.end(); itr++ )
+ {
+ printf("%s BYTE ARRAY %s (length: %i)\n", Prefix, itr->first.c_str(), sizeof(itr->second) );
+ }
+
delete Prefix;
}
@@ -524,9 +529,9 @@ void cNBTData::ParseLong( bool a_bNamed )
{
std::string Name;
if( a_bNamed ) Name = ReadName();
- long Value = ReadLong();
+ long long Value = ReadLong();
- PutInteger( Name, Value );
+ PutInteger( Name, (int)Value );
printf("LONG: %s %li\n", Name.c_str(), Value );//re
}
@@ -554,12 +559,8 @@ void cNBTData::ParseByteArray( bool a_bNamed )
char* ByteArray = new char[ Length ];
if( Length > 0 )
{
- for(int i = 0; i < Length; i++, m_Index++)
- {
- ByteArray[i] = m_Buffer[ m_Index ];
- //ByteArray[i].push_back( m_Buffer[m_Index] );
- //String.push_back( m_Buffer[m_Index] );
- }
+ memcpy( ByteArray, &m_Buffer[ m_Index ], Length );
+ m_Index += Length;
}
PutByteArray( Name, ByteArray );
@@ -607,11 +608,11 @@ int cNBTData::ReadInt()
return ntohl( Value );
}
-long cNBTData::ReadLong()
+long long cNBTData::ReadLong()
{
- long Value = 0;
- memcpy( &Value, m_Buffer+m_Index, sizeof(long) );
- m_Index+=sizeof(long);
+ long long Value = 0;
+ memcpy( &Value, m_Buffer+m_Index, sizeof(long long) );
+ m_Index+=sizeof(long long);
return ntohl( Value );
}
@@ -757,4 +758,4 @@ void cNBTList::Clear()
}
}
m_List.clear();
-}
+}
\ No newline at end of file
diff --git a/converter/cNBTData.h b/converter/cNBTData.h
index a0a40e68b..2ab5b0e21 100644
--- a/converter/cNBTData.h
+++ b/converter/cNBTData.h
@@ -20,14 +20,16 @@ public:
#endif
{
TAG_End = 0,
- TAG_Byte,
- TAG_Short,
- TAG_Int,
- TAG_Long,
+ TAG_Byte = 1,
+ TAG_Short = 2,
+ TAG_Int = 3,
+ TAG_Long = 4,
+ TAG_Float = 5,
+ TAG_Double = 6,
TAG_ByteArray = 7,
- TAG_String,
- TAG_List,
- TAG_Compound,
+ TAG_String = 8,
+ TAG_List = 9,
+ TAG_Compound = 10,
TAG_NumTags // Not a real tag, but contains number of tags
};
@@ -167,7 +169,7 @@ private:
std::string ReadName();
char ReadByte();
int ReadInt();
- long ReadLong();
+ long long ReadLong();
cNBTCompound* m_CurrentCompound;