Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

Commit

Permalink
Version 1.3
Browse files Browse the repository at this point in the history
- Added notification system for new updates and if files are missing (upon launch)
- Remove "command line" version, it isn't really useful and wasn't updated
- Added in depth logging (saved to logs folder)
- Added a hint for when logging into the game so you don't get confused on what to use as the code
- Removed extra buttons in the main window that were no longer needed and added confusion
- Added stats (updated every 500 ms-ish). Has info on CPU, RAM, R/W speed, provide speed (to programs using the served files), download speed, "drive" latency (for programs reading the files), and thread count
- Progress window has placeholders (instead of being empty)
- Overhauled setup window
- Rewrote config code to work better for backwards compatibility
- Rewrote http code to use curl instead of httplib
- Better memory handling when compressing chunks
- Storage, manifest, chunks, auth, etc, classes are now OOP instead of C-style functions
- EGL2 is now self signed with a certificate (and no longer compressed with upx) to deter any false positive antivirus detection
- Refactored/rewrote MountedBuild.cpp to be cleaner
- EGL2 now mounts to /game instead of the A: drive (should fix any admin access shenanigans)
- Dang that's a lot of changes
  • Loading branch information
WorkingRobot committed May 29, 2020
1 parent 80a224f commit b34041e
Show file tree
Hide file tree
Showing 82 changed files with 6,575 additions and 7,039 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
out/
.vs/
.vs/

cert.pfx
cert.pwd
78 changes: 49 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,83 @@

project (EGL2)

set(WITH_GUI ON CACHE BOOL "Compile with a GUI" FORCE)
set(WX_DIR "J:\\Code\\wxWidgets" CACHE PATH "wxWidgets directory" FORCE)

aux_source_directory(. FILE_SOURCES)
aux_source_directory(filesystem FILESYSTEM_FILE_SOURCES)
aux_source_directory(storage STORAGE_FILE_SOURCES)
aux_source_directory(web WEB_FILE_SOURCES)
aux_source_directory(web/manifest MANIFEST_FILE_SOURCES)
aux_source_directory(web/http HTTP_FILE_SOURCES)
aux_source_directory(checks CHECKS_FILE_SOURCES)
aux_source_directory(gui INTERFACE_FILE_SOURCES)
aux_source_directory(libraries/wintoast WINTOAST_FILE_SOURCES)
aux_source_directory(libraries/curlion CURLION_FILE_SOURCES)

if (WITH_GUI)
message("Building with GUI")
add_executable(EGL2 WIN32
${INTERFACE_FILE_SOURCES}
"resources.rc"
${WINTOAST_FILE_SOURCES}
${CURLION_FILE_SOURCES}
${FILESYSTEM_FILE_SOURCES}
${STORAGE_FILE_SOURCES}
${WEB_FILE_SOURCES}
${MANIFEST_FILE_SOURCES}
${HTTP_FILE_SOURCES}
${CHECKS_FILE_SOURCES}
${FILE_SOURCES})

aux_source_directory(gui INTERFACE_FILE_SOURCES)
add_executable(EGL2 WIN32 ${INTERFACE_FILE_SOURCES} "gui/resources.rc" ${FILESYSTEM_FILE_SOURCES} ${STORAGE_FILE_SOURCES} ${WEB_FILE_SOURCES} ${CHECKS_FILE_SOURCES} ${FILE_SOURCES})

set(wxWidgets_ROOT_DIR "${WX_DIR}")
set(wxWidgets_LIB_DIR "${WX_DIR}/lib/vc_x64_lib")
set(wxWidgets_EXCLUDE_COMMON_LIBRARIES TRUE)

if (CMAKE_BUILD_TYPE EQUAL "DEBUG")
set(wxWidgets_USE_DEBUG ON)
else()
set(wxWidgets_USE_DEBUG OFF)
endif()

set(wxWidgets_USE_STATIC ON)
set(wxWidgets_USE_UNICODE ON)

find_package(wxWidgets REQUIRED COMPONENTS core base png zlib)
include(${wxWidgets_USE_FILE})
target_link_libraries(EGL2 PUBLIC ${wxWidgets_LIBRARIES})
set(wxWidgets_ROOT_DIR "${WX_DIR}")
set(wxWidgets_LIB_DIR "${WX_DIR}/lib/vc_x64_lib")
set(wxWidgets_EXCLUDE_COMMON_LIBRARIES TRUE)
set(wxWidgets_USE_STATIC ON)
set(wxWidgets_USE_UNICODE ON)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(wxWidgets_USE_DEBUG ON)
else()
message("Building without GUI")

aux_source_directory(cmd INTERFACE_FILE_SOURCES)
add_executable(EGL2 ${INTERFACE_FILE_SOURCES} ${FILESYSTEM_FILE_SOURCES} ${STORAGE_FILE_SOURCES} ${WEB_FILE_SOURCES} ${CHECKS_FILE_SOURCES} ${FILE_SOURCES})
set(wxWidgets_USE_DEBUG OFF)
endif()

set(Boost_USE_STATIC_LIBS ON)
add_definitions(-DBOOST_ASIO_DISABLE_CONCEPTS)

set_property(TARGET EGL2 PROPERTY CXX_STANDARD 20)

