|
@@ -12,7 +12,6 @@
|
|
|
|
|
|
#include "LotroDat.h"
|
|
|
using namespace LOTRO_DAT;
|
|
|
-using namespace std;
|
|
|
|
|
|
void DatStatusChangedHandler(DatStatus::ProgressInfo info) {
|
|
|
if (info.status == DatStatus::DAT_STATUS::E_FREE) {
|
|
@@ -63,7 +62,7 @@ void DatStatusChangedHandler(DatStatus::ProgressInfo info) {
|
|
|
|
|
|
int main() {
|
|
|
std::cout.precision(1);
|
|
|
- std::cout << fixed;
|
|
|
+ std::cout << std::fixed;
|
|
|
std::cout << "Gi1dor's LotRO .dat patcher ver. " << LOTRO_DAT_VERSION << std::endl;
|
|
|
freopen("patcher_errors.log", "w", stderr);
|
|
|
|
|
@@ -77,16 +76,29 @@ int main() {
|
|
|
"if you write path to it (with name of file) in file \"dat_file_path.txt\"\n";
|
|
|
DatFile file;
|
|
|
|
|
|
- ifstream in("dat_file_path.txt");
|
|
|
+ std::ifstream in("dat_file_path.txt");
|
|
|
if (!in.fail()) {
|
|
|
std::string filename;
|
|
|
- getline(in, filename);
|
|
|
+ std::getline(in, filename);
|
|
|
+
|
|
|
+ std::string file_id_str;
|
|
|
+ std::getline(in, file_id_str);
|
|
|
+ int file_id = 0;
|
|
|
+ try {
|
|
|
+ file_id = stoi(file_id_str);
|
|
|
+ } catch (std::invalid_argument) {
|
|
|
+ file_id = -1;
|
|
|
+ std::cout << "Invalid file_id on second line of file dat_file_path.txt!\n\n";
|
|
|
+ }
|
|
|
|
|
|
- std::cout << "Using .dat file from dat_file_path.txt...\n";
|
|
|
- std::cout << "Opening file " << filename << std::endl;
|
|
|
- auto operation = file.Initialise(filename, 0);
|
|
|
- if (operation.result == ERROR)
|
|
|
- std::cout << "Cannot initialise dat file " << filename << " \n";
|
|
|
+ if (file_id != -1) {
|
|
|
+ std::cout << "Using .dat file from dat_file_path.txt...\n";
|
|
|
+ std::cout << "Opening file " << filename << " with id = " << file_id << std::endl;
|
|
|
+ auto operation = file.Initialise(filename, file_id);
|
|
|
+ if (operation.result == false) {
|
|
|
+ std::cout << "Dat initialisation failed. Error message: " << operation.msg << "\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
while (!file.Initialized()) {
|
|
@@ -95,11 +107,23 @@ int main() {
|
|
|
std::string filename;
|
|
|
std::getline(std::cin, filename);
|
|
|
|
|
|
+ std::cout << "Enter file id: ";
|
|
|
+ std::string file_id_str;
|
|
|
+ std::getline(std::cin, file_id_str);
|
|
|
+ int file_id = 0;
|
|
|
+ try {
|
|
|
+ file_id = stoi(file_id_str);
|
|
|
+ } catch (std::invalid_argument) {
|
|
|
+ std::cout << "Invalid command entered!\n\n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
|
|
|
|
- auto operation = file.Initialise(filename, 0);
|
|
|
- if (operation.result == ERROR)
|
|
|
- std::cout << "Cannot initialise dat file " << filename << ", please, try again\n";
|
|
|
+ auto operation = file.Initialise(filename, file_id);
|
|
|
+ if (operation.result == false) {
|
|
|
+ std::cout << "Dat initialisation failed. Error message: " << operation.msg << "\nTo try again enter path to .dat file\n";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
std::cout << "Great! File initialised successfully!\n";
|
|
@@ -111,12 +135,16 @@ int main() {
|
|
|
"print disabled categories (enter 6), create backup (enter 7), remove backup (enter 8), "
|
|
|
"restore .dat file from backup (enter 9), check if backup exists (enter 10) or exit (enter -1)\n";
|
|
|
|
|
|
- int cmd = 0;
|
|
|
std::cout << "Enter number of command (1-10): ";
|
|
|
- std::cin >> cmd;
|
|
|
-
|
|
|
- std::string tmp;
|
|
|
- std::getline(std::cin, tmp);
|
|
|
+ std::string command;
|
|
|
+ std::getline(std::cin, command);
|
|
|
+ int cmd = -10;
|
|
|
+ try {
|
|
|
+ cmd = stoi(command);
|
|
|
+ } catch (std::invalid_argument) {
|
|
|
+ std::cout << "Invalid command entered!\n\n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
if (cmd == -1) {
|
|
|
std::cout << "Exiting. Thanks for using me!\n";
|
|
@@ -170,14 +198,14 @@ int main() {
|
|
|
}
|
|
|
}
|
|
|
if (cmd == 2) {
|
|
|
- std::cout << "Old locale is " << (file.GetLocaleManager().GetCurrentLocale() == DatLocaleManager::PATCHED ? "RU" : "Original") << endl;
|
|
|
+ std::cout << "Old locale is " << (file.GetLocaleManager().GetCurrentLocale() == DatLocaleManager::PATCHED ? "RU" : "Original") << std::endl;
|
|
|
std::cout << "Changing locale..." << std::endl;
|
|
|
file.GetLocaleManager().SetLocale(file.GetLocaleManager().GetCurrentLocale() == DatLocaleManager::PATCHED ? DatLocaleManager::ORIGINAL : DatLocaleManager::PATCHED);
|
|
|
- std::cout << "New locale is " << (file.GetLocaleManager().GetCurrentLocale() == DatLocaleManager::PATCHED ? "RU" : "Original") << endl;
|
|
|
+ std::cout << "New locale is " << (file.GetLocaleManager().GetCurrentLocale() == DatLocaleManager::PATCHED ? "RU" : "Original") << std::endl;
|
|
|
}
|
|
|
|
|
|
if (cmd == 3) {
|
|
|
- std::cout << "Current locale is " << (file.GetLocaleManager().GetCurrentLocale() == DatLocaleManager::PATCHED ? "RU" : "Original") << endl;
|
|
|
+ std::cout << "Current locale is " << (file.GetLocaleManager().GetCurrentLocale() == DatLocaleManager::PATCHED ? "RU" : "Original") << std::endl;
|
|
|
}
|
|
|
|
|
|
if (cmd == 4) {
|
|
@@ -200,7 +228,7 @@ int main() {
|
|
|
std::cout << "Disabled categories: ";
|
|
|
for (auto i : file.GetLocaleManager().GetInactiveCategories())
|
|
|
std::cout << i << " ";
|
|
|
- std::cout << endl;
|
|
|
+ std::cout << std::endl;
|
|
|
}
|
|
|
|
|
|
if (cmd == 7) {
|