add '--dbg-server' command-line argument & add debugging server draft

This commit is contained in:
MihailRis
2025-10-05 23:54:29 +03:00
parent 2895cff5f2
commit 80cd187c6f
7 changed files with 142 additions and 5 deletions
+22 -1
View File
@@ -14,6 +14,7 @@
#include "coders/commons.hpp"
#include "devtools/Editor.hpp"
#include "devtools/Project.hpp"
#include "devtools/DebuggingServer.hpp"
#include "content/ContentControl.hpp"
#include "core_defs.hpp"
#include "io/io.hpp"
@@ -115,6 +116,9 @@ void Engine::initializeClient() {
if (ENGINE_DEBUG_BUILD) {
title += " [debug]";
}
if (debuggingServer) {
title = "[debugging] " + title;
}
auto [window, input] = Window::initialize(&settings.display, title);
if (!window || !input){
throw initialize_error("could not initialize window");
@@ -173,6 +177,18 @@ void Engine::initialize(CoreParameters coreParameters) {
cmd = std::make_unique<cmd::CommandsInterpreter>();
network = network::Network::create(settings.network);
if (!params.debugServerString.empty()) {
try {
debuggingServer = std::make_unique<devtools::DebuggingServer>(
*this, params.debugServerString
);
} catch (const std::runtime_error& err) {
throw initialize_error(
"debugging server error: " + std::string(err.what())
);
}
}
if (!params.scriptFile.empty()) {
paths.setScriptFolder(params.scriptFile.parent_path());
}
@@ -299,7 +315,11 @@ void Engine::saveSettings() {
io::write_string(EnginePaths::SETTINGS_FILE, toml::stringify(*settingsHandler));
if (!params.headless) {
logger.info() << "saving bindings";
io::write_string(EnginePaths::CONTROLS_FILE, input->getBindings().write());
if (input) {
io::write_string(
EnginePaths::CONTROLS_FILE, input->getBindings().write()
);
}
}
}
@@ -318,6 +338,7 @@ void Engine::close() {
logger.info() << "gui finished";
}
audio::close();
debuggingServer.reset();
network.reset();
clearKeepedObjects();
project.reset();
+3
View File
@@ -36,6 +36,7 @@ namespace network {
namespace devtools {
class Editor;
class DebuggingServer;
}
class initialize_error : public std::runtime_error {
@@ -50,6 +51,7 @@ struct CoreParameters {
std::filesystem::path userFolder = ".";
std::filesystem::path scriptFile;
std::filesystem::path projectFolder;
std::string debugServerString;
int tps = 20;
};
@@ -72,6 +74,7 @@ class Engine : public util::ObjectsKeeper {
std::unique_ptr<Input> input;
std::unique_ptr<gui::GUI> gui;
std::unique_ptr<devtools::Editor> editor;
std::unique_ptr<devtools::DebuggingServer> debuggingServer;
PostRunnables postRunnables;
Time time;
OnWorldOpen levelConsumer;