Added min-game-version 105 enforcement

This commit is contained in:
Anuken
2020-09-09 16:40:08 -04:00
parent 6787bbdc05
commit c03e3f56aa
8 changed files with 60 additions and 11 deletions

View File

@@ -114,6 +114,7 @@ mod.disable = Disable
mod.content = Content: mod.content = Content:
mod.delete.error = Unable to delete mod. File may be in use. mod.delete.error = Unable to delete mod. File may be in use.
mod.requiresversion = [scarlet]Requires min game version: [accent]{0} 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.missingdependencies = [scarlet]Missing dependencies: {0}
mod.erroredcontent = [scarlet]Content Errors mod.erroredcontent = [scarlet]Content Errors
mod.errors = Errors have occurred loading content. mod.errors = Errors have occurred loading content.

View File

@@ -1210,6 +1210,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
if(sensor == LAccess.y) return y; if(sensor == LAccess.y) return y;
if(sensor == LAccess.team) return team.id; if(sensor == LAccess.team) return team.id;
if(sensor == LAccess.health) return health; if(sensor == LAccess.health) return health;
if(sensor == LAccess.maxHealth) return maxHealth();
if(sensor == LAccess.efficiency) return efficiency(); if(sensor == LAccess.efficiency) return efficiency();
if(sensor == LAccess.rotation) return rotation; if(sensor == LAccess.rotation) return rotation;
if(sensor == LAccess.totalItems && items != null) return items.total(); if(sensor == LAccess.totalItems && items != null) return items.total();

View File

@@ -75,6 +75,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
if(sensor == LAccess.totalItems) return stack().amount; if(sensor == LAccess.totalItems) return stack().amount;
if(sensor == LAccess.rotation) return rotation; if(sensor == LAccess.rotation) return rotation;
if(sensor == LAccess.health) return health; if(sensor == LAccess.health) return health;
if(sensor == LAccess.maxHealth) return maxHealth;
if(sensor == LAccess.x) return x; if(sensor == LAccess.x) return x;
if(sensor == LAccess.y) return y; if(sensor == LAccess.y) return y;
if(sensor == LAccess.team) return team.id; if(sensor == LAccess.team) return team.id;

View File

@@ -15,6 +15,7 @@ public enum LAccess{
powerNetIn, powerNetIn,
powerNetOut, powerNetOut,
health, health,
maxHealth,
heat, heat,
efficiency, efficiency,
rotation, rotation,

View File

@@ -493,7 +493,9 @@ public class LExecutor{
//this should avoid any garbage allocation //this should avoid any garbage allocation
Var v = exec.vars[value]; Var v = exec.vars[value];
if(v.isobj && value != 0){ 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 Content ? "[content]" :
v.objval instanceof Building ? "[building]" : v.objval instanceof Building ? "[building]" :
v.objval instanceof Unit ? "[unit]" : v.objval instanceof Unit ? "[unit]" :

View File

@@ -707,14 +707,51 @@ public class Mods implements Loadable{
/** @return whether this mod is supported by the game verison */ /** @return whether this mod is supported by the game verison */
public boolean isSupported(){ public boolean isSupported(){
if(Version.build <= 0 || meta.minGameVersion == null) return true; if(isOutdated()) return false;
if(meta.minGameVersion.contains(".")){
String[] split = meta.minGameVersion.split("\\."); 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){ 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 @Override
@@ -792,7 +829,7 @@ public class Mods implements Loadable{
/** Mod metadata information.*/ /** Mod metadata information.*/
public static class ModMeta{ 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<String> dependencies = Seq.with(); public Seq<String> dependencies = Seq.with();
/** Hidden mods are only server-side or client-side, and do not support adding new content. */ /** Hidden mods are only server-side or client-side, and do not support adding new content. */
public boolean hidden; public boolean hidden;

View File

@@ -162,11 +162,17 @@ public class ModsDialog extends BaseDialog{
}}).size(h - 8f).padTop(-8f).padLeft(-8f).padRight(8f); }}).size(h - 8f).padTop(-8f).padLeft(-8f).padRight(8f);
title.table(text -> { 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(); .wrap().top().width(300f).growX().left();
text.row(); 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.labelWrap(Core.bundle.format("mod.requiresversion", mod.meta.minGameVersion)).growX();
text.row(); text.row();
}else if(mod.hasUnmetDependencies()){ }else if(mod.hasUnmetDependencies()){

View File

@@ -170,11 +170,11 @@ public class DesktopLauncher extends ClientLauncher{
String finalMessage = Strings.getFinalMesage(e); String finalMessage = Strings.getFinalMesage(e);
String total = Strings.getCauses(e).toString(); 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( dialog.get(() -> message(
total.contains("Couldn't create window") ? "A graphics initialization error has occured! Try to update your graphics drivers:\n" + finalMessage : 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" + "Try to update your graphics drivers. If this doesn't work, your computer may not support Mindustry.\n\n" +
"Full message: " + finalMessage)); "Full message: " + finalMessage));
badGPU = true; badGPU = true;