small fixes

This commit is contained in:
Akash Mozumdar 2019-04-22 13:35:40 -04:00
parent a8100b4d8c
commit 2f7365acbd
3 changed files with 6 additions and 7 deletions

View File

@ -13,7 +13,6 @@ add_compile_options(
/D_UNICODE /D_UNICODE
) )
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x64) set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x64)
set(LIBDIR x64libs) set(LIBDIR x64libs)

View File

@ -1,4 +1,4 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "defs.h" #include "defs.h"
#include "extenwindow.h" #include "extenwindow.h"
@ -135,6 +135,7 @@ void MainWindow::ProcessConnected(DWORD processId)
}); });
if (process == "???") return; if (process == "???") return;
// This does add (potentially tons of) duplicates to the file, but as long as I don't perform Ω(N^2) operations it shouldn't be an issue
QTextFile(GAME_SAVE_FILE, QIODevice::WriteOnly | QIODevice::Append).write((process + "\n").toUtf8()); QTextFile(GAME_SAVE_FILE, QIODevice::WriteOnly | QIODevice::Append).write((process + "\n").toUtf8());
QStringList allProcesses = QString(QTextFile(HOOK_SAVE_FILE, QIODevice::ReadOnly).readAll()).split("\n", QString::SkipEmptyParts); QStringList allProcesses = QString(QTextFile(HOOK_SAVE_FILE, QIODevice::ReadOnly).readAll()).split("\n", QString::SkipEmptyParts);
@ -310,9 +311,8 @@ void MainWindow::SaveHooks()
} }
} }
auto hookInfo = QStringList() << S(processName.value()) << hookCodes.values(); auto hookInfo = QStringList() << S(processName.value()) << hookCodes.values();
TextThread& current = Host::GetThread(ParseTextThreadString(ui->ttCombo->currentText())); ThreadParam tp = current.load()->tp;
if (current.tp.processId == GetSelectedProcessId()) if (tp.processId == GetSelectedProcessId()) hookInfo << QString("|%1:%2:%3").arg(tp.ctx).arg(tp.ctx2).arg(S(Util::GenerateCode(Host::GetHookParam(tp), tp.processId)));
hookInfo << QString("|%1:%2:%3").arg(current.tp.ctx).arg(current.tp.ctx2).arg(S(Util::GenerateCode(Host::GetHookParam(current.tp), current.tp.processId)));
QTextFile(HOOK_SAVE_FILE, QIODevice::WriteOnly | QIODevice::Append).write((hookInfo.join(" , ") + "\n").toUtf8()); QTextFile(HOOK_SAVE_FILE, QIODevice::WriteOnly | QIODevice::Append).write((hookInfo.join(" , ") + "\n").toUtf8());
} }
} }

View File

@ -24,11 +24,11 @@ public:
if (current != &root) current->value = replacement; if (current != &root) current->value = replacement;
} }
std::pair<int, std::optional<std::wstring>> Lookup(const std::wstring& text) std::pair<int, std::optional<std::wstring>> Lookup(const std::wstring& text) const
{ {
std::pair<int, std::optional<std::wstring>> result = {}; std::pair<int, std::optional<std::wstring>> result = {};
int length = 0; int length = 0;
Node* current = &root; const Node* current = &root;
for (auto ch : text) for (auto ch : text)
{ {
if (Ignore(ch)) if (Ignore(ch))