Fixed transfer exploit

This commit is contained in:
Anuken
2018-04-14 20:38:33 -04:00
parent cc26e61d7a
commit 89f06506c1
2 changed files with 20 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Sat Apr 14 13:47:10 EDT 2018 #Sat Apr 14 20:37:32 EDT 2018
version=release version=release
androidBuildCode=918 androidBuildCode=920
name=Mindustry name=Mindustry
code=3.5 code=3.5
build=custom build build=custom build

View File

@@ -30,7 +30,7 @@ public abstract class InputHandler extends InputAdapter{
public PlaceMode breakMode = android ? PlaceMode.none : PlaceMode.holdDelete; public PlaceMode breakMode = android ? PlaceMode.none : PlaceMode.holdDelete;
public PlaceMode lastPlaceMode = placeMode; public PlaceMode lastPlaceMode = placeMode;
public PlaceMode lastBreakMode = breakMode; public PlaceMode lastBreakMode = breakMode;
public boolean droppingItem; public boolean droppingItem, transferring;
public boolean shooting; public boolean shooting;
public float playerSelectRange = Unit.dp.scl(60f); public float playerSelectRange = Unit.dp.scl(60f);
@@ -66,18 +66,33 @@ public abstract class InputHandler extends InputAdapter{
public void dropItem(Tile tile, ItemStack stack){ public void dropItem(Tile tile, ItemStack stack){
if(tile.block().acceptStack(stack, tile, player)){ if(tile.block().acceptStack(stack, tile, player)){
if(transferring) return;
transferring = true;
int accepted = tile.block().handleStack(stack, tile, player); int accepted = tile.block().handleStack(stack, tile, player);
stack.amount -= accepted; boolean clear = stack.amount == accepted;
if(stack.amount == 0) player.inventory.clear();
float backTrns = 3f; float backTrns = 3f;
int sent = Mathf.clamp(accepted/4, 1, 8); int sent = Mathf.clamp(accepted/4, 1, 8);
int removed = accepted/sent;
int[] remaining = {accepted};
for(int i = 0; i < sent; i ++){ for(int i = 0; i < sent; i ++){
boolean end = i == sent-1;
Timers.run(i * 3, () -> { Timers.run(i * 3, () -> {
new ItemAnimationEffect(stack.item, new ItemAnimationEffect(stack.item,
player.x + Angles.trnsx(rotation + 180f, backTrns), player.y + Angles.trnsy(rotation + 180f, backTrns), player.x + Angles.trnsx(rotation + 180f, backTrns), player.y + Angles.trnsy(rotation + 180f, backTrns),
tile.drawx(), tile.drawy()).add(); tile.drawx(), tile.drawy()).add();
stack.amount -= removed;
remaining[0] -= removed;
if(end){
stack.amount -= remaining[0];
if(clear) player.inventory.clear();
transferring = false;
}
}); });
} }
}else{ }else{