From 6fc4349b9127705e23657ef015a41e0c7faf844a Mon Sep 17 00:00:00 2001 From: Anon Date: Sat, 10 Sep 2016 22:27:30 -0500 Subject: [PATCH] Fix travis build issues. --- src/common/string_util.cpp | 4 +++- src/core/cheat_core.cpp | 11 ++++++----- src/core/cheat_core.h | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 5bd4e30a6..462992ee6 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -517,7 +517,9 @@ std::string RTrim(std::string & s) { } std::string Trim(std::string & s) { - return LTrim(RTrim(s)); + auto temp = RTrim(s); + auto temp2 = LTrim(temp); + return temp2; } std::string Join(const std::vector& elements, const char* const separator) { diff --git a/src/core/cheat_core.cpp b/src/core/cheat_core.cpp index 0d96329f3..0dd6d6a4e 100644 --- a/src/core/cheat_core.cpp +++ b/src/core/cheat_core.cpp @@ -38,10 +38,10 @@ void RefreshCheats() { namespace CheatEngine { CheatEngine::CheatEngine() { //Create folder and file for cheats if it doesn't exist - FileUtil::CreateDir(FileUtil::GetExeDirectory() + "\\user\\cheats"); + FileUtil::CreateDir(FileUtil::GetUserPath(D_USER_IDX) + "\\cheats"); char buffer[50]; sprintf(buffer, "%016llX", Loader::program_id); - std::string file_path = FileUtil::GetExeDirectory() + "\\user\\cheats\\" + std::string(buffer) + ".txt"; + std::string file_path = FileUtil::GetUserPath(D_USER_IDX) + "\\cheats\\" + std::string(buffer) + ".txt"; if (!FileUtil::Exists(file_path)) FileUtil::CreateEmptyFile(file_path); cheats_list = ReadFileContents(); @@ -50,7 +50,7 @@ namespace CheatEngine { std::vector> CheatEngine::ReadFileContents() { char buffer[50]; auto a = sprintf(buffer, "%016llX", Loader::program_id); - std::string file_path = FileUtil::GetExeDirectory() + "\\user\\cheats\\" + std::string(buffer) + ".txt"; + std::string file_path = FileUtil::GetUserPath(D_USER_IDX) + "\\cheats\\" + std::string(buffer) + ".txt"; std::string contents; FileUtil::ReadFileToString(true, file_path.c_str(), contents); @@ -64,7 +64,8 @@ namespace CheatEngine { std::string name; bool enabled = false; for (int i = 0; i < lines.size(); i++) { - std::string current_line = Common::Trim(std::string(lines[i].c_str())); + std::string current_line = std::string(lines[i].c_str()); + current_line = Common::Trim(current_line); if (current_line == "[Gateway]") { // Codetype header code_type = "Gateway"; @@ -113,7 +114,7 @@ namespace CheatEngine { void CheatEngine::Save(std::vector> cheats) { char buffer[50]; auto a = sprintf(buffer, "%016llX", Loader::program_id); - std::string file_path = FileUtil::GetExeDirectory() + "\\user\\cheats\\" + std::string(buffer) + ".txt"; + std::string file_path = FileUtil::GetUserPath(D_USER_IDX) + "\\cheats\\" + std::string(buffer) + ".txt"; FileUtil::IOFile file = FileUtil::IOFile(file_path, "w+"); bool sectionGateway = false; for (auto& cheat : cheats) { diff --git a/src/core/cheat_core.h b/src/core/cheat_core.h index 72eb02410..142c4929e 100644 --- a/src/core/cheat_core.h +++ b/src/core/cheat_core.h @@ -22,7 +22,8 @@ namespace CheatEngine { */ struct CheatLine { CheatLine(std::string line) { - line = Common::Trim(std::string(line.c_str())); // remove '/0' characters if any. + line = std::string(line.c_str()); // remove '/0' characters if any. + line = Common::Trim(line); if (line.length() != 17) { type = -1; cheat_line = line;