NetPlay controls synch strategy improved

This commit is contained in:
ppeccin 2018-01-22 23:32:23 -02:00
parent 7bcee30e74
commit b47157a1c8
4 changed files with 12 additions and 12 deletions

View file

@ -270,7 +270,7 @@ jt.DOMConsoleControls = function(room, keyForwardControls) {
// Then other controls
if (room.netController)
room.netController.processLocalControlState(control, press);
room.netController.processControlState(control, press);
else
consoleControlsSocket.controlStateChanged(control, press);
}
@ -278,7 +278,7 @@ jt.DOMConsoleControls = function(room, keyForwardControls) {
function processControlValue(control, value) {
if (room.netController)
room.netController.processLocalControlValue(control, value);
room.netController.processControlValue(control, value);
else
consoleControlsSocket.controlValueChanged(control, value);
}

View file

@ -48,7 +48,7 @@ jt.DOMPeripheralControls = function(room) {
this.controlActivated = function(control, altPower, secPort) { // Never secPort
// Check for NetPlay blocked controls
if (room.netController && !room.netController.processCheckLocalPeripheralControl(control)) return;
if (room.netController && !room.netController.processCheckPeripheralControl(control)) return;
// All controls are Press-only and repeatable
switch(control) {

View file

@ -70,7 +70,7 @@ jt.NetClient = function(room) {
// Client gets clocks from Server at onServerNetUpdate()
};
this.processLocalControlState = function (control, press) {
this.processControlState = function (control, press) {
// Reject controls not available to NetPlay Clients
if (disabledControls.has(control))
return room.showOSD("Function not available in NetPlay Client mode", true, true);
@ -79,12 +79,12 @@ jt.NetClient = function(room) {
controlsToSend.push((control << 4) | press ); // binary encoded, always < 16000
};
this.processLocalControlValue = function (control, value) {
this.processControlValue = function (control, value) {
// Store change to be sent only to Server, do not process locally
controlsToSend.push(control + (value + 10)); // always > 16000
};
this.processCheckLocalPeripheralControl = function (control) {
this.processCheckPeripheralControl = function (control) {
// Reject controls not available to NetPlay Clients
if (disabledPeripheralControls.has(control)) {
room.showOSD("Function not available in NetPlay Client mode", true, true);

View file

@ -100,7 +100,7 @@ jt.NetServer = function(room) {
atariConsole.videoClockPulseApplyPulldowns(videoPulls);
};
this.processLocalControlState = function (control, press) {
this.processControlState = function (control, press) {
consoleControlsSocket.controlStateChanged(control, press);
// Store changes to be sent to Clients
@ -108,14 +108,14 @@ jt.NetServer = function(room) {
controlsToSend.push((control << 4) | press ); // binary encoded, always < 16000
};
this.processLocalControlValue = function (control, value) {
this.processControlValue = function (control, value) {
consoleControlsSocket.controlValueChanged(control, value);
// Store changes to be sent to Clients
controlsToSend.push(control + (value + 10)); // always > 16000
};
this.processCheckLocalPeripheralControl = function (control) {
this.processCheckPeripheralControl = function (control) {
// All controls allowed
return true;
};
@ -277,13 +277,13 @@ jt.NetServer = function(room) {
function onClientNetUpdate(netUpdate) {
if (!netUpdate.c) return;
// Apply changes as if they were local controls
// Process changes as if they were local controls
for (var i = 0, changes = netUpdate.c, len = changes.length; i < len; ++i) {
var change = changes[i];
if (change < 16000)
self.processLocalControlState(change >> 4, change & 0x01); // binary encoded
self.processControlState(change >> 4, change & 0x01); // binary encoded
else
self.processLocalControlValue(change & ~0x3fff, (change & 0x3fff) - 10);
self.processControlValue(change & ~0x3fff, (change & 0x3fff) - 10);
}
}