Bugfixes / Unit test fix

This commit is contained in:
Anuken 2019-04-23 11:59:07 -04:00
parent 30650efd98
commit 79b0e76be0
13 changed files with 54 additions and 35 deletions

Binary file not shown.

View File

@ -147,7 +147,7 @@ public class Zones implements ContentList{
}};
}};
tarFields = new Zone("tarFields", new MapGenerator("tarFields", 1)
tarFields = new Zone("tarFields", new MapGenerator("tarFields")
.dist(0f, false)
.decor(new Decoration(Blocks.shale, Blocks.shaleBoulder, 0.02))){{
loadout = Loadouts.basicFoundation;

View File

@ -126,6 +126,13 @@ public class Renderer implements ApplicationListener{
}
}
@Override
public void dispose(){
minimap.dispose();
shieldBuffer.dispose();
blocks.dispose();
}
void updateShake(float scale){
if(shaketime > 0){
float intensity = shakeIntensity * (settings.getInt("screenshake", 4) / 4f) * scale;

View File

@ -77,7 +77,7 @@ public class GlobalData{
/**
* Makes this piece of content 'unlocked', if possible.
* If this piece of content is already unlocked or cannot be unlocked due to dependencies, nothing changes.
* If this piece of content is already unlocked, nothing changes.
* Results are not saved until you call {@link #save()}.
*/
public void unlockContent(UnlockableContent content){

View File

@ -9,6 +9,7 @@ import io.anuke.arc.graphics.Texture.TextureFilter;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Fill;
import io.anuke.arc.graphics.glutils.FrameBuffer;
import io.anuke.arc.util.Disposable;
import io.anuke.arc.util.Tmp;
import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.game.EventType.TileChangeEvent;
@ -20,7 +21,7 @@ import io.anuke.mindustry.world.Tile;
import static io.anuke.arc.Core.camera;
import static io.anuke.mindustry.Vars.*;
public class BlockRenderer{
public class BlockRenderer implements Disposable{
private final static int initialRequests = 32 * 32;
private final static int expandr = 9;
private final static Color shadowColor = new Color(0, 0, 0, 0.71f);
@ -294,6 +295,14 @@ public class BlockRenderer{
requestidx++;
}
@Override
public void dispose(){
shadows.dispose();
fog.dispose();
shadows = fog = null;
floor.dispose();
}
private class BlockRequest implements Comparable<BlockRequest>{
Tile tile;
Layer layer;

View File

@ -18,7 +18,7 @@ import java.util.Arrays;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.world;
public class FloorRenderer{
public class FloorRenderer implements Disposable{
private final static int chunksize = 64;
private Chunk[][] cache;
@ -221,6 +221,14 @@ public class FloorRenderer{
Log.info("Time to cache: {0}", Time.elapsed());
}
@Override
public void dispose(){
if(cbatch != null){
cbatch.dispose();
cbatch = null;
}
}
private class Chunk{
int[] caches = new int[CacheLayer.values().length];
}

View File

@ -152,7 +152,7 @@ public class MapGenerator extends Generator{
if(enemySpawns != -1){
if(enemySpawns > enemies.size){
throw new IllegalArgumentException("Enemy spawn pool greater than map spawn number.");
throw new IllegalArgumentException("Enemy spawn pool greater than map spawn number for map: " + mapName);
}
enemies.shuffle();

View File

@ -1,6 +1,5 @@
package io.anuke.mindustry.ui;
import io.anuke.arc.function.Supplier;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.scene.ui.Image;
import io.anuke.arc.scene.ui.layout.Stack;
@ -18,14 +17,6 @@ public class ItemImage extends Stack{
add(t);
}
public ItemImage(TextureRegion region, Supplier<CharSequence> text){
Table t = new Table().left().bottom();
t.label(text).name("item-label");
add(new Image(region));
add(t);
}
public ItemImage(ItemStack stack){
add(new Image(stack.item.icon(Icon.large)));

View File

@ -10,7 +10,6 @@ import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Align;
import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
@ -18,14 +17,9 @@ import static io.anuke.mindustry.Vars.*;
public class BlockConfigFragment extends Fragment{
private Table table = new Table();
private InputHandler input;
private Tile configTile;
private Block configBlock;
public BlockConfigFragment(InputHandler input){
this.input = input;
}
@Override
public void build(Group parent){
table.visible(false);

View File

@ -5,22 +5,25 @@ import io.anuke.annotations.Annotations.Remote;
import io.anuke.arc.Core;
import io.anuke.arc.collection.IntSet;
import io.anuke.arc.function.BooleanProvider;
import io.anuke.arc.function.Supplier;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.input.KeyCode;
import io.anuke.arc.math.Interpolation;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.math.geom.Vector2;
import io.anuke.arc.scene.Element;
import io.anuke.arc.scene.Group;
import io.anuke.arc.scene.actions.Actions;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.ui.Image;
import io.anuke.arc.scene.ui.layout.Stack;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.*;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Item.Icon;
import io.anuke.mindustry.ui.ItemImage;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.*;
@ -30,15 +33,10 @@ public class BlockInventoryFragment extends Fragment{
private Table table;
private Tile tile;
private InputHandler input;
private float holdTime = 0f;
private boolean holding;
private Item lastItem;
public BlockInventoryFragment(InputHandler input){
this.input = input;
}
@Remote(called = Loc.server, targets = Loc.both, forward = true)
public static void requestItem(Player player, Tile tile, Item item, int amount){
if(player == null || tile == null) return;
@ -133,7 +131,7 @@ public class BlockInventoryFragment extends Fragment{
HandCursorListener l = new HandCursorListener();
l.setEnabled(canPick);
ItemImage image = new ItemImage(item.icon(Icon.xlarge), () -> {
Element image = itemImage(item.icon(Icon.xlarge), () -> {
if(tile == null || tile.entity == null){
return "";
}
@ -182,9 +180,9 @@ public class BlockInventoryFragment extends Fragment{
private String round(float f){
f = (int)f;
if(f >= 1000000){
return Strings.fixed(f / 1000000f, 1) + "[gray]mil[]";
return (int)(f / 1000000f) + "[gray]mil[]";
}else if(f >= 1000){
return Strings.fixed(f / 1000, 1) + "k";
return (int)(f / 1000) + "k";
}else{
return (int)f + "";
}
@ -195,4 +193,15 @@ public class BlockInventoryFragment extends Fragment{
table.pack();
table.setPosition(v.x, v.y, Align.topLeft);
}
private Element itemImage(TextureRegion region, Supplier<CharSequence> text){
Stack stack = new Stack();
Table t = new Table().left().bottom();
t.label(text);
stack.add(new Image(region));
stack.add(t);
return stack;
}
}

View File

@ -34,7 +34,6 @@ public class ChatFragment extends Table{
private BitmapFont font;
private GlyphLayout layout = new GlyphLayout();
private float offsetx = Unit.dp.scl(4), offsety = Unit.dp.scl(4), fontoffsetx = Unit.dp.scl(2), chatspace = Unit.dp.scl(50);
private float textWidth = Unit.dp.scl(600);
private Color shadowColor = new Color(0, 0, 0, 0.4f);
private float textspacing = Unit.dp.scl(10);
private Array<String> history = new Array<>();
@ -124,6 +123,7 @@ public class ChatFragment extends Table{
@Override
public void draw(){
float opacity = Core.settings.getInt("chatopacity") / 100f;
float textWidth = Math.min(Core.graphics.getWidth()/1.5f, Unit.dp.scl(700f));
Draw.color(shadowColor);

View File

@ -3,7 +3,7 @@ package io.anuke.mindustry.ui.fragments;
import io.anuke.arc.scene.Group;
import io.anuke.mindustry.input.InputHandler;
/** Fragment for displaying overlays such as block inventories. One is created for each input handler. */
/** Fragment for displaying overlays such as block inventories. */
public class OverlayFragment extends Fragment{
public final BlockInventoryFragment inv;
public final BlockConfigFragment config;
@ -11,8 +11,8 @@ public class OverlayFragment extends Fragment{
private Group group = new Group();
public OverlayFragment(InputHandler input){
inv = new BlockInventoryFragment(input);
config = new BlockConfigFragment(input);
inv = new BlockInventoryFragment();
config = new BlockConfigFragment();
}
@Override

View File

@ -284,7 +284,8 @@ public class Block extends BlockStorage{
/** Call when some content is produced. This unlocks the content if it is applicable. */
public void useContent(Tile tile, UnlockableContent content){
if(!headless && tile.getTeam() == player.getTeam()){
//only unlocks content in zones
if(!headless && tile.getTeam() == player.getTeam() && world.isZone()){
logic.handleContent(content);
}
}