Reset the actual morepackets (vehicle) data on calling that method.

This commit is contained in:
asofold 2016-05-21 19:30:31 +02:00
parent 4818d95d60
commit 6f53b63db2
2 changed files with 9 additions and 5 deletions

View File

@ -125,6 +125,8 @@ public class MovingData extends ACheckData {
*/
private static final LiftOffEnvelope defaultLiftOffEnvelope = LiftOffEnvelope.UNKNOWN;
public static final int vehicleMorePacketsBufferDefault = 50;
/** Tolerance value for using vertical velocity (the client sends different values than received with fight damage). */
private static final double TOL_VVEL = 0.0625;
@ -305,7 +307,7 @@ public class MovingData extends ACheckData {
public MoveConsistency vehicleConsistency = MoveConsistency.INCONSISTENT; // Workaround
public final DefaultSetBackStorage vehicleSetBacks = new DefaultSetBackStorage();
// Data of the more packets vehicle check.
public int vehicleMorePacketsBuffer = 50;
public int vehicleMorePacketsBuffer = vehicleMorePacketsBufferDefault;
public long vehicleMorePacketsLastTime;
/** Task id of the vehicle set-back task. */
public int vehicleSetBackTaskId = -1;
@ -554,7 +556,9 @@ public class MovingData extends ACheckData {
}
public void clearVehicleMorePacketsData() {
vehicleSetBacks.getMidTermEntry().setValid(false);
vehicleMorePacketsLastTime = 0;
vehicleMorePacketsBuffer = vehicleMorePacketsBufferDefault;
vehicleSetBacks.getMidTermEntry().setValid(false); // TODO: Will have other resetting conditions later on.
// TODO: Also reset other data ?
}

View File

@ -79,7 +79,7 @@ public class VehicleMorePackets extends Check {
if (data.vehicleMorePacketsLastTime + 1000 < time) {
// More than 1 second elapsed, but how many?
final double seconds = (time - data.vehicleMorePacketsLastTime) / 1000D;
final double seconds = (time - data.vehicleMorePacketsLastTime) / 1000.0;
// For each second, fill the buffer.
data.vehicleMorePacketsBuffer += packetsPerTimeframe * seconds;
@ -89,9 +89,9 @@ public class VehicleMorePackets extends Check {
if (data.vehicleMorePacketsBuffer > 100) {
data.vehicleMorePacketsBuffer = 100;
}
} else if (data.vehicleMorePacketsBuffer > 50) {
} else if (data.vehicleMorePacketsBuffer > MovingData.vehicleMorePacketsBufferDefault) {
// Only allow growth up to 50.
data.vehicleMorePacketsBuffer = 50;
data.vehicleMorePacketsBuffer = MovingData.vehicleMorePacketsBufferDefault;
}
// Set the new "last" time.