]> git.mxchange.org Git - flightgear.git/commitdiff
add error messages for invalid args to settimer()
authormfranz <mfranz>
Sat, 12 May 2007 18:15:45 +0000 (18:15 +0000)
committermfranz <mfranz>
Sat, 12 May 2007 18:15:45 +0000 (18:15 +0000)
src/Scripting/NasalSys.cxx
src/Scripting/NasalSys.hxx

index 95ecda99b0da7b60ac272c5503de45356d37d3ac..7287578b301d8168f8375e7936787a972d358bbf 100644 (file)
@@ -259,7 +259,7 @@ static naRef f_fgcommand(naContext c, naRef me, int argc, naRef* args)
 // FGNasalSys::setTimer().  See there for docs.
 static naRef f_settimer(naContext c, naRef me, int argc, naRef* args)
 {
-    nasalSys->setTimer(argc, args);
+    nasalSys->setTimer(c, argc, args);
     return naNil();
 }
 
@@ -612,15 +612,20 @@ bool FGNasalSys::handleCommand(const SGPropertyNode* arg)
 // "saved" somehow lest they be inadvertently cleaned.  In this case,
 // they are inserted into a globals.__gcsave hash and removed on
 // expiration.
-void FGNasalSys::setTimer(int argc, naRef* args)
+void FGNasalSys::setTimer(naContext c, int argc, naRef* args)
 {
     // Extract the handler, delta, and simtime arguments:
     naRef handler = argc > 0 ? args[0] : naNil();
-    if(!(naIsCode(handler) || naIsCCode(handler) || naIsFunc(handler)))
+    if(!(naIsCode(handler) || naIsCCode(handler) || naIsFunc(handler))) {
+        naRuntimeError(c, "settimer() with invalid function argument");
         return;
+    }
 
     naRef delta = argc > 1 ? args[1] : naNil();
-    if(naIsNil(delta)) return;
+    if(naIsNil(delta)) {
+        naRuntimeError(c, "settimer() with invalid time argument");
+        return;
+    }
 
     bool simtime = (argc > 2 && naTrue(args[2])) ? false : true;
 
index 700b23011c902fde83270ae8be09112f64511f22..1a02caaf4fa2756ac5ed497f4d501d5fe29d2570 100644 (file)
@@ -40,7 +40,7 @@ public:
     FGNasalScript* parseScript(const char* src, const char* name=0);
 
     // Implementation of the settimer extension function
-    void setTimer(int argc, naRef* args);
+    void setTimer(naContext c, int argc, naRef* args);
 
     // Implementation of the setlistener extension function
     naRef setListener(naContext c, int argc, naRef* args);