From 1b7783f8e0b864d81c8ab7bb4d83cd2f789b0d48 Mon Sep 17 00:00:00 2001 From: auth12 <67507608+auth12@users.noreply.github.com> Date: Fri, 28 Aug 2020 17:02:54 +0100 Subject: Added version checks on server. Changed main thread behaviour. Fixed events bug where packet seq would get corrupted. Changed session packet behaviour. --- client/src/util/events.h | 4 ++-- client/src/util/io.cpp | 2 -- client/src/util/io.h | 13 +++++++------ client/src/util/util.cpp | 5 ----- 4 files changed, 9 insertions(+), 15 deletions(-) (limited to 'client/src/util') 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; std::mutex event_lock; - std::list m_funcs; + std::vector m_funcs; public: void add(const func_type& func) { std::lock_guard 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& 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 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(params)...); +#endif } template 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(params)...); - } +#endif +} bool read_file(const std::string_view path, std::vector& 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("NtClose"); auto status = nt_close(handle); -- cgit v1.2.3