1
0
Fork 0

Nasal: accept strings-containing-ints as

arguments to leg altitude/speed constraints.
This commit is contained in:
James Turner 2013-11-05 15:46:19 -08:00
parent 0b17c68f59
commit f0011bc759

View file

@ -2192,7 +2192,15 @@ static naRef f_leg_setSpeed(naContext c, naRef me, int argc, naRef* args)
}
RouteRestriction rr = routeRestrictionFromString(naStr_data(args[1]));
leg->setSpeed(rr, args[0].num);
if (naIsNum(args[0])) {
leg->setSpeed(rr, args[0].num);
} else if (naIsString(args[0])) {
leg->setSpeed(rr, simgear::strutils::to_int(naStr_data(args[0])));
} else {
naRuntimeError(c, "bad speed value for leg.setSpeed");
}
return naNil();
}
@ -2208,7 +2216,14 @@ static naRef f_leg_setAltitude(naContext c, naRef me, int argc, naRef* args)
}
RouteRestriction rr = routeRestrictionFromString(naStr_data(args[1]));
leg->setAltitude(rr, args[0].num);
if (naIsNum(args[0])) {
leg->setAltitude(rr, args[0].num);
} else if (naIsString(args[0])) {
leg->setAltitude(rr, simgear::strutils::to_int(naStr_data(args[0])));
} else {
naRuntimeError(c, "bad value for setAltitude");
}
return naNil();
}