From 0b7decbfdd4122858dcf5a0f4cd4c4e349fe5b51 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 18 Jul 2018 10:40:31 -0400 Subject: [PATCH] Removed static block layer / Minor bugfixes --- .../src/io/anuke/mindustry/core/Renderer.java | 2 +- core/src/io/anuke/mindustry/core/UI.java | 2 +- .../mindustry/graphics/BlockRenderer.java | 30 ++++++--------- .../anuke/mindustry/graphics/CacheLayer.java | 3 +- .../mindustry/graphics/FloorRenderer.java | 20 +++------- .../anuke/mindustry/net/Administration.java | 37 +++---------------- .../mindustry/world/blocks/StaticBlock.java | 13 ------- 7 files changed, 25 insertions(+), 82 deletions(-) delete mode 100644 core/src/io/anuke/mindustry/world/blocks/StaticBlock.java diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 1447b1b5f7..c52fd12b91 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -155,7 +155,7 @@ public class Renderer extends RendererModule{ setCamera(position.x + 0.0001f, position.y + 0.0001f); } - clampCamera(-tilesize / 2f, -tilesize / 2f + 1, world.width() * tilesize - tilesize / 2f, world.height() * tilesize - tilesize / 2f); + //clampCamera(-tilesize / 2f, -tilesize / 2f + 1, world.width() * tilesize - tilesize / 2f, world.height() * tilesize - tilesize / 2f); float prex = camera.position.x, prey = camera.position.y; updateShake(0.75f); diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 259340491a..fc6d38fd0e 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -228,7 +228,7 @@ public class UI extends SceneModule{ } public void loadLogic(String text, Runnable call){ - loadfrag.show(); + loadfrag.show(text); Timers.runTask(7f, () -> { threads.run(() -> { call.run(); diff --git a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java index 0f6317a7e0..ffa10fdf7b 100644 --- a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java @@ -6,7 +6,6 @@ import io.anuke.mindustry.content.blocks.Blocks; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.blocks.StaticBlock; import io.anuke.ucore.core.Graphics; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.util.Mathf; @@ -68,23 +67,22 @@ public class BlockRenderer{ tile.block().drawShadow(tile); } - if(!(block instanceof StaticBlock)){ - if(block != Blocks.air){ - if(!expanded){ - addRequest(tile, Layer.block); + if(block != Blocks.air){ + if(!expanded){ + addRequest(tile, Layer.block); + } + + if(block.expanded || !expanded){ + if(block.layer != null && block.isLayer(tile)){ + addRequest(tile, block.layer); } - if(block.expanded || !expanded){ - if(block.layer != null && block.isLayer(tile)){ - addRequest(tile, block.layer); - } - - if(block.layer2 != null && block.isLayer2(tile)){ - addRequest(tile, block.layer2); - } + if(block.layer2 != null && block.isLayer2(tile)){ + addRequest(tile, block.layer2); } } } + } } } @@ -95,12 +93,6 @@ public class BlockRenderer{ Graphics.flushSurface(); Draw.color(); - Graphics.end(); - floorRenderer.beginDraw(); - floorRenderer.drawLayer(CacheLayer.walls); - floorRenderer.endDraw(); - Graphics.begin(); - Sort.instance().sort(requests.items, 0, requestidx); iterateidx = 0; } diff --git a/core/src/io/anuke/mindustry/graphics/CacheLayer.java b/core/src/io/anuke/mindustry/graphics/CacheLayer.java index aecf703ae2..c7790c10ef 100644 --- a/core/src/io/anuke/mindustry/graphics/CacheLayer.java +++ b/core/src/io/anuke/mindustry/graphics/CacheLayer.java @@ -53,8 +53,7 @@ public enum CacheLayer{ endShader(Shaders.space); } }, - normal, - walls; + normal; public void begin(){ diff --git a/core/src/io/anuke/mindustry/graphics/FloorRenderer.java b/core/src/io/anuke/mindustry/graphics/FloorRenderer.java index 5ccefa23be..647ec56d9f 100644 --- a/core/src/io/anuke/mindustry/graphics/FloorRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/FloorRenderer.java @@ -10,7 +10,6 @@ import com.badlogic.gdx.utils.IntSet; import com.badlogic.gdx.utils.IntSet.IntSetIterator; import com.badlogic.gdx.utils.ObjectSet; import io.anuke.mindustry.game.EventType.WorldLoadGraphicsEvent; -import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Events; @@ -94,7 +93,7 @@ public class FloorRenderer{ drawnLayers.clear(); drawnLayerSet.clear(); - //preliminary layer check: + //preliminary layer check for(int x = -crangex; x <= crangex; x++){ for(int y = -crangey; y <= crangey; y++){ int worldx = Mathf.scl(camera.position.x, chunksize * tilesize) + x; @@ -106,7 +105,7 @@ public class FloorRenderer{ Chunk chunk = cache[worldx][worldy]; //loop through all layers, and add layer index if it exists - for(int i = 0; i < layers - 1; i++){ + for(int i = 0; i < layers; i++){ if(chunk.caches[i] != -1){ drawnLayerSet.add(i); } @@ -191,7 +190,6 @@ public class FloorRenderer{ private void cacheChunk(int cx, int cy){ Chunk chunk = cache[cx][cy]; - //long time = TimeUtils.nanoTime(); ObjectSet used = new ObjectSet<>(); @@ -199,8 +197,7 @@ public class FloorRenderer{ for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){ Tile tile = world.tile(tilex, tiley); if(tile != null){ - used.add(tile.block().cacheLayer == CacheLayer.walls ? - CacheLayer.walls : tile.floor().cacheLayer); + used.add(tile.floor().cacheLayer); } } } @@ -208,8 +205,6 @@ public class FloorRenderer{ for(CacheLayer layer : used){ cacheChunkLayer(cx, cy, chunk, layer); } - - // Log.info("Time to cache a chunk: {0}", TimeUtils.timeSinceNanos(time) / 1000000f); } private void cacheChunkLayer(int cx, int cy, Chunk chunk, CacheLayer layer){ @@ -222,16 +217,11 @@ public class FloorRenderer{ Tile tile = world.tile(tilex, tiley); if(tile == null) continue; - if(tile.floor().cacheLayer == layer && tile.block().cacheLayer != CacheLayer.walls){ + if(tile.floor().cacheLayer == layer){ tile.floor().draw(tile); - }else if(tile.floor().cacheLayer.ordinal() < layer.ordinal() && tile.block().cacheLayer != CacheLayer.walls && layer != CacheLayer.walls){ + }else if(tile.floor().cacheLayer.ordinal() < layer.ordinal()){ tile.floor().drawNonLayer(tile); } - - if(tile.block().cacheLayer == layer && layer == CacheLayer.walls){ - Block block = tile.block(); - block.draw(tile); - } } } diff --git a/core/src/io/anuke/mindustry/net/Administration.java b/core/src/io/anuke/mindustry/net/Administration.java index bb838d4afd..fbaf7b3bfa 100644 --- a/core/src/io/anuke/mindustry/net/Administration.java +++ b/core/src/io/anuke/mindustry/net/Administration.java @@ -4,41 +4,28 @@ import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.IntMap; import com.badlogic.gdx.utils.ObjectMap; import com.badlogic.gdx.utils.TimeUtils; -import io.anuke.mindustry.entities.Player; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.blocks.BlockPart; -import io.anuke.mindustry.world.blocks.Floor; -import io.anuke.mindustry.world.blocks.Rock; -import io.anuke.mindustry.world.blocks.StaticBlock; import io.anuke.ucore.core.Settings; import static io.anuke.mindustry.Vars.headless; -import static io.anuke.mindustry.Vars.world; public class Administration{ public static final int defaultMaxBrokenBlocks = 15; public static final int defaultBreakCooldown = 1000 * 15; - /** - * All player info. Maps UUIDs to info. This persists throughout restarts. - */ + /**All player info. Maps UUIDs to info. This persists throughout restarts.*/ private ObjectMap playerInfo = new ObjectMap<>(); - /** - * Maps UUIDs to trace infos. This is wiped when a player logs off. - */ + /**Maps UUIDs to trace infos. This is wiped when a player logs off.*/ private ObjectMap traceInfo = new ObjectMap<>(); - /** - * Maps packed coordinates to logs for that coordinate - */ + /** Maps packed coordinates to logs for that coordinate*/ private IntMap> editLogs = new IntMap<>(); private Array bannedIPs = new Array<>(); public Administration(){ Settings.defaultList( - "antigrief", false, - "antigrief-max", defaultMaxBrokenBlocks, - "antigrief-cooldown", defaultBreakCooldown + "antigrief", false, + "antigrief-max", defaultMaxBrokenBlocks, + "antigrief-cooldown", defaultBreakCooldown ); load(); @@ -76,18 +63,6 @@ public class Administration{ return editLogs; } - public void logEdit(int x, int y, Player player, Block block, int rotation, EditLog.EditAction action){ - if(block instanceof BlockPart || block instanceof Rock || block instanceof Floor || block instanceof StaticBlock) - return; - if(editLogs.containsKey(x + y * world.width())){ - editLogs.get(x + y * world.width()).add(new EditLog(player.name, block, rotation, action)); - }else{ - Array logs = new Array<>(); - logs.add(new EditLog(player.name, block, rotation, action)); - editLogs.put(x + y * world.width(), logs); - } - } - /* public void rollbackWorld(int rollbackTimes) { for(IntMap.Entry> editLog : editLogs.entries()) { diff --git a/core/src/io/anuke/mindustry/world/blocks/StaticBlock.java b/core/src/io/anuke/mindustry/world/blocks/StaticBlock.java deleted file mode 100644 index c39015cff9..0000000000 --- a/core/src/io/anuke/mindustry/world/blocks/StaticBlock.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.anuke.mindustry.world.blocks; - -import io.anuke.mindustry.graphics.CacheLayer; -import io.anuke.mindustry.world.Block; - -public class StaticBlock extends Block{ - - public StaticBlock(String name){ - super(name); - cacheLayer = CacheLayer.walls; - } - -}