From 8b8172421e3ccd630c6d1ca2d3b6450535dec0bc Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 8 Oct 2017 11:50:31 -0400 Subject: [PATCH] Fixed error when saving with empty conduits --- .../mindustry/world/blocks/types/Conduit.java | 5 +++-- .../mindustry/world/blocks/types/Pump.java | 4 +++- desktop/mindustry-saves/2.mins | Bin 362 -> 1594 bytes 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Conduit.java b/core/src/io/anuke/mindustry/world/blocks/types/Conduit.java index f2d4a2c9c7..bc535a1ea7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Conduit.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Conduit.java @@ -106,13 +106,14 @@ public class Conduit extends Block{ @Override public void write(DataOutputStream stream) throws IOException{ - stream.writeByte(liquid.ordinal()); + stream.writeByte(liquid == null ? -1 : liquid.ordinal()); stream.writeByte((byte)(liquidAmount)); } @Override public void read(DataInputStream stream) throws IOException{ - liquid = Liquid.values()[stream.readByte()]; + byte ordinal = stream.readByte(); + liquid = ordinal == -1 ? null : Liquid.values()[ordinal]; liquidAmount = stream.readByte(); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Pump.java b/core/src/io/anuke/mindustry/world/blocks/types/Pump.java index 705da5655f..59135904c4 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Pump.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Pump.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.types; import io.anuke.mindustry.resource.Liquid; import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Timers; @@ -32,7 +33,8 @@ public class Pump extends Conduit{ public void update(Tile tile){ ConduitEntity entity = tile.entity(); - if(Timers.get(tile, "pump", 8) && entity.liquidAmount < liquidCapacity){ + if(tile.floor() == Blocks.water && + Timers.get(tile, "pump", 8) && entity.liquidAmount < liquidCapacity){ entity.liquid = Liquid.water; entity.liquidAmount += pumpspeed; } diff --git a/desktop/mindustry-saves/2.mins b/desktop/mindustry-saves/2.mins index d52c495f97acf62a5872e4704553b0be0fbdfc3d..55b363adbff773199a7627977e404c8828f45d45 100644 GIT binary patch literal 1594 zcmZXUNo!M47=}+BTC6s=Y3`8Qq~117nl!d)q_K9eqKz#gb!Y_@K~X5;^aEVF(4|`y zaiI%!qX;e>DmYO~wK#zy4jV;8SK?mK?>)Rnnwu;R&w0M-+>_iWrRtQb+5hLp*;Ptl zG=9J?|2p4R{+&4@`zcksSgky@Z>cON7h$Q9<-`(@lI67I;PY-?mNQDNcCm{pRX7K* zluG%4Mx{D0(pUi@VW6Nva-x?Q>ee78bs0vWs6iU`8#B;`kj%=bm=kRWNKS8>kiNo@ z*FjS>(0>(1%463U@^b{YlMut5pkeGfA>Rd%s-^;sXTZHllk6b`#zc!WiCdD;iCZsnK>?atW!48+~j9}Y>Mc+A;&d3X?9K8Na zDdm?z(zLk@&4>Rh7@L9k-_zcNZADL8XH+PsI?K^nz8bpl3~jq-WWmkVJq2L$XlU{p z9g!4!w&DoRSk)06ol*T*r7<=y%@X{%(3I31BVC&f7}Kx?Mh=j8&d^$8;`5<43A~#6 zmoOfR1mi4j*C6d0U(onlk(dd zYY%f`9{`rT{d;MO9|?n>2!+oC>kB|;kWla) zA(@^rkkud~`VJu^Im>?l#AFTR4>Qzbpx1=z@fVM(`k#ajV@evNPvj^=1IGYjdX8)J E55Jj)djJ3c literal 362 zcmZQzU|?flV2ssKbbX(S`lt1ea`0J}{5T#sB_amrR>|U>;DVkEcsXVj^6n ziA&D8aG1)s(_Aul7=w6>49;HL?ztprya4j#7=dQKh;@lP58*Mn__oQp1i$wJ$pLM* zI~wGYGYjYssO{HX3WaWgc|hBbUUSI^2nF$gW(NB6yF_|_0qFyo`LfR?;!G8o$K>KC zZQ~MYb{oV4nrV9WkxS_ZS&%-kk1o3u#;1UJOfCTe1uj`%LAHa;^ozOX5)gpB