Skip to content

Commit

Permalink
Change buffer amount to positive.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Aug 29, 2013
1 parent 1d2f291 commit 048cada
Showing 1 changed file with 9 additions and 8 deletions.
Expand Up @@ -245,11 +245,6 @@ else if (data.sfOnIce > 0) {
}
}
}

// Finally check horizontal buffer regain.
if (hDistanceAboveLimit < 0.0 && hDistance > 0.0 && data.sfHorizontalBuffer < hBufMax) {
hBufRegain(hDistance, hDistanceAboveLimit, data);
}

//////////////////////////
// Vertical move.
Expand Down Expand Up @@ -387,6 +382,12 @@ else if (!data.sfDirty){
if (now - data.sfVLTime > cc.survivalFlyVLFreeze) {
data.survivalFlyVL *= 0.95D;
}

// Finally check horizontal buffer regain.
if (hDistanceAboveLimit < 0.0 && result <= 0.0 && hDistance > 0.0 && data.sfHorizontalBuffer < hBufMax) {
// TODO: max min other conditions ?
hBufRegain(hDistance, Math.min(0.1, Math.abs(hDistanceAboveLimit)), data);
}
}

// Set data for normal move or violation without cancel (cancel would have returned above)
Expand Down Expand Up @@ -929,18 +930,18 @@ else if (hDistance >= walkSpeed) { // if (sprinting){
/**
* Legitimate move: increase horizontal buffer somehow.
* @param hDistance
* @param hDistanceAboveLimit
* @param amount Positive amount.
* @param data
*/
private void hBufRegain(final double hDistance, final double hDistanceAboveLimit, final MovingData data){
private void hBufRegain(final double hDistance, final double amount, final MovingData data){
/*
* TODO: Consider different concepts:
* - full resetting with harder conditions.
* - maximum regain amount.
* - reset or regain only every x blocks h distance.
*/
// TODO: Confine general conditions for buffer regain further (regain in air, whatever)?
data.sfHorizontalBuffer = Math.min(hBufMax, data.sfHorizontalBuffer - hDistanceAboveLimit);
data.sfHorizontalBuffer = Math.min(hBufMax, data.sfHorizontalBuffer + amount);
}

/**
Expand Down

0 comments on commit 048cada

Please sign in to comment.