aboutsummaryrefslogtreecommitdiff
path: root/client/src/util
diff options
context:
space:
mode:
authorauth12 <[email protected]>2020-08-28 17:02:54 +0100
committerauth12 <[email protected]>2020-08-28 17:02:54 +0100
commit1b7783f8e0b864d81c8ab7bb4d83cd2f789b0d48 (patch)
treeda0324fe611754ac7a816c9a96eafa84a8cf5e4b /client/src/util
parentImproved CPU usage drastically. (diff)
downloadloader-1b7783f8e0b864d81c8ab7bb4d83cd2f789b0d48.tar.xz
loader-1b7783f8e0b864d81c8ab7bb4d83cd2f789b0d48.zip
Added version checks on server.
Changed main thread behaviour. Fixed events bug where packet seq would get corrupted. Changed session packet behaviour.
Diffstat (limited to 'client/src/util')
-rw-r--r--client/src/util/events.h4
-rw-r--r--client/src/util/io.cpp2
-rw-r--r--client/src/util/io.h13
-rw-r--r--client/src/util/util.cpp5
4 files changed, 9 insertions, 15 deletions
diff --git a/client/src/util/events.h b/client/src/util/events.h
index 67c4b1f..ffad3c6 100644
--- a/client/src/util/events.h
+++ b/client/src/util/events.h
@@ -5,13 +5,13 @@ class event {
using func_type = std::function<void(Args...)>;
std::mutex event_lock;
- std::list<func_type> m_funcs;
+ std::vector<func_type> m_funcs;
public:
void add(const func_type& func) {
std::lock_guard<std::mutex> lock(event_lock);
- m_funcs.push_back(std::move(func));
+ m_funcs.emplace_back(func);
}
void call(Args... params) {
diff --git a/client/src/util/io.cpp b/client/src/util/io.cpp
index bfd58db..47d9dbe 100644
--- a/client/src/util/io.cpp
+++ b/client/src/util/io.cpp
@@ -1,8 +1,6 @@
#include "../include.h"
#include "io.h"
-std::mutex io::file_mutex;
-
bool io::read_file(const std::string_view path, std::vector<char>& out) {
std::ifstream file(path.data(), std::ios::binary);
if (!file.good()) {
diff --git a/client/src/util/io.h b/client/src/util/io.h
index 2b99434..99339c5 100644
--- a/client/src/util/io.h
+++ b/client/src/util/io.h
@@ -5,36 +5,37 @@
#include "../client/enc.h"
-
-
namespace io {
- extern std::mutex file_mutex;
template<typename... Args>
void log(const std::string_view str, Args... params) {
+#ifndef _REL
static auto handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_GREEN);
fmt::print("$> ");
SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
- std::string msg{str};
+ std::string msg{ str };
msg.append("\n");
fmt::print(msg, std::forward<Args>(params)...);
+#endif
}
template<typename... Args>
void log_error(const std::string_view str, Args... params) {
+#ifndef _REL
static auto handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_RED);
fmt::print("$> ");
SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
- std::string msg{str};
+ std::string msg{ str };
msg.append("\n");
fmt::print(msg, std::forward<Args>(params)...);
- }
+#endif
+}
bool read_file(const std::string_view path, std::vector<char>& out);
}; // namespace io
diff --git a/client/src/util/util.cpp b/client/src/util/util.cpp
index 7103604..b78d616 100644
--- a/client/src/util/util.cpp
+++ b/client/src/util/util.cpp
@@ -39,11 +39,6 @@ std::wstring util::multibyte_to_wide(const std::string& str) {
}
bool util::close_handle(HANDLE handle) {
- if (!handle) {
- io::log_error("invalid handle to close.");
- return false;
- }
-
static auto nt_close = g_syscalls.get<native::NtClose>("NtClose");
auto status = nt_close(handle);