From 9d25ab249f55f0c6921e62720f3b2ad5c4bb14f8 Mon Sep 17 00:00:00 2001 From: Hleb Valoshka <375gnu@gmail.com> Date: Sat, 17 Nov 2018 20:53:36 +0300 Subject: [PATCH] Add from_ssc command for CEL scripts --- scripts/tests/from_ssc.cel | 3 +++ src/celengine/cmdparser.cpp | 6 ++++++ src/celengine/command.cpp | 17 +++++++++++++++++ src/celengine/command.h | 11 +++++++++++ 4 files changed, 37 insertions(+) create mode 100644 scripts/tests/from_ssc.cel diff --git a/scripts/tests/from_ssc.cel b/scripts/tests/from_ssc.cel new file mode 100644 index 000000000..910818421 --- /dev/null +++ b/scripts/tests/from_ssc.cel @@ -0,0 +1,3 @@ +{ + from_ssc { fragment "Modify \"433 Eros:Eros:1898 DQ\" \"Sol\" {UniformRotation {Period 0.01}}" } +} diff --git a/src/celengine/cmdparser.cpp b/src/celengine/cmdparser.cpp index e82fff93e..eda03804d 100644 --- a/src/celengine/cmdparser.cpp +++ b/src/celengine/cmdparser.cpp @@ -895,6 +895,12 @@ Command* CommandParser::parseCommand() paramList->getString("path", path); cmd = new CommandSetRingsTexture(object, texture, path); } + else if (commandName == "from_ssc") + { + string fragment; + paramList->getString("fragment", fragment); + cmd = new CommandFromSSC(fragment); + } else { error("Unknown command name '" + commandName + "'"); diff --git a/src/celengine/command.cpp b/src/celengine/command.cpp index ae6b3ab5c..6f93dd03e 100644 --- a/src/celengine/command.cpp +++ b/src/celengine/command.cpp @@ -1175,3 +1175,20 @@ void CommandSetRingsTexture::process(ExecutionEnvironment& env) sel.body()->getRings()->texture = MultiResTexture(textureName, path); } } + + +/////////////// +// FromSSC command +CommandFromSSC::CommandFromSSC(string _fragment) : + fragment(_fragment) +{ +} + +void CommandFromSSC::process(ExecutionEnvironment& env) +{ + Universe* u = env.getSimulation()->getUniverse(); + if (u == nullptr) + return; + istringstream in(fragment); + LoadSolarSystemObjects(in, *u, ""); +} diff --git a/src/celengine/command.h b/src/celengine/command.h index 7a301e7fe..03e10a6fe 100644 --- a/src/celengine/command.h +++ b/src/celengine/command.h @@ -813,4 +813,15 @@ class CommandSetRingsTexture : public InstantaneousCommand std::string object, textureName, path; }; + +class CommandFromSSC : public InstantaneousCommand +{ + public: + CommandFromSSC(std::string); + void process(ExecutionEnvironment&); + + private: + std::string fragment; +}; + #endif // _COMMAND_H_