From ca04504573fbb705307cf8e8ebed8430869d0163 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 5 Dec 2018 15:38:32 -0500 Subject: [PATCH] Renamed internal 'noWaves' mode / Fixed text encoding issues --- core/assets/bundles/bundle.properties | 16 +++++++------ .../src/io/anuke/mindustry/game/GameMode.java | 2 +- .../maps/missions/BattleMission.java | 2 +- .../mindustry/maps/missions/Mission.java | 4 +--- .../mindustry/maps/missions/WaveMission.java | 2 +- core/src/io/anuke/mindustry/net/Host.java | 6 ++++- .../src/io/anuke/mindustry/net/NetworkIO.java | 23 +++++++++++-------- .../world/blocks/power/PowerNode.java | 1 - .../mindustry/desktop/DesktopPlatform.java | 2 +- 9 files changed, 32 insertions(+), 26 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index bff7ab1003..ab0e7e3510 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -409,14 +409,16 @@ keybind.chat_scroll.name = Chat scroll keybind.drop_unit.name = drop unit keybind.zoom_minimap.name = Zoom minimap mode.text.help.title = Description of modes -mode.waves.name = waves -mode.waves.description = the normal mode. limited resources and automatic incoming waves. -mode.sandbox.name = sandbox -mode.sandbox.description = infinite resources and no timer for waves. -mode.freebuild.name = freebuild -mode.freebuild.description = limited resources and no timer for waves. +mode.waves.name = Waves +mode.waves.description = The normal mode. Limited resources and automatic incoming waves. +mode.sandbox.name = Sandbox +mode.sandbox.description = Infinite resources and no timer for waves. +mode.freebuild.name = Freebuild +mode.freebuild.description = Limited resources and no timer for waves. mode.pvp.name = PvP -mode.pvp.description = fight against other players locally. +mode.pvp.description = Fight against other players locally. +mode.attack.name = Attack +mode.attack.descrption = No waves, with the goal to destroy the enemy base. content.item.name = Items content.liquid.name = Liquids content.unit.name = Units diff --git a/core/src/io/anuke/mindustry/game/GameMode.java b/core/src/io/anuke/mindustry/game/GameMode.java index 6d14023da8..0e7de8475f 100644 --- a/core/src/io/anuke/mindustry/game/GameMode.java +++ b/core/src/io/anuke/mindustry/game/GameMode.java @@ -11,7 +11,7 @@ public enum GameMode{ freebuild{{ disableWaveTimer = true; }}, - noWaves{{ + attack{{ disableWaves = true; hidden = true; enemyCheat = true; diff --git a/core/src/io/anuke/mindustry/maps/missions/BattleMission.java b/core/src/io/anuke/mindustry/maps/missions/BattleMission.java index bd2e8e26a9..e1f5bc5614 100644 --- a/core/src/io/anuke/mindustry/maps/missions/BattleMission.java +++ b/core/src/io/anuke/mindustry/maps/missions/BattleMission.java @@ -38,7 +38,7 @@ public class BattleMission extends MissionWithStartingCore{ @Override public GameMode getMode(){ - return GameMode.noWaves; + return GameMode.attack; } @Override diff --git a/core/src/io/anuke/mindustry/maps/missions/Mission.java b/core/src/io/anuke/mindustry/maps/missions/Mission.java index 25c9c5574e..eba443be21 100644 --- a/core/src/io/anuke/mindustry/maps/missions/Mission.java +++ b/core/src/io/anuke/mindustry/maps/missions/Mission.java @@ -2,10 +2,8 @@ package io.anuke.mindustry.maps.missions; import com.badlogic.gdx.math.GridPoint2; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.content.blocks.StorageBlocks; import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.game.SpawnGroup; -import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.UnlockableContent; import io.anuke.mindustry.maps.Sector; import io.anuke.mindustry.maps.generation.Generation; @@ -34,7 +32,7 @@ public abstract class Mission{ } public GameMode getMode(){ - return GameMode.noWaves; + return GameMode.attack; } /**Sets the message displayed on mission begin. Returns this mission for chaining.*/ diff --git a/core/src/io/anuke/mindustry/maps/missions/WaveMission.java b/core/src/io/anuke/mindustry/maps/missions/WaveMission.java index be7d83bf46..e31120af00 100644 --- a/core/src/io/anuke/mindustry/maps/missions/WaveMission.java +++ b/core/src/io/anuke/mindustry/maps/missions/WaveMission.java @@ -74,7 +74,7 @@ public class WaveMission extends MissionWithStartingCore{ @Override public void update(){ if(state.wave > target){ - state.mode = GameMode.noWaves; + state.mode = GameMode.attack; } } diff --git a/core/src/io/anuke/mindustry/net/Host.java b/core/src/io/anuke/mindustry/net/Host.java index 77a281d8ec..261c60fc7e 100644 --- a/core/src/io/anuke/mindustry/net/Host.java +++ b/core/src/io/anuke/mindustry/net/Host.java @@ -1,5 +1,7 @@ package io.anuke.mindustry.net; +import io.anuke.mindustry.game.GameMode; + public class Host{ public final String name; public final String address; @@ -8,8 +10,9 @@ public class Host{ public final int players; public final int version; public final String versionType; + public final GameMode mode; - public Host(String name, String address, String mapname, int wave, int players, int version, String versionType){ + public Host(String name, String address, String mapname, int wave, int players, int version, String versionType, GameMode mode){ this.name = name; this.address = address; this.players = players; @@ -17,5 +20,6 @@ public class Host{ this.wave = wave; this.version = version; this.versionType = versionType; + this.mode = mode; } } diff --git a/core/src/io/anuke/mindustry/net/NetworkIO.java b/core/src/io/anuke/mindustry/net/NetworkIO.java index d1173ec19d..f8a9a5ddbe 100644 --- a/core/src/io/anuke/mindustry/net/NetworkIO.java +++ b/core/src/io/anuke/mindustry/net/NetworkIO.java @@ -21,6 +21,7 @@ import io.anuke.ucore.util.Bits; import java.io.*; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import static io.anuke.mindustry.Vars.*; @@ -305,17 +306,18 @@ public class NetworkIO{ ByteBuffer buffer = ByteBuffer.allocate(128); - buffer.put((byte) host.getBytes().length); - buffer.put(host.getBytes()); + buffer.put((byte) host.getBytes(StandardCharsets.UTF_8).length); + buffer.put(host.getBytes(StandardCharsets.UTF_8)); - buffer.put((byte) map.getBytes().length); - buffer.put(map.getBytes()); + buffer.put((byte) map.getBytes(StandardCharsets.UTF_8).length); + buffer.put(map.getBytes(StandardCharsets.UTF_8)); buffer.putInt(playerGroup.size()); buffer.putInt(state.wave); buffer.putInt(Version.build); - buffer.put((byte)Version.type.getBytes().length); - buffer.put(Version.type.getBytes()); + buffer.put((byte)Version.type.getBytes(StandardCharsets.UTF_8).length); + buffer.put(Version.type.getBytes(StandardCharsets.UTF_8)); + buffer.put((byte)state.mode.ordinal()); return buffer; } @@ -328,8 +330,8 @@ public class NetworkIO{ byte[] mb = new byte[mlength]; buffer.get(mb); - String host = new String(hb); - String map = new String(mb); + String host = new String(hb, StandardCharsets.UTF_8); + String map = new String(mb, StandardCharsets.UTF_8); int players = buffer.getInt(); int wave = buffer.getInt(); @@ -337,8 +339,9 @@ public class NetworkIO{ byte tlength = buffer.get(); byte[] tb = new byte[tlength]; buffer.get(tb); - String vertype = new String(tb); + String vertype = new String(tb, StandardCharsets.UTF_8); + GameMode mode = GameMode.values()[buffer.get()]; - return new Host(host, hostAddress, map, wave, players, version, vertype); + return new Host(host, hostAddress, map, wave, players, version, vertype, mode); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java index 9a2e80e55c..20504efd70 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java @@ -252,7 +252,6 @@ public class PowerNode extends PowerBlock{ Draw.color(Palette.powerLight, Palette.power, Mathf.absin(Timers.time(), 8f, 1f)); Lines.stroke(2f); Lines.line(x1, y1, x2, y2); - } } diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java index d4cd5ad4e7..0604d62e53 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java @@ -60,7 +60,7 @@ public class DesktopPlatform extends Platform{ presence.largeImageText = "Wave " + state.wave; } - if(state.mode != GameMode.noWaves){ + if(state.mode != GameMode.attack){ presence.state = Strings.capitalize(state.mode.name()); }else{ presence.state = unitGroups[players[0].getTeam().ordinal()].size() == 1 ? "1 Unit Active" :