From 3728d137cd94b952ad5065c94cb6fbe14f046384 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 11 Feb 2022 13:48:27 -0500 Subject: [PATCH] Fixed tests --- core/src/mindustry/content/Blocks.java | 17 +++++++--- core/src/mindustry/graphics/FogRenderer.java | 11 +++++-- core/src/mindustry/io/SaveFileReader.java | 4 ++- .../io/versions/LegacyRegionSaveVersion.java | 31 +++++++++++++++++++ .../io/versions/LegacySaveVersion.java | 3 +- .../io/versions/LegacySaveVersion2.java | 3 +- core/src/mindustry/io/versions/Save6.java | 24 +------------- .../world/blocks/defense/turrets/Turret.java | 3 +- 8 files changed, 60 insertions(+), 36 deletions(-) create mode 100644 core/src/mindustry/io/versions/LegacyRegionSaveVersion.java diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index a97b04df2e..9bc5336edc 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -3318,18 +3318,23 @@ public class Blocks{ disperse = new ItemTurret("disperse"){{ requirements(Category.turret, with(Items.carbide, 250, Items.surgeAlloy, 160, Items.silicon, 300, Items.beryllium, 400)); - ammo(Items.graphite, new BasicBulletType(){{ + ammo(Items.scrap, new BasicBulletType(){{ damage = 40; - speed = 7f; - width = 9f; - height = 15f; + speed = 8f; + width = 11f; + height = 16f; trailColor = Pal.bulletYellowBack; + velocityInaccuracy = 0.11f; + collidesGround = false; + collidesTiles = false; + shootEffect = Fx.shootBig2; + smokeEffect = Fx.shootBigSmoke2; }}); //TODO bullet. //recoilAmount = 1f; - reloadTime = 5f; + reloadTime = 8f; shootLength = 15f; rotateSpeed = 5f; @@ -3343,7 +3348,9 @@ public class Blocks{ shots = 4; alternate = true; widthSpread = true; + targetGround = false; spread = 4.6f; + inaccuracy = 8f; restitution = 0.1f; shootWarmupSpeed = 0.08f; diff --git a/core/src/mindustry/graphics/FogRenderer.java b/core/src/mindustry/graphics/FogRenderer.java index 582fb99b8a..475016e231 100644 --- a/core/src/mindustry/graphics/FogRenderer.java +++ b/core/src/mindustry/graphics/FogRenderer.java @@ -60,11 +60,18 @@ public class FogRenderer implements CustomChunk{ public void drawFog(){ //resize if world size changes - buffer.resize(world.width(), world.height()); + boolean clear = buffer.resizeCheck(world.width(), world.height()); //set projection to whole map Draw.proj(0, 0, buffer.getWidth() * tilesize, buffer.getHeight() * tilesize); - buffer.begin(); + + //if the buffer resized, it contains garbage now, clear it. + if(clear){ + buffer.begin(Color.black); + }else{ + buffer.begin(); + } + Gl.blendEquationSeparate(Gl.max, Gl.max); ScissorStack.push(rect.set(1, 1, buffer.getWidth() - 2, buffer.getHeight() - 2)); diff --git a/core/src/mindustry/io/SaveFileReader.java b/core/src/mindustry/io/SaveFileReader.java index 1cde38be1b..d16f1f32be 100644 --- a/core/src/mindustry/io/SaveFileReader.java +++ b/core/src/mindustry/io/SaveFileReader.java @@ -203,6 +203,8 @@ public abstract class SaveFileReader{ public interface CustomChunk{ void write(DataOutput stream) throws IOException; void read(DataInput stream) throws IOException; - boolean shouldWrite(); + default boolean shouldWrite(){ + return true; + } } } diff --git a/core/src/mindustry/io/versions/LegacyRegionSaveVersion.java b/core/src/mindustry/io/versions/LegacyRegionSaveVersion.java new file mode 100644 index 0000000000..73b39f5347 --- /dev/null +++ b/core/src/mindustry/io/versions/LegacyRegionSaveVersion.java @@ -0,0 +1,31 @@ +package mindustry.io.versions; + +import arc.util.io.*; +import mindustry.io.*; +import mindustry.world.*; + +import java.io.*; + +import static mindustry.Vars.*; + +/** This version does not read custom chunk data (<= 6). */ +public class LegacyRegionSaveVersion extends SaveVersion{ + + public LegacyRegionSaveVersion(int version){ + super(version); + } + + @Override + public void read(DataInputStream stream, CounterInputStream counter, WorldContext context) throws IOException{ + region("meta", stream, counter, this::readMeta); + region("content", stream, counter, this::readContentHeader); + + try{ + region("map", stream, counter, in -> readMap(in, context)); + region("entities", stream, counter, this::readEntities); + }finally{ + content.setTemporaryMapper(null); + + } + } +} diff --git a/core/src/mindustry/io/versions/LegacySaveVersion.java b/core/src/mindustry/io/versions/LegacySaveVersion.java index 6ac135f6e2..0e1f876824 100644 --- a/core/src/mindustry/io/versions/LegacySaveVersion.java +++ b/core/src/mindustry/io/versions/LegacySaveVersion.java @@ -4,14 +4,13 @@ import arc.util.*; import arc.util.io.*; import mindustry.content.*; import mindustry.game.*; -import mindustry.io.*; import mindustry.world.*; import java.io.*; import static mindustry.Vars.*; -public abstract class LegacySaveVersion extends SaveVersion{ +public abstract class LegacySaveVersion extends LegacyRegionSaveVersion{ public LegacySaveVersion(int version){ super(version); diff --git a/core/src/mindustry/io/versions/LegacySaveVersion2.java b/core/src/mindustry/io/versions/LegacySaveVersion2.java index e5658d4096..02a986cb85 100644 --- a/core/src/mindustry/io/versions/LegacySaveVersion2.java +++ b/core/src/mindustry/io/versions/LegacySaveVersion2.java @@ -3,12 +3,11 @@ package mindustry.io.versions; import arc.func.*; import arc.util.io.*; import mindustry.gen.*; -import mindustry.io.*; import java.io.*; /** This version did not read/write entity IDs to the save. */ -public class LegacySaveVersion2 extends SaveVersion{ +public class LegacySaveVersion2 extends LegacyRegionSaveVersion{ public LegacySaveVersion2(int version){ super(version); diff --git a/core/src/mindustry/io/versions/Save6.java b/core/src/mindustry/io/versions/Save6.java index 8e9af9fd23..3e8ab423a5 100644 --- a/core/src/mindustry/io/versions/Save6.java +++ b/core/src/mindustry/io/versions/Save6.java @@ -1,31 +1,9 @@ package mindustry.io.versions; -import arc.util.io.*; -import mindustry.io.*; -import mindustry.world.*; - -import java.io.*; - -import static mindustry.Vars.*; - /** This version does not read custom chunk data. */ -public class Save6 extends SaveVersion{ +public class Save6 extends LegacyRegionSaveVersion{ public Save6(){ super(6); } - - @Override - public void read(DataInputStream stream, CounterInputStream counter, WorldContext context) throws IOException{ - region("meta", stream, counter, this::readMeta); - region("content", stream, counter, this::readContentHeader); - - try{ - region("map", stream, counter, in -> readMap(in, context)); - region("entities", stream, counter, this::readEntities); - }finally{ - content.setTemporaryMapper(null); - - } - } } diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index e814efee5d..ac91d6c78a 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -553,6 +553,7 @@ public class Turret extends ReloadTurret{ bulletOffset.trns(rotation - 90, (spread) * i + Mathf.range(xRand), shootLength); bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy)); shotCounter ++; + effects(); } }else{ bulletOffset.trns(rotation, shootLength, Mathf.range(xRand)); @@ -561,11 +562,11 @@ public class Turret extends ReloadTurret{ bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i - (int)(shots / 2f)) * spread); shotCounter ++; } + effects(); } recoil = recoilAmount; heat = 1f; - effects(); useAmmo(); } }