Skip to content

Commit 0cc6723

Browse files
committed
TRUNK updated to 4.6.1 Final
1 parent f5db84e commit 0cc6723

File tree

8 files changed

+154
-127
lines changed

8 files changed

+154
-127
lines changed

soarForm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ extern Boolean logactive;
102102
extern EWMRData *ewmrdata;
103103
extern Boolean recordevent;
104104
extern UInt32 lastevent;
105+
extern Boolean tskoffterrain;
105106

106107
// External variables used by new polar code
107108
extern Int16 numOfPolars;
@@ -9680,6 +9681,8 @@ Boolean form_question_event_handler(EventPtr event)
96809681
EvtAddEventToQueue(&newEvent);
96819682
break;
96829683
case Qacttaskchg:
9684+
// re-load task terrain
9685+
tskoffterrain = !loadtskterrain(&data.task);
96839686
// copy active task back to record first record in task db
96849687
OpenDBUpdateRecord(task_db, sizeof(TaskData), &data.task, 0);
96859688
set_task_changed = false;

soarMap.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
#ifndef RAD2DEG
2121
#define RAD2DEG ((double)57.29577951308)
2222
#endif
23-
// Nautical Miles per Radian
24-
#define NMPR 3437.74
25-
// Feet per Nautical Mile
26-
#define FPNM 6076.131
2723

2824
// screen defines for ease and central location
2925
#define WIDTH_MIN 0

soarTask.c

Lines changed: 49 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ extern Int32 prevnumtskter;
111111
extern Int32 numtskter;
112112
extern Boolean tskoffterrain;
113113
extern Boolean tskcrash;
114+
extern Boolean terrainvalid;
114115
extern Int32 rxrecs;
115116
extern char rxtype[15];
116117
extern DateTimeType curtime;
@@ -310,59 +311,8 @@ void refresh_task_details(Int16 action)
310311
StrCopy(data.activetask.declaredtg, SecondsToDateOrTimeString(TimGetSeconds(), tempchar, 4, data.config.timezone*-1));
311312
}
312313

313-
// clear terrain array
314-
if ((prevnumtskter > 0) && (tskterheights != NULL)) {
315-
// free previous array
316-
FreeMem((void *)&tskterheights);
317-
tskterheights = NULL;
318-
}
319-
320314
// load terrain on task
321-
if (data.config.usefgterrain) {
322-
323-
// calculate array size
324-
numtskter = 0;
325-
for (x = 0; x < tsk->numwaypts; x++) {
326-
// HostTraceOutputTL(appErrorClass, "Task Terrain Index %s", DblToStr(numtskter,0));
327-
if ((tsk->waypttypes[x] & CONTROL) == 0) numtskter += (Int32)(tsk->distances[x] * TERGRID)+1;
328-
// HostTraceOutputTL(appErrorClass, "Task Terrain Points %s", DblToStr(numtskter,0));
329-
tsk->terrainidx[x] = numtskter;
330-
}
331-
tsk->terrainidx[x] = numtskter;
332-
333-
// allocate new size array
334-
if (AllocMem((void *)&tskterheights, (numtskter+1)*sizeof(double))) {
335-
MemSet(tskterheights, (numtskter+1)*sizeof(double), 0);
336-
prevnumtskter = numtskter;
337-
338-
// load terrain array for each leg
339-
// HostTraceOutputTL(appErrorClass, "Loading Task Terrain.....");
340-
tskoffterrain = false;
341-
for (x = 0; x < tsk->numwaypts-1; x++) {
342-
while (tsk->waypttypes[x] & CONTROL) x++;
343-
z = x + 1;
344-
while (tsk->waypttypes[z] & CONTROL) z++;
345-
// HostTraceOutputTL(appErrorClass, "Load Terrain From %s", tsk->wayptnames[x]);
346-
// HostTraceOutputTL(appErrorClass, "Load Terrain To %s", tsk->wayptnames[z]);
347-
// HostTraceOutputTL(appErrorClass, "start Terrain Points %s", DblToStr((tsk->terrainidx[x]),0));
348-
// HostTraceOutputTL(appErrorClass, "Task Terrain Points %s", DblToStr((tsk->terrainidx[z]-tsk->terrainidx[x]),0));
349-
tskoffterrain = tskoffterrain | !loadterrain(&tskterheights[tsk->terrainidx[x]], (tsk->terrainidx[z]-tsk->terrainidx[x]), tsk->wayptlats[x], tsk->wayptlons[x], tsk->elevations[x], tsk->wayptlats[z], tsk->wayptlons[z], tsk->elevations[z]);
350-
}
351-
352-
// HostTraceOutputTL(appErrorClass, "Terrain Heights.....");
353-
//for (x = 0; x < numtskter; x++) {
354-
// HostTraceOutputTL(appErrorClass, "Task Terrain Height %s", DblToStr(tskterheights[x],0));
355-
//}
356-
357-
// check full task for terrain crash
358-
tskcrash = false;
359-
} else {
360-
// AllocMeme failed
361-
tskoffterrain = true;
362-
}
363-
} else {
364-
tskcrash = false;
365-
}
315+
tskoffterrain = !loadtskterrain(tsk);
366316