find_package(OpenSSL REQUIRED)
find_package(RapidJSON CONFIG REQUIRED)
find_package(ZLIB REQUIRED)
find_package(lz4 REQUIRED)
find_package(zstd CONFIG REQUIRED)
find_package(CURL CONFIG REQUIRED)
find_package(BOOST 1.68.0 REQUIRED COMPONENTS asio)
find_package(wxWidgets REQUIRED COMPONENTS core base png zlib)
include(${wxWidgets_USE_FILE})

if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Signing files")
file(READ "cert.pwd" SIGN_PASS)
add_custom_command(TARGET EGL2 POST_BUILD
COMMAND
"${CMAKE_SOURCE_DIR}/libraries/signtool/signtool" sign /f "${CMAKE_SOURCE_DIR}/cert.pfx" /p "${SIGN_PASS}" /fd sha1 /t http://timestamp.digicert.com /v $<TARGET_FILE:EGL2> &&
"${CMAKE_SOURCE_DIR}/libraries/signtool/signtool" sign /f "${CMAKE_SOURCE_DIR}/cert.pfx" /p "${SIGN_PASS}" /fd sha256 /tr http://timestamp.digicert.com?td=sha256 /td sha256 /as /v $<TARGET_FILE:EGL2>
)
endif()

set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()

target_link_options(EGL2 PRIVATE "/DELAYLOAD:winfsp-x64.dll")
target_include_directories(EGL2 PRIVATE "$ENV{ProgramFiles\(x86\)}\\WinFsp\\inc" ${RAPIDJSON_INCLUDE_DIRS} "libdeflate")
target_link_libraries(EGL2 PRIVATE "$ENV{ProgramFiles\(x86\)}\\WinFsp\\lib\\winfsp-x64.lib" OpenSSL::SSL OpenSSL::Crypto Crypt32 ZLIB::ZLIB lz4::lz4 delayimp "${CMAKE_CURRENT_SOURCE_DIR}\\libdeflate\\libdeflatestatic.lib")
target_include_directories(EGL2 PRIVATE "$ENV{ProgramFiles\(x86\)}\\WinFsp\\inc" ${Boost_LIBRARIES} ${RAPIDJSON_INCLUDE_DIRS} "libraries\\libdeflate" "libraries\\wintoast" "libraries\\curlion")
target_link_libraries(EGL2 PRIVATE "$ENV{ProgramFiles\(x86\)}\\WinFsp\\lib\\winfsp-x64.lib" ${wxWidgets_LIBRARIES} CURL::libcurl OpenSSL::Crypto Crypt32 libzstd lz4::lz4 delayimp "${CMAKE_CURRENT_SOURCE_DIR}\\libraries\\libdeflate\\libdeflatestatic.lib")
15 changes: 15 additions & 0 deletions Logger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "Logger.h"

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

bool Logger::Setup() {
auto stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
if (stdoutHandle != INVALID_HANDLE_VALUE) {
DWORD outMode;
if (GetConsoleMode(stdoutHandle, &outMode)) {
return SetConsoleMode(stdoutHandle, outMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
}
}
return false;
}
73 changes: 73 additions & 0 deletions Logger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#pragma once

#define LOG_DEBUG(str, ...) Logger::Log(Logger::LogLevel::DEBUG, LOG_SECTION, str, __VA_ARGS__)
#define LOG_INFO(str, ...) Logger::Log(Logger::LogLevel::INFO, LOG_SECTION, str, __VA_ARGS__)
#define LOG_WARN(str, ...) Logger::Log(Logger::LogLevel::WARN, LOG_SECTION, str, __VA_ARGS__)
#define LOG_ERROR(str, ...) Logger::Log(Logger::LogLevel::ERROR_, LOG_SECTION, str, __VA_ARGS__)
#define LOG_FATAL(str, ...) Logger::Log(Logger::LogLevel::FATAL, LOG_SECTION, str, __VA_ARGS__)

#include <functional>
#include <memory>

class Logger {
public:
enum class LogLevel : uint8_t {
UNKNOWN,
DEBUG,
INFO,
WARN,
ERROR_,
FATAL
};

static bool Setup();

template<typename... Args>
static void Log(LogLevel level, const char* section, const char* str, Args... args) {
auto size = snprintf(nullptr, 0, str, args...) + 1;
auto buf = std::make_unique<char[]>(size);
snprintf(buf.get(), size, str, args...);
Callback(level, section, buf.get());
}

static constexpr const char* LevelAsString(LogLevel level) {
switch (level)
{
case LogLevel::DEBUG:
return "Debug";
case LogLevel::INFO:
return "Info ";
case LogLevel::WARN:
return "Warn ";
case LogLevel::ERROR_:
return "Error";
case LogLevel::FATAL:
return "Fatal";
default:
return "Unkwn";
}
}

static constexpr const char* LevelAsColor(LogLevel level) {
switch (level)
{
case LogLevel::DEBUG:
return "\33[0;37m";
case LogLevel::INFO:
return "\33[0;92m";
case LogLevel::WARN:
return "\33[0;93m";
case LogLevel::ERROR_:
return "\33[0;91m";
case LogLevel::FATAL:
return "\33[0;31m";
default:
return "\33[0;95m";
}
}

static constexpr const char* ResetColor = "\33[0m";

using callback = std::function<void(LogLevel, const char*, const char*)>;
static inline callback Callback = nullptr;
};
Loading

0 comments on commit b34041e

Please sign in to comment.