|
@@ -11,12 +11,12 @@
|
|
|
#define mkdir(dir, mode) _mkdir(dir)
|
|
|
#endif
|
|
|
|
|
|
-#include "../../include/LotroDatPatcher.h"
|
|
|
+#include "LotroDat.h"
|
|
|
using namespace LOTRO_DAT;
|
|
|
using namespace std;
|
|
|
|
|
|
int main() {
|
|
|
- std::cout << "Gi1dor's LotRO .dat patcher ver. 2.0.0" << std::endl;
|
|
|
+ std::cout << "Gi1dor's LotRO .dat patcher ver. 2.1.0" << std::endl;
|
|
|
freopen("errors.log", "w", stderr);
|
|
|
|
|
|
|
|
@@ -27,7 +27,8 @@ int main() {
|
|
|
|
|
|
try {
|
|
|
std::cout << "Hello! I'm a basic shell version of .dat file patcher.\n";
|
|
|
- DatFile *a = nullptr;
|
|
|
+ DatFile file;
|
|
|
+
|
|
|
ifstream in("dat_file_path.txt");
|
|
|
if (!in.fail()) {
|
|
|
std::string filename;
|
|
@@ -35,14 +36,13 @@ int main() {
|
|
|
try {
|
|
|
std::cout << "Using .dat file from dat_file_path.txt...\n";
|
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
|
-
|
|
|
- a = new DatFile(filename.c_str(), 0);
|
|
|
+ file.InitDatFile(filename.c_str(), 0);
|
|
|
} catch (DatException &e) {
|
|
|
std::cout << "Dat file path from dat_file_path.txt - " << filename << " may be incorrect (cannot open DatFile there)\n";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- while (a == nullptr) {
|
|
|
+ while (file.DatFileState() == CLOSED) {
|
|
|
std::cout << "Please, tell, where the .dat file is\n";
|
|
|
std::cout << "Enter path to file (including filename): ";
|
|
|
std::string filename;
|
|
@@ -51,22 +51,22 @@ int main() {
|
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
|
|
|
|
try {
|
|
|
- a = new DatFile(filename.c_str(), 0);
|
|
|
+ file.InitDatFile(filename.c_str(), 0);
|
|
|
} catch (DatException &e) {
|
|
|
if (e.type() == NOFILE_EXCEPTION)
|
|
|
std::cout << "Cannot find file... Could you enter .dat filename once more?" << std::endl;
|
|
|
else
|
|
|
std::cout << "Some error caused while opening the file... "
|
|
|
"Could you enter .dat filename once more?" << std::endl;
|
|
|
- delete a;
|
|
|
+ file.CloseDatFile();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
std::cout << "Great! File initialised successfully!\n";
|
|
|
- std::cout << "Files number: " << a->files_number() << std::endl;
|
|
|
+ std::cout << "Files number: " << file.files_number() << std::endl;
|
|
|
|
|
|
while (true) {
|
|
|
- std::cout << "Please, choose, what should I do. I can patch data from database to .dat file (enter 1), "
|
|
|
+ std::cout << "Please, choose, what should I do. I can patch datfile from database to .dat file (enter 1), "
|
|
|
"change locale (enter 2), print current locale (enter 3) or exit (enter -1)\n";
|
|
|
int cmd = 0;
|
|
|
std::cout << "Enter number of command (1-4): ";
|
|
@@ -112,19 +112,19 @@ int main() {
|
|
|
size_t all = db.CountRows();
|
|
|
size_t now = 0;
|
|
|
|
|
|
- SubfileData data;
|
|
|
+ SubfileData subfile;
|
|
|
|
|
|
try {
|
|
|
- data = db.GetNextFile();
|
|
|
+ subfile = db.GetNextFile();
|
|
|
} catch (std::exception &e) {
|
|
|
fprintf(stderr, "Caught %s exception.\n", e.what());
|
|
|
fprintf(stderr, "DatFile::PatchAllDatabase() error! Caught exception while fetching "
|
|
|
"file from database! Stopping...\n");
|
|
|
return false;
|
|
|
}
|
|
|
- while (data != SubfileData()) {
|
|
|
+ while (!subfile.Empty()) {
|
|
|
try {
|
|
|
- a->PatchFile(data);
|
|
|
+ file.PatchFile(subfile);
|
|
|
} catch (std::exception &e) {
|
|
|
fprintf(stderr, "Caught %s exception.\n", e.what());
|
|
|
fprintf(stderr, "DatFile::PatchAllDatabase() error! Caught exception while "
|
|
@@ -132,7 +132,7 @@ int main() {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- data = db.GetNextFile();
|
|
|
+ subfile = db.GetNextFile();
|
|
|
} catch (std::exception &e) {
|
|
|
fprintf(stderr, "Caught %s exception.\n", e.what());
|
|
|
fprintf(stderr,"DatFile::PatchAllDatabase() error! Caught exception while fetching "
|
|
@@ -144,8 +144,8 @@ int main() {
|
|
|
std::cout << now * 100 / all << "%\n";
|
|
|
}
|
|
|
|
|
|
- a->CommitChanges();
|
|
|
- a->CommitLocales();
|
|
|
+ db.CloseDatabase();
|
|
|
+ file.CommitChanges();
|
|
|
|
|
|
fprintf(stdout, "Spent %f seconds on patching! Thank you for your patience!\n",
|
|
|
float(clock() - begin_time) / CLOCKS_PER_SEC);
|
|
@@ -155,17 +155,17 @@ int main() {
|
|
|
}
|
|
|
}
|
|
|
if (cmd == 2) {
|
|
|
- std::cout << "Old locale is " << (a->current_locale() == PATCHED ? "RU" : "Original") << endl;
|
|
|
+ std::cout << "Old locale is " << (file.current_locale() == PATCHED ? "RU" : "Original") << endl;
|
|
|
std::cout << "Changing locale..." << std::endl;
|
|
|
- a->SetLocale(a->current_locale() == PATCHED ? ORIGINAL : PATCHED);
|
|
|
- std::cout << "New locale is " << (a->current_locale() == PATCHED ? "RU" : "Original") << endl << endl;
|
|
|
+ file.SetLocale(file.current_locale() == PATCHED ? ORIGINAL : PATCHED);
|
|
|
+ std::cout << "New locale is " << (file.current_locale() == PATCHED ? "RU" : "Original") << endl << endl;
|
|
|
}
|
|
|
|
|
|
if (cmd == 3) {
|
|
|
- std::cout << "Current locale is " << (a->current_locale() == PATCHED ? "RU" : "Original") << endl << endl;
|
|
|
+ std::cout << "Current locale is " << (file.current_locale() == PATCHED ? "RU" : "Original") << endl << endl;
|
|
|
}
|
|
|
}
|
|
|
- delete a;
|
|
|
+ file.CloseDatFile();
|
|
|
} catch (std::exception &e) {
|
|
|
fprintf(stderr, "Caught %s exception.", e.what());
|
|
|
printf("Caught %s exception.", e.what());
|