367317
// copy task
368318
// HostTraceOutputTL(appErrorClass, "Copy to data.task");
@@ -2995,6 +2945,7 @@ void HandleTask(Int16 action)
29952945

29962946
//************* TSKNONE
29972947
x = activetskway;
2948+
glidingtoheight = ELEVATION;
29982949
if (tasknotfinished && !taskonhold && (activetskway >= 0)) {
29992950
if (data.config.AATmode == AAT_MTURN_ON) {
30002951
// update range / bearing to target in current area
@@ -3023,9 +2974,13 @@ void HandleTask(Int16 action)
30232974
// check if gliging to min finish height
30242975
glidingtoheight = FINISHHEIGHT;
30252976
data.inuseWaypoint.elevation = data.activetask.finishheight;
2977+
} else if ((data.task.waypttypes[x] & AREA)
2978+
&& (LatLonToRange2(data.task.targetlats[x],data.task.targetlons[x],data.task.wayptlats[x],data.task.wayptlons[x]) > 0.25)) {
2979+
// gliding to area target elevation
2980+
data.inuseWaypoint.elevation = GetTerrainElev(data.inuseWaypoint.lat, data.inuseWaypoint.lon);
2981+
if (!terrainvalid) data.inuseWaypoint.elevation = data.task.elevations[x];
30262982
} else {
3027-
// gliding to normal elevation
3028-
glidingtoheight = ELEVATION;
2983+
// gliding to normal waypoint elevation
30292984
data.inuseWaypoint.elevation = data.task.elevations[x];
30302985
}
30312986
data.input.destination_elev = data.inuseWaypoint.elevation;
@@ -3040,8 +2995,6 @@ void HandleTask(Int16 action)
30402995
data.inuseWaypoint.arearadius = data.task.arearadii[x];
30412996
data.inuseWaypoint.arearadius2 = data.task.arearadii2[x];
30422997
data.input.destination_valid = true;
3043-
} else {
3044-
glidingtoheight = ELEVATION;
30452998
}
30462999
InuseWaypointCalcEvent();
30473000

@@ -3136,30 +3089,18 @@ Boolean InSectorTest(double leftbrg, double rightbrg, double inrng, double outrn
31363089
return(true);
31373090
}
31383091

