Make cancelling flying/waiting packets configurable.

This commit is contained in:
asofold 2017-04-29 10:12:08 +02:00
parent de0cabd1b8
commit c7d72101c2
4 changed files with 35 additions and 8 deletions

View File

@ -225,14 +225,29 @@ public class MovingFlying extends BaseAdapter {
if (data.debug) {
debug(player, "Incoming packet, still waiting for ACK on outgoing position.");
}
// Don't add to the flying queue for now (assumed invalid).
final AckReference ackReference = data.teleportQueue.getLastAckReference();
if (ackReference.lastOutgoingId != Integer.MIN_VALUE
&& ackReference.lastOutgoingId != ackReference.maxConfirmedId) {
// Still waiting for a 'confirm teleport' packet. More or less safe to cancel this out.
// TODO: Timeout -> either skip cancel or schedule a set back (to last valid pos or other).
// TODO: Config?
cancel = true;
if (cc.supersededFlyingCancelWaiting) {
// Don't add to the flying queue for now (assumed invalid).
final AckReference ackReference = data.teleportQueue.getLastAckReference();
if (ackReference.lastOutgoingId != Integer.MIN_VALUE
&& ackReference.lastOutgoingId != ackReference.maxConfirmedId) {
// Still waiting for a 'confirm teleport' packet. More or less safe to cancel this out.
/*
* TODO: The actual issue with this, apart from
* potential freezing, also concerns gameplay experience
* in case of minor set backs, which also could be
* caused by the server, e.g. with 'moved wrongly' or
* setting players outside of blocks. In this case the
* moves sent before teleport ack would still be valid
* after the teleport, because distances are small. The
* actual solution should still be to a) not have false
* positives b) somehow get rid all the
* position-correction teleporting the server does, for
* the cases a plugin can handle.
*/
// TODO: Timeout -> either skip cancel or schedule a set back (to last valid pos or other).
// TODO: Config?
cancel = true;
}
}
break;
}

View File

@ -58,6 +58,8 @@ public class NetConfig extends ACheckConfig {
/** Maximum distance for lightning effects (squared). */
public final double soundDistanceSq;
public final boolean supersededFlyingCancelWaiting;
public NetConfig(final ConfigFile config) {
super(config, ConfPaths.NET, new String[] {
Permissions.NET_ATTACKFREQUENCY,
@ -97,6 +99,8 @@ public class NetConfig extends ACheckConfig {
double dist = config.getDouble(ConfPaths.NET_SOUNDDISTANCE_MAXDISTANCE);
soundDistanceSq = dist * dist;
supersededFlyingCancelWaiting = config.getBoolean(ConfPaths.NET_SUPERSEDED_FLYING_CANCELWAITING);
}
@Override

View File

@ -732,6 +732,11 @@ public abstract class ConfPaths {
public static final String NET_SOUNDDISTANCE_ACTIVE = NET_SOUNDDISTANCE + "active";
public static final String NET_SOUNDDISTANCE_MAXDISTANCE = NET_SOUNDDISTANCE + "maxdistance";
/** Somehow superseded packets, typically leniency options .*/
private static final String NET_SUPERSEDED = NET + "superseded.";
private static final String NET_SUPERSEDED_FLYING = NET_SUPERSEDED + "flying.";
public static final String NET_SUPERSEDED_FLYING_CANCELWAITING = NET_SUPERSEDED_FLYING + "cancelwaiting";
public static final String STRINGS = "strings";
// Compatibility section (possibly temporary).

View File

@ -520,6 +520,9 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.NET_SOUNDDISTANCE_ACTIVE, true, 785);
set(ConfPaths.NET_SOUNDDISTANCE_MAXDISTANCE, 320, 785);
// Superseded
set(ConfPaths.NET_SUPERSEDED_FLYING_CANCELWAITING, true, 1090);
// TODO: An extra file might suit these.
final String start = "[player] failed [check]: ";