mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
feat: debugging server does not require network permission now
This commit is contained in:
parent
4c7043d4c2
commit
6cdd6b833c
4 changed files with 14 additions and 4 deletions
|
|
@ -139,7 +139,8 @@ void Engine::initialize(CoreParameters coreParameters) {
|
|||
editor = std::make_unique<devtools::Editor>(*this);
|
||||
cmd = std::make_unique<cmd::CommandsInterpreter>();
|
||||
|
||||
if (project->permissions.has(Permissions::NETWORK)) {
|
||||
if (project->permissions.has(Permissions::NETWORK) ||
|
||||
!params.debugServerString.empty()) {
|
||||
network = network::Network::create(settings.network);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ static int l_start_debug_instance(lua::State* L) {
|
|||
throw std::runtime_error("could not find free port");
|
||||
}
|
||||
}
|
||||
auto projectPath = lua::isstring(L, 2) ? lua::require_lstring(L, 2) : "";
|
||||
const auto& paths = engine->getPaths();
|
||||
|
||||
std::vector<std::string> args {
|
||||
|
|
@ -36,6 +37,11 @@ static int l_start_debug_instance(lua::State* L) {
|
|||
"--dir", paths.getUserFilesFolder().u8string(),
|
||||
"--dbg-server", "tcp:" + std::to_string(port),
|
||||
};
|
||||
if (!projectPath.empty()) {
|
||||
args.emplace_back("--project");
|
||||
args.emplace_back(io::resolve(std::string(projectPath)).string());
|
||||
}
|
||||
|
||||
platform::new_engine_instance(std::move(args));
|
||||
return lua::pushinteger(L, port);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "coders/json.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
#include "network/Network.hpp"
|
||||
#include "devtools/Project.hpp"
|
||||
|
||||
#include <variant>
|
||||
#include <utility>
|
||||
|
|
@ -439,7 +440,7 @@ static int l_is_nodelay(lua::State* L, network::Network& network) {
|
|||
return lua::pushboolean(L, false);
|
||||
}
|
||||
|
||||
static int l_pull_events(lua::State* L, network::Network& network) {
|
||||
static int l_pull_events(lua::State* L) {
|
||||
std::vector<NetworkEvent> local_queue;
|
||||
{
|
||||
std::lock_guard lock(events_queue_mutex);
|
||||
|
|
@ -528,7 +529,8 @@ int wrap(lua_State* L) {
|
|||
int result = 0;
|
||||
try {
|
||||
auto network = engine->getNetwork();
|
||||
if (network == nullptr) {
|
||||
const auto& permissions = engine->getProject().permissions;
|
||||
if (network == nullptr || !permissions.has(Permissions::NETWORK)) {
|
||||
throw std::runtime_error(
|
||||
"network subsystem is not available in the project"
|
||||
);
|
||||
|
|
@ -554,7 +556,7 @@ const luaL_Reg networklib[] = {
|
|||
{"get_total_download", wrap<l_get_total_download>},
|
||||
{"find_free_port", wrap<l_find_free_port>},
|
||||
{"is_available", lua::wrap<l_is_available>},
|
||||
{"__pull_events", wrap<l_pull_events>},
|
||||
{"__pull_events", lua::wrap<l_pull_events>},
|
||||
{"__open_tcp", wrap<l_open_tcp>},
|
||||
{"__open_udp", wrap<l_open_udp>},
|
||||
{"__closeserver", wrap<l_closeserver>},
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ void platform::new_engine_instance(const std::vector<std::string>& args) {
|
|||
ss << " >/dev/null &";
|
||||
|
||||
auto command = ss.str();
|
||||
logger.info() << command;
|
||||
if (int res = system(command.c_str())) {
|
||||
throw std::runtime_error(
|
||||
"starting an engine instance failed with code: " +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue