diff --git a/android/src/io/anuke/mindustry/AndroidLauncher.java b/android/src/io/anuke/mindustry/AndroidLauncher.java index ebd5f40d5f..660caabb4e 100644 --- a/android/src/io/anuke/mindustry/AndroidLauncher.java +++ b/android/src/io/anuke/mindustry/AndroidLauncher.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.telephony.TelephonyManager; import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; +import com.esotericsoftware.minlog.Log; import io.anuke.kryonet.KryoClient; import io.anuke.kryonet.KryoServer; import io.anuke.mindustry.io.PlatformFunction; @@ -64,6 +65,8 @@ public class AndroidLauncher extends AndroidApplication{ config.hideStatusBar = true; + Log.set(Log.LEVEL_DEBUG); + Net.setClientProvider(new KryoClient()); Net.setServerProvider(new KryoServer()); diff --git a/build.gradle b/build.gradle index e737d3b7cf..52d19a7b29 100644 --- a/build.gradle +++ b/build.gradle @@ -114,7 +114,7 @@ project(":kryonet") { dependencies { compile project(":core") - compile "com.esotericsoftware:kryonet:2.22.0-RC1" + compile 'com.github.crykn:kryonet:2.22.1' } } diff --git a/core/assets-raw/sprites/ui/icons/icon-host.png b/core/assets-raw/sprites/ui/icons/icon-host.png new file mode 100644 index 0000000000..82d5d2d153 Binary files /dev/null and b/core/assets-raw/sprites/ui/icons/icon-host.png differ diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 291bf3401e..229b0e804c 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -13,8 +13,9 @@ text.loadgame=Load Game text.joingame=Join Game text.quit=Quit text.server.connected=A player has joined. -text.server.disconnected=A player has disconnected. +text.server.disconnected={0} has disconnected. text.hostserver=Host Server +text.host=Host text.joingame.title=Join Game text.joingame.ip=IP: text.disconnect=Disconnected. diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index f1f4d17a0e..8d8c150fcc 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -27,49 +27,49 @@ blocks/blackrock1 index: -1 blocks/blackrockshadow1 rotate: false - xy: 315, 91 + xy: 482, 95 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstone1 rotate: false - xy: 315, 81 + xy: 988, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstone2 rotate: false - xy: 325, 91 + xy: 998, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstone3 rotate: false - xy: 325, 81 + xy: 1008, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock1 rotate: false - xy: 335, 91 + xy: 841, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock2 rotate: false - xy: 335, 81 + xy: 841, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock3 rotate: false - xy: 345, 91 + xy: 851, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -83,7 +83,7 @@ blocks/blackstoneedge index: -1 blocks/block rotate: false - xy: 355, 91 + xy: 861, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -111,119 +111,119 @@ blocks/chainturret index: -1 blocks/chainturret-icon rotate: false - xy: 123, 79 + xy: 109, 35 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/coal1 rotate: false - xy: 193, 63 + xy: 871, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal2 rotate: false - xy: 203, 63 + xy: 871, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal3 rotate: false - xy: 213, 63 + xy: 881, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coaldrill rotate: false - xy: 223, 63 + xy: 881, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalgenerator rotate: false - xy: 233, 63 + xy: 891, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalgenerator-top rotate: false - xy: 243, 63 + xy: 891, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalpurifier rotate: false - xy: 253, 63 + xy: 901, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/combustiongenerator rotate: false - xy: 263, 63 + xy: 901, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/compositewall rotate: false - xy: 273, 63 + xy: 911, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduit rotate: false - xy: 283, 63 + xy: 911, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitbottom rotate: false - xy: 293, 63 + xy: 921, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitliquid rotate: false - xy: 303, 67 + xy: 921, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduittop rotate: false - xy: 531, 136 + xy: 931, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyor rotate: false - xy: 527, 126 + xy: 931, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyormove rotate: false - xy: 365, 95 + xy: 941, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyortunnel rotate: false - xy: 365, 85 + xy: 941, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -237,42 +237,42 @@ blocks/core index: -1 blocks/cross rotate: false - xy: 375, 95 + xy: 951, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/crucible rotate: false - xy: 375, 85 + xy: 951, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/deepwater rotate: false - xy: 385, 95 + xy: 961, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt1 rotate: false - xy: 385, 85 + xy: 961, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt2 rotate: false - xy: 395, 95 + xy: 971, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt3 rotate: false - xy: 395, 85 + xy: 971, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -286,7 +286,7 @@ blocks/dirtedge index: -1 blocks/door rotate: false - xy: 405, 95 + xy: 851, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -300,7 +300,7 @@ blocks/door-large index: -1 blocks/door-large-icon rotate: false - xy: 405, 85 + xy: 861, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -314,21 +314,21 @@ blocks/door-large-open index: -1 blocks/door-open rotate: false - xy: 415, 95 + xy: 871, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/doubleturret rotate: false - xy: 123, 67 + xy: 95, 7 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/duriumwall rotate: false - xy: 415, 85 + xy: 881, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -342,266 +342,266 @@ blocks/duriumwall-large index: -1 blocks/duriumwall-large-icon rotate: false - xy: 425, 95 + xy: 891, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/enemyspawn rotate: false - xy: 425, 85 + xy: 901, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/flameturret rotate: false - xy: 135, 79 + xy: 536, 181 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/fluxpump rotate: false - xy: 435, 85 + xy: 921, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass1 rotate: false - xy: 445, 95 + xy: 931, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass2 rotate: false - xy: 445, 85 + xy: 941, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass3 rotate: false - xy: 455, 95 + xy: 951, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock1 rotate: false - xy: 455, 85 + xy: 961, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock2 rotate: false - xy: 465, 95 + xy: 971, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassedge rotate: false - xy: 136, 91 + xy: 152, 91 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/ice1 rotate: false - xy: 465, 85 + xy: 981, 473 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ice2 rotate: false - xy: 475, 95 + xy: 981, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ice3 rotate: false - xy: 475, 85 + xy: 981, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iceedge rotate: false - xy: 150, 91 + xy: 166, 91 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/icerock1 rotate: false - xy: 524, 107 + xy: 991, 475 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/icerock2 rotate: false - xy: 786, 393 + xy: 991, 465 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/icerockshadow1 rotate: false - xy: 796, 393 + xy: 1001, 475 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow1 rotate: false - xy: 796, 393 + xy: 1001, 475 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/icerockshadow2 rotate: false - xy: 844, 485 + xy: 991, 455 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow2 rotate: false - xy: 844, 485 + xy: 991, 455 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron1 rotate: false - xy: 924, 485 + xy: 512, 82 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron2 rotate: false - xy: 934, 485 + xy: 522, 82 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron3 rotate: false - xy: 944, 485 + xy: 801, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/irondrill rotate: false - xy: 954, 485 + xy: 811, 445 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ironwall rotate: false - xy: 964, 485 + xy: 821, 445 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/junction rotate: false - xy: 974, 485 + xy: 831, 445 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/laserturret rotate: false - xy: 243, 85 + xy: 844, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/lava rotate: false - xy: 984, 485 + xy: 841, 444 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/lavaedge rotate: false - xy: 164, 91 + xy: 95, 75 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/lavasmelter rotate: false - xy: 994, 485 + xy: 851, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquiditemjunction rotate: false - xy: 1004, 485 + xy: 861, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidjunction rotate: false - xy: 1014, 485 + xy: 871, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidrouter rotate: false - xy: 841, 475 + xy: 881, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/machineturret rotate: false - xy: 243, 73 + xy: 856, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/megarepairturret rotate: false - xy: 255, 85 + xy: 868, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mortarturret rotate: false - xy: 255, 73 + xy: 880, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mossblock rotate: false - xy: 851, 475 + xy: 901, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/mossstone rotate: false - xy: 851, 475 + xy: 901, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -622,7 +622,7 @@ blocks/nuclearreactor-center index: -1 blocks/nuclearreactor-icon rotate: false - xy: 851, 465 + xy: 921, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -643,196 +643,196 @@ blocks/nuclearreactor-small index: -1 blocks/oil rotate: false - xy: 861, 475 + xy: 931, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/oiledge rotate: false - xy: 95, 61 + xy: 109, 75 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/oilrefinery rotate: false - xy: 851, 455 + xy: 941, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/omnidrill rotate: false - xy: 861, 465 + xy: 951, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/plasmaturret rotate: false - xy: 267, 85 + xy: 892, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/playerspawn rotate: false - xy: 871, 475 + xy: 961, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerbooster rotate: false - xy: 861, 455 + xy: 971, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyor rotate: false - xy: 871, 465 + xy: 981, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyormove rotate: false - xy: 881, 475 + xy: 991, 445 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaser rotate: false - xy: 871, 455 + xy: 1001, 445 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlasercorner rotate: false - xy: 881, 465 + xy: 1011, 445 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaserrouter rotate: false - xy: 891, 475 + xy: 109, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduit rotate: false - xy: 881, 455 + xy: 736, 381 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduitbottom rotate: false - xy: 891, 465 + xy: 740, 371 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduittop rotate: false - xy: 901, 475 + xy: 740, 361 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pump rotate: false - xy: 891, 455 + xy: 740, 351 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/repairturret rotate: false - xy: 267, 73 + xy: 904, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/rock1 rotate: false - xy: 911, 475 + xy: 740, 331 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2 rotate: false - xy: 901, 455 + xy: 740, 321 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/router rotate: false - xy: 911, 465 + xy: 798, 393 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rtgenerator rotate: false - xy: 921, 475 + xy: 180, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rtgenerator-top rotate: false - xy: 911, 455 + xy: 190, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sand1 rotate: false - xy: 921, 465 + xy: 200, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sand2 rotate: false - xy: 931, 475 + xy: 210, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sand3 rotate: false - xy: 921, 455 + xy: 220, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sandblock1 rotate: false - xy: 931, 465 + xy: 230, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sandblock2 rotate: false - xy: 941, 475 + xy: 240, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sandblock3 rotate: false - xy: 931, 455 + xy: 250, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -846,126 +846,126 @@ blocks/sandedge index: -1 blocks/shadow rotate: false - xy: 279, 85 + xy: 916, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/shieldgenerator rotate: false - xy: 951, 475 + xy: 270, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shotgunturret rotate: false - xy: 279, 73 + xy: 928, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/shrub rotate: false - xy: 961, 475 + xy: 527, 126 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shrubshadow rotate: false - xy: 951, 455 + xy: 527, 116 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/smelter rotate: false - xy: 961, 465 + xy: 524, 106 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sniperturret rotate: false - xy: 291, 85 + xy: 940, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/snow1 rotate: false - xy: 971, 475 + xy: 362, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snow2 rotate: false - xy: 961, 455 + xy: 372, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snow3 rotate: false - xy: 971, 465 + xy: 382, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowblock1 rotate: false - xy: 981, 475 + xy: 392, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowblock2 rotate: false - xy: 971, 455 + xy: 402, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowblock3 rotate: false - xy: 981, 465 + xy: 412, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowedge rotate: false - xy: 95, 19 + xy: 95, 33 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/sorter rotate: false - xy: 991, 475 + xy: 422, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyor rotate: false - xy: 981, 455 + xy: 432, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyormove rotate: false - xy: 991, 465 + xy: 442, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelwall rotate: false - xy: 1001, 475 + xy: 452, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -979,98 +979,98 @@ blocks/steelwall-large index: -1 blocks/steelwall-large-icon rotate: false - xy: 991, 455 + xy: 462, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone1 rotate: false - xy: 1001, 465 + xy: 472, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone2 rotate: false - xy: 1011, 475 + xy: 482, 76 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone3 rotate: false - xy: 1001, 455 + xy: 492, 72 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock1 rotate: false - xy: 1011, 465 + xy: 502, 72 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock2 rotate: false - xy: 1011, 455 + xy: 512, 72 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock3 rotate: false - xy: 533, 178 + xy: 522, 72 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonedrill rotate: false - xy: 537, 168 + xy: 107, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneedge rotate: false - xy: 109, 77 + xy: 109, 47 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/stoneformer rotate: false - xy: 537, 158 + xy: 746, 381 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonewall rotate: false - xy: 537, 148 + xy: 750, 371 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter rotate: false - xy: 801, 443 + xy: 750, 361 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter-top rotate: false - xy: 811, 445 + xy: 750, 351 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/thermalgenerator rotate: false - xy: 821, 445 + xy: 750, 341 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1084,56 +1084,56 @@ blocks/titancannon index: -1 blocks/titancannon-icon rotate: false - xy: 291, 73 + xy: 952, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/titanium1 rotate: false - xy: 831, 445 + xy: 750, 331 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium2 rotate: false - xy: 841, 445 + xy: 750, 321 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium3 rotate: false - xy: 851, 445 + xy: 740, 311 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumdrill rotate: false - xy: 861, 445 + xy: 750, 311 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumpurifier rotate: false - xy: 871, 445 + xy: 734, 301 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumshieldwall rotate: false - xy: 881, 445 + xy: 744, 301 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumwall rotate: false - xy: 891, 445 + xy: 754, 301 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1147,77 +1147,77 @@ blocks/titaniumwall-large index: -1 blocks/titaniumwall-large-icon rotate: false - xy: 901, 445 + xy: 528, 96 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/turret rotate: false - xy: 303, 89 + xy: 964, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/uranium1 rotate: false - xy: 931, 445 + xy: 532, 86 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium2 rotate: false - xy: 941, 445 + xy: 532, 76 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium3 rotate: false - xy: 951, 445 + xy: 542, 86 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uraniumdrill rotate: false - xy: 961, 445 + xy: 542, 76 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/water rotate: false - xy: 971, 445 + xy: 756, 381 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/wateredge rotate: false - xy: 109, 63 + xy: 95, 19 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/waveturret rotate: false - xy: 303, 77 + xy: 976, 483 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 bullet rotate: false - xy: 355, 81 + xy: 861, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 chainbullet rotate: false - xy: 183, 64 + xy: 841, 454 size: 8, 7 orig: 8, 7 offset: 0, 0 @@ -1294,14 +1294,14 @@ enemies/targetenemy-t1 index: -1 enemies/enemy-t2 rotate: false - xy: 108, 91 + xy: 124, 91 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 enemies/enemy-t3 rotate: false - xy: 122, 91 + xy: 138, 91 size: 12, 12 orig: 12, 12 offset: 0, 0 @@ -1392,63 +1392,63 @@ enemies/healerenemy-t3 index: -1 enemies/mortarenemy-t1 rotate: false - xy: 738, 412 + xy: 738, 396 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/mortarenemy-t2 rotate: false - xy: 738, 396 + xy: 754, 414 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/mortarenemy-t3 rotate: false - xy: 754, 414 + xy: 754, 398 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/rapidenemy-t1 rotate: false - xy: 754, 398 + xy: 770, 414 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/rapidenemy-t2 rotate: false - xy: 770, 414 + xy: 770, 398 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/rapidenemy-t3 rotate: false - xy: 770, 398 + xy: 786, 419 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/tankenemy-t1 rotate: false - xy: 786, 419 + xy: 786, 403 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/tankenemy-t2 rotate: false - xy: 786, 403 + xy: 92, 89 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/tankenemy-t3 rotate: false - xy: 92, 89 + xy: 108, 89 size: 14, 14 orig: 14, 14 offset: 0, 0 @@ -1476,63 +1476,63 @@ enemies/titanenemy-t3 index: -1 enemyarrow rotate: false - xy: 527, 117 + xy: 482, 86 size: 8, 7 orig: 8, 7 offset: 0, 0 index: -1 icon-coal rotate: false - xy: 854, 485 + xy: 1001, 465 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-dirium rotate: false - xy: 864, 485 + xy: 1001, 455 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-iron rotate: false - xy: 874, 485 + xy: 1011, 475 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-steel rotate: false - xy: 884, 485 + xy: 1011, 465 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-stone rotate: false - xy: 894, 485 + xy: 1011, 455 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-titanium rotate: false - xy: 904, 485 + xy: 492, 82 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-uranium rotate: false - xy: 914, 485 + xy: 502, 82 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 laser rotate: false - xy: 178, 91 + xy: 533, 178 size: 1, 12 orig: 1, 12 offset: 0, 0 @@ -1553,42 +1553,42 @@ laserfull index: -1 mechs/mech-standard rotate: false - xy: 95, 75 + xy: 95, 61 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 mechs/ship-standard rotate: false - xy: 95, 33 + xy: 109, 61 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 shell rotate: false - xy: 941, 465 + xy: 260, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot rotate: false - xy: 941, 455 + xy: 280, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot-long rotate: false - xy: 951, 465 + xy: 290, 87 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 titanshell rotate: false - xy: 911, 445 + xy: 534, 106 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1687,14 +1687,14 @@ ui/check-over index: -1 ui/clear rotate: false - xy: 109, 51 + xy: 109, 23 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/cursor rotate: false - xy: 69, 3 + xy: 734, 311 size: 4, 4 orig: 4, 4 offset: 0, 0 @@ -1715,7 +1715,7 @@ ui/icons/icon-add index: -1 ui/icons/icon-areaDelete rotate: false - xy: 109, 39 + xy: 537, 169 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1729,28 +1729,28 @@ ui/icons/icon-arrow index: -1 ui/icons/icon-arrow-down rotate: false - xy: 135, 67 + xy: 537, 157 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-arrow-left rotate: false - xy: 147, 79 + xy: 537, 145 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-arrow-right rotate: false - xy: 109, 27 + xy: 786, 391 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-arrow-up rotate: false - xy: 147, 67 + xy: 302, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1799,21 +1799,21 @@ ui/icons/icon-close-over index: -1 ui/icons/icon-crafting rotate: false - xy: 159, 79 + xy: 314, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-cursor rotate: false - xy: 159, 67 + xy: 326, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-defense rotate: false - xy: 95, 7 + xy: 338, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1827,7 +1827,7 @@ ui/icons/icon-discord index: -1 ui/icons/icon-distribution rotate: false - xy: 109, 15 + xy: 350, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1897,14 +1897,14 @@ ui/icons/icon-grid index: -1 ui/icons/icon-hold rotate: false - xy: 171, 79 + xy: 362, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-holdDelete rotate: false - xy: 171, 67 + xy: 374, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1916,9 +1916,16 @@ ui/icons/icon-home orig: 14, 14 offset: 0, 0 index: -1 +ui/icons/icon-host + rotate: false + xy: 631, 204 + size: 14, 14 + orig: 14, 14 + offset: 0, 0 + index: -1 ui/icons/icon-info rotate: false - xy: 107, 3 + xy: 386, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1932,7 +1939,7 @@ ui/icons/icon-line index: -1 ui/icons/icon-load rotate: false - xy: 631, 204 + xy: 647, 227 size: 14, 14 orig: 14, 14 offset: 0, 0 @@ -1960,21 +1967,21 @@ ui/icons/icon-loading index: -1 ui/icons/icon-menu rotate: false - xy: 183, 85 + xy: 398, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-none rotate: false - xy: 183, 73 + xy: 410, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-pause rotate: false - xy: 195, 85 + xy: 422, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1995,35 +2002,35 @@ ui/icons/icon-pick index: -1 ui/icons/icon-play rotate: false - xy: 195, 73 + xy: 434, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-play-2 rotate: false - xy: 647, 227 + xy: 647, 211 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icons/icon-power rotate: false - xy: 207, 85 + xy: 446, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-production rotate: false - xy: 207, 73 + xy: 458, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-quit rotate: false - xy: 647, 211 + xy: 647, 195 size: 14, 14 orig: 14, 14 offset: 0, 0 @@ -2037,7 +2044,7 @@ ui/icons/icon-redo index: -1 ui/icons/icon-rename rotate: false - xy: 647, 195 + xy: 631, 188 size: 14, 14 orig: 14, 14 offset: 0, 0 @@ -2051,35 +2058,35 @@ ui/icons/icon-resize index: -1 ui/icons/icon-rotate rotate: false - xy: 631, 188 + xy: 647, 179 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icons/icon-rotate-arrow rotate: false - xy: 647, 179 + xy: 722, 411 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icons/icon-rotate-left rotate: false - xy: 722, 411 + xy: 722, 395 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icons/icon-rotate-right rotate: false - xy: 722, 395 + xy: 724, 365 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icons/icon-save rotate: false - xy: 724, 365 + xy: 724, 349 size: 14, 14 orig: 14, 14 offset: 0, 0 @@ -2100,7 +2107,7 @@ ui/icons/icon-save-map index: -1 ui/icons/icon-settings rotate: false - xy: 219, 85 + xy: 470, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -2114,35 +2121,35 @@ ui/icons/icon-terrain index: -1 ui/icons/icon-tools rotate: false - xy: 724, 349 + xy: 724, 333 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icons/icon-touch rotate: false - xy: 219, 73 + xy: 492, 92 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-touchDelete rotate: false - xy: 231, 85 + xy: 504, 92 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-trash rotate: false - xy: 724, 333 + xy: 724, 317 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icons/icon-tutorial rotate: false - xy: 724, 317 + xy: 738, 412 size: 14, 14 orig: 14, 14 offset: 0, 0 @@ -2156,7 +2163,7 @@ ui/icons/icon-undo index: -1 ui/icons/icon-weapon rotate: false - xy: 231, 73 + xy: 516, 92 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -2234,7 +2241,7 @@ ui/scroll-knob-vertical-black index: -1 ui/selection rotate: false - xy: 524, 117 + xy: 592, 284 size: 1, 1 orig: 1, 1 offset: 0, 0 @@ -2313,7 +2320,7 @@ ui/textfield-over index: -1 ui/white rotate: false - xy: 535, 188 + xy: 738, 391 size: 3, 3 orig: 3, 3 offset: 0, 0 @@ -2336,42 +2343,42 @@ ui/window-empty index: -1 weapons/blaster rotate: false - xy: 345, 81 + xy: 851, 463 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/flamer rotate: false - xy: 435, 95 + xy: 911, 453 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/mortar rotate: false - xy: 841, 465 + xy: 891, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/multigun rotate: false - xy: 841, 455 + xy: 911, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/railgun rotate: false - xy: 901, 465 + xy: 740, 341 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/triblaster rotate: false - xy: 921, 445 + xy: 538, 96 size: 8, 8 orig: 8, 8 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index 62f0be40b9..c0118c8038 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 4dde75ca9c..572770fa43 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -43,6 +43,7 @@ public class Vars{ public static final int zoomScale = Math.round(Unit.dp.scl(1)); //if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available public static boolean debug = false; + public static boolean debugNet = false; //whether the player can clip through walls public static boolean noclip = false; //whether to draw chunk borders diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 8e7bce2f43..949695e2bf 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -194,6 +194,7 @@ public class Control extends Module{ } player = new Player(); + player.isAndroid = Vars.android; player.isLocal = true; spawns = WaveCreator.getSpawns(); @@ -397,6 +398,10 @@ public class Control extends Module{ } public void coreDestroyed(){ + if(Net.active() && Net.server()){ + Net.closeServer(); + } + Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y); Sounds.play("corexplode"); for(int i = 0; i < 16; i ++){ diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index f037d272f9..34307b80a8 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.core; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.utils.TimeUtils; import com.badlogic.gdx.utils.reflect.ClassReflection; import com.badlogic.gdx.utils.reflect.ReflectionException; import io.anuke.mindustry.Vars; @@ -33,7 +34,7 @@ import java.util.Arrays; public class NetClient extends Module { boolean connecting = false; boolean gotEntities = false; - float playerSyncTime = 3; + float playerSyncTime = 2; public NetClient(){ @@ -44,6 +45,11 @@ public class NetClient extends Module { Vars.ui.hideLoading(); Vars.ui.showLoading("$text.connecting.data"); }); + + ConnectPacket c = new ConnectPacket(); + c.name = UCore.getProperty("user.name"); + c.android = Vars.android; + Net.send(c, SendMode.tcp); }); Net.handle(Disconnect.class, packet -> { @@ -98,7 +104,7 @@ public class NetClient extends Module { int id = packet.ids[i]; if(id != Vars.player.id){ Entity entity = null; - if(id >= packet.enemyStart){ + if(i >= packet.enemyStart){ entity = Vars.control.enemyGroup.getByID(id); }else { entity = Vars.control.playerGroup.getByID(id); @@ -106,7 +112,10 @@ public class NetClient extends Module { Syncable sync = ((Syncable)entity); - if(sync == null) continue; + if(sync == null){ + Gdx.app.error("Mindustry", "Unknown entity ID: " + id + " " + (i >= packet.enemyStart ? "(enemy)" : "(player)")); + continue; + } //augh ((Interpolator)sync.getInterpolator()).type.read(entity, packet.data[i]); @@ -136,6 +145,8 @@ public class NetClient extends Module { } Vars.control.setWaveData(packet.enemies, packet.wave, packet.countdown); + Timers.resetTime(packet.time + (float)(TimeUtils.timeSinceMillis(packet.timestamp) / 1000.0 * 60.0)); + Gdx.app.postRunnable(() -> { Vars.ui.updateItems(); }); @@ -217,6 +228,18 @@ public class NetClient extends Module { e.printStackTrace(); } }); + + Net.handle(DisconnectPacket.class, packet -> { + Player player = Vars.control.playerGroup.getByID(packet.playerid); + + if(player != null){ + player.remove(); + } + }); + + Net.handle(Player.class, player -> { + player.add(); + }); } public void update(){ @@ -259,7 +282,7 @@ public class NetClient extends Module { if(Timers.get("syncPlayer", playerSyncTime)){ PositionPacket packet = new PositionPacket(); packet.data = Vars.player.getInterpolator().type.write(Vars.player); - Net.send(packet, SendMode.tcp); //TODO udp instead? + Net.send(packet, SendMode.udp); //TODO udp instead? } } } diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 016618912a..a74777fff3 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.utils.IntArray; import com.badlogic.gdx.utils.IntMap; +import com.badlogic.gdx.utils.TimeUtils; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.BulletType; @@ -24,6 +25,7 @@ import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.Entity; import io.anuke.ucore.modules.Module; +import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Mathf; import java.io.ByteArrayInputStream; @@ -39,8 +41,14 @@ public class NetServer extends Module{ public NetServer(){ - Net.handleServer(Connect.class, packet -> { - UCore.log("Sending world data to client (ID="+packet.id+"/"+packet.addressTCP+")"); + Net.handleServer(Connect.class, connect -> { + UCore.log("Connection found: " + connect.addressTCP); + }); + + Net.handleServer(ConnectPacket.class, packet -> { + int id = Net.getLastConnection(); + + UCore.log("Sending world data to client (ID="+id+")"); WorldData data = new WorldData(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); @@ -51,7 +59,7 @@ public class NetServer extends Module{ //TODO compress and uncompress when sending data.stream = new ByteArrayInputStream(stream.toByteArray()); - Net.sendStream(packet.id, data); + Net.sendStream(id, data); Gdx.app.postRunnable(() -> { Vars.ui.showInfo("$text.server.connected"); @@ -59,25 +67,38 @@ public class NetServer extends Module{ EntityDataPacket dp = new EntityDataPacket(); Player player = new Player(); - player.clientid = packet.id; + player.clientid = id; + player.name = packet.name; + player.isAndroid = packet.android; player.set(Vars.control.core.worldx(), Vars.control.core.worldy() - Vars.tilesize*2); player.add(); - connections.put(packet.id, player); + connections.put(id, player); dp.playerid = player.id; dp.players = Vars.control.playerGroup.all().toArray(Player.class); UCore.log("Sending entities: " + Arrays.toString(dp.players)); - //TODO send pathfind positions - //TODO save enemy nodes + Net.sendExcept(id, player, SendMode.tcp); - Net.sendTo(packet.id, dp, SendMode.tcp); + Net.sendTo(id, dp, SendMode.tcp); }); }); Net.handleServer(Disconnect.class, packet -> { - Gdx.app.postRunnable(() -> Vars.ui.showInfo("$text.server.disconnected")); + Player player = connections.get(packet.id); + + if(player == null) { + Gdx.app.postRunnable(() -> Vars.ui.showInfo(Bundles.format("text.server.disconnected", ""))); + return; + } + + Gdx.app.postRunnable(() -> Vars.ui.showInfo(Bundles.format("text.server.disconnected", player.name))); + + DisconnectPacket dc = new DisconnectPacket(); + dc.playerid = player.id; + + Net.send(dc, SendMode.tcp); }); Net.handleServer(PositionPacket.class, pos -> { @@ -200,7 +221,7 @@ public class NetServer extends Module{ packet.ids = new int[amount]; packet.data = new float[amount][0]; - int index = 0; + short index = 0; for(Player player : Vars.control.playerGroup.all()){ float[] out = player.getInterpolator().type.write(player); @@ -229,23 +250,24 @@ public class NetServer extends Module{ packet.countdown = Vars.control.getWaveCountdown(); packet.enemies = Vars.control.getEnemiesRemaining(); packet.wave = Vars.control.getWave(); + packet.time = Timers.time(); + packet.timestamp = TimeUtils.millis(); Net.send(packet, SendMode.udp); } if(Timers.get("serverBlockSync", blockSyncTime)){ - BlockSyncPacket packet = new BlockSyncPacket(); IntArray connections = Net.getConnections(); for(int i = 0; i < connections.size; i ++){ int id = connections.get(i); - Player player = this.connections.get(i); + Player player = this.connections.get(id); if(player == null) continue; int x = Mathf.scl2(player.x, Vars.tilesize); int y = Mathf.scl2(player.y, Vars.tilesize); - int w = 14; - int h = 10; + int w = 16; + int h = 12; sendBlockSync(id, x, y, w, h); } @@ -270,7 +292,7 @@ public class NetServer extends Module{ byte times = 0; for(; times < tile.entity.timer.getTimes().length; times ++){ - if(tile.entity.timer.getTimes()[times] > 0){ + if(tile.entity.timer.getTimes()[times] <= 1f){ break; } } @@ -278,7 +300,7 @@ public class NetServer extends Module{ stream.writeByte(times); for(int i = 0; i < times; i ++){ - stream.writeFloat(tile.entity.timer.getTimes()[times]); + stream.writeFloat(tile.entity.timer.getTimes()[i]); } tile.entity.write(stream); diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 4d9afffd38..9236def916 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -418,10 +418,8 @@ public class Renderer extends RendererModule{ drawHealth(entity); } - if(!Vars.android && Vars.showPlayer) { - for(Player player : Vars.control.playerGroup.all()){ - if(!player.isDead()) drawHealth(player); - } + for(Player player : Vars.control.playerGroup.all()){ + if(!player.isDead() && !player.isAndroid) drawHealth(player); } } } diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index fb374ab12b..fe12ea4369 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -181,10 +181,12 @@ public class UI extends SceneModule{ join = new FloatingDialog("$text.joingame.title"); join.content().add("$text.joingame.ip").left(); - join.content().addField("localhost", text -> lastip = text).size(180f, 54f); + Mindustry.platforms.addDialog(join.content().addField("localhost", text -> lastip = text).size(180f, 54f).get()); join.content().row(); join.content().add("$text.server.port").left(); - join.content().addField(Vars.port + "", new DigitsOnlyFilter(), text -> lastport = Strings.parseInt(text)).size(180f, 54f); + Mindustry.platforms.addDialog(join.content() + .addField(Vars.port + "", new DigitsOnlyFilter(), text -> lastport = Strings.parseInt(text)) + .size(180f, 54f).get()); join.buttons().defaults().size(140f, 60f).pad(4f); join.buttons().addButton("$text.cancel", join::hide); join.buttons().addButton("$text.ok", () -> { @@ -472,6 +474,21 @@ public class UI extends SceneModule{ public void showInfo(String info){ scene.table().add(info).get().getParent().actions(Actions.fadeOut(4f), Actions.removeActor()); } + + public void showHostServer(){ + showTextInput("$text.hostserver", "$text.server.port", Vars.port + "", new DigitsOnlyFilter(), text -> { + int result = Strings.parseInt(text); + if(result == Integer.MIN_VALUE || result >= 65535){ + Vars.ui.showError("$text.server.invalidport"); + }else{ + try{ + Net.host(result); + }catch (IOException e){ + Vars.ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false))); + } + } + }); + } public void showAbout(){ about.show(); diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index b4cba08ad4..10543d8e95 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -11,6 +11,7 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.ucore.core.*; import io.anuke.ucore.entities.DestructibleEntity; +import io.anuke.ucore.entities.SolidEntity; import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; @@ -19,10 +20,14 @@ import static io.anuke.mindustry.Vars.*; public class Player extends DestructibleEntity implements Syncable{ private static final float speed = 1.1f; private static final float dashSpeed = 1.8f; - + + public String name = "player name"; public transient Weapon weapon = Weapon.blaster; public Mech mech = Mech.standard; public float angle; + public boolean isAndroid; + + public transient float targetAngle = 0f; public transient int clientid; public transient boolean isLocal = false; @@ -43,15 +48,20 @@ public class Player extends DestructibleEntity implements Syncable{ } @Override - public Interpolator getInterpolator() { + public Interpolator getInterpolator() { return inter; } @Override public void damage(int amount){ - if(!Vars.debug && !Vars.android) + if(!Vars.debug) super.damage(amount); } + + @Override + public boolean collides(SolidEntity other){ + return super.collides(other) && !isAndroid; + } @Override public void onDeath(){ @@ -79,9 +89,13 @@ public class Player extends DestructibleEntity implements Syncable{ @Override public void draw(){ - if((Vars.debug && (!Vars.showPlayer || !Vars.showUI)) || (Vars.android && isLocal)) return; + if(isAndroid && isLocal){ + angle = Mathf.lerpAngDelta(angle, targetAngle, 0.2f); + } - String part = Vars.android ? "ship" : "mech"; + if((Vars.debug && (!Vars.showPlayer || !Vars.showUI)) || (isAndroid && isLocal)) return; + + String part = isAndroid ? "ship" : "mech"; if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate")){ Draw.rect(part+"-"+mech.name(), (int)x, (int)y, angle-90); @@ -93,7 +107,7 @@ public class Player extends DestructibleEntity implements Syncable{ @Override public void update(){ - if(!isLocal || android){ + if(!isLocal || isAndroid){ if(!isDead() && !isLocal) inter.update(this); return; } @@ -153,4 +167,9 @@ public class Player extends DestructibleEntity implements Syncable{ public Player add(){ return add(Vars.control.playerGroup); } + + @Override + public String toString() { + return "Player{" + id + ", android=" + isAndroid + ", local=" + isLocal + ", " + x + ", " + y + "}\n"; + } } diff --git a/core/src/io/anuke/mindustry/input/GestureHandler.java b/core/src/io/anuke/mindustry/input/GestureHandler.java index 94bc361802..1330783edb 100644 --- a/core/src/io/anuke/mindustry/input/GestureHandler.java +++ b/core/src/io/anuke/mindustry/input/GestureHandler.java @@ -52,7 +52,7 @@ public class GestureHandler extends GestureAdapter{ float dx = deltaX*Core.camera.zoom/Core.cameraScale, dy = deltaY*Core.camera.zoom/Core.cameraScale; player.x -= dx; player.y += dy; - player.angle = Mathf.lerpAngDelta(player.angle, Mathf.atan2(dx, dy), 0.5f); + player.targetAngle = Mathf.atan2(dx, -dy); }else if(player.placeMode.lockCamera && (player.placeMode.pan && player.recipe != null)){ input.mousex += deltaX; input.mousey += deltaY; diff --git a/core/src/io/anuke/mindustry/io/NetworkIO.java b/core/src/io/anuke/mindustry/io/NetworkIO.java index 44f09db95a..4b8c60bf95 100644 --- a/core/src/io/anuke/mindustry/io/NetworkIO.java +++ b/core/src/io/anuke/mindustry/io/NetworkIO.java @@ -1,7 +1,6 @@ package io.anuke.mindustry.io; import com.badlogic.gdx.files.FileHandle; -import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.TimeUtils; import com.badlogic.gdx.utils.reflect.ClassReflection; import io.anuke.mindustry.Vars; @@ -12,8 +11,6 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.types.BlockPart; import io.anuke.mindustry.world.blocks.types.Rock; -import io.anuke.mindustry.world.blocks.types.production.Generator; -import io.anuke.ucore.UCore; import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.Entities; @@ -141,7 +138,7 @@ public class NetworkIO { byte times = 0; for(; times < tile.entity.timer.getTimes().length; times ++){ - if(tile.entity.timer.getTimes()[times] > 0){ + if(tile.entity.timer.getTimes()[times] <= 1){ break; } } @@ -149,7 +146,7 @@ public class NetworkIO { stream.writeByte(times); for(int i = 0; i < times; i ++){ - stream.writeFloat(tile.entity.timer.getTimes()[times]); + stream.writeFloat(tile.entity.timer.getTimes()[i]); } tile.entity.write(stream); @@ -204,8 +201,6 @@ public class NetworkIO { int enemies = stream.readInt(); - Array enemiesToUpdate = new Array<>(); - for(int i = 0; i < enemies; i ++){ int id = stream.readInt(); byte type = stream.readByte(); @@ -226,7 +221,6 @@ public class NetworkIO { enemy.tier = tier; enemy.node = node; enemy.add(Vars.control.enemyGroup); - enemiesToUpdate.add(enemy); }catch (Exception e){ throw new RuntimeException(e); } @@ -234,8 +228,7 @@ public class NetworkIO { Vars.control.setWaveData(enemies, wave, wavetime); - if(!android) - Vars.player.add(); + Vars.player.add(); //map diff --git a/core/src/io/anuke/mindustry/io/Saves.java b/core/src/io/anuke/mindustry/io/Saves.java index 140034b6e3..8e7fd21e54 100644 --- a/core/src/io/anuke/mindustry/io/Saves.java +++ b/core/src/io/anuke/mindustry/io/Saves.java @@ -2,12 +2,7 @@ package io.anuke.mindustry.io; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Array; -import com.badlogic.gdx.utils.Timer; -import com.badlogic.gdx.utils.Timer.Task; import com.badlogic.gdx.utils.async.AsyncExecutor; -import com.badlogic.gdx.utils.reflect.ClassReflection; -import com.badlogic.gdx.utils.reflect.Field; -import com.badlogic.gdx.utils.reflect.ReflectionException; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState.State; @@ -156,6 +151,7 @@ public class Saves { public void delete(){ SaveIO.fileFor(index).delete(); + saves.removeValue(this, true); if(this == current){ current = null; } diff --git a/core/src/io/anuke/mindustry/net/Net.java b/core/src/io/anuke/mindustry/net/Net.java index 7c79dfe6cd..66f24c47a4 100644 --- a/core/src/io/anuke/mindustry/net/Net.java +++ b/core/src/io/anuke/mindustry/net/Net.java @@ -192,6 +192,8 @@ public class Net{ public IntArray getConnections(); /**Register classes to be sent.*/ public void register(Class... types); + /**Returns the ping for a certain connection.*/ + public int getPingFor(int connection); } public enum SendMode{ diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index 13fc79d516..965ae42a9f 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -28,17 +28,27 @@ public class Packets { public static class SyncPacket{ public int[] ids; public float[][] data; - public int enemyStart = 0; + public short enemyStart; } public static class BlockSyncPacket extends Streamable{ } - public static class StateSyncPacket { + public static class ConnectPacket{ + public String name; + public boolean android; + } + + public static class DisconnectPacket{ + public int playerid; + } + + public static class StateSyncPacket{ public int[] items; - public float countdown; + public float countdown, time; public int enemies, wave; + public long timestamp; } public static class PositionPacket{ diff --git a/core/src/io/anuke/mindustry/net/Registrator.java b/core/src/io/anuke/mindustry/net/Registrator.java index a9f733317c..15537a7ada 100644 --- a/core/src/io/anuke/mindustry/net/Registrator.java +++ b/core/src/io/anuke/mindustry/net/Registrator.java @@ -31,6 +31,8 @@ public class Registrator { EnemyDeathPacket.class, BlockUpdatePacket.class, BlockDestroyPacket.class, + ConnectPacket.class, + DisconnectPacket.class, Class.class, byte[].class, diff --git a/core/src/io/anuke/mindustry/net/Syncable.java b/core/src/io/anuke/mindustry/net/Syncable.java index 6e31f342c3..a5fee2b06b 100644 --- a/core/src/io/anuke/mindustry/net/Syncable.java +++ b/core/src/io/anuke/mindustry/net/Syncable.java @@ -1,7 +1,6 @@ package io.anuke.mindustry.net; import com.badlogic.gdx.math.Vector2; -import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.graphics.Fx; @@ -37,11 +36,11 @@ public interface Syncable { @Override public void update(Player entity, Interpolator interpolator) { Interpolator i = entity.getInterpolator(); - if(i.target.dst(entity.x, entity.y) > 16){ + if(i.target.dst(entity.x, entity.y) > 16 && !entity.isAndroid){ entity.set(i.target.x, i.target.y); } - if(Vars.android && i.target.dst(entity.x, entity.y) > 2f && Timers.get(entity, "dashfx", 3)){ + if(entity.isAndroid && i.target.dst(entity.x, entity.y) > 2f && Timers.get(entity, "dashfx", 2)){ Angles.translation(entity.angle + 180, 3f); Effects.effect(Fx.dashsmoke, entity.x + Angles.x(), entity.y + Angles.y()); } diff --git a/core/src/io/anuke/mindustry/ui/MenuDialog.java b/core/src/io/anuke/mindustry/ui/MenuDialog.java index ea5a67eccc..79a16e6826 100644 --- a/core/src/io/anuke/mindustry/ui/MenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/MenuDialog.java @@ -10,11 +10,7 @@ import io.anuke.ucore.scene.Element; import io.anuke.ucore.scene.builders.build; import io.anuke.ucore.scene.builders.imagebutton; import io.anuke.ucore.scene.ui.ImageButton; -import io.anuke.ucore.scene.ui.TextField.TextFieldFilter.DigitsOnlyFilter; import io.anuke.ucore.util.Bundles; -import io.anuke.ucore.util.Strings; - -import java.io.IOException; import static io.anuke.mindustry.Vars.ui; @@ -62,26 +58,13 @@ public class MenuDialog extends FloatingDialog{ content().row(); - content().addButton("$text.hostserver", () -> { - Vars.ui.showTextInput("$text.hostserver", "$text.server.port", Vars.port + "", new DigitsOnlyFilter(), text -> { - int result = Strings.parseInt(text); - if(result == Integer.MIN_VALUE || result >= 65535){ - Vars.ui.showError("$text.server.invalidport"); - }else{ - try{ - Net.host(result); - GameState.set(State.playing); - }catch (IOException e){ - Vars.ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false))); - } - } - }); - }).disabled(b -> Net.active() || (Net.active() && !Net.server())); + content().addButton("$text.hostserver", () -> ui.showHostServer()) + .disabled(b -> Net.active() || (Net.active() && !Net.server())); content().row(); content().addButton("$text.quit", () -> { - Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> { + ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> { runSave(); hide(); GameState.set(State.menu); @@ -105,8 +88,12 @@ public class MenuDialog extends FloatingDialog{ new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f); new imagebutton("icon-save", isize, ()-> save.show()).text("$text.save").padTop(4f); + + content().row(); new imagebutton("icon-load", isize, () -> load.show()).text("$text.load").padTop(4f); + + new imagebutton("icon-host", isize, () -> ui.showHostServer()).text("$text.host").padTop(4f); new imagebutton("icon-quit", isize, () -> { Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> { diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 2b3f050554..8cf72e324f 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -150,6 +150,14 @@ public class HudFragment implements Fragment{ }}.end(); + if(Vars.debugNet) { + new table() {{ + new label(() -> "players: " + Vars.control.playerGroup.amount()); + row(); + new label(() -> "" + Vars.control.playerGroup.all()); + }}.end(); + } + blockfrag.build(); } diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index 7abea26796..ffb946ea76 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -72,7 +72,7 @@ public class MenuFragment implements Fragment{ new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f); - new imagebutton("icon-tools", isize, () -> ui.showJoinGame()).text("$text.joingame").padTop(4f); + new imagebutton("icon-add", isize, () -> ui.showJoinGame()).text("$text.joingame").padTop(4f); if(Mindustry.donationsCallable != null){ new imagebutton("icon-donate", isize, () -> { diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Conveyor.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Conveyor.java index 47cd9b0830..89e9def39e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Conveyor.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Conveyor.java @@ -1,15 +1,7 @@ package io.anuke.mindustry.world.blocks.types.distribution; -import static io.anuke.mindustry.Vars.tilesize; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.*; - import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.IntArray; - import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.world.Block; @@ -17,7 +9,20 @@ import io.anuke.mindustry.world.Layer; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Timers; -import io.anuke.ucore.util.*; +import io.anuke.ucore.util.Bits; +import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Strings; +import io.anuke.ucore.util.Tmp; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.AbstractList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import static io.anuke.mindustry.Vars.tilesize; public class Conveyor extends Block{ private static ItemPos pos1 = new ItemPos(); @@ -182,6 +187,7 @@ public class Conveyor extends Block{ @Override public void read(DataInputStream stream) throws IOException{ + convey.clear(); int amount = stream.readInt(); convey.ensureCapacity(amount); diff --git a/kryonet/build/libs/kryonet-release.jar b/kryonet/build/libs/kryonet-release.jar new file mode 100644 index 0000000000..e2350720b9 Binary files /dev/null and b/kryonet/build/libs/kryonet-release.jar differ diff --git a/kryonet/build/tmp/jar/MANIFEST.MF b/kryonet/build/tmp/jar/MANIFEST.MF new file mode 100644 index 0000000000..59499bce4a --- /dev/null +++ b/kryonet/build/tmp/jar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/kryonet/src/io/anuke/kryonet/KryoServer.java b/kryonet/src/io/anuke/kryonet/KryoServer.java index c3cbfc8843..7b697997ac 100644 --- a/kryonet/src/io/anuke/kryonet/KryoServer.java +++ b/kryonet/src/io/anuke/kryonet/KryoServer.java @@ -133,6 +133,11 @@ public class KryoServer implements ServerProvider { } } + @Override + public int getPingFor(int connection) { + return getByID(connection).getReturnTripTime(); + } + @Override public void register(Class... types) { for(Class c : types){