summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-31 23:02:04 +0100
committeradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-31 23:02:04 +0100
commitdda41a040696c8dcc3f6189c5650befec200cf0e (patch)
tree59657d723e4de5a894faa93252ae706154bfd4ef
parentPlayer data is saved and loaded as human readable JSON now. (diff)
downloadcuberite-dda41a040696c8dcc3f6189c5650befec200cf0e.tar
cuberite-dda41a040696c8dcc3f6189c5650befec200cf0e.tar.gz
cuberite-dda41a040696c8dcc3f6189c5650befec200cf0e.tar.bz2
cuberite-dda41a040696c8dcc3f6189c5650befec200cf0e.tar.lz
cuberite-dda41a040696c8dcc3f6189c5650befec200cf0e.tar.xz
cuberite-dda41a040696c8dcc3f6189c5650befec200cf0e.tar.zst
cuberite-dda41a040696c8dcc3f6189c5650befec200cf0e.zip
-rw-r--r--converter/cConvert.cpp53
-rwxr-xr-xconverter/denotchbin216850 -> 221817 bytes
-rw-r--r--source/cChunkMap.cpp17
3 files changed, 56 insertions, 14 deletions
diff --git a/converter/cConvert.cpp b/converter/cConvert.cpp
index a608d6a61..4ee5b6b74 100644
--- a/converter/cConvert.cpp
+++ b/converter/cConvert.cpp
@@ -2,18 +2,51 @@
#include <fstream>
#include <string>
#include <stdio.h>
-#include <string.h>
+//#include <string.h>
#include <ctype.h>
#include "zlib.h"
#include "cNBTData.h"
#include "timer.h"
#include "quicksort.h"
+#include <dirent.h>
+//#include "dircont.h"
using namespace std;
int main () {
+ string dir;
+ DIR* dp;
+ struct dirent *entry;
+ int found;
+ string entrys;
+ string str2;
+ string str3;
+ string filexPos;
+ string filezPos;
+ string pak_name;
+ //string* dir_array;
+ int dir_num_files = 0;
+ int ctr = 0;
+
+ if(dp = opendir("region/")){
+ while(entry = readdir(dp)){
+ entrys = entry->d_name;
+ found = entrys.find(".mcr");
+ if ( (found!=string::npos) && (entry->d_type==8) ) {
+ str2 = entrys.substr (2,sizeof(entrys));
+ filexPos = str2.substr (0,(int)str2.find("."));
+ str3 = str2.substr ((int)str2.find(".")+1, sizeof(str2));
+ filezPos = str3.substr (0,(int)str3.find("."));
+ pak_name = "X" + filexPos + "_Z" + filezPos + ".pak";
+ //printf ("pak_name: %s\n", pak_name.c_str());
+
+ // } //moving down to test
+ // } //mvong down to test
+ // closedir(dp); //moving down to test
+ //} //moving down to test
+
char SourceFile[128];
char OutputFile[128];
//ifstream file ("region/r.0.0.mcr", ios::in|ios::binary|ios::ate);
@@ -25,16 +58,17 @@ int main () {
FILE* f = 0;
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(SourceFile, 128, "region/%s",entrys.c_str()); //replace hard coded file with file array variable
+ sprintf_s(OutputFile, 128, "world/%s",pak_name.c_str()); //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
- sprintf(OutputFile, "world/%s","X0_Z0.pak");
+ sprintf(SourceFile, "region/%s",entrys.c_str()); //same as above but for linux
+ sprintf(OutputFile, "world/%s",pak_name.c_str());
if( (wf = fopen(OutputFile, "wb" )) != 0 ) {} else { cout << "uhoh!" << endl; return 0; }
#endif
+ printf ("Now Converting %s to %s\n", entrys.c_str(), pak_name.c_str() );
if( (f = fopen(SourceFile, "rb" )) != 0 ) { // no error
char* t_FakeHeader;
@@ -222,7 +256,7 @@ int main () {
}
- printf("Coord(X,Z):ChunkSize: %i,%i:%i\n", NBTData->GetInteger("xPos"), NBTData->GetInteger("zPos"), (int)CompressedSize );
+ //printf("Coord(X,Z):ChunkSize: %i,%i:%i\n", NBTData->GetInteger("xPos"), NBTData->GetInteger("zPos"), (int)CompressedSize );
NBTData->CloseCompound();// Close the compounds after you're done
NBTData->CloseCompound();
@@ -257,6 +291,13 @@ int main () {
clock_t end=clock();
cout << "Time elapsed: " << double(diffclock(end,begin)) << " ms"<< endl;
+
+
+ } //moving down to test
+ } //mvong down to test
+ closedir(dp); //moving down to test
+ } //moving down to test
+
return 0;
diff --git a/converter/denotch b/converter/denotch
index 7637b9d6c..afef48860 100755
--- a/converter/denotch
+++ b/converter/denotch
Binary files differ
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index 44dfe3a29..b5a907f09 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -652,13 +652,13 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
{
char PakVersion = 0;
char ChunkVersion = 0;
- if( fread( &PakVersion, sizeof(PakVersion), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &PakVersion, sizeof(PakVersion), 1, f) != 1 ) { LOGERROR("ERROR 1 READING FROM FILE %s", SourceFile); fclose(f); return false; }
if( PakVersion != 1 ) { LOGERROR("WRONG PAK VERSION!"); fclose(f); return 0; }
- if( fread( &ChunkVersion, sizeof(ChunkVersion), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &ChunkVersion, sizeof(ChunkVersion), 1, f) != 1 ) { LOGERROR("ERROR 2 READING FROM FILE %s", SourceFile); fclose(f); return false; }
if( PakVersion != 1 ) { LOGERROR("WRONG CHUNK VERSION!"); fclose(f); return 0; }
short NumChunks = 0;
- if( fread( &NumChunks, sizeof(NumChunks), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &NumChunks, sizeof(NumChunks), 1, f) != 1 ) { LOGERROR("ERROR 3 READING FROM FILE %s", SourceFile); fclose(f); return false; }
LOG("Num chunks: %i", NumChunks );
cChunkLayer* Layer = new cChunkLayer( LAYER_SIZE*LAYER_SIZE );
@@ -670,13 +670,13 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
{
int ChunkX = 0;
int ChunkZ = 0;
- if( fread( &ChunkX, sizeof(ChunkX), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
- if( fread( &ChunkZ, sizeof(ChunkZ), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &ChunkX, sizeof(ChunkX), 1, f) != 1 ) { LOGERROR("ERROR 4 READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &ChunkZ, sizeof(ChunkZ), 1, f) != 1 ) { LOGERROR("ERROR 5 READING FROM FILE %s", SourceFile); fclose(f); return false; }
cChunkData* Data = Layer->GetChunk( ChunkX, ChunkZ );
if( Data )
{
- if( fread( &Data->m_CompressedSize, sizeof(Data->m_CompressedSize), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
- if( fread( &Data->m_UncompressedSize, sizeof(Data->m_UncompressedSize), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &Data->m_CompressedSize, sizeof(Data->m_CompressedSize), 1, f) != 1 ) { LOGERROR("ERROR 6 READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ if( fread( &Data->m_UncompressedSize, sizeof(Data->m_UncompressedSize), 1, f) != 1 ) { LOGERROR("ERROR 7 READING FROM FILE %s", SourceFile); fclose(f); return false; }
}
else
{
@@ -693,7 +693,8 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
{
cChunkData* Data = OrderedData[i];
Data->m_Compressed = new char[ Data->m_CompressedSize ];
- if( fread( Data->m_Compressed, Data->m_CompressedSize, 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
+ //printf("Compressed chunk size: %i\n",Data->m_CompressedSize);
+ if( fread( Data->m_Compressed, Data->m_CompressedSize, 1, f) != 1 ) { LOGERROR("ERROR 8 READING FROM FILE %s", SourceFile); fclose(f); return false; }
/* // Some testing...
uLongf DestSize = Data->m_UncompressedSize;