Fixed #2591 / Fixed #2591 / Fixed #2589 / Fixed #2587

This commit is contained in:
Anuken
2020-09-18 11:21:50 -04:00
parent c71be9ae32
commit 6b6783f201
21 changed files with 4512 additions and 4335 deletions

View File

@@ -58,6 +58,7 @@ public class FormationAI extends AIController implements FormationMember{
public void removed(Unit unit){
if(formation != null){
formation.removeMember(this);
unit.resetController();
}
}

View File

@@ -35,6 +35,7 @@ public class PhysicsProcess implements AsyncProcess{
refs.removeAll(ref -> {
if(!ref.entity.isAdded()){
physics.destroyBody(ref.body);
ref.entity.physref(null);
return true;
}
return false;

View File

@@ -231,8 +231,14 @@ public class MapEditor{
int px = offsetX + x, py = offsetY + y;
if(previous.in(px, py)){
tiles.set(x, y, previous.getn(px, py));
tiles.getn(x, y).x = (short)x;
tiles.getn(x, y).y = (short)y;
Tile tile = tiles.getn(x, y);
tile.x = (short)x;
tile.y = (short)y;
if(tile.build != null && tile.isCenter()){
tile.build.x = x * tilesize + tile.block().offset;
tile.build.y = y * tilesize + tile.block().offset;
}
}else{
tiles.set(x, y, new EditorTile(x, y, Blocks.stone.id, (short)0, (short)0));
}

View File

@@ -48,6 +48,9 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
unit.remove();
payloads.add(new UnitPayload(unit));
Fx.unitPickup.at(unit);
if(Vars.net.client()){
Vars.netClient.clearRemovedEntity(unit.id);
}
}
void pickup(Building tile){

View File

@@ -225,7 +225,7 @@ public class DesktopInput extends InputHandler{
if(!player.dead() && !state.isPaused() && !(Core.scene.getKeyboardFocus() instanceof TextField)){
updateMovement(player.unit());
if(Core.input.keyDown(Binding.respawn) && !player.unit().spawnedByCore()){
if(Core.input.keyDown(Binding.respawn) && !player.unit().spawnedByCore() && !scene.hasField()){
Call.unitClear(player);
controlledType = null;
}

View File

@@ -3,6 +3,7 @@ package mindustry.io;
import arc.*;
import arc.files.*;
import arc.struct.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.*;
import mindustry.game.EventType.*;
@@ -41,7 +42,7 @@ public class SaveIO{
if(exists) file.moveTo(backupFileFor(file));
try{
write(file);
}catch(Exception e){
}catch(Throwable e){
if(exists) backupFileFor(file).moveTo(file);
throw new RuntimeException(e);
}
@@ -56,9 +57,9 @@ public class SaveIO{
}
public static boolean isSaveValid(Fi file){
try{
return isSaveValid(new DataInputStream(new InflaterInputStream(file.read(bufferSize))));
}catch(Exception e){
try(DataInputStream stream = new DataInputStream(new InflaterInputStream(file.read(bufferSize)))){
return isSaveValid(stream);
}catch(Throwable e){
return false;
}
}
@@ -67,8 +68,8 @@ public class SaveIO{
try{
getMeta(stream);
return true;
}catch(Exception e){
e.printStackTrace();
}catch(Throwable e){
Log.err(e);
return false;
}
}
@@ -76,8 +77,8 @@ public class SaveIO{
public static SaveMeta getMeta(Fi file){
try{
return getMeta(getStream(file));
}catch(Exception e){
e.printStackTrace();
}catch(Throwable e){
Log.err(e);
return getMeta(getBackupStream(file));
}
}
@@ -120,7 +121,7 @@ public class SaveIO{
}else{
getVersion().write(stream, tags);
}
}catch(Exception e){
}catch(Throwable e){
throw new RuntimeException(e);
}
}
@@ -134,7 +135,7 @@ public class SaveIO{
//try and load; if any exception at all occurs
load(new InflaterInputStream(file.read(bufferSize)), context);
}catch(SaveException e){
e.printStackTrace();
Log.err(e);
Fi backup = file.sibling(file.name() + "-backup." + file.extension());
if(backup.exists()){
load(new InflaterInputStream(backup.read(bufferSize)), context);
@@ -154,7 +155,7 @@ public class SaveIO{
ver.read(stream, counter, context);
Events.fire(new SaveLoadEvent());
}catch(Exception e){
}catch(Throwable e){
throw new SaveException(e);
}finally{
world.setGenerating(false);

View File

@@ -377,8 +377,18 @@ public class ResearchDialog extends BaseDialog{
}
boolean canSpend(TechNode node){
//can spend when there's at least 1 item that can be spent
return selectable(node) && (node.requirements.length == 0 || Structs.contains(node.requirements, i -> items.has(i.item)));
if(!selectable(node)) return false;
if(node.requirements.length == 0) return true;
//can spend when there's at least 1 item that can be spent (non complete)
for(int i = 0; i < node.requirements.length; i++){
if(node.finishedRequirements[i].amount < node.requirements[i].amount && items.has(node.requirements[i].item)){
return true;
}
}
return false;
}
void spend(TechNode node){