1
0
Fork 0

Additional checks, for waypoint role setting.

Added these while investigating a defect, which unfortunately still
remains elusive. But the checks are wise anyway.
This commit is contained in:
James Turner 2013-07-24 08:51:35 +01:00
parent a1451f592f
commit 3e46c7998c
2 changed files with 15 additions and 0 deletions

View file

@ -91,6 +91,10 @@ bool Waypt::flag(WayptFlag aFlag) const
void Waypt::setFlag(WayptFlag aFlag, bool aV)
{
if (aFlag == 0) {
throw sg_range_exception("invalid waypoint flag set");
}
_flags = (_flags & ~aFlag);
if (aV) _flags |= aFlag;
}

View file

@ -1920,6 +1920,10 @@ static naRef f_createWP(naContext c, naRef me, int argc, naRef* args)
// set waypt flags - approach, departure, pseudo, etc
if (argc > argOffset) {
WayptFlag f = wayptFlagFromString(naStr_data(args[argOffset++]));
if (f == 0) {
naRuntimeError(c, "createWP: bad waypoint role");
}
wpt->setFlag(f);
}
@ -1947,6 +1951,9 @@ static naRef f_createWPFrom(naContext c, naRef me, int argc, naRef* args)
// set waypt flags - approach, departure, pseudo, etc
if (argc > 1) {
WayptFlag f = wayptFlagFromString(naStr_data(args[1]));
if (f == 0) {
naRuntimeError(c, "createWPFrom: bad waypoint role");
}
wpt->setFlag(f);
}
@ -2116,6 +2123,10 @@ static naRef f_flightplan_clearWPType(naContext c, naRef me, int argc, naRef* ar
}
WayptFlag flag = wayptFlagFromString(naStr_data(args[0]));
if (flag == 0) {
naRuntimeError(c, "clearWPType: bad waypoint role");
}
fp->clearWayptsWithFlag(flag);
return naNil();
}