Changed long to long long so it works fine on 32bit systems
Added printing for Byte array tags (the length is incorrect though) Structured the tags enums a bit more In cConvert.cpp the correct compounds are opened before accessing data Added VS2010 project so the converter can be compiled through VS2010 git-svn-id: http://mc-server.googlecode.com/svn/trunk@27 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
0673834955
commit
ca1d98a7ba
83
VC2010/Converter.vcxproj
Normal file
83
VC2010/Converter.vcxproj
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\converter\cConvert.cpp" />
|
||||||
|
<ClCompile Include="..\converter\cNBTData.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\converter\cNBTData.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{9AB1FB82-2148-40E4-919F-3B184B4593C8}</ProjectGuid>
|
||||||
|
<RootNamespace>Converter</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>../converter/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>../converter/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../zlib-1.2.5</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalLibraryDirectories>./Debug/</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;ZLib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<AdditionalIncludeDirectories>../zlib-1.2.5</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalLibraryDirectories>./Release/</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;ZLib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
30
VC2010/Converter.vcxproj.filters
Normal file
30
VC2010/Converter.vcxproj.filters
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\converter\cConvert.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\converter\cNBTData.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\converter\cNBTData.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
11
VC2010/Converter.vcxproj.user
Normal file
11
VC2010/Converter.vcxproj.user
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebServer", "WebServer.vcxp
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JsonCpp", "JsonCpp.vcxproj", "{ADBF25B9-7192-4E54-B35E-8EC47CA5EF86}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JsonCpp", "JsonCpp.vcxproj", "{ADBF25B9-7192-4E54-B35E-8EC47CA5EF86}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Converter", "Converter.vcxproj", "{9AB1FB82-2148-40E4-919F-3B184B4593C8}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
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.ActiveCfg = Release|Win32
|
||||||
{ADBF25B9-7192-4E54-B35E-8EC47CA5EF86}.Release|Win32.Build.0 = Release|Win32
|
{ADBF25B9-7192-4E54-B35E-8EC47CA5EF86}.Release|Win32.Build.0 = Release|Win32
|
||||||
{ADBF25B9-7192-4E54-B35E-8EC47CA5EF86}.Release|x64.ActiveCfg = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "cNBTData.cpp"
|
#include "cNBTData.h"
|
||||||
|
|
||||||
void quicksort(int*, int, int);
|
void quicksort(int*, int, int);
|
||||||
int partition(int*, int, int, int);
|
int partition(int*, int, int, int);
|
||||||
@ -107,8 +107,8 @@ int main () {
|
|||||||
//cout << "frloc: " << frloc << endl;
|
//cout << "frloc: " << frloc << endl;
|
||||||
|
|
||||||
|
|
||||||
|
// TODO - delete [] temparr after you're done with it, now it's a memory leak
|
||||||
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 = 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; }
|
if( fread( temparr, compdlength, 1, f) != 1 ) { cout << "ERROR rf22 READING FROM FILE " << SourceFile; fclose(f); return false; }
|
||||||
frloc = frloc + compdlength;
|
frloc = frloc + compdlength;
|
||||||
/*
|
/*
|
||||||
@ -173,7 +173,7 @@ int main () {
|
|||||||
|
|
||||||
|
|
||||||
//testing of nbtparser.
|
//testing of nbtparser.
|
||||||
cNBTData* NBTData = new cNBTData::cNBTData(BlockData, (testr));
|
cNBTData* NBTData = new cNBTData(BlockData, (testr));
|
||||||
//NBTData->m_bDecompressed = true;
|
//NBTData->m_bDecompressed = true;
|
||||||
NBTData->ParseData();
|
NBTData->ParseData();
|
||||||
NBTData->PrintData();
|
NBTData->PrintData();
|
||||||
@ -181,10 +181,14 @@ int main () {
|
|||||||
//NBTData->GetByteArray("Blocks");
|
//NBTData->GetByteArray("Blocks");
|
||||||
//for(unsigned int i = 0; i < 111; i++) {//re
|
//for(unsigned int i = 0; i < 111; i++) {//re
|
||||||
//printf("Blocks?: %i\n", NBTData->cNBTCompound::GetByteArray("Blocks")[0]);
|
//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") );
|
printf("xPos: %i\n", NBTData->GetInteger("xPos") );
|
||||||
//will print
|
//will print
|
||||||
//xPos: 0
|
//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;
|
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
|
||||||
|
@ -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 );
|
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;
|
delete Prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,9 +529,9 @@ void cNBTData::ParseLong( bool a_bNamed )
|
|||||||
{
|
{
|
||||||
std::string Name;
|
std::string Name;
|
||||||
if( a_bNamed ) Name = ReadName();
|
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
|
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 ];
|
char* ByteArray = new char[ Length ];
|
||||||
if( Length > 0 )
|
if( Length > 0 )
|
||||||
{
|
{
|
||||||
for(int i = 0; i < Length; i++, m_Index++)
|
memcpy( ByteArray, &m_Buffer[ m_Index ], Length );
|
||||||
{
|
m_Index += Length;
|
||||||
ByteArray[i] = m_Buffer[ m_Index ];
|
|
||||||
//ByteArray[i].push_back( m_Buffer[m_Index] );
|
|
||||||
//String.push_back( m_Buffer[m_Index] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PutByteArray( Name, ByteArray );
|
PutByteArray( Name, ByteArray );
|
||||||
@ -607,11 +608,11 @@ int cNBTData::ReadInt()
|
|||||||
return ntohl( Value );
|
return ntohl( Value );
|
||||||
}
|
}
|
||||||
|
|
||||||
long cNBTData::ReadLong()
|
long long cNBTData::ReadLong()
|
||||||
{
|
{
|
||||||
long Value = 0;
|
long long Value = 0;
|
||||||
memcpy( &Value, m_Buffer+m_Index, sizeof(long) );
|
memcpy( &Value, m_Buffer+m_Index, sizeof(long long) );
|
||||||
m_Index+=sizeof(long);
|
m_Index+=sizeof(long long);
|
||||||
|
|
||||||
return ntohl( Value );
|
return ntohl( Value );
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,16 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
TAG_End = 0,
|
TAG_End = 0,
|
||||||
TAG_Byte,
|
TAG_Byte = 1,
|
||||||
TAG_Short,
|
TAG_Short = 2,
|
||||||
TAG_Int,
|
TAG_Int = 3,
|
||||||
TAG_Long,
|
TAG_Long = 4,
|
||||||
|
TAG_Float = 5,
|
||||||
|
TAG_Double = 6,
|
||||||
TAG_ByteArray = 7,
|
TAG_ByteArray = 7,
|
||||||
TAG_String,
|
TAG_String = 8,
|
||||||
TAG_List,
|
TAG_List = 9,
|
||||||
TAG_Compound,
|
TAG_Compound = 10,
|
||||||
TAG_NumTags // Not a real tag, but contains number of tags
|
TAG_NumTags // Not a real tag, but contains number of tags
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -167,7 +169,7 @@ private:
|
|||||||
std::string ReadName();
|
std::string ReadName();
|
||||||
char ReadByte();
|
char ReadByte();
|
||||||
int ReadInt();
|
int ReadInt();
|
||||||
long ReadLong();
|
long long ReadLong();
|
||||||
|
|
||||||
cNBTCompound* m_CurrentCompound;
|
cNBTCompound* m_CurrentCompound;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user