From 12af1482e7ca86d78c775a61470cf401f4c813ff Mon Sep 17 00:00:00 2001 From: janodesbois Date: Tue, 9 Jun 2015 21:12:48 +0200 Subject: [PATCH] little adjustements for the mp patch --- Nasal/lag_adjust.nas | 52 ++++++++++++++++++++++---------------- Translations/en/menu.xml | 2 +- gui/dialogs/lag-adjust.xml | 2 +- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Nasal/lag_adjust.nas b/Nasal/lag_adjust.nas index 7e69d0194..2ba14999d 100644 --- a/Nasal/lag_adjust.nas +++ b/Nasal/lag_adjust.nas @@ -8,15 +8,26 @@ var apply_close = "false"; var master = 0; var close = 0; +var ls_spect = nil; +var ls_spctoffset = nil; +var ls_range = nil; +var ls_offset = nil; +var ls_close = nil; + +# the compensatelag value are used like that by AIMultiplayer.cxx: +# +# 1 : old behaviour, trying to keep the plane without doing prediction +# 2 : predict the plane position in the futur +# 3 : display more in the past to avoid predictions + var mpCheck = func() { - var mpname = getprop("/ai/models/multiplayer["~i~"]/callsign"); - if (mpname != nil) { - if (spectator) { + var mpname = getprop("/ai/models/multiplayer["~i~"]/callsign"); + if (mpname != nil) { + if (spectator) { setprop("/ai/models/multiplayer["~i~"]/controls/compensate-lag", 3); setprop("/ai/models/multiplayer["~i~"]/controls/player-lag", -spectator_offset); } else { - var lag = offset; - if (apply_close) { + if (apply_close) { var self = geo.aircraft_position(); var x = getprop("/ai/models/multiplayer["~i~"]/position/global-x"); var y = getprop("/ai/models/multiplayer["~i~"]/position/global-y"); @@ -27,13 +38,13 @@ var mpCheck = func() { setprop("/ai/models/multiplayer["~i~"]/controls/compensate-lag", 1); } else { setprop("/ai/models/multiplayer["~i~"]/controls/compensate-lag", 2); - setprop("/ai/models/multiplayer["~i~"]/controls/player-lag", lag); + setprop("/ai/models/multiplayer["~i~"]/controls/player-lag", offset); } } else { setprop("/ai/models/multiplayer["~i~"]/controls/compensate-lag", 1); } } - i += 1; + i += 1; } else { i = 0; if (close) close = 0; @@ -45,22 +56,20 @@ var mpCheck = func() { var mpInit = func() { print("initialising the mp lag system"); - var ls_spect = setlistener("/sim/multiplay/lag/spectator",func { spectator = getprop("/sim/multiplay/lag/spectator")}, 1); - var ls_spctoffset = setlistener("/sim/multiplay/lag/spectator-offset",func { spectator_offset = getprop("/sim/multiplay/lag/spectator-offset")}, 1); - var ls_range = setlistener("/sim/multiplay/lag/range",func { range = getprop("/sim/multiplay/lag/range")}, 1); - var ls_wingmen = setlistener("/sim/multiplay/lag/apply-to-wingmen",func { apply_to_wingmen = getprop("/sim/multiplay/lag/apply-to-wingmen")}, 1); - var ls_offset = setlistener("/sim/multiplay/lag/offset",func { offset = getprop("/sim/multiplay/lag/offset")}, 1); - var ls_close = setlistener("/sim/multiplay/lag/apply-close", func { apply_close = getprop("/sim/multiplay/lag/apply-close")}, 1); + ls_spect = setlistener("/sim/multiplay/lag/spectator",func { spectator = getprop("/sim/multiplay/lag/spectator")}, 1); + ls_spctoffset = setlistener("/sim/multiplay/lag/spectator-offset",func { spectator_offset = getprop("/sim/multiplay/lag/spectator-offset")}, 1); + ls_range = setlistener("/sim/multiplay/lag/range",func { range = getprop("/sim/multiplay/lag/range")}, 1); + ls_offset = setlistener("/sim/multiplay/lag/offset",func { offset = getprop("/sim/multiplay/lag/offset")}, 1); + ls_close = setlistener("/sim/multiplay/lag/apply-close", func { apply_close = getprop("/sim/multiplay/lag/apply-close")}, 1); } var mpClean = func() { - i = 0; - spectator = 0; - spectator_offset = 0.5; - range = 3.0; - apply_to_wingmen = 0; - apply_close = 0; - offset = 0.0; + removelistener(ls_spect); + removelistener(ls_spctoffset); + removelistener(ls_range); + removelistener(ls_offset); + removelistener(ls_close); + close = 1; master = 0; } @@ -70,9 +79,8 @@ var mpStart = func() { if (test == nil) { settimer(mpStart, 2); } else { - mpInit(); setlistener("/sim/multiplay/lag/master", masterSwitch,1); - } + } } var masterSwitch = func() { diff --git a/Translations/en/menu.xml b/Translations/en/menu.xml index f5c37d243..604330f5b 100644 --- a/Translations/en/menu.xml +++ b/Translations/en/menu.xml @@ -83,7 +83,7 @@ Chat Menu Pilot List MPCarrier Selection - lag options + Lag Settings Debug diff --git a/gui/dialogs/lag-adjust.xml b/gui/dialogs/lag-adjust.xml index 4e095a44d..ceafae500 100644 --- a/gui/dialogs/lag-adjust.xml +++ b/gui/dialogs/lag-adjust.xml @@ -13,7 +13,7 @@ 1 - + 1