3092+
// Determine if currently within the defined range limits
3093+
if (currng >= inrng && currng <= outrng) {
3094+
withinrng = true;
3095+
// HostTraceOutputTL(appErrorClass, "IST:withinrng =|%hd|", (Int16)withinrng);
3096+
} else {
3097+
return(false);
3098+
}
3099+
31393100
if (leftbrg != rightbrg) {
31403101
recipbrg = RecipCse(curbrg);
31413102
// HostTraceOutputTL(appErrorClass, "IST:recipbrg =|%s|", DblToStr(recipbrg, 1));
31423103

3143-
// OLD METHOD
3144-
/* // Determine if currently within the defined bearing limits
3145-
if (leftbrg < 180.0) {
3146-
if (recipbrg >= leftbrg && recipbrg <= rightbrg) {
3147-
withinbrg = true;
3148-
// HostTraceOutputTL(appErrorClass, "IST:withinbrg1 =|%hd|", (Int16)withinbrg);
3149-
}
3150-
} else if (rightbrg < 360.0 && rightbrg > leftbrg) {
3151-
if (recipbrg >= leftbrg && recipbrg <= rightbrg) {
3152-
withinbrg = true;
3153-
// HostTraceOutputTL(appErrorClass, "IST:withinbrg2 =|%hd|", (Int16)withinbrg);
3154-
}
3155-
} else {
3156-
if (recipbrg >= leftbrg || recipbrg <= rightbrg) {
3157-
withinbrg = true;
3158-
// HostTraceOutputTL(appErrorClass, "IST:withinbrg3 =|%hd|", (Int16)withinbrg);
3159-
}
3160-
}
3161-
*/
3162-
// NEW METHOD
31633104
if (leftbrg > rightbrg) {
31643105
rightbrg += 360.0;
31653106
}
@@ -3174,20 +3115,7 @@ Boolean InSectorTest(double leftbrg, double rightbrg, double inrng, double outrn
31743115
// HostTraceOutputTL(appErrorClass, "IST:withinbrg4 =|%hd|", (Int16)withinbrg);
31753116
}
31763117

3177-
// Determine if currently within the defined range limits
3178-
if (currng >= inrng && currng <= outrng) {
3179-
withinrng = true;
3180-
// HostTraceOutputTL(appErrorClass, "IST:withinrng =|%hd|", (Int16)withinrng);
3181-
}
3182-
if (withinbrg && withinrng) {
3183-
// HostTraceOutputTL(appErrorClass, "IST:return(true)");
3184-
// HostTraceOutputTL(appErrorClass, "IST:--------------------------------");
3185-
return(true);
3186-
} else {
3187-
// HostTraceOutputTL(appErrorClass, "IST:return(false)");
3188-
// HostTraceOutputTL(appErrorClass, "IST:--------------------------------");
3189-
return(false);
3190-
}
3118+
return(withinbrg);
31913119
}
31923120

31933121
// Doesn't matter whether bearings are true or magnectic
@@ -4478,8 +4406,7 @@ void HandleTaskAutoZoom(double range, double radius, Boolean reset)
44784406
// HostTraceOutputTL(appErrorClass, "ct %s", DblToStr(ct,0));
44794407
ct++;
44804408
}
4481-
// do once - progressive zoom in
4482-
// HandleTaskAutoZoom2(range, radius, reset);
4409+
return;
44834410
}
44844411

44854412
// new method - based on range to target point
@@ -4555,21 +4482,21 @@ Boolean HandleTaskAutoZoom2(double range, double radius, Boolean reset)
45554482
actualmapscale = curmapscale * data.input.disconst;
45564483
savemapscale = 0.0;
45574484
tempscale = 100;
4558-
data.input.logpollint = data.config.slowlogint;
45594485
// HostTraceOutputTL(appErrorClass, "Zoom Out Reset");
45604486
}
45614487
}
45624488
}
4563-
45644489
// HostTraceOutputTL(appErrorClass, "Zoom act %s", DblToStr(curmapscale,1));
45654490

