diff options
| author | Rider Linden <rider@lindenlab.com> | 2026-08-26 15:17:40 -0700 |
|---|---|---|
| committer | Rider Linden <rider@lindenlab.com> | 2026-08-26 15:17:40 -0700 |
| commit | e86a0501bc655548aaadeb1d6475fa1652787098 (patch) | |
| tree | 971b03588db325aba24874d1d2f0c7f8023335cd /indra/newview/llscripteditorws.cpp | |
| parent | 20280de17db765f128d5e31109ce97baec62bc9c (diff) | |
Issue #6191: implemented both recompile_all and reset_all commands through command interface.
Diffstat (limited to 'indra/newview/llscripteditorws.cpp')
| -rw-r--r-- | indra/newview/llscripteditorws.cpp | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/indra/newview/llscripteditorws.cpp b/indra/newview/llscripteditorws.cpp index 56dc2bf15e..729f335db4 100644 --- a/indra/newview/llscripteditorws.cpp +++ b/indra/newview/llscripteditorws.cpp @@ -34,6 +34,7 @@ #include "llagentcamera.h" #include "llappviewer.h" #include "llchat.h" +#include "llcompilequeue.h" #include "lldate.h" #include "llerror.h" #include "lleventcoro.h" @@ -239,6 +240,29 @@ LLScriptEditorWSServer::LLScriptEditorWSServer(const std::string& name, U16 port { return this->handleSaveBackToObjectContents(connection_id, p); }); + + registerCommand({ "viewer.script.reset_all", + "Reset all scripts in an in-world object", + object_id_command_params() }, + [this](U32 connection_id, const LLSD& p) -> LLSD + { + return this->handleObjectScriptResetAll(connection_id, p); + }); + + registerCommand({ "viewer.script.recompile_all", + "Recompile all scripts in an in-world object", + LLSDMap("object_id", + LLSDMap("type", "string") + ("required", true)) + ("target", + LLSDMap("type", "string") + ("required", true) + ("description", + "Compilation target: luau, lsl2, mono, or auto")) }, + [this](U32 connection_id, const LLSD& p) -> LLSD + { + return this->handleObjectScriptRecompileAll(connection_id, p); + }); } LLScriptEditorWSServer::ptr_t LLScriptEditorWSServer::getServer() @@ -814,6 +838,146 @@ LLSD LLScriptEditorWSServer::handleObjectScriptReset(U32 connection_id, const LL return response; } +LLSD LLScriptEditorWSServer::handleObjectScriptResetAll(U32 connection_id, const LLSD& params) +{ + LLUUID prim_id = params["object_id"].asUUID(); + if (prim_id.isNull()) + { + throw LLJSONRPCConnection::InvalidParams("object_id is required"); + } + + LLViewerObject* prim = gObjectList.findObject(prim_id); + if (!prim) + { + throw LLJSONRPCConnection::InvalidParams("Object not found"); + } + + LLViewerObject* root = prim->getRootEdit(); + if (!root || !isObjectPublished(root->getID())) + { + throw LLJSONRPCConnection::ForbiddenError("Object is not published"); + } + + if (!prim->flagScripted()) + { + throw LLJSONRPCConnection::InvalidParams( + "Prim contains no scripts"); + } + + if (!prim->permModify()) + { + throw LLJSONRPCConnection::ForbiddenError( + "No modify permission on prim"); + } + + LLUUID queue_id; + queue_id.generate(); + + LLFloaterScriptQueue* queue = + LLFloaterReg::getTypedInstance<LLFloaterScriptQueue>( + "reset_queue", LLSD(queue_id)); + if (!queue) + { + throw LLJSONRPCConnection::InternalError( + "Unable to open reset queue"); + } + + queue->addObject(prim->getID(), prim->getID().asString()); + if (!queue->start()) + { + queue->closeFloater(); + throw LLJSONRPCConnection::InternalError( + "Unable to start reset queue"); + } + + queue->setTitle(LLTrans::getString("ResetQueueTitle")); + + LLSD response; + response["success"] = true; + response["object_id"] = prim->getID(); + response["queued"] = true; + return response; +} + +LLSD LLScriptEditorWSServer::handleObjectScriptRecompileAll( + U32 connection_id, const LLSD& params) +{ + LLUUID object_id = params["object_id"].asUUID(); + if (object_id.isNull()) + { + throw LLJSONRPCConnection::InvalidParams("object_id is required"); + } + + std::string target = params["target"].asString(); + if (target != "luau" && + target != "lsl2" && + target != "mono" && + target != "auto") + { + throw LLJSONRPCConnection::InvalidParams( + "target must be 'luau', 'lsl2', 'mono', or 'auto'"); + } + + LLViewerObject* object = gObjectList.findObject(object_id); + if (!object) + { + throw LLJSONRPCConnection::InvalidParams("Object not found"); + } + + LLViewerObject* root = object->getRootEdit(); + if (!root || root->getID() != object_id || !isObjectPublished(root->getID())) + { + throw LLJSONRPCConnection::ForbiddenError("Object is not published"); + } + + if (!root->flagScripted()) + { + throw LLJSONRPCConnection::InvalidParams( + "Object contains no scripts"); + } + + if (!root->permModify()) + { + throw LLJSONRPCConnection::ForbiddenError( + "No modify permission on object"); + } + + if (target == "luau") + { + target = "auto-luau"; + } + + LLUUID queue_id; + queue_id.generate(); + + LLFloaterCompileQueue* queue = + LLFloaterReg::getTypedInstance<LLFloaterCompileQueue>( + "compile_queue", LLSD(queue_id)); + if (!queue) + { + throw LLJSONRPCConnection::InternalError( + "Unable to open compile queue"); + } + + queue->setCompileTarget(target); + queue->addObject(root->getID(), root->getID().asString()); + if (!queue->start()) + { + queue->closeFloater(); + throw LLJSONRPCConnection::InternalError( + "Unable to start compile queue"); + } + + queue->setTitle(LLTrans::getString("CompileQueueTitle")); + + LLSD response; + response["success"] = true; + response["object_id"] = root->getID(); + response["target"] = target; + response["queued"] = true; + return response; +} + LLSD LLScriptEditorWSServer::handleObjectModify(U32 connection_id, const LLSD& params) { // Step 1: Parameter Validation |
