mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-12 03:37:27 +07:00
Fixed deconstruction exploit
This commit is contained in:
parent
0dc2d4445b
commit
2a8b8d040b
@ -220,14 +220,17 @@ public class BuildBlock extends Block{
|
||||
setDeconstruct(previous);
|
||||
}
|
||||
|
||||
//make sure you take into account that you can't deconstruct more than there is deconstructed
|
||||
float clampedAmount = Math.min(amount, progress);
|
||||
|
||||
for(int i = 0; i < requirements.length; i++){
|
||||
int reqamount = Math.round(state.rules.buildCostMultiplier * requirements[i].amount);
|
||||
accumulator[i] += Math.min(amount * deconstructMultiplier * reqamount, deconstructMultiplier * reqamount - totalAccumulator[i]); //add scaled amount progressed to the accumulator
|
||||
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * amount * deconstructMultiplier, reqamount);
|
||||
accumulator[i] += Math.min(clampedAmount * deconstructMultiplier * reqamount, deconstructMultiplier * reqamount - totalAccumulator[i]); //add scaled amount progressed to the accumulator
|
||||
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * clampedAmount * deconstructMultiplier, reqamount);
|
||||
|
||||
int accumulated = (int)(accumulator[i]); //get amount
|
||||
|
||||
if(amount > 0 && accumulated > 0){ //if it's positive, add it to the core
|
||||
if(clampedAmount > 0 && accumulated > 0){ //if it's positive, add it to the core
|
||||
if(core != null){
|
||||
int accepting = core.tile.block().acceptStack(requirements[i].item, accumulated, core.tile, builder);
|
||||
core.tile.block().handleStack(requirements[i].item, accepting, core.tile, builder);
|
||||
|
Loading…
Reference in New Issue
Block a user