| 973 | |
| 974 | |
| 975 | static ScriptedRotation* |
| 976 | CreateScriptedRotation(Hash* rotationData, |
| 977 | const string& path) |
| 978 | { |
| 979 | #if !defined(CELX) |
| 980 | clog << "ScriptedRotation not usable without scripting support.\n"; |
| 981 | return NULL; |
| 982 | #else |
| 983 | |
| 984 | // Function name is required |
| 985 | string funcName; |
| 986 | if (!rotationData->getString("Function", funcName)) |
| 987 | { |
| 988 | clog << "Function name missing from scripted rotation definition.\n"; |
| 989 | return NULL; |
| 990 | } |
| 991 | |
| 992 | // Module name is optional |
| 993 | string moduleName; |
| 994 | rotationData->getString("Module", moduleName); |
| 995 | |
| 996 | string* pathCopy = new string(path); |
| 997 | Value* pathValue = new Value(*pathCopy); |
| 998 | rotationData->addValue("AddonPath", *pathValue); |
| 999 | |
| 1000 | ScriptedRotation* scriptedRotation = new ScriptedRotation(); |
| 1001 | if (scriptedRotation != NULL) |
| 1002 | { |
| 1003 | if (!scriptedRotation->initialize(moduleName, funcName, rotationData)) |
| 1004 | { |
| 1005 | delete scriptedRotation; |
| 1006 | scriptedRotation = NULL; |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | return scriptedRotation; |
| 1011 | #endif |
| 1012 | } |
| 1013 | |
| 1014 | |
| 1015 | // Parse rotation information. Unfortunately, Celestia didn't originally have |
no test coverage detected