From 785e6ddc38086b300180a689b0fc686a1202e932 Mon Sep 17 00:00:00 2001 From: Ritchie Cunningham Date: Sat, 1 Nov 2025 18:06:54 +0000 Subject: [PATCH] [Refactor] Use Lua script for C2S_BUILD_FILE handling. --- server/src/network_manager.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/server/src/network_manager.cpp b/server/src/network_manager.cpp index 9fa267c..f3056b7 100644 --- a/server/src/network_manager.cpp +++ b/server/src/network_manager.cpp @@ -222,14 +222,13 @@ void NetworkManager::on_message(std::shared_ptr connection, /* Save the file to ensure the VFS is up to date. */ session->write_file(path, content); - /* The 'build.lua' script is just a wrapper around 'api::create_executable'. */ - std::string exec_path = path; - size_t dot_pos = exec_path.rfind(".lua"); - if(dot_pos != std::string::npos) { - exec_path.erase(dot_pos); - } - /* The api function returns an error string, but we'll ignore it here for now. */ - api::create_executable(*session, exec_path, content); + /* Execute the build command via the session. */ + std::string response = session->process_command("build " + path); + /* Send response back to client. */ + std::string new_prompt = get_full_path(session->get_current_dir()); + response += "\n" + new_prompt; + connection->send(net_protocol::build_message(net_protocol::Opcode::S2C_COMMAND_RESPONSE, + {args[0], response})); } } break;