public float advanceUpgrade(float progress) {
    if (upgradeIndex == -1) upgradeIndex = nextUpgradeIndex() ;
    if (upgradeIndex == -1) return 0 ;
    //
    //  Update progress, and store the change for return later-
    final int US = upgradeStates[upgradeIndex] ;
    final float oldP = upgradeProgress ;
    upgradeProgress = Visit.clamp(upgradeProgress + progress, 0, 1) ;
    float amount = upgradeProgress - oldP ;
    if (US == STATE_SALVAGE) amount *= -0.5f ;
    //
    //  If progress is complete, change the current upgrade's state:
    if (upgradeProgress >= 1) {
      final float condition = integrity * 1f / maxIntegrity() ;
      if (US == STATE_SALVAGE) deleteUpgrade(upgradeIndex) ;
      else upgradeStates[upgradeIndex] = STATE_INTACT ;
      upgradeProgress = 0 ;
      upgradeIndex = -1 ;
      integrity = maxIntegrity() * condition ;
    }
    return amount ;
  }