diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 3db581844c..543934f2df 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -114,6 +114,7 @@ mod.disable = Disable mod.content = Content: mod.delete.error = Unable to delete mod. File may be in use. mod.requiresversion = [scarlet]Requires min game version: [accent]{0} +mod.outdated = [scarlet]Not compatible with V6 (no min-game-version: 105) mod.missingdependencies = [scarlet]Missing dependencies: {0} mod.erroredcontent = [scarlet]Content Errors mod.errors = Errors have occurred loading content. diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index f310844566..898cf355b9 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -1210,6 +1210,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, if(sensor == LAccess.y) return y; if(sensor == LAccess.team) return team.id; if(sensor == LAccess.health) return health; + if(sensor == LAccess.maxHealth) return maxHealth(); if(sensor == LAccess.efficiency) return efficiency(); if(sensor == LAccess.rotation) return rotation; if(sensor == LAccess.totalItems && items != null) return items.total(); diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 1eb509c785..b20d37d36a 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -75,6 +75,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I if(sensor == LAccess.totalItems) return stack().amount; if(sensor == LAccess.rotation) return rotation; if(sensor == LAccess.health) return health; + if(sensor == LAccess.maxHealth) return maxHealth; if(sensor == LAccess.x) return x; if(sensor == LAccess.y) return y; if(sensor == LAccess.team) return team.id; diff --git a/core/src/mindustry/logic/LAccess.java b/core/src/mindustry/logic/LAccess.java index 2128028153..95217ddd71 100644 --- a/core/src/mindustry/logic/LAccess.java +++ b/core/src/mindustry/logic/LAccess.java @@ -15,6 +15,7 @@ public enum LAccess{ powerNetIn, powerNetOut, health, + maxHealth, heat, efficiency, rotation, diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index 5ac84a72ae..1b7793165b 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -493,7 +493,9 @@ public class LExecutor{ //this should avoid any garbage allocation Var v = exec.vars[value]; if(v.isobj && value != 0){ - String strValue = v.objval instanceof String ? (String)v.objval : v.objval == null ? "null" : + String strValue = + v.objval == null ? "null" : + v.objval instanceof String ? (String)v.objval : v.objval instanceof Content ? "[content]" : v.objval instanceof Building ? "[building]" : v.objval instanceof Unit ? "[unit]" : diff --git a/core/src/mindustry/mod/Mods.java b/core/src/mindustry/mod/Mods.java index 433e66ca7a..71cc8b188f 100644 --- a/core/src/mindustry/mod/Mods.java +++ b/core/src/mindustry/mod/Mods.java @@ -707,14 +707,51 @@ public class Mods implements Loadable{ /** @return whether this mod is supported by the game verison */ public boolean isSupported(){ - if(Version.build <= 0 || meta.minGameVersion == null) return true; - if(meta.minGameVersion.contains(".")){ - String[] split = meta.minGameVersion.split("\\."); + if(isOutdated()) return false; + + int major = getMinMinor(), minor = getMinMinor(); + + if(Version.build <= 0) return true; + + return Version.build >= major && Version.revision >= minor; + } + + /** @return whether this mod is outdated, e.g. not compatible with v6. */ + public boolean isOutdated(){ + //must be at least 105 to indicate v6 compat + return getMinMinor() < 105; + } + + public int getMinMajor(){ + int major = 0; + + String ver = meta.minGameVersion == null ? "0" : meta.minGameVersion; + + if(ver.contains(".")){ + String[] split = ver.split("\\."); if(split.length == 2){ - return Version.build >= Strings.parseInt(split[0], 0) && Version.revision >= Strings.parseInt(split[1], 0); + major = Strings.parseInt(split[0], 0); + } + }else{ + major = Strings.parseInt(ver, 0); + } + + return major; + } + + public int getMinMinor(){ + int minor = 0; + + String ver = meta.minGameVersion == null ? "0" : meta.minGameVersion; + + if(ver.contains(".")){ + String[] split = ver.split("\\."); + if(split.length == 2){ + return Strings.parseInt(split[1], 0); } } - return Version.build >= Strings.parseInt(meta.minGameVersion, 0); + + return 0; } @Override @@ -792,7 +829,7 @@ public class Mods implements Loadable{ /** Mod metadata information.*/ public static class ModMeta{ - public String name, displayName, author, description, version, main, minGameVersion; + public String name, displayName, author, description, version, main, minGameVersion = "0"; public Seq dependencies = Seq.with(); /** Hidden mods are only server-side or client-side, and do not support adding new content. */ public boolean hidden; diff --git a/core/src/mindustry/ui/dialogs/ModsDialog.java b/core/src/mindustry/ui/dialogs/ModsDialog.java index f674fa5f86..4695091886 100644 --- a/core/src/mindustry/ui/dialogs/ModsDialog.java +++ b/core/src/mindustry/ui/dialogs/ModsDialog.java @@ -162,11 +162,17 @@ public class ModsDialog extends BaseDialog{ }}).size(h - 8f).padTop(-8f).padLeft(-8f).padRight(8f); title.table(text -> { - text.add("" + mod.meta.displayName() + "\n[lightgray]v" + mod.meta.version + (mod.enabled() ? "" : "\n" + Core.bundle.get("mod.disabled") + "")) + boolean hideDisabled = !mod.isSupported() || mod.hasUnmetDependencies() || mod.hasContentErrors(); + + text.add("" + mod.meta.displayName() + "\n[lightgray]v" + mod.meta.version + (mod.enabled() || hideDisabled ? "" : "\n" + Core.bundle.get("mod.disabled") + "")) .wrap().top().width(300f).growX().left(); text.row(); - if(!mod.isSupported()){ + + if(mod.isOutdated()){ + text.labelWrap("@mod.outdated").growX(); + text.row(); + }else if(!mod.isSupported()){ text.labelWrap(Core.bundle.format("mod.requiresversion", mod.meta.minGameVersion)).growX(); text.row(); }else if(mod.hasUnmetDependencies()){ diff --git a/desktop/src/mindustry/desktop/DesktopLauncher.java b/desktop/src/mindustry/desktop/DesktopLauncher.java index a2f6db7d56..bd9ec3e81b 100644 --- a/desktop/src/mindustry/desktop/DesktopLauncher.java +++ b/desktop/src/mindustry/desktop/DesktopLauncher.java @@ -170,11 +170,11 @@ public class DesktopLauncher extends ClientLauncher{ String finalMessage = Strings.getFinalMesage(e); String total = Strings.getCauses(e).toString(); - if(total.contains("Couldn't create window") || total.contains("OpenGL 2.0 or higher") || total.toLowerCase().contains("pixel format") || total.contains("GLEW")){ + if(total.contains("Couldn't create window") || total.contains("OpenGL 2.0 or higher") || total.toLowerCase().contains("pixel format") || total.contains("GLEW")|| total.contains("unsupported combination of formats")){ dialog.get(() -> message( total.contains("Couldn't create window") ? "A graphics initialization error has occured! Try to update your graphics drivers:\n" + finalMessage : - "Your graphics card does not support OpenGL 2.0 with the framebuffer_object extension!\n" + + "Your graphics card does not support the right OpenGL features.\n" + "Try to update your graphics drivers. If this doesn't work, your computer may not support Mindustry.\n\n" + "Full message: " + finalMessage)); badGPU = true;