45664491
// // Change the logger interval to fast if getting close to the task point
4567-
// if (range <= radius * 1.5) {
4568-
// data.input.logpollint = data.config.fastlogint;
4569-
// } else {
4570-
// data.input.logpollint = data.config.slowlogint;
4571-
// }
4492+
if (range > radius + 0.5) {
4493+
// more than 0.5nm away, so set to slow logging
4494+
data.input.logpollint = data.config.slowlogint;
4495+
} else {
4496+
data.input.logpollint = data.config.fastlogint;
4497+
}
45724498
}
4499+
45734500
return(zoomchg);
45744501
}
45754502

@@ -6074,7 +6001,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
60746001
double sect1, sect2;
60756002
double truecse, xfactor, yfactor;
60766003
Int16 y;
6077-
static Boolean origmanualzoomchg;
6004+
static Boolean origmanualzoomchg, targetmoved;
60786005

60796006
#define zoomfactor 3.0
60806007
#define buttonsize 30
@@ -6232,6 +6159,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
62326159
data.config.sectormaporient = NORTHUP;
62336160
data.input.curmaporient = NORTHUP;
62346161
}
6162+
targetmoved = false;
62356163
UpdateMap2(false, sectorlat, sectorlon, sectorscale, false, tsktoedit, false);
62366164

62376165
handled=true;
@@ -6279,13 +6207,22 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
62796207
// question->type = Qacttaskchg;
62806208
// FrmPopupForm(form_question);
62816209
// }
6210+
// load terrain on task
6211+
tskoffterrain = !loadtskterrain(tsktoedit);
62826212
} else if (!gototskwpt) {
62836213
// restore edittsk prior to changes
62846214
MemMove(temptsk, edittsk, sizeof(TaskData));
62856215
}
62866216
gototskwpt = false;
62876217
goingtomenu = false;
62886218
break;
6219+
case nilEvent:
6220+
if (targetmoved) {
6221+
// load terrain on task if target point has changed in active task
6222+
if (activetasksector) tskoffterrain = !loadtskterrain(tsktoedit);
6223+
targetmoved = false;
6224+
}
6225+
break;
62896226
case ctlSelectEvent:
62906227
PlayKeySound();
62916228
// if (taskIndex == 0) set_task_changed = true;
@@ -6303,6 +6240,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
63036240
}
63046241
tsktoedit->aataimtype = AATusr;
63056242
updatemap = true;
6243+
targetmoved = true;
63066244
break;
63076245
case form_waypoint_sector_min:
63086246
// HostTraceOutputTL(appErrorClass, "Min");
@@ -6317,6 +6255,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
63176255
}
63186256
tsktoedit->aataimtype = AATusr;
63196257
updatemap = true;
6258+
targetmoved = true;
63206259
break;
63216260
case form_waypoint_sector_center:
63226261
// HostTraceOutputTL(appErrorClass, "Center");
@@ -6338,6 +6277,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
63386277
}
63396278
tsktoedit->aataimtype = AATusr;
63406279
updatemap = true;
6280+
targetmoved = true;
63416281
break;
63426282
default:
63436283
break;
@@ -6533,7 +6473,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
65336473
//}
65346474
tsktoedit->aataimtype = AATusr;
65356475
updatemap = true;
6536-
// if (taskIndex == 0) set_task_changed = true;
6476+
targetmoved = true;
65376477
handled=true;
65386478
}
65396479

@@ -6569,11 +6509,12 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
65696509
} else {
65706510
temprng = tsktoedit->arearadii2[selectedTaskWayIdx];
65716511
}
6572-
RangeBearingToLatLonLinearInterp(tsktoedit->wayptlats[selectedTaskWayIdx], tsktoedit->wayptlons[selectedTaskWayIdx], temprng, nice_brg(tempbrg+180), &tsktoedit->targetlats[selectedTaskWayIdx], &tsktoedit->targetlons[selectedTaskWayIdx]);
6512+
RangeBearingToLatLonLinearInterp(tsktoedit->wayptlats[selectedTaskWayIdx], tsktoedit->wayptlons[selectedTaskWayIdx], temprng, nice_brg(tempbrg+180), &tsktoedit->targetlats[selectedTaskWayIdx], &tsktoedit->targetlons[selectedTaskWayIdx]);
65736513
}
65746514
tsktoedit->aataimtype = AATusr;
65756515
// if (taskIndex == 0) set_task_changed = true;
65766516
updatemap = true;
6517+
targetmoved = true;
65776518
handled=true;
65786519
}
65796520

