1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-11 08:15:35 +03:00

Faster, smaller server / Bundle check cleanup

This commit is contained in:
Anuken 2019-03-09 19:12:54 -05:00
parent 2a35e22dd2
commit a0905d5695
14 changed files with 124 additions and 77 deletions

1
.gitignore vendored
View File

@ -28,6 +28,7 @@ logs/
/ios/src/io/anuke/mindustry/gen/
/core/src/io/anuke/mindustry/gen/
ios/robovm.properties
packr-out/
config/
*.gif

View File

@ -19,8 +19,8 @@ public class Zones implements ContentList{
public void load(){
groundZero = new Zone("groundZero", new MapGenerator("groundZero", 1)){{
baseLaunchCost = ItemStack.with(Items.copper, -50);
startingItems = ItemStack.list(Items.copper, 50);
baseLaunchCost = ItemStack.with(Items.copper, -100);
startingItems = ItemStack.list(Items.copper, 100);
alwaysUnlocked = true;
conditionWave = 5;
launchPeriod = 5;

View File

@ -39,6 +39,8 @@ public class BundleLoader{
}
private static void loadBundle(){
if(headless) return;
try{
//try loading external bundle
FileHandle handle = Core.files.local("bundle");

View File

@ -5,8 +5,6 @@ import io.anuke.arc.collection.Array;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Log;
import io.anuke.arc.util.Strings;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.mindustry.graphics.Pal;
@ -42,11 +40,6 @@ public class Item extends UnlockableContent implements Comparable<Item>{
super(name);
this.color = color;
this.description = Core.bundle.getOrNull("item." + this.name + ".description");
if(!Core.bundle.has("item." + this.name + ".name")){
Log.err("Warning: item '" + name + "' is missing a localized name. Add the following to bundle.properties:");
Log.err("item." + this.name + ".name = " + Strings.capitalize(name.replace('-', '_')));
}
}
public void load(){

View File

@ -5,8 +5,6 @@ import io.anuke.arc.collection.ObjectSet;
import io.anuke.arc.function.Supplier;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Log;
import io.anuke.arc.util.Strings;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.entities.traits.TypeTrait;
import io.anuke.mindustry.entities.type.BaseUnit;
@ -46,11 +44,6 @@ public class UnitType extends UnlockableContent{
this.description = Core.bundle.getOrNull("unit." + name + ".description");
TypeTrait.registerType(type, mainConstructor);
if(!Core.bundle.has("unit." + this.name + ".name")){
Log.err("Warning: unit '" + name + "' is missing a localized name. Add the follow to bundle.properties:");
Log.err("unit." + this.name + ".name=" + Strings.capitalize(name.replace('-', '_')));
}
}
@Override

View File

@ -1,20 +1,14 @@
package io.anuke.mindustry.world.meta;
import io.anuke.arc.Core;
import io.anuke.arc.collection.ObjectMap.Entry;
import io.anuke.arc.collection.OrderedMap;
import io.anuke.arc.util.Log;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.meta.values.*;
import java.util.Locale;
/**Hold and organizes a list of block stats.*/
public class BlockStats{
private static final boolean errorWhenMissing = false;
private final OrderedMap<StatCategory, OrderedMap<BlockStat, StatValue>> map = new OrderedMap<>();
private boolean dirty;
@ -50,22 +44,6 @@ public class BlockStats{
/**Adds a stat value.*/
public void add(BlockStat stat, StatValue value){
if(!Core.bundle.has("blocks." + stat.name().toLowerCase(Locale.ROOT))){
if(!errorWhenMissing){
Log.err("Warning: No bundle entry for stat type \"" + stat + "\"!");
}else{
throw new RuntimeException("No bundle entry for stat type \"" + stat + "\"!");
}
}
if(!Core.bundle.has("category." + stat.category.name().toLowerCase(Locale.ROOT))){
if(!errorWhenMissing){
Log.err("Warning: No bundle entry for stat category \"" + stat.category + "\"!");
}else{
throw new RuntimeException("No bundle entry for stat category \"" + stat.category + "\"!");
}
}
if(map.containsKey(stat.category) && map.get(stat.category).containsKey(stat)){
throw new RuntimeException("Duplicate stat entry: \"" + stat + "\" in block.");
}

View File

@ -16,10 +16,6 @@ public class NumberValue implements StatValue{
public NumberValue(float value, StatUnit unit){
this.unit = unit;
this.value = value;
if(unit != StatUnit.none && unit.localized().contains("???")){
throw new RuntimeException("No bundle definition found for unit: '" + unit + "'");
}
}
@Override

View File

@ -6,25 +6,24 @@ sourceSets.main.java.srcDirs = ["src/"]
project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../core/assets")
def PACKR_DIR = "$System.env.PACKR_DIR"
import com.badlogicgames.packr.PackrConfig
import com.badlogicgames.packr.Packr
def JDK_DIR = "$System.env.PACKR_DIR"
def ICON_DIR = new File("core/assets/sprites/icon.icns")
ext.getPlatform = {
if(project.hasProperty("platform")){
def lc = platform.toLowerCase()
if(lc == "windows64"){
return "windows64"
}else if(lc == "windows32"){
return "windows32"
}else if(lc == "linux"){
return "linux64"
}else if(lc == "mac"){
return "mac"
}else{
throw new InvalidUserDataException("Invalid platform. Set platform with -Pplatform=windows/linux/mac")
}
def lc = project.hasProperty("platform") ? platform.toLowerCase() : ""
if(lc == "windows64"){
return PackrConfig.Platform.Windows64
}else if(lc == "windows32"){
return PackrConfig.Platform.Windows32
}else if(lc == "linux"){
return PackrConfig.Platform.Linux64
}else if(lc == "mac"){
return PackrConfig.Platform.MacOS
}else{
throw new InvalidUserDataException("No platform defined. Set platform with -Pplatform=windows/linux/mac")
throw new InvalidUserDataException("Invalid platform. Set platform with -Pplatform=windows64/windows32/linux/mac")
}
}
@ -80,27 +79,26 @@ task clearOut(type: Delete){
task packrCmd(){
doLast{
def config = new PackrConfig()
config.with{
config.executable = appName
verbose = true
platform = getPlatform()
bundleIdentifier = getPackage() + ".mac"
iconResource = ICON_DIR
outDir = file("packr-out/")
mainClass = project.ext.mainClassName
classpath = ["desktop/build/libs/desktop-release.jar"]
vmArgs = ["Djava.net.preferIPv4Stack=true"]
minimizeJre = "desktop/packr_minimize.json"
jdk = JDK_DIR + "jdk-${getPlatform().toString().toLowerCase()}.zip"
copy{
into PACKR_DIR
from "build/libs/desktop-release.jar"
if(getPlatform() == PackrConfig.Platform.MacOS){
vmArgs += "XstartOnFirstThread"
}
}
exec{
commandLine("java", "-jar", PACKR_DIR + "packr.jar",
"--verbose",
"--bundle", getPackage() + ".mac",
"--platform", getPlatform(),
"--executable", appName,
"--output", "packr-out/",
"--mainclass", project.ext.mainClassName,
"--jdk", PACKR_DIR + "jdk-" + getPlatform() + ".zip",
"--icon", ICON_DIR.getAbsolutePath(),
"--vmargs", (getPlatform() == "mac" ? "XstartOnFirstThread" : "Xms256m"),
"Djava.net.preferIPv4Stack=true",
"--classpath", "--", PACKR_DIR + "config.json")
}
new Packr().pack(config)
}
}
@ -121,13 +119,13 @@ task fixWindows32(type: Copy){
dependsOn "packrCmd"
into "packr-out/jre/bin/"
from PACKR_DIR + "zip.dll"
from JDK_DIR + "zip.dll"
rename("zip.dll", "ojdkbuild_zlib.dll")
doLast{
copy{
into "packr-out/jre/bin/"
from PACKR_DIR + "zip.dll"
from JDK_DIR + "zip.dll"
}
}
}

View File

@ -0,0 +1,82 @@
{
"reduce": [
{
"archive": "jre/lib/rt.jar",
"paths": [
"javax/transaction",
"javax/tools",
"javax/swing",
"javax/sql",
"javax/smartcardio",
"javax/rmi",
"javax/print",
"javax/naming",
"javax/management",
"javax/lang",
"javax/jws",
"javax/swing",
"javax/imageio",
"javax/annotation",
"javax/activity",
"javax/activation",
"javax/accessibility",
"com/sun/corba",
"com/sun/jmx",
"com/sun/jndi",
"com/sun/xml",
"com/sun/script",
"com/sun/media",
"com/sun/naming",
"java/awt",
"com/sun/org/apache/xpath",
"com/sun/rowset",
"com/sun/script",
"sun/applet",
"sun/corba",
"sun/management"
]
},
{
"archive": "jre/lib/charsets.jar",
"paths": [
]
},
{
"archive": "jre/lib/jsse.jar",
"paths": [
]
},
{
"archive": "jre/lib/resources.jar",
"paths": [
]
}
],
"remove": [
{
"platform": "*",
"paths": [
"jre/lib/rhino.jar"
]
},
{
"platform": "linux",
"paths": [
"jre/lib/amd64/libawt.so",
"jre/lib/amd64/libawt_xawt.so",
"jre/lib/amd64/libjawt.so"
]
},
{
"platform": "windows",
"paths": [
"jre/bin/*.exe",
"jre/bin/client",
"jre/bin/awt.dll"
]
}
]
}

View File

@ -31,6 +31,10 @@ task dist(type: Jar) {
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir)
exclude("sprites/**")
exclude("fonts/**")
exclude("com/badlogic/gdx/**")
exclude("bundles/**")
writeVersion()