From 4ed9f10c1bb2e791d4eb763dfcd584e46e8fc1c5 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 4 Jul 2021 09:51:39 -0400 Subject: [PATCH 1/5] Cleanup --- core/src/mindustry/maps/Maps.java | 4 ++-- core/src/mindustry/mod/Scripts.java | 7 +++---- gradle.properties | 2 +- ios/src/mindustry/ios/IOSLauncher.java | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/src/mindustry/maps/Maps.java b/core/src/mindustry/maps/Maps.java index 72fcc09aa1..46b74799d9 100644 --- a/core/src/mindustry/maps/Maps.java +++ b/core/src/mindustry/maps/Maps.java @@ -422,7 +422,7 @@ public class Maps{ } private void writeCache(Map map) throws IOException{ - try(DataOutputStream stream = new DataOutputStream(map.cacheFile().write(false, Streams.DEFAULT_BUFFER_SIZE))){ + try(DataOutputStream stream = new DataOutputStream(map.cacheFile().write(false, Streams.defaultBufferSize))){ stream.write(0); stream.writeInt(map.spawns); stream.write(map.teams.size); @@ -434,7 +434,7 @@ public class Maps{ } private void readCache(Map map) throws IOException{ - try(DataInputStream stream = new DataInputStream(map.cacheFile().read(Streams.DEFAULT_BUFFER_SIZE))){ + try(DataInputStream stream = new DataInputStream(map.cacheFile().read(Streams.defaultBufferSize))){ stream.read(); //version map.spawns = stream.readInt(); int teamsize = stream.readByte(); diff --git a/core/src/mindustry/mod/Scripts.java b/core/src/mindustry/mod/Scripts.java index 1aa69b9ab7..8dd10759bc 100644 --- a/core/src/mindustry/mod/Scripts.java +++ b/core/src/mindustry/mod/Scripts.java @@ -7,9 +7,9 @@ import arc.assets.loaders.SoundLoader.*; import arc.audio.*; import arc.files.*; import arc.func.*; -import arc.struct.*; import arc.util.*; import arc.util.Log.*; +import arc.util.io.*; import mindustry.*; import mindustry.mod.Mods.*; import rhino.*; @@ -18,7 +18,6 @@ import rhino.module.provider.*; import java.io.*; import java.net.*; -import java.util.*; import java.util.regex.*; public class Scripts implements Disposable{ @@ -131,7 +130,7 @@ public class Scripts implements Disposable{ /** writeFile but for a byte[] */ public void writeBinFile(String purpose, String ext, byte[] contents){ - if(contents == null) contents = new byte[0]; + if(contents == null) contents = Streams.emptyBytes; final byte[] fContents = contents; selectFile(false, purpose, ext, fi -> fi.writeBytes(fContents)); } @@ -183,7 +182,7 @@ public class Scripts implements Disposable{ } private class ScriptModuleProvider extends UrlModuleSourceProvider{ - private Pattern directory = Pattern.compile("^(.+?)/(.+)"); + private final Pattern directory = Pattern.compile("^(.+?)/(.+)"); public ScriptModuleProvider(){ super(null, null); diff --git a/gradle.properties b/gradle.properties index cd18c70c04..5aa6936a7b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,4 @@ kapt.include.compile.classpath=false kotlin.stdlib.default.dependency=false #needed for android compilation android.useAndroidX=true -archash=b5d3986d159cc42f2b38da24682ad0cc19c6c656 +archash=ca296ad37aeca186fcef3290bb8a6e9143bdd245 diff --git a/ios/src/mindustry/ios/IOSLauncher.java b/ios/src/mindustry/ios/IOSLauncher.java index 4171862d2b..efb0874504 100644 --- a/ios/src/mindustry/ios/IOSLauncher.java +++ b/ios/src/mindustry/ios/IOSLauncher.java @@ -219,7 +219,7 @@ public class IOSLauncher extends IOSApplication.Delegate{ if(SaveIO.isSaveValid(file)){ try{ - SaveMeta meta = SaveIO.getMeta(new DataInputStream(new InflaterInputStream(file.read(Streams.DEFAULT_BUFFER_SIZE)))); + SaveMeta meta = SaveIO.getMeta(new DataInputStream(new InflaterInputStream(file.read(Streams.defaultBufferSize)))); if(meta.tags.containsKey("name")){ //is map if(!ui.editor.isShown()){ From 416007593fcdb9f876e676c7439d4ed9937f0db8 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 4 Jul 2021 19:14:11 -0400 Subject: [PATCH 2/5] convert_sounds.sh is no longer needed --- core/convert_sounds.sh | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100755 core/convert_sounds.sh diff --git a/core/convert_sounds.sh b/core/convert_sounds.sh deleted file mode 100755 index 02db793811..0000000000 --- a/core/convert_sounds.sh +++ /dev/null @@ -1,12 +0,0 @@ -#convert from stereo to mono -cd assets/sounds/ -for i in *.ogg; do - echo $i - ffmpeg -i "$i" -ac 1 "OUT_$i" -done - -find . -type f ! -name "OUT_*" -delete - -for file in OUT_*; do mv "$file" "${file#OUT_}"; done; - -cd ../../ From 4fdb817d4a9876e5843f3ab350ce2dd307c5d3ef Mon Sep 17 00:00:00 2001 From: TranquillyUnpleasant <62061444+TranquillyUnpleasant@users.noreply.github.com> Date: Mon, 5 Jul 2021 06:16:47 +0500 Subject: [PATCH 3/5] move domains (#5542) --- servers_v6.json | 4 ---- servers_v7.json | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/servers_v6.json b/servers_v6.json index aea751bf79..1be97e5f26 100644 --- a/servers_v6.json +++ b/servers_v6.json @@ -27,10 +27,6 @@ "name": "BE6.RUN", "address": ["be6.run", "mindustrycn.top"] }, - { - "name": "io", - "address": ["mindustry.io.community", "mindustry.io.community:1000", "mindustry.io.community:2000", "mindustry.io.community:3000", "mindustry.io.community:4000"] - }, { "name": "ECAN", "address": ["mindustry.ecansol.com:6597", "mindustry.ecansol.com:6499", "mindustry.ecansol.com:6599"] diff --git a/servers_v7.json b/servers_v7.json index 47bd240cb2..6342cdb659 100644 --- a/servers_v7.json +++ b/servers_v7.json @@ -41,5 +41,9 @@ { "name": "Obvilion Network", "address": "obvilionnetwork.ru:7004" + }, + { + "name": "io", + "address": ["mindustry.io.community", "mindustry.io.community:1000", "mindustry.io.community:2000", "mindustry.io.community:3000"] } ] From 789e35440028f32ae087633eb68521da8c605ba8 Mon Sep 17 00:00:00 2001 From: TranquillyUnpleasant <62061444+TranquillyUnpleasant@users.noreply.github.com> Date: Mon, 5 Jul 2021 06:18:41 +0500 Subject: [PATCH 4/5] Server qol (#5534) --- core/assets/contributors | 1 + .../src/mindustry/server/ServerControl.java | 44 ++++++++++++------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/core/assets/contributors b/core/assets/contributors index 89f98a6bda..5099ab7e37 100644 --- a/core/assets/contributors +++ b/core/assets/contributors @@ -126,3 +126,4 @@ Skat WilloIzCitron SAMBUYYA genNAowl +TranquillyUnpleasant diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 19d6506f2c..424d64af0b 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -163,9 +163,9 @@ public class ServerControl implements ApplicationListener{ Events.on(GameOverEvent.class, event -> { if(inExtraRound) return; if(state.rules.waves){ - info("Game over! Reached wave @ with @ players online on map @.", state.wave, Groups.player.size(), Strings.capitalize(state.map.name())); + info("Game over! Reached wave @ with @ players online on map @.", state.wave, Groups.player.size(), Strings.capitalize(Strings.stripColors(state.map.name()))); }else{ - info("Game over! Team @ is victorious with @ players online on map @.", event.winner.name, Groups.player.size(), Strings.capitalize(state.map.name())); + info("Game over! Team @ is victorious with @ players online on map @.", event.winner.name, Groups.player.size(), Strings.capitalize(Strings.stripColors(state.map.name()))); } //set next map to be played @@ -174,14 +174,14 @@ public class ServerControl implements ApplicationListener{ if(map != null){ Call.infoMessage((state.rules.pvp ? "[accent]The " + event.winner.name + " team is victorious![]\n" : "[scarlet]Game over![]\n") - + "\nNext selected map:[accent] " + map.name() + "[]" + + "\nNext selected map:[accent] " + Strings.stripColors(map.name()) + "[]" + (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[white]" : "") + "." + "\nNew game begins in " + roundExtraTime + " seconds."); state.gameOver = true; Call.updateGameOver(event.winner); - info("Selected next map to be @.", map.name()); + info("Selected next map to be @.", Strings.stripColors(map.name())); play(true, () -> world.loadMap(map, map.applyRules(lastMode))); }else{ @@ -259,10 +259,20 @@ public class ServerControl implements ApplicationListener{ } protected void registerCommands(){ - handler.register("help", "Displays this command list.", arg -> { - info("Commands:"); - for(Command command : handler.getCommandList()){ - info(" &b&lb " + command.text + (command.paramText.isEmpty() ? "" : " &lc&fi") + command.paramText + "&fr - &lw" + command.description); + handler.register("help", "[command]", "Display the command list, or get help for a specific command.", arg -> { + if(arg.length > 0){ + Command command = handler.getCommandList().find(c -> c.text.equalsIgnoreCase(arg[0])); + if(command == null){ + err("Command " + arg[0] + " not found!"); + }else{ + info(command.text + ":"); + info(" &b&lb " + command.text + (command.paramText.isEmpty() ? "" : " &lc&fi") + command.paramText + "&fr - &lw" + command.description); + } + }else{ + info("Commands:"); + for(Command command : handler.getCommandList()){ + info(" &b&lb " + command.text + (command.paramText.isEmpty() ? "" : " &lc&fi") + command.paramText + "&fr - &lw" + command.description); + } } }); @@ -306,7 +316,7 @@ public class ServerControl implements ApplicationListener{ Map result; if(arg.length > 0){ - result = maps.all().find(map -> map.name().equalsIgnoreCase(arg[0].replace('_', ' ')) || map.name().equalsIgnoreCase(arg[0])); + result = maps.all().find(map -> Strings.stripColors(map.name().replace('_', ' ')).equalsIgnoreCase(Strings.stripColors(arg[0]).replace('_', ' '))); if(result == null){ err("No map with name '@' found.", arg[0]); @@ -335,14 +345,16 @@ public class ServerControl implements ApplicationListener{ } }); - handler.register("maps", "Display all available maps.", arg -> { + handler.register("maps", "[all]", "Display available maps. 'all' to include default maps.", arg -> { + boolean all = arg.length > 0 && arg[0].equalsIgnoreCase("all"); if(!maps.all().isEmpty()){ info("Maps:"); - for(Map map : maps.all()){ + for(Map map : all ? maps.all() : maps.customMaps()){ + String mapName = Strings.stripColors(map.name()).replace(' ', '_'); if(map.custom){ - info(" @ (@): &fiCustom / @x@", map.name().replace(' ', '_'), map.file.name(), map.width, map.height); + info(" @ (@): &fiCustom / @x@", mapName, map.file.name(), map.width, map.height); }else{ - info(" @: &fiDefault / @x@", map.name().replace(' ', '_'), map.width, map.height); + info(" @: &fiDefault / @x@", mapName, map.width, map.height); } } }else{ @@ -366,7 +378,7 @@ public class ServerControl implements ApplicationListener{ info("Status: &rserver closed"); }else{ info("Status:"); - info(" Playing on map &fi@ / Wave @", Strings.capitalize(state.map.name()), state.wave); + info(" Playing on map &fi@ / Wave @", Strings.capitalize(Strings.stripColors(state.map.name())), state.wave); if(state.rules.waves){ info(" @ enemies.", state.enemies); @@ -650,10 +662,10 @@ public class ServerControl implements ApplicationListener{ }); handler.register("nextmap", "", "Set the next map to be played after a game-over. Overrides shuffling.", arg -> { - Map res = maps.all().find(map -> map.name().equalsIgnoreCase(arg[0].replace('_', ' ')) || map.name().equalsIgnoreCase(arg[0])); + Map res = maps.all().find(map -> Strings.stripColors(map.name().replace('_', ' ')).equalsIgnoreCase(Strings.stripColors(arg[0]).replace('_', ' '))); if(res != null){ nextMapOverride = res; - info("Next map set to '@'.", res.name()); + info("Next map set to '@'.", Strings.stripColors(res.name())); }else{ err("No map '@' found.", arg[0]); } From 3d8d84177b2d820b982d3e4391f72acfeb8fcb88 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 4 Jul 2021 21:30:47 -0400 Subject: [PATCH 5/5] Map listing improvements --- .../src/mindustry/server/ServerControl.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 424d64af0b..e25d44d6f5 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -345,16 +345,28 @@ public class ServerControl implements ApplicationListener{ } }); - handler.register("maps", "[all]", "Display available maps. 'all' to include default maps.", arg -> { - boolean all = arg.length > 0 && arg[0].equalsIgnoreCase("all"); + handler.register("maps", "[all/custom/default]", "Display available maps. Displays only custom maps by default.", arg -> { + boolean custom = arg.length == 0 || arg[0].equals("custom") || arg[0].equals("all"); + boolean def = arg.length > 0 && (arg[0].equals("default") || arg[0].equals("all")); + if(!maps.all().isEmpty()){ - info("Maps:"); - for(Map map : all ? maps.all() : maps.customMaps()){ - String mapName = Strings.stripColors(map.name()).replace(' ', '_'); - if(map.custom){ - info(" @ (@): &fiCustom / @x@", mapName, map.file.name(), map.width, map.height); - }else{ - info(" @: &fiDefault / @x@", mapName, map.width, map.height); + Seq all = new Seq<>(); + + if(custom) all.addAll(maps.customMaps()); + if(def) all.addAll(maps.defaultMaps()); + + if(all.isEmpty()){ + info("No custom maps loaded. &fiTo display built-in maps, use the \"@\" argument.", "all"); + }else{ + info("Maps:"); + + for(Map map : all){ + String mapName = Strings.stripColors(map.name()).replace(' ', '_'); + if(map.custom){ + info(" @ (@): &fiCustom / @x@", mapName, map.file.name(), map.width, map.height); + }else{ + info(" @: &fiDefault / @x@", mapName, map.width, map.height); + } } } }else{