From 2f7365acbd549747ef1ce9e19f53affb490d9e77 Mon Sep 17 00:00:00 2001
From: Akash Mozumdar <akashmozumdar@gmail.com>
Date: Mon, 22 Apr 2019 13:35:40 -0400
Subject: [PATCH] small fixes

---
 CMakeLists.txt          | 1 -
 GUI/mainwindow.cpp      | 8 ++++----
 extensions/replacer.cpp | 4 ++--
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 804055d..84ca512 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,6 @@ add_compile_options(
   /D_UNICODE
 )
 
-
 if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
   set(CMAKE_FINAL_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/builds/${CMAKE_BUILD_TYPE}_x64)
   set(LIBDIR x64libs)
diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp
index c9c36c9..1d2e161 100644
--- a/GUI/mainwindow.cpp
+++ b/GUI/mainwindow.cpp
@@ -1,4 +1,4 @@
-#include "mainwindow.h"
+#include "mainwindow.h"
 #include "ui_mainwindow.h"
 #include "defs.h"
 #include "extenwindow.h"
@@ -135,6 +135,7 @@ void MainWindow::ProcessConnected(DWORD processId)
 	});
 	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());
 
 	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();
-		TextThread& current = Host::GetThread(ParseTextThreadString(ui->ttCombo->currentText()));
-		if (current.tp.processId == GetSelectedProcessId())
-			hookInfo << QString("|%1:%2:%3").arg(current.tp.ctx).arg(current.tp.ctx2).arg(S(Util::GenerateCode(Host::GetHookParam(current.tp), current.tp.processId)));
+		ThreadParam tp = current.load()->tp;
+		if (tp.processId == GetSelectedProcessId()) hookInfo << QString("|%1:%2:%3").arg(tp.ctx).arg(tp.ctx2).arg(S(Util::GenerateCode(Host::GetHookParam(tp), tp.processId)));
 		QTextFile(HOOK_SAVE_FILE, QIODevice::WriteOnly | QIODevice::Append).write((hookInfo.join(" , ") + "\n").toUtf8());
 	}
 }
diff --git a/extensions/replacer.cpp b/extensions/replacer.cpp
index c2e960e..c2684ab 100644
--- a/extensions/replacer.cpp
+++ b/extensions/replacer.cpp
@@ -24,11 +24,11 @@ public:
 		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 = {};
 		int length = 0;
-		Node* current = &root;
+		const Node* current = &root;
 		for (auto ch : text)
 		{
 			if (Ignore(ch))