From dda41a040696c8dcc3f6189c5650befec200cf0e Mon Sep 17 00:00:00 2001 From: "admin@omencraft.com" Date: Mon, 31 Oct 2011 22:02:04 +0000 Subject: denotch map converter works! :D git-svn-id: http://mc-server.googlecode.com/svn/trunk@36 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- converter/cConvert.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'converter/cConvert.cpp') 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 #include #include -#include +//#include #include #include "zlib.h" #include "cNBTData.h" #include "timer.h" #include "quicksort.h" +#include +//#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; -- cgit v1.2.3