Misc bug/crash fixes

This commit is contained in:
Anuken
2018-12-02 12:03:18 -05:00
parent 735935c0c4
commit 3397d6c907
7 changed files with 18 additions and 16 deletions

View File

@@ -21,7 +21,7 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
public class WaveSpawner{
private static final int quadsize = 4;
private static final int quadsize = 6;
private GridBits quadrants;
@@ -164,7 +164,7 @@ public class WaveSpawner{
for(int y = quady * quadsize; y < world.height() && y < (quady + 1) * quadsize; y++){
Tile tile = world.tile(x, y);
if(tile == null || tile.solid() || world.pathfinder.getValueforTeam(Team.red, x, y) == Float.MAX_VALUE){
if(tile == null || tile.solid() || world.pathfinder.getValueforTeam(Team.red, x, y) == Float.MAX_VALUE || tile.floor().isLiquid){
setQuad(quadx, quady, false);
break outer;
}
@@ -217,8 +217,8 @@ public class WaveSpawner{
//TODO instead of randomly scattering locations around the map, find spawns close to each other
private void findLocation(GroundSpawn spawn){
spawn.x = -1;
spawn.y = -1;
spawn.x = Mathf.random(quadWidth()-1);
spawn.y = Mathf.random(quadHeight()-1);
int shellWidth = quadWidth() * 2 + quadHeight() * 2 * 6;
shellWidth = Math.min(quadWidth() * quadHeight() / 4, shellWidth);

View File

@@ -567,16 +567,16 @@ public class MapEditorDialog extends Dialog implements Disposable{
button.getImage().remove();
button.update(() -> button.setChecked(editor.getDrawBlock() == block));
group.add(button);
content.add(button).size(60f);
content.add(button).size(50f);
if(i++ % 3 == 2){
if(++i % 4 == 0){
content.row();
}
}
group.getButtons().get(2).setChecked(true);
table.table("underline", extra -> extra.labelWrap(() -> editor.getDrawBlock().formalName).width(220f).center()).growX();
table.table("underline", extra -> extra.labelWrap(() -> editor.getDrawBlock().formalName).width(200f).center()).growX();
table.row();
table.add(pane).growY().fillX();
}

View File

@@ -95,7 +95,7 @@ public abstract class InputHandler extends InputAdapter{
ItemTransfer.create(item,
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns),
new Translator(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
if(tile.block() != block || tile.entity == null) return;
if(tile.block() != block || tile.entity == null || tile.entity.items == null) return;
tile.block().handleStack(item, removed, tile, player);
remaining[1] -= removed;

View File

@@ -53,6 +53,10 @@ public class TypeIO{
@WriteClass(Unit.class)
public static void writeUnit(ByteBuffer buffer, Unit unit){
if(unit.getGroup() == null){
buffer.put((byte)-1);
return;
}
buffer.put((byte) unit.getGroup().getID());
buffer.putInt(unit.getID());
}
@@ -60,6 +64,7 @@ public class TypeIO{
@ReadClass(Unit.class)
public static Unit readUnit(ByteBuffer buffer){
byte gid = buffer.get();
if(gid == -1) return null;
int id = buffer.getInt();
return (Unit) Entities.getGroup(gid).getByID(id);
}

View File

@@ -38,10 +38,6 @@ public class FileChooser extends FloatingDialog{
private Consumer<FileHandle> selectListener;
private boolean open;
public FileChooser(String title, boolean open, Consumer<FileHandle> result){
this(title, defaultFilter, open, result);
}
public FileChooser(String title, Predicate<FileHandle> filter, boolean open, Consumer<FileHandle> result){
super(title);
this.open = open;
@@ -127,7 +123,7 @@ public class FileChooser extends FloatingDialog{
updateFiles(true);
});
icontable.defaults().height(50).growX().uniform();
icontable.defaults().height(50).growX().padTop(5).uniform();
icontable.add(home);
icontable.add(back);
icontable.add(forward);
@@ -202,7 +198,7 @@ public class FileChooser extends FloatingDialog{
//macs are confined to the Downloads/ directory
if(!OS.isMac){
Image upimage = new Image("icon-folder-parent");
TextButton upbutton = new TextButton(".." + directory.toString());
TextButton upbutton = new TextButton(".." + directory.toString(), "clear");
upbutton.clicked(() -> {
directory = directory.parent();
updateFiles(true);
@@ -224,7 +220,7 @@ public class FileChooser extends FloatingDialog{
String filename = file.name();
TextButton button = new TextButton(shorten(filename), "toggle");
TextButton button = new TextButton(shorten(filename), "clear");
group.add(button);
button.clicked(() -> {

View File

@@ -4,6 +4,7 @@ import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
@@ -12,7 +13,6 @@ import io.anuke.mindustry.world.meta.BlockGroup;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Mathf;
import io.anuke.mindustry.gen.Call;
import java.io.DataInput;
import java.io.DataOutput;