Merge commit 'e033ac2f106efd45155341f877242b448dd8ded5' into next
This is merge request #20 MP Patch first step fgdata part: nasal to check wich planes we are displaying in the futur, with a distance check , one plane each frame.
This commit is contained in:
commit
19fe180e3e
6 changed files with 286 additions and 1 deletions
89
Nasal/lag_adjust.nas
Normal file
89
Nasal/lag_adjust.nas
Normal file
|
@ -0,0 +1,89 @@
|
|||
var i = 0;
|
||||
var net_raw = "false";
|
||||
var spectator = "false";
|
||||
var spectator_offset = 0.5;
|
||||
var range = 3.0;
|
||||
var offset = 0.0;
|
||||
var apply_close = "false";
|
||||
var master = 0;
|
||||
var close = 0;
|
||||
|
||||
var mpCheck = func() {
|
||||
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 server = getprop("/sim/multiplay/txhost");
|
||||
var lag = offset
|
||||
} 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");
|
||||
var z = getprop("/ai/models/multiplayer["~i~"]/position/global-z");
|
||||
var ac = geo.Coord.new().set_xyz(x, y, z);
|
||||
var distance = self.distance_to(ac)*M2NM;
|
||||
if ((distance > range)or(distance==nil)) {
|
||||
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);
|
||||
};
|
||||
} else {
|
||||
setprop("/ai/models/multiplayer["~i~"]/controls/compensate-lag", 1);
|
||||
}
|
||||
i += 1;
|
||||
} else {
|
||||
i = 0;
|
||||
if (close) close = 0;
|
||||
}
|
||||
if ((master) or (close)) {
|
||||
settimer(mpCheck, 1);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
var mpClean = func() {
|
||||
i = 0;
|
||||
spectator = 0;
|
||||
spectator_offset = 0.5;
|
||||
range = 3.0;
|
||||
apply_to_wingmen = 0;
|
||||
apply_close = 0;
|
||||
offset = 0.0;
|
||||
close = 1;
|
||||
master = 0;
|
||||
}
|
||||
|
||||
var mpStart = func() {
|
||||
var test = getprop("/sim/multiplay/lag/master");
|
||||
if (test == nil) {
|
||||
settimer(mpStart, 2);
|
||||
} else {
|
||||
mpInit();
|
||||
setlistener("/sim/multiplay/lag/master", masterSwitch,1);
|
||||
}
|
||||
}
|
||||
|
||||
var masterSwitch = func() {
|
||||
master = getprop("/sim/multiplay/lag/master");
|
||||
if (master) {
|
||||
mpInit();
|
||||
mpCheck();
|
||||
} else {
|
||||
mpClean();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_setlistener("/sim/signals/nasal-dir-initialized", mpStart);
|
|
@ -83,6 +83,7 @@
|
|||
<mp-chat-menu>Chat Menu</mp-chat-menu>
|
||||
<mp-list>Pilot List</mp-list>
|
||||
<mp-carrier>MPCarrier Selection</mp-carrier>
|
||||
<lag-adjust>lag options</lag-adjust>
|
||||
|
||||
<!-- Debug menu -->
|
||||
<debug>Debug</debug>
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
<mp-chat-menu>Menu de clavardage</mp-chat-menu> <!-- English: "Chat Menu" -->
|
||||
<mp-list>Liste des pilotes</mp-list> <!-- English: "Pilot List" -->
|
||||
<mp-carrier>Choix du porte-avions multijoueurs</mp-carrier> <!-- English: "MPCarrier Selection" -->
|
||||
|
||||
<lag-adjust>Correction de lag</lag-adjust>
|
||||
<!-- Debug menu -->
|
||||
<debug>Débogage</debug> <!-- English: "Debug" -->
|
||||
<!-- Note: Debug menu items may not need to be translated
|
||||
|
|
180
gui/dialogs/lag-adjust.xml
Normal file
180
gui/dialogs/lag-adjust.xml
Normal file
|
@ -0,0 +1,180 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
|
||||
<PropertyList>
|
||||
<name>lag-adjust</name>
|
||||
<layout>vbox</layout>
|
||||
<resizable>false</resizable>
|
||||
|
||||
|
||||
<!-- titlebar -->
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<empty><stretch>1</stretch></empty>
|
||||
|
||||
<text>
|
||||
<label>Lag-correction settings</label>
|
||||
</text>
|
||||
|
||||
<empty><stretch>1</stretch></empty>
|
||||
|
||||
<button>
|
||||
<pref-width>16</pref-width>
|
||||
<pref-height>16</pref-height>
|
||||
<legend></legend>
|
||||
<keynum>27</keynum>
|
||||
<border>2</border>
|
||||
<binding>
|
||||
<command>dialog-close</command>
|
||||
</binding>
|
||||
</button>
|
||||
</group>
|
||||
<hrule/>
|
||||
|
||||
<!-- main dialog area -->
|
||||
<group>
|
||||
<layout>table</layout>
|
||||
<halign>center</halign>
|
||||
|
||||
<text>
|
||||
<row>0</row>
|
||||
<col>0</col>
|
||||
<halign>right</halign>
|
||||
<label>Master switch:</label>
|
||||
</text>
|
||||
<checkbox>
|
||||
<row>0</row>
|
||||
<col>1</col>
|
||||
<colspan>2</colspan>
|
||||
<halign>left</halign>
|
||||
<name>master</name>
|
||||
<property>/sim/multiplay/lag/master</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>master</object-name>
|
||||
</binding>
|
||||
</checkbox>
|
||||
|
||||
<text>
|
||||
<row>1</row>
|
||||
<col>0</col>
|
||||
<halign>right</halign>
|
||||
<label>Lag adjustment:</label>
|
||||
</text>
|
||||
<slider>
|
||||
<row>1</row>
|
||||
<col>1</col>
|
||||
<name>lag-adjustment</name>
|
||||
<min>-0.1</min>
|
||||
<max>0.15</max>
|
||||
<step>0.001</step>
|
||||
<property>/sim/multiplay/lag/offset</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>lag-adjustment</object-name>
|
||||
</binding>
|
||||
</slider>
|
||||
<text>
|
||||
<!--<visible>
|
||||
<property>/sim/multiplay/online</property>
|
||||
</visible> -->
|
||||
<row>1</row>
|
||||
<col>3</col>
|
||||
<halign>left</halign>
|
||||
<label>MMMMMMMMMMMMMMMMMM</label>
|
||||
<format>%.3f s</format>
|
||||
<property>/sim/multiplay/lag/offset</property>
|
||||
<live>true</live>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<row>2</row>
|
||||
<col>0</col>
|
||||
<label>Apply to close mp</label>
|
||||
<halign>right</halign>
|
||||
</text>
|
||||
<checkbox>
|
||||
<row>2</row>
|
||||
<col>1</col>
|
||||
<colspan>2</colspan>
|
||||
<halign>left</halign>
|
||||
<name>apply-close</name>
|
||||
<property>/sim/multiplay/lag/apply-close</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>apply-close</object-name>
|
||||
</binding>
|
||||
</checkbox>
|
||||
<slider>
|
||||
<row>2</row>
|
||||
<col>2</col>
|
||||
<name>Range</name>
|
||||
<min>1</min>
|
||||
<max>15</max>
|
||||
<step>0.1</step>
|
||||
<property>/sim/multiplay/lag/range</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>range</object-name>
|
||||
</binding>
|
||||
</slider>
|
||||
<text>
|
||||
<!-- <visible>
|
||||
<property>/sim/multiplay/online</property>
|
||||
</visible> -->
|
||||
<row>2</row>
|
||||
<col>3</col>
|
||||
<halign>left</halign>
|
||||
<label>MMMMMMMMMMMMMMMMMMMMM</label>
|
||||
<format>%.1f nm</format>
|
||||
<property>/sim/multiplay/lag/range</property>
|
||||
<live>true</live>
|
||||
</text>
|
||||
|
||||
<text>
|
||||
<row>3</row>
|
||||
<col>0</col>
|
||||
<label>Spectator mode</label>
|
||||
<halign>right</halign>
|
||||
</text>
|
||||
<checkbox>
|
||||
<row>3</row>
|
||||
<col>1</col>
|
||||
<colspan>2</colspan>
|
||||
<halign>left</halign>
|
||||
<name>spectator</name>
|
||||
<!-- <label>Hide replay sessions over MP (less annoying to other players)</label> -->
|
||||
<property>/sim/multiplay/lag/spectator</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>spectator</object-name>
|
||||
</binding>
|
||||
</checkbox>
|
||||
<slider>
|
||||
<row>3</row>
|
||||
<col>2</col>
|
||||
<name>spectator-offset</name>
|
||||
<min>0</min>
|
||||
<max>1</max>
|
||||
<step>0.05</step>
|
||||
<property>/sim/multiplay/lag/spectator-offset</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>spectator-offset</object-name>
|
||||
</binding>
|
||||
</slider>
|
||||
<text>
|
||||
<!-- <visible>
|
||||
<property>/sim/multiplay/online</property>
|
||||
</visible> -->
|
||||
<row>3</row>
|
||||
<col>3</col>
|
||||
<halign>left</halign>
|
||||
<label>MMMMMMMMMMMMMMMMMMMMM</label>
|
||||
<format>%.2f s</format>
|
||||
<property>/sim/multiplay/lag/spectator-offset</property>
|
||||
<live>true</live>
|
||||
</text>
|
||||
</group>
|
||||
|
||||
</PropertyList>
|
|
@ -547,6 +547,13 @@
|
|||
</binding>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<name>lag-adjust</name>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>lag-adjust</dialog-name>
|
||||
</binding>
|
||||
</item>
|
||||
</menu>
|
||||
|
||||
<menu>
|
||||
|
|
|
@ -772,6 +772,14 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
<callsign type="string" userarchive="y">callsign</callsign>
|
||||
<selected-server type="string" userarchive="y"/>
|
||||
<txhost type="string" preserve="y"/>
|
||||
<lag>
|
||||
<range type="float" userarchive="y">3.0</range>
|
||||
<offset type="float" userarchive="y">0</offset>
|
||||
<master type="bool" userarchive="y">0</master>
|
||||
<spectator type="bool" userarchive="y">0</spectator>
|
||||
<spectator-offset type="float" userarchive="y">0</spectator-offset>
|
||||
<apply-close type="bool" userarchive="y">0</apply-close>
|
||||
</lag>
|
||||
</multiplay>
|
||||
<user>
|
||||
<callsign type="string" preserve="y">Golf Foxtrot Sierra</callsign>
|
||||
|
|
Loading…
Reference in a new issue