From 6a27245ae87d796be660c85af18edf86484d1b4d Mon Sep 17 00:00:00 2001 From: Macocian Alexandru Victor Date: Tue, 2 Apr 2024 18:59:21 +0200 Subject: [PATCH] Release 0.9.9.25 (#618) --- Daybreak.GWCA/CMakeLists.txt | 2 +- Daybreak.GWCA/source/EntityNameModule.cpp | 11 +- Daybreak.GWCA/source/GameModule.cpp | 9 +- Daybreak.GWCA/source/GameStateModule.cpp | 9 +- Daybreak.GWCA/source/InventoryModule.cpp | 9 +- Daybreak.GWCA/source/ItemNameModule.cpp | 13 +-- Daybreak.GWCA/source/LoginModule.cpp | 9 +- Daybreak.GWCA/source/MainPlayerModule.cpp | 9 +- Daybreak.GWCA/source/MapModule.cpp | 9 +- .../source/PathingMetadataModule.cpp | 9 +- Daybreak.GWCA/source/PathingModule.cpp | 9 +- Daybreak.GWCA/source/PreGameModule.cpp | 9 +- Daybreak.GWCA/source/SessionModule.cpp | 9 +- Daybreak.GWCA/source/TitleInfoModule.cpp | 11 +- Daybreak.GWCA/source/UserModule.cpp | 9 +- Daybreak.GWCA/source/pipesrv.cpp | 106 ------------------ Daybreak/Daybreak.csproj | 2 +- 17 files changed, 48 insertions(+), 196 deletions(-) delete mode 100644 Daybreak.GWCA/source/pipesrv.cpp diff --git a/Daybreak.GWCA/CMakeLists.txt b/Daybreak.GWCA/CMakeLists.txt index a43c64d6..2f05232f 100644 --- a/Daybreak.GWCA/CMakeLists.txt +++ b/Daybreak.GWCA/CMakeLists.txt @@ -11,7 +11,7 @@ endif() set(VERSION_MAJOR 0) set(VERSION_MINOR 9) set(VERSION_PATCH 9) -set(VERSION_TWEAK 10) +set(VERSION_TWEAK 25) set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY) diff --git a/Daybreak.GWCA/source/EntityNameModule.cpp b/Daybreak.GWCA/source/EntityNameModule.cpp index 6831c304..c251e207 100644 --- a/Daybreak.GWCA/source/EntityNameModule.cpp +++ b/Daybreak.GWCA/source/EntityNameModule.cpp @@ -93,7 +93,6 @@ namespace Daybreak::Modules::EntityNameModule { } void GetName(const httplib::Request& req, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; uint32_t id = 0; auto it = req.params.find("id"); if (it == req.params.end()) { @@ -114,16 +113,14 @@ namespace Daybreak::Modules::EntityNameModule { id = static_cast(result); } - auto response = new std::tuple>(); - std::get<0>(*response) = id; - std::promise& promise = std::get<1>(*response); + auto response = std::tuple>(); + std::get<0>(response) = id; + std::promise& promise = std::get<1>(response); EnsureInitialized(); - PromiseQueue.emplace(response); + PromiseQueue.emplace(&response); json responsePayload = promise.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/GameModule.cpp b/Daybreak.GWCA/source/GameModule.cpp index 1b741031..9fe0cff2 100644 --- a/Daybreak.GWCA/source/GameModule.cpp +++ b/Daybreak.GWCA/source/GameModule.cpp @@ -593,15 +593,12 @@ namespace Daybreak::Modules::GameModule { } void GetGameInfo(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/GameStateModule.cpp b/Daybreak.GWCA/source/GameStateModule.cpp index 017b2920..2d6a8ba2 100644 --- a/Daybreak.GWCA/source/GameStateModule.cpp +++ b/Daybreak.GWCA/source/GameStateModule.cpp @@ -100,15 +100,12 @@ namespace Daybreak::Modules::GameStateModule { } void GetGameStateInfo(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/InventoryModule.cpp b/Daybreak.GWCA/source/InventoryModule.cpp index 032c078a..4892c614 100644 --- a/Daybreak.GWCA/source/InventoryModule.cpp +++ b/Daybreak.GWCA/source/InventoryModule.cpp @@ -102,15 +102,12 @@ namespace Daybreak::Modules::InventoryModule { } void GetInventoryInfo(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/ItemNameModule.cpp b/Daybreak.GWCA/source/ItemNameModule.cpp index f1fc01c3..8d7e95eb 100644 --- a/Daybreak.GWCA/source/ItemNameModule.cpp +++ b/Daybreak.GWCA/source/ItemNameModule.cpp @@ -103,7 +103,6 @@ namespace Daybreak::Modules::ItemNameModule { } void GetName(const httplib::Request& req, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; uint32_t id = 0; std::vector modifiers; @@ -146,17 +145,15 @@ namespace Daybreak::Modules::ItemNameModule { } } - auto response = new std::tuple, std::promise>(); - std::get<0>(*response) = id; - std::promise& promise = std::get<2>(*response); - std::get<1>(*response) = modifiers; + auto response = std::tuple, std::promise>(); + std::get<0>(response) = id; + std::promise& promise = std::get<2>(response); + std::get<1>(response) = modifiers; EnsureInitialized(); - PromiseQueue.emplace(response); + PromiseQueue.emplace(&response); json responsePayload = promise.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/LoginModule.cpp b/Daybreak.GWCA/source/LoginModule.cpp index 7b7d0a64..4f5c058e 100644 --- a/Daybreak.GWCA/source/LoginModule.cpp +++ b/Daybreak.GWCA/source/LoginModule.cpp @@ -51,15 +51,12 @@ namespace Daybreak::Modules::LoginModule { } void GetLoginInfo(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/MainPlayerModule.cpp b/Daybreak.GWCA/source/MainPlayerModule.cpp index eb4f2e35..fff1f155 100644 --- a/Daybreak.GWCA/source/MainPlayerModule.cpp +++ b/Daybreak.GWCA/source/MainPlayerModule.cpp @@ -467,15 +467,12 @@ namespace Daybreak::Modules::MainPlayerModule { } void GetMainPlayer(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/MapModule.cpp b/Daybreak.GWCA/source/MapModule.cpp index 7d64d1c6..41451446 100644 --- a/Daybreak.GWCA/source/MapModule.cpp +++ b/Daybreak.GWCA/source/MapModule.cpp @@ -58,15 +58,12 @@ namespace Daybreak::Modules::MapModule { } void GetMapInfo(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/PathingMetadataModule.cpp b/Daybreak.GWCA/source/PathingMetadataModule.cpp index a9fb598d..475ba5d2 100644 --- a/Daybreak.GWCA/source/PathingMetadataModule.cpp +++ b/Daybreak.GWCA/source/PathingMetadataModule.cpp @@ -57,15 +57,12 @@ namespace Daybreak::Modules::PathingMetadataModule { } void GetPathingMetadata(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/PathingModule.cpp b/Daybreak.GWCA/source/PathingModule.cpp index 3ed49834..a1da8fb4 100644 --- a/Daybreak.GWCA/source/PathingModule.cpp +++ b/Daybreak.GWCA/source/PathingModule.cpp @@ -84,15 +84,12 @@ namespace Daybreak::Modules::PathingModule { } void GetPathingData(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/PreGameModule.cpp b/Daybreak.GWCA/source/PreGameModule.cpp index 29c98f32..f0587480 100644 --- a/Daybreak.GWCA/source/PreGameModule.cpp +++ b/Daybreak.GWCA/source/PreGameModule.cpp @@ -60,15 +60,12 @@ namespace Daybreak::Modules::PreGameModule { } void GetPreGameInfo(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/SessionModule.cpp b/Daybreak.GWCA/source/SessionModule.cpp index 006e460b..5fee2f45 100644 --- a/Daybreak.GWCA/source/SessionModule.cpp +++ b/Daybreak.GWCA/source/SessionModule.cpp @@ -62,15 +62,12 @@ namespace Daybreak::Modules::SessionModule { } void GetSessionInfo(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/TitleInfoModule.cpp b/Daybreak.GWCA/source/TitleInfoModule.cpp index 6b775bc3..d308ca9b 100644 --- a/Daybreak.GWCA/source/TitleInfoModule.cpp +++ b/Daybreak.GWCA/source/TitleInfoModule.cpp @@ -128,7 +128,6 @@ namespace Daybreak::Modules::TitleInfoModule { } void GetTitleInfo(const httplib::Request& req, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; uint32_t id = 0; auto it = req.params.find("id"); if (it == req.params.end()) { @@ -149,16 +148,14 @@ namespace Daybreak::Modules::TitleInfoModule { id = static_cast(result); } - auto response = new std::tuple>(); - std::get<0>(*response) = id; - std::promise& promise = std::get<1>(*response); + auto response = std::tuple>(); + std::get<0>(response) = id; + std::promise& promise = std::get<1>(response); EnsureInitialized(); - PromiseQueue.emplace(response); + PromiseQueue.emplace(&response); json responsePayload = promise.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/UserModule.cpp b/Daybreak.GWCA/source/UserModule.cpp index 56a811f8..c8636d08 100644 --- a/Daybreak.GWCA/source/UserModule.cpp +++ b/Daybreak.GWCA/source/UserModule.cpp @@ -66,15 +66,12 @@ namespace Daybreak::Modules::UserModule { } void GetUserInfo(const httplib::Request&, httplib::Response& res) { - auto callbackEntry = new GW::HookEntry; - auto response = new std::promise; + auto response = std::promise(); EnsureInitialized(); - PromiseQueue.emplace(response); - json responsePayload = response->get_future().get(); + PromiseQueue.emplace(&response); + json responsePayload = response.get_future().get(); - delete callbackEntry; - delete response; res.set_content(responsePayload.dump(), "text/json"); } } \ No newline at end of file diff --git a/Daybreak.GWCA/source/pipesrv.cpp b/Daybreak.GWCA/source/pipesrv.cpp deleted file mode 100644 index 5ab31073..00000000 --- a/Daybreak.GWCA/source/pipesrv.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "pch.h" -#include -#include -#include -#include - -namespace PipeServer { - // Function to handle a single client connection - void HandleClient(HANDLE hPipe) - { - while (true) - { - char buffer[1024]; - DWORD bytesRead; - - if (!ReadFile(hPipe, buffer, sizeof(buffer), &bytesRead, NULL) || bytesRead == 0) - { - break; // Error or client closed the connection - } - - // Process data received from the client (e.g., display or manipulate it) - std::cout << "Received from client: " << buffer << std::endl; - - // Send a response back to the client (optional) - const char* response = "Hello from server!"; - DWORD bytesWritten; - WriteFile(hPipe, response, static_cast(strlen(response) + 1), &bytesWritten, NULL); - } - - // Close the pipe handle when the client disconnects - CloseHandle(hPipe); - } - - void StartServer() - { - DWORD processId = GetCurrentProcessId(); - // Create a buffer to store the formatted process ID as a wide string - wchar_t processIdStr[12]; // Assuming DWORD can be represented in 10 characters - - // Format the process ID into the buffer as a wide string - swprintf_s(processIdStr, L"%u", processId); - std::wstring pipeName = L"\\\\.\\pipe\\Daybreak"; - pipeName += processIdStr; - - HANDLE hPipe = CreateNamedPipeW( - pipeName.c_str(), // Use the generated pipe name - PIPE_ACCESS_DUPLEX, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, - 1, - 1024, 1024, - 1000, - NULL - ); - - if (hPipe == INVALID_HANDLE_VALUE) - { - std::cerr << "Error: CreateNamedPipe failed with error code " << GetLastError() << std::endl; - return; - } - - std::cout << "Created named pipe "; - wprintf(L"%s\n", pipeName.c_str()); - std::cout << "Waiting for clients to connect..." << std::endl; - // Wait for client connections and handle them in separate threads - std::vector clientThreads; - HANDLE io_event = CreateEvent(NULL, FALSE, FALSE, NULL); - OVERLAPPED overlapped; - if (io_event == NULL) { - std::cout << "Failed to create event" << std::endl; - return; - } - - while (true) - { - overlapped.hEvent = io_event; - if (ConnectNamedPipe(hPipe, &overlapped)) - { - // A client has connected, create a thread to handle it - std::cout << "Client connected" << std::endl; - clientThreads.emplace_back(HandleClient, hPipe); - clientThreads.back().detach(); - } - else { - DWORD err = GetLastError(); - std::cout << "Failed to connect named pipe " << err << std::endl; - if (err == ERROR_PIPE_CONNECTED) { - std::cout << "Pipe connection was successful. Client connected" << std::endl; - clientThreads.emplace_back(HandleClient, hPipe); - clientThreads.back().detach(); - } - - if (err == ERROR_IO_PENDING) - { - std::cout << "Error IO Pending" << std::endl; - } - if (err == ERROR_PIPE_LISTENING) - { - std::cout << "Error Pipe Listening" << std::endl; - } - } - } - - CloseHandle(hPipe); // Close the server pipe when done - return; - } -} \ No newline at end of file diff --git a/Daybreak/Daybreak.csproj b/Daybreak/Daybreak.csproj index 3e559809..1a4968dc 100644 --- a/Daybreak/Daybreak.csproj +++ b/Daybreak/Daybreak.csproj @@ -11,7 +11,7 @@ preview Daybreak.ico true - 0.9.9.24 + 0.9.9.25 true cfb2a489-db80-448d-a969-80270f314c46 True