Skip to content

Commit

Permalink
Add comments, reorder slightly.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Feb 6, 2013
1 parent 7399bfa commit 261fca0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
Expand Up @@ -76,6 +76,7 @@ public Location check(final Player player, final PlayerLocation from, final Play
final double speedModifier = mcAccess.getFasterMovementAmplifier(player);
final double fSpeed;

// TODO: Make this configurable ! [Speed effect should not affect flying if not on ground.]
if (speedModifier == Double.NEGATIVE_INFINITY) fSpeed = 1D;
else fSpeed = 1D + 0.2D * (speedModifier + 1D);

Expand All @@ -88,25 +89,29 @@ public Location check(final Player player, final PlayerLocation from, final Play

data.bunnyhopDelay--;

if (resultH > 0 && sprinting)
if (resultH > 0 && sprinting){
// TODO: Flying and bunnyhop ? <- 8 blocks per second - could be a case.
// Try to treat it as a the "bunnyhop" problem. The bunnyhop problem is that landing and immediately jumping
// again leads to a player moving almost twice as far in that step.
if (data.bunnyhopDelay <= 0 && resultH < 0.4D) {
data.bunnyhopDelay = 9;
resultH = 0D;
}
}

resultH *= 100D;

final double limitV = cc.creativeFlyVerticalSpeed / 100D * VERTICAL_SPEED; // * data.jumpAmplifier;

// Super simple, just check distance compared to max distance vertical.
// TODO: max descending speed ! [max fall speed, use maximum with speed or added ?]
final double resultV = Math.max(0D, yDistance - data.verticalFreedom - limitV) * 100D;

final double result = resultH + resultV;

// The player went to far, either horizontal or vertical.
if (result > 0D) {
// TODO: Get rid of creativeFlyPreviousRefused.
if (data.creativeFlyPreviousRefused) {
// Increment violation level.
data.creativeFlyVL += result;
Expand Down
Expand Up @@ -74,29 +74,42 @@ public static void clear(){
*/
private static final MediumLiftOff defaultMediumLiftOff = MediumLiftOff.LIMIT_JUMP;

// Violation levels.
// Violation levels -----
public double creativeFlyVL = 0D;
public double morePacketsVL = 0D;
public double morePacketsVehicleVL = 0D;
public double noFallVL = 0D;
public double survivalFlyVL = 0D;

// Data shared between the fly checks.
// Data shared between the fly checks -----
public int bunnyhopDelay;
public double horizontalFreedom;
public double jumpAmplifier;

// Velocity handling.
// TODO: consider resetting these with clearFlyData and onSetBack.
public double verticalFreedom;
public double horizontalVelocityCounter;
public double verticalVelocity;
public int verticalVelocityCounter;
public double horizontalVelocityCounter;
public double horizontalFreedom;

// Coordinates.
/** Last from coordinates. */
public double fromX = Double.MAX_VALUE, fromY, fromZ;
/** Last to coordinates. */
public double toX = Double.MAX_VALUE, toY, toZ;

// sf rather
/** To/from was ground or web or assumed to be etc. */
public boolean toWasReset, fromWasReset;
public MediumLiftOff mediumLiftOff = defaultMediumLiftOff;

// Locations shared between all checks.
private Location setBack = null;
private Location teleported = null;

// Check specific data -----

// Data of the creative check.
public boolean creativeFlyPreviousRefused;

Expand All @@ -117,8 +130,6 @@ public static void clear(){

// Data of the no fall check.
public float noFallFallDistance = 0;
// public boolean noFallOnGround;
// public boolean noFallWasOnGround;
/** Last y coordinate from when the player was on ground. */
public double noFallMaxY = 0;
/** Indicate that NoFall should assume the player to be on ground. */
Expand All @@ -145,16 +156,8 @@ public static void clear(){
public long sfVLTime = 0;

// Accounting info.
// TODO: optimize later.
// public final ActionFrequency hDistCount = new ActionFrequency(3, 333);
// public final ActionFrequency hDistSum = new ActionFrequency(3, 333);
public final ActionAccumulator vDistAcc = new ActionAccumulator(3, 3);
// public final ActionFrequency vDistSum = new ActionFrequency(3, 333);
// public final ActionFrequency vDistCount = new ActionFrequency(3, 333);

// Locations shared between all checks.
private Location setBack = null;
private Location teleported = null;

/**
* Clear the data of the fly checks (not more-packets).
Expand Down

0 comments on commit 261fca0

Please sign in to comment.