diff --git a/build.gradle b/build.gradle index 95438b6d42..ce1b985c77 100644 --- a/build.gradle +++ b/build.gradle @@ -190,7 +190,7 @@ project(":desktop"){ implementation arcModule("natives:natives-box2d-desktop") implementation arcModule("natives:natives-desktop") implementation arcModule("natives:natives-freetype-desktop") - implementation arcModule("extensions:discord") + implementation 'com.github.MinnDevelopment:java-discord-rpc:v2.0.1' if(debugged()) implementation project(":debug") diff --git a/core/src/mindustry/ai/Pathfinder.java b/core/src/mindustry/ai/Pathfinder.java index d5ced3fe18..5b8f58b93e 100644 --- a/core/src/mindustry/ai/Pathfinder.java +++ b/core/src/mindustry/ai/Pathfinder.java @@ -128,33 +128,35 @@ public class Pathfinder implements Runnable{ if(net.client()) return; try{ - queue.run(); + if(state.isPlaying()){ + queue.run(); - //total update time no longer than maxUpdate - for(Flowfield data : threadList){ - updateFrontier(data, maxUpdate / threadList.size); + //total update time no longer than maxUpdate + for(Flowfield data : threadList){ + updateFrontier(data, maxUpdate / threadList.size); - //remove flowfields that have 'timed out' so they can be garbage collected and no longer waste space - if(data.target.refreshRate() > 0 && Time.timeSinceMillis(data.lastUpdateTime) > fieldTimeout){ - //make sure it doesn't get removed twice - data.lastUpdateTime = Time.millis(); + //remove flowfields that have 'timed out' so they can be garbage collected and no longer waste space + if(data.target.refreshRate() > 0 && Time.timeSinceMillis(data.lastUpdateTime) > fieldTimeout){ + //make sure it doesn't get removed twice + data.lastUpdateTime = Time.millis(); - Team team = data.team; + Team team = data.team; - Core.app.post(() -> { - //remove its used state - if(fieldMap[team.uid] != null){ - fieldMap[team.uid].remove(data.target); - fieldMapUsed[team.uid].remove(data.target); - } - //remove from main thread list - mainList.remove(data); - }); + Core.app.post(() -> { + //remove its used state + if(fieldMap[team.uid] != null){ + fieldMap[team.uid].remove(data.target); + fieldMapUsed[team.uid].remove(data.target); + } + //remove from main thread list + mainList.remove(data); + }); - queue.post(() -> { - //remove from this thread list with a delay - threadList.remove(data); - }); + queue.post(() -> { + //remove from this thread list with a delay + threadList.remove(data); + }); + } } } diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index c17d256bdf..b03b7cece3 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -132,10 +132,10 @@ public class Logic implements ApplicationListener{ if(!state.isCampaign()){ for(TeamData team : state.teams.getActive()){ if(team.hasCore()){ - Tilec entity = team.core(); - entity.items().clear(); + TileEntity entity = team.core(); + entity.items.clear(); for(ItemStack stack : state.rules.loadout){ - entity.items().add(stack.item, stack.amount); + entity.items.add(stack.item, stack.amount); } } } diff --git a/core/src/mindustry/editor/MapResizeDialog.java b/core/src/mindustry/editor/MapResizeDialog.java index bd8b758e61..0b493fc477 100644 --- a/core/src/mindustry/editor/MapResizeDialog.java +++ b/core/src/mindustry/editor/MapResizeDialog.java @@ -2,8 +2,10 @@ package mindustry.editor; import arc.func.*; import arc.math.*; +import arc.scene.ui.TextField.*; import arc.scene.ui.layout.*; -import mindustry.gen.*; +import arc.util.*; +import mindustry.*; import mindustry.ui.dialogs.*; public class MapResizeDialog extends BaseDialog{ @@ -22,21 +24,12 @@ public class MapResizeDialog extends BaseDialog{ for(boolean w : Mathf.booleans){ table.add(w ? "$width" : "$height").padRight(8f); table.defaults().height(60f).padTop(8); - table.button("<", () -> { - if(w) - width = move(width, -1); - else - height = move(height, -1); - }).size(60f); - table.table(Tex.button, t -> t.label(() -> (w ? width : height) + "")).width(200); + Vars.platform.addDialog(table.field((w ? width : height) + "", TextFieldFilter.digitsOnly, value -> { + int val = Integer.parseInt(value); + if(w) width = val; else height = val; + }).valid(value -> Strings.canParsePostiveInt(value) && Integer.parseInt(value) <= maxSize && Integer.parseInt(value) >= minSize).get()); - table.button(">", () -> { - if(w) - width = move(width, 1); - else - height = move(height, 1); - }).size(60f); table.row(); } cont.row(); @@ -51,8 +44,4 @@ public class MapResizeDialog extends BaseDialog{ hide(); }); } - - static int move(int value, int direction){ - return Mathf.clamp((value / increment + direction) * increment, minSize, maxSize); - } } diff --git a/core/src/mindustry/graphics/MinimapRenderer.java b/core/src/mindustry/graphics/MinimapRenderer.java index cd7fffd9dd..9506116187 100644 --- a/core/src/mindustry/graphics/MinimapRenderer.java +++ b/core/src/mindustry/graphics/MinimapRenderer.java @@ -133,7 +133,7 @@ public class MinimapRenderer implements Disposable{ } public void update(Tile tile){ - if(world.isGenerating()) return; + if(world.isGenerating() || !state.isGame()) return; int color = colorFor(world.tile(tile.x, tile.y)); pixmap.draw(tile.x, pixmap.getHeight() - 1 - tile.y, color); diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 14baf187f9..7847333d29 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -94,8 +94,10 @@ public class Sector{ return (normal.dot(light) + 1f) / 2f; } + /** @return the sector size, in tiles */ public int getSize(){ - return (int)(rect.radius * 3200); + int res = (int)(rect.radius * 3200); + return res % 2 == 0 ? res : res + 1; } //TODO implement diff --git a/desktop/src/mindustry/desktop/DesktopLauncher.java b/desktop/src/mindustry/desktop/DesktopLauncher.java index 16d445c3d3..22973e0e59 100644 --- a/desktop/src/mindustry/desktop/DesktopLauncher.java +++ b/desktop/src/mindustry/desktop/DesktopLauncher.java @@ -4,8 +4,6 @@ import arc.*; import arc.Files.*; import arc.backend.sdl.*; import arc.backend.sdl.jni.*; -import arc.discord.*; -import arc.discord.DiscordRPC.*; import arc.files.*; import arc.func.*; import arc.math.*; @@ -13,6 +11,7 @@ import arc.struct.*; import arc.util.*; import arc.util.async.*; import arc.util.serialization.*; +import club.minnced.discord.rpc.*; import com.codedisaster.steamworks.*; import mindustry.*; import mindustry.core.*; @@ -32,7 +31,8 @@ import static mindustry.Vars.*; public class DesktopLauncher extends ClientLauncher{ public final static String discordID = "610508934456934412"; - boolean useDiscord = OS.is64Bit && !OS.hasProp("nodiscord"), loadError = false; + //discord RPC is only enabled on linux right now + boolean useDiscord = OS.is64Bit && !OS.isARM && !OS.hasProp("nodiscord"), loadError = false; Throwable steamError; public static void main(String[] arg){ @@ -58,9 +58,9 @@ public class DesktopLauncher extends ClientLauncher{ if(useDiscord){ try{ - DiscordRPC.initialize(discordID, true, "1127400"); + DiscordRPC.INSTANCE.Discord_Initialize(discordID, null, true, "1127400"); Log.info("Initialized Discord rich presence."); - Runtime.getRuntime().addShutdownHook(new Thread(DiscordRPC::shutdown)); + Runtime.getRuntime().addShutdownHook(new Thread(DiscordRPC.INSTANCE::Discord_Shutdown)); }catch(Throwable t){ useDiscord = false; Log.err("Failed to initialize discord.", t); @@ -282,7 +282,7 @@ public class DesktopLauncher extends ClientLauncher{ presence.largeImageKey = "logo"; - DiscordRPC.updatePresence(presence); + DiscordRPC.INSTANCE.Discord_UpdatePresence(presence); } if(steam){ diff --git a/settings.gradle b/settings.gradle index 309f43672a..6883be3f0d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -36,7 +36,6 @@ if(!hasProperty("release")){ ':Arc:extensions:box2d', ':Arc:extensions:g3d', ':Arc:extensions:fx', - ':Arc:extensions:discord', ':Arc:natives', ':Arc:natives:natives-desktop', ':Arc:natives:natives-android',