Skip to content

Commit

Permalink
MFD: Make HAS use use sim time instead of real time.
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaiVChr committed May 23, 2023
1 parent 1dc0fc4 commit 17b5eea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
14 changes: 4 additions & 10 deletions Nasal/MFD/MFD_main.nas
Original file line number Diff line number Diff line change
Expand Up @@ -4679,10 +4679,6 @@ var MFD_Device =
return;
#print("\nHAD update:\n=======");

# make sure it can maddog
# filters for table
# when having 2 HAS displays, sensor might get table confused, and check for other issues.
# test
me.harmSelected = 0;
if (pylons.fcs != nil) {
me.radWeap = pylons.fcs.getSelectedWeapon();
Expand Down Expand Up @@ -4746,8 +4742,6 @@ var MFD_Device =
f16.resetSlew();
}

me.dt = noti.getproper("elapsed") - me.elapsed;

if (me.IMSOI) {
if ((me.slew_x != 0 or me.slew_y != 0 or slew_c != 0) and (cursor_lock == -1 or cursor_lock == me.root.index) and noti.getproper("viewName") != "TGP" and me.sensor.handoffTarget == nil) {
cursor_destination = nil;
Expand Down Expand Up @@ -4837,7 +4831,7 @@ var MFD_Device =
}
}
if (me.sensor.enabled) {
me.cycleTimeLeft = math.max(0,me.sensor.dura-(systime()-me.sensor.searchStart));
me.cycleTimeLeft = math.max(0,me.sensor.dura-(me.elapsed-me.sensor.searchStart));
me.root.searchText.setText(sprintf("%d:%02d SCT-%d",(me.cycleTimeLeft)/60, math.mod(me.cycleTimeLeft,60),me.sensor.searchCounter));
me.root.searchText.show();
} else {
Expand All @@ -4849,7 +4843,7 @@ var MFD_Device =

if (me.harmSelected and me.sensor.handoffTarget != nil and me.radWeap.status < armament.MISSILE_LOCK) {
# This makes sure we go from handover back to search when missile loses lock
if (systime()-me.sensor.handoffTime > 1) {
if (me.elapsed-me.sensor.handoffTime > 1) {
# It had time to get lock, but failed or masterarm was off
me.radWeap.setContacts([]);
me.sensor.handoffTarget = nil;
Expand Down Expand Up @@ -4928,7 +4922,7 @@ var MFD_Device =
me.clickableItems = [];
for (me.txt_count = 0; me.txt_count < 5; me.txt_count += 1) {
me.check = !(me.txt_count > me.iter);
me.checkFresh = me.check and me.items[me.txt_count].discover < systime()-me.sensor.searchStart and me.items[me.txt_count].discoverSCT==me.sensor.searchCounter;
me.checkFresh = me.check and me.items[me.txt_count].discover < me.elapsed-me.sensor.searchStart and me.items[me.txt_count].discoverSCT==me.sensor.searchCounter;
me.checkFading = me.check and me.items[me.txt_count]["discoverSCTShown"] == me.sensor.searchCounter-1;
#if (me.check) print(" fresh ",me.checkFresh,", fading ",me.checkFading, ", timetoshow ", me.items[me.txt_count].discover);
#if (me.check) print(" time ",me.items[me.txt_count].discover > systime()-me.sensor.searchStart,", shown ",me.items[me.txt_count].discoverSCT," now",me.sensor.searchCounter);
Expand Down Expand Up @@ -4956,7 +4950,7 @@ var MFD_Device =
if (cursor_click == me.root.index) {
me.handoffTarget = me.click(me.clickableItems);
if (me.handoffTarget != nil) {
me.sensor.handoffTime = systime();
me.sensor.handoffTime = me.elapsed;
me.sensor.handoffTarget = me.handoffTarget;
#print("MFD: Clicked handoff on ",!cursor_click?"LEFT":"RIGHT");#TODO: need right display
}
Expand Down
9 changes: 5 additions & 4 deletions Nasal/radar/apg-68.nas
Original file line number Diff line number Diff line change
Expand Up @@ -2672,7 +2672,7 @@ var RadSensor = {
me.timing = math.min(5, me.timing);
me.timer.restart(me.timing);
me.timer.start();
me.searchStart = systime();
me.searchStart = elapsedProp.getValue();

#print("setEnabled again");
} elsif (!e) {
Expand All @@ -2682,7 +2682,7 @@ var RadSensor = {
},
reset: func {
me.searchTime = 0;
me.searchStart = systime();
me.searchStart = elapsedProp.getValue();
foreach(me.seen;me.vector_aicontacts_seen) {
me.seen.discover = 0;
me.seen.discoverSCT = -2;
Expand All @@ -2701,11 +2701,12 @@ var RadSensor = {
me.vector_aicontacts_seen = [];
return;
}
me.elapsed = elapsedProp.getValue();

me.searchTime = systime()-me.searchStart;
me.searchTime = me.elapsed-me.searchStart;
if (me.searchTime > me.dura) {
me.index = -1;
me.searchStart = systime();
me.searchStart = me.elapsed;
me.searchCounter += 1;
me.searchTime = 0;
#print("finished search");
Expand Down

0 comments on commit 17b5eea

Please sign in to comment.