64 lines
2.2 KiB
C++
64 lines
2.2 KiB
C++
#include <iostream>
|
|
|
|
int replace_string(const std::string&, const std::string&, const std::string&);
|
|
int dir_not_exists(const std::string&);
|
|
|
|
int calibrate_preferences()
|
|
{
|
|
std::cout << "Calibrating preferences.empire_script.txt..." << std::endl;
|
|
|
|
/* Converting .txt file from UCS-2 to UTF-8 into a new .txt_utf8 file */
|
|
if (system("iconv -f ucs-2 -t utf-8 -o ~/.local/share/feral-interactive/Empire/AppData/scripts/preferences.empire_script.txt_utf8 ~/.local/share/feral-interactive/Empire/AppData/scripts/preferences.empire_script.txt"))
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
/* Replacing string in utf_8 */
|
|
if (replace_string("~/.local/share/feral-interactive/Empire/AppData/scripts/preferences.empire_script.txt_utf8", "write_preferences_at_exit true", "write_preferences_at_exit false"))
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
/* Converting back from UTF-8 to UCS-2 in .txt*/
|
|
return system("iconv -f utf-8 -t ucs-2 -o ~/.local/share/feral-interactive/Empire/AppData/scripts/preferences.empire_script.txt ~/.local/share/feral-interactive/Empire/AppData/scripts/preferences.empire_script.txt_utf8");
|
|
|
|
/** NOT FUNCTIONAL
|
|
|
|
// Verifying MD5 checksum
|
|
md5sum(path[i], md5_local);
|
|
if ((strcmp(to_hex(md5_local).c_str(), path_md5[i]) != 0))
|
|
{
|
|
print_md5_sum(md5_local);
|
|
std::cerr << " != " << path_md5[i] << "\nFailed to calibrate preferences.empire_script.txt !" << std::endl;
|
|
}
|
|
|
|
*/
|
|
}
|
|
|
|
int calibrate_text_bug_fix()
|
|
{
|
|
std::cout << "Calibrating preferences XML file..." << std::endl;
|
|
|
|
/* Replacing string */
|
|
return replace_string("~/.local/share/feral-interactive/Empire/preferences", "\"UsePBOSurfaces\" type=\"integer\">1", "\"UsePBOSurfaces\" type=\"integer\">0");
|
|
}
|
|
|
|
int calibrate_backup(const std::string& hd)
|
|
{
|
|
std::cout << "Searching for backup files and directories..." << std::endl;
|
|
|
|
if (dir_not_exists(hd + "/.local/share/Steam/steamapps/common/Empire\ Total\ War/data/campaigns/main_backup/"))
|
|
{
|
|
std::cerr << "data/campaigns/main_backup/ not found!" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
if (dir_not_exists(hd + "/.local/share/Steam/steamapps/common/Empire\ Total\ War/data/campaign_maps/global_map_backup/"))
|
|
{
|
|
std::cerr << "data/campaign_maps/global_map_backup/ not found!" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|