@@ -6609,11 +6550,12 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
66096550
} else {
66106551
temprng = tsktoedit->arearadii2[selectedTaskWayIdx];
66116552
}
6612-
RangeBearingToLatLonLinearInterp(tsktoedit->wayptlats[selectedTaskWayIdx], tsktoedit->wayptlons[selectedTaskWayIdx], temprng, nice_brg(tempbrg+180), &tsktoedit->targetlats[selectedTaskWayIdx], &tsktoedit->targetlons[selectedTaskWayIdx]);
6553+
RangeBearingToLatLonLinearInterp(tsktoedit->wayptlats[selectedTaskWayIdx], tsktoedit->wayptlons[selectedTaskWayIdx], temprng, nice_brg(tempbrg+180), &tsktoedit->targetlats[selectedTaskWayIdx], &tsktoedit->targetlons[selectedTaskWayIdx]);
66136554
}
66146555
tsktoedit->aataimtype = AATusr;
66156556
// if (taskIndex == 0) set_task_changed = true;
66166557
updatemap = true;
6558+
targetmoved = true;
66176559
handled=true;
66186560
}
66196561

@@ -6648,11 +6590,12 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
66486590
} else {
66496591
temprng = tsktoedit->arearadii2[selectedTaskWayIdx];
66506592
}
6651-
RangeBearingToLatLonLinearInterp(tsktoedit->wayptlats[selectedTaskWayIdx], tsktoedit->wayptlons[selectedTaskWayIdx], temprng, nice_brg(tempbrg+180), &tsktoedit->targetlats[selectedTaskWayIdx], &tsktoedit->targetlons[selectedTaskWayIdx]);
6593+
RangeBearingToLatLonLinearInterp(tsktoedit->wayptlats[selectedTaskWayIdx], tsktoedit->wayptlons[selectedTaskWayIdx], temprng, nice_brg(tempbrg+180), &tsktoedit->targetlats[selectedTaskWayIdx], &tsktoedit->targetlons[selectedTaskWayIdx]);
66526594
}
66536595
tsktoedit->aataimtype = AATusr;
66546596
// if (taskIndex == 0) set_task_changed = true;
66556597
updatemap = true;
6598+
targetmoved = true;
66566599
handled=true;
66576600
}
66586601

@@ -6683,11 +6626,12 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
66836626
} else {
66846627
temprng = tsktoedit->arearadii2[selectedTaskWayIdx];
66856628
}
6686-
RangeBearingToLatLonLinearInterp(tsktoedit->wayptlats[selectedTaskWayIdx], tsktoedit->wayptlons[selectedTaskWayIdx], temprng, nice_brg(tempbrg+180), &tsktoedit->targetlats[selectedTaskWayIdx], &tsktoedit->targetlons[selectedTaskWayIdx]);
6629+
RangeBearingToLatLonLinearInterp(tsktoedit->wayptlats[selectedTaskWayIdx], tsktoedit->wayptlons[selectedTaskWayIdx], temprng, nice_brg(tempbrg+180), &tsktoedit->targetlats[selectedTaskWayIdx], &tsktoedit->targetlons[selectedTaskWayIdx]);
66876630
}
66886631
tsktoedit->aataimtype = AATusr;
66896632
// if (taskIndex == 0) set_task_changed = true;
66906633
updatemap = true;
6634+
targetmoved = true;
66916635
handled=true;
66926636
}
66936637

0 commit comments

Comments
 (0)