From f3b976bdd1d100c7d0d83752d34d3d9a0f39cf16 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 31 Jul 2018 12:57:34 -0400 Subject: [PATCH] All web version bugs fixed --- android/build.gradle | 1 - build.gradle | 2 -- core/assets/bundles/bundle.properties | 10 +++++----- core/src/Mindustry.gwt.xml | 2 ++ core/src/io/anuke/mindustry/Vars.java | 2 -- core/src/io/anuke/mindustry/core/Platform.java | 4 ---- core/src/io/anuke/mindustry/game/Saves.java | 2 +- core/src/io/anuke/mindustry/graphics/FogRenderer.java | 6 +++--- core/src/io/anuke/mindustry/io/SaveIO.java | 8 +++----- core/src/io/anuke/mindustry/net/Net.java | 8 ++++++++ .../io/anuke/mindustry/ui/dialogs/PausedDialog.java | 2 +- .../io/anuke/mindustry/ui/fragments/HudFragment.java | 4 +++- .../io/anuke/mindustry/ui/fragments/MenuFragment.java | 4 ++-- html/build.gradle | 1 + html/src/io/anuke/mindustry/GdxDefinition.gwt.xml | 2 -- html/src/io/anuke/mindustry/client/HtmlLauncher.java | 6 ------ 16 files changed, 29 insertions(+), 35 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index a2d912a486..ef46301699 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -24,7 +24,6 @@ dependencies { natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64" - implementation "com.badlogicgames.gdx:gdx-ai:$aiVersion" implementation "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion" } diff --git a/build.gradle b/build.gradle index 2e50770736..cc3e3674b4 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,6 @@ allprojects { appName = 'Mindustry' gdxVersion = '1.9.8' roboVMVersion = '2.3.0' - aiVersion = '1.8.1' uCoreVersion = '239e6a5bad' getVersionString = { @@ -112,7 +111,6 @@ project(":html") { compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion" compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources" compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources" - compile "com.badlogicgames.gdx:gdx-ai:$aiVersion:sources" compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion:sources" compile "com.badlogicgames.gdx:gdx-controllers-gwt:$gdxVersion" diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 6d5ea2167c..09a30667fe 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -11,8 +11,6 @@ text.link.wiki.description=official Mindustry wiki text.linkfail=Failed to open link!\nThe URL has been copied to your cliboard. text.editor.web=The web version does not support the editor!\nDownload the game to use it. text.web.unsupported=The web version does not support this feature! Download the game to use it. -text.multiplayer.web=The web version of the game does not support multiplayer!\nUse the downloadable PC, Android or iOS versions. -text.host.web=The web version does not support hosting games! Download the game to use this feature. text.gameover=Your core has been destroyed text.sector.gameover=This sector has been lost. Re-deploy? text.sector.retry=Retry @@ -87,7 +85,7 @@ text.server.kicked.nameInUse=There is someone with that name\nalready on this se text.server.kicked.nameEmpty=Your name must contain at least one character or number. text.server.kicked.idInUse=You are already on this server! Connecting with two accounts is not permitted. text.server.kicked.customClient=This server does not support custom builds. Download an official version. -text.host.info=The [accent]host[] button hosts a server on ports [scarlet]6567[] and [scarlet]6568.[]\nAnybody on the same [LIGHT_GRAY]wifi or local network[] should be able to see your server in their server list.\n\nIf you want people to be able to connect from anywhere by IP, [accent]port forwarding[] is required.\n\n[LIGHT_GRAY]Note: If someone is experiencing trouble connecting to your LAN game, make sure you have allowed Mindustry access to your local network in your firewall settings. +text.host.info=The [accent]host[] button hosts a server on port [scarlet]6567[]. \nAnybody on the same [LIGHT_GRAY]wifi or local network[] should be able to see your server in their server list.\n\nIf you want people to be able to connect from anywhere by IP, [accent]port forwarding[] is required.\n\n[LIGHT_GRAY]Note: If someone is experiencing trouble connecting to your LAN game, make sure you have allowed Mindustry access to your local network in your firewall settings. text.join.info=Here, you can enter a [accent]server IP[] to connect to, or discover [accent]local network[] servers to connect to.\nBoth LAN and WAN multiplayer is supported.\n\n[LIGHT_GRAY]Note: There is no automatic global server list; if you want to connect to someone by IP, you would need to ask the host for their IP. text.hostserver=Host Server text.host=Host @@ -531,8 +529,10 @@ unit.drone.description=The starter drone unit. Spawns in the core by default. Au unit.fabricator.name=Fabricator unit.fabricator.description=An advanced drone unit. Automatically mines ores, collects items and repairs blocks. Significantly more effective than a drone. unit.scout.name=Scout -unit.scout.description=A basic ground unit. Uses tungsten as ammo. +unit.scout.description=A basic ground unit. Uses lead as ammo. unit.titan.name=Titan unit.titan.description=An advanced armored ground unit. Uses carbide as ammo. Attacks both ground and air targets. unit.monsoon.name=Monsoon -unit.monsoon.description=A heavy carpet bomber. Uses blast compound or pyratite as ammo. \ No newline at end of file +unit.monsoon.description=A heavy carpet bomber. Uses blast compound or pyratite as ammo. +unit.interceptor.name=Interceptor +unit.interceptor.description=A fast, hit-and-run strike unit. Uses lead as ammo. \ No newline at end of file diff --git a/core/src/Mindustry.gwt.xml b/core/src/Mindustry.gwt.xml index 5e6f994b46..7b014a3888 100644 --- a/core/src/Mindustry.gwt.xml +++ b/core/src/Mindustry.gwt.xml @@ -19,4 +19,6 @@ + + \ No newline at end of file diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 1d58b8b5ed..b1759ce794 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -138,8 +138,6 @@ public class Vars{ String code = stra[i]; if(code.contains("_")){ locales[i] = new Locale(code.split("_")[0], code.split("_")[1]); - }else if(code.contains("-")){ - locales[i] = new Locale(code.split("-")[0], code.split("-")[1]); }else{ locales[i] = new Locale(code); } diff --git a/core/src/io/anuke/mindustry/core/Platform.java b/core/src/io/anuke/mindustry/core/Platform.java index 95fe6316f8..94a1bf9008 100644 --- a/core/src/io/anuke/mindustry/core/Platform.java +++ b/core/src/io/anuke/mindustry/core/Platform.java @@ -43,10 +43,6 @@ public abstract class Platform { public String getLocaleName(Locale locale){ return locale.toString(); } - /**Whether joining games is supported.*/ - public boolean canJoinGame(){ - return true; - } /**Whether debug mode is enabled.*/ public boolean isDebug(){return false;} /**Must be a base64 string 8 bytes in length.*/ diff --git a/core/src/io/anuke/mindustry/game/Saves.java b/core/src/io/anuke/mindustry/game/Saves.java index 75802e0913..fd5da35bc0 100644 --- a/core/src/io/anuke/mindustry/game/Saves.java +++ b/core/src/io/anuke/mindustry/game/Saves.java @@ -214,7 +214,7 @@ public class Saves{ } public boolean isAutosave(){ - return Settings.getBool("save-" + index + "-autosave", !gwt); + return Settings.getBool("save-" + index + "-autosave", true); } public void setAutosave(boolean save){ diff --git a/core/src/io/anuke/mindustry/graphics/FogRenderer.java b/core/src/io/anuke/mindustry/graphics/FogRenderer.java index ee8391b41e..42e819b63f 100644 --- a/core/src/io/anuke/mindustry/graphics/FogRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/FogRenderer.java @@ -62,7 +62,7 @@ public class FogRenderer implements Disposable{ } } - pixelBuffer = ByteBuffer.allocateDirect(world.width() * world.height() * 3); + pixelBuffer = ByteBuffer.allocateDirect(world.width() * world.height() * 4); dirty = true; }); @@ -79,7 +79,7 @@ public class FogRenderer implements Disposable{ buffer.begin(); pixelBuffer.position(0); Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1); - Gdx.gl.glReadPixels(padding, padding, world.width(), world.height(), GL20.GL_RGB, GL20.GL_UNSIGNED_BYTE, pixelBuffer); + Gdx.gl.glReadPixels(padding, padding, world.width(), world.height(), GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixelBuffer); pixelBuffer.position(0); for(int i = 0; i < world.width() * world.height(); i++){ @@ -87,7 +87,7 @@ public class FogRenderer implements Disposable{ if(r != 0){ world.tile(i).setVisibility((byte)1); } - pixelBuffer.position(pixelBuffer.position() + 2); + pixelBuffer.position(pixelBuffer.position() + 3); } buffer.end(); } diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index 98ed4b251c..69a5645382 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -49,9 +49,7 @@ public class SaveIO{ public static void loadFromSlot(int slot){ if(gwt){ - String string = Settings.getString("save-" + slot + "-data", ""); - ByteArrayInputStream stream = new ByteArrayInputStream(Base64Coder.decode(string)); - load(stream); + load(getSlotStream(slot)); }else{ load(fileFor(slot)); } @@ -113,14 +111,14 @@ public class SaveIO{ } public static void write(FileHandle file){ - write(file.write(false)); + write(new DeflaterOutputStream(file.write(false))); } public static void write(OutputStream os){ DataOutputStream stream; try{ - stream = new DataOutputStream(new DeflaterOutputStream(os)); + stream = new DataOutputStream(os); getVersion().write(stream); stream.close(); }catch(Exception e){ diff --git a/core/src/io/anuke/mindustry/net/Net.java b/core/src/io/anuke/mindustry/net/Net.java index bd15fc6614..3a38764218 100644 --- a/core/src/io/anuke/mindustry/net/Net.java +++ b/core/src/io/anuke/mindustry/net/Net.java @@ -38,6 +38,14 @@ public class Net{ private static IntMap streams = new IntMap<>(); + public static boolean hasClient(){ + return clientProvider != null; + } + + public static boolean hasServer(){ + return serverProvider != null; + } + /** * Display a network error. */ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java index ae1b598569..ab0212f5d2 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java @@ -56,7 +56,7 @@ public class PausedDialog extends FloatingDialog{ if(!gwt){ ui.host.show(); }else{ - ui.showInfo("$text.host.web"); + ui.showInfo("$text.web.unsupported"); } }).disabled(b -> Net.active()); diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 85b3c3d25b..0245cfe2cb 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -109,7 +109,9 @@ public class HudFragment extends Fragment{ t.label(() -> fps.get(Gdx.graphics.getFramesPerSecond())).padRight(10); t.label(() -> tps.get(threads.getTPS())).visible(() -> threads.isEnabled()); t.row(); - t.label(() -> ping.get(Net.getPing())).visible(() -> Net.client() && !gwt).colspan(2); + if(Net.hasClient()){ + t.label(() -> ping.get(Net.getPing())).visible(() -> Net.client() && !gwt).colspan(2); + } }).size(-1).visible(() -> Settings.getBool("fps")).get(); //make wave box appear below rest of menu diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index b08d2adbb8..74ca174ba9 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -153,11 +153,11 @@ public class MenuFragment extends Fragment{ dialog.content().row(); dialog.content().add(new MenuButton("icon-add", "$text.joingame", () -> { - if(Platform.instance.canJoinGame()){ + if(!gwt){ ui.join.show(); dialog.hide(); }else{ - ui.showInfo("$text.multiplayer.web"); + ui.showInfo("$text.web.unsupported"); } })); diff --git a/html/build.gradle b/html/build.gradle index bfc2ceac5c..ae3ae651a6 100644 --- a/html/build.gradle +++ b/html/build.gradle @@ -13,6 +13,7 @@ gwt { compiler { strict = true disableCastChecking = true + //style = Style.DETAILED } } diff --git a/html/src/io/anuke/mindustry/GdxDefinition.gwt.xml b/html/src/io/anuke/mindustry/GdxDefinition.gwt.xml index e1a5cefdca..15601ef897 100644 --- a/html/src/io/anuke/mindustry/GdxDefinition.gwt.xml +++ b/html/src/io/anuke/mindustry/GdxDefinition.gwt.xml @@ -1,11 +1,9 @@ - - diff --git a/html/src/io/anuke/mindustry/client/HtmlLauncher.java b/html/src/io/anuke/mindustry/client/HtmlLauncher.java index 96c3f7be08..5215771eda 100644 --- a/html/src/io/anuke/mindustry/client/HtmlLauncher.java +++ b/html/src/io/anuke/mindustry/client/HtmlLauncher.java @@ -115,12 +115,6 @@ public class HtmlLauncher extends GwtApplication { return NumberFormat.getDecimalFormat().format(number); } - @Override - public boolean canJoinGame(){ - String ref = Document.get().getReferrer(); - return !ref.startsWith("https") && !ref.contains("itch.io"); - } - @Override public void downloadFile(String name, byte[] bytes) { downloadBytes(name, new String(Base64Coder.encode(bytes)));