Skip to content

Commit

Permalink
Merge branch 'Anuken:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dloe authored Sep 12, 2024
2 parents ab540c8 + 375d0c7 commit bbc24ab
Show file tree
Hide file tree
Showing 311 changed files with 14,365 additions and 7,184 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ body:
required: true
- label: I have searched the closed and open issues to make sure that this problem has not already been reported.
required: true
- label: "I am not using Foo's Client, and have made sure the bug is not caused by mods I have installed."
required: true
10 changes: 10 additions & 0 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Validate Gradle Wrapper"
on: [push, pull_request]

jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run unit tests
run: ./gradlew clean cleanTest test --stacktrace
run: ./gradlew tests:test --stacktrace --rerun
- name: Run unit tests and build JAR
run: ./gradlew desktop:dist
- name: Upload desktop JAR for testing
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
if [ -n "$(git status --porcelain)" ]; then
git config --global user.name "Github Actions"
git config --global user.email "[email protected]"
git add core/assets/bundles/*
git commit -m "Automatic bundle update"
git push
Expand All @@ -42,7 +43,7 @@ jobs:
if: ${{ github.repository == 'Anuken/Mindustry' }}
run: |
git config --global user.name "Github Actions"
git config --global user.email "cli@github.com"
git config --global user.email "actions@github.com"
cd ../
cp -r ./Mindustry ./MindustryJitpack
cd MindustryJitpack
Expand All @@ -57,4 +58,4 @@ jobs:
git push https://Anuken:${{ secrets.API_TOKEN_GITHUB }}@github.com/Anuken/MindustryJitpack
cd ../Mindustry
- name: Run unit tests
run: ./gradlew clean cleanTest test --stacktrace
run: ./gradlew tests:test --rerun --stacktrace
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ See [CONTRIBUTING](CONTRIBUTING.md).
Bleeding-edge builds are generated automatically for every commit. You can see them [here](https://github.com/Anuken/MindustryBuilds/releases).

If you'd rather compile on your own, follow these instructions.
First, make sure you have [JDK 16-17](https://adoptium.net/archive.html?variant=openjdk17&jvmVariant=hotspot) installed. **Other JDK versions will not work.** Open a terminal in the Mindustry directory and run the following commands:
First, make sure you have [JDK 17](https://adoptium.net/archive.html?variant=openjdk17&jvmVariant=hotspot) installed. **Other JDK versions will not work.** Open a terminal in the Mindustry directory and run the following commands:

### Windows

Expand Down
9 changes: 6 additions & 3 deletions SERVERLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ You'll need to either hire some moderators, or make use of (currently non-existe
4. **Get some good maps.** *(optional, but highly recommended)*. Add some maps to your server and set the map rotation to custom-only. You can get maps from the Steam workshop by subscribing and exporting them; using the `#maps` channel on Discord is also an option.
5. **Check your server configuration.** *(optional)* I would recommend adding a message rate limit of 1 second (`config messageRateLimit 1`), and disabling connect/disconnect messages to reduce spam (`config showConnectMessages false`).
6. Finally, **submit a pull request** to add your server's IP to the list.
This should be fairly straightforward: Press the edit button on the [server file](https://github.com/Anuken/Mindustry/blob/master/servers_v7.json), then add a JSON object with a single key, indicating your server address.
For example, if your server address is `example.com:6000`, you would add a comma after the last entry and insert:
This should be fairly straightforward: Press the edit button on the [server file](https://github.com/Anuken/Mindustry/blob/master/servers_v7.json), then add a JSON object with the following format:
```json
{
"address": "example.com:6000"
"name": "Your Server Group Name",
"address": ["your.server.address"]
}
```

If your group has multiple servers, simply add extra addresses inside the square brackets, separated by commas. For example: `["address1", "address2"]`

> Note that Mindustry also support SRV records. This allows you to use a subdomain for your server address instead of specifying the port. For example, if you want to use `play.example.com` instead of `example.com:6000`, in the dns settings of your domain, add an SRV record with `_mindustry` as the service, `tcp` as the protocol, `play` as the target and `6000` as the port. You can also setup fallback servers by modifying the weight or priority of the record. Although SRV records are very convenient, keep in mind they are slower than regular addresses. Avoid using them in the server list, but rather as an easy way to share your server address.

Then, press the *'submit pull request'* button and I'll take a look at your server. If I have any issues with it, I'll let you know in the PR comments.
3 changes: 1 addition & 2 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.anuke.mindustry">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-feature android:name="android.hardware.type.pc" android:required="false" />
Expand Down
13 changes: 8 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript{
}

dependencies{
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:8.2.2'
}
}

Expand All @@ -29,8 +29,9 @@ task deploy(type: Copy){
}

android{
buildToolsVersion '33.0.2'
compileSdkVersion 33
namespace = "io.anuke.mindustry"
buildToolsVersion = '34.0.0'
compileSdk = 34
sourceSets{
main{
manifest.srcFile 'AndroidManifest.xml'
Expand All @@ -56,7 +57,7 @@ android{

applicationId "io.anuke.mindustry"
minSdkVersion 14
targetSdkVersion 33
targetSdkVersion 34

versionName versionNameResult
versionCode = vcode
Expand All @@ -65,14 +66,16 @@ android{
props['androidBuildCode'] = (vcode + 1).toString()
}
props.store(file('../core/assets/version.properties').newWriter(), null)

multiDexEnabled true
}

compileOptions{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

flavorDimensions "google"
flavorDimensions = ["google"]

signingConfigs{
release{
Expand Down
5 changes: 3 additions & 2 deletions android/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
-dontobfuscate

#these are essential packages that should not be "optimized" in any way
#the main purpose of d8 here is to shrink the absurdly-large google play games libraries
-keep class mindustry.** { *; }
-keep class arc.** { *; }
-keep class net.jpountz.** { *; }
-keep class rhino.** { *; }
-keep class com.android.dex.** { *; }
-keepattributes Signature,*Annotation*,InnerClasses,EnclosingMethod

-dontwarn javax.naming.**

#-printusage out.txt
111 changes: 59 additions & 52 deletions android/src/mindustry/android/AndroidLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public void shareFile(Fi file){

@Override
public ClassLoader loadJar(Fi jar, ClassLoader parent) throws Exception{
//Required to load jar files in Android 14: https://developer.android.com/about/versions/14/behavior-changes-14#safer-dynamic-code-loading
jar.file().setReadOnly();
return new DexClassLoader(jar.file().getPath(), getFilesDir().getPath(), null, parent){
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException{
Expand Down Expand Up @@ -101,64 +103,68 @@ public void showFileChooser(boolean open, String title, String extension, Cons<F
}

void showFileChooser(boolean open, String title, Cons<Fi> cons, String... extensions){
String extension = extensions[0];

if(VERSION.SDK_INT >= VERSION_CODES.Q){
Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType(extension.equals("zip") && !open && extensions.length == 1 ? "application/zip" : "*/*");

addResultListener(i -> startActivityForResult(intent, i), (code, in) -> {
if(code == Activity.RESULT_OK && in != null && in.getData() != null){
Uri uri = in.getData();

if(uri.getPath().contains("(invalid)")) return;

Core.app.post(() -> Core.app.post(() -> cons.get(new Fi(uri.getPath()){
@Override
public InputStream read(){
try{
return getContentResolver().openInputStream(uri);
}catch(IOException e){
throw new ArcRuntimeException(e);
try{
String extension = extensions[0];

if(VERSION.SDK_INT >= VERSION_CODES.Q){
Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType(extension.equals("zip") && !open && extensions.length == 1 ? "application/zip" : "*/*");

addResultListener(i -> startActivityForResult(intent, i), (code, in) -> {
if(code == Activity.RESULT_OK && in != null && in.getData() != null){
Uri uri = in.getData();

if(uri.getPath().contains("(invalid)")) return;

Core.app.post(() -> Core.app.post(() -> cons.get(new Fi(uri.getPath()){
@Override
public InputStream read(){
try{
return getContentResolver().openInputStream(uri);
}catch(IOException e){
throw new ArcRuntimeException(e);
}
}
}

@Override
public OutputStream write(boolean append){
try{
return getContentResolver().openOutputStream(uri);
}catch(IOException e){
throw new ArcRuntimeException(e);

@Override
public OutputStream write(boolean append){
try{
return getContentResolver().openOutputStream(uri);
}catch(IOException e){
throw new ArcRuntimeException(e);
}
}
}
})));
}
});
}else if(VERSION.SDK_INT >= VERSION_CODES.M && !(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
})));
}
});
}else if(VERSION.SDK_INT >= VERSION_CODES.M && !(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
chooser = new FileChooser(title, file -> Structs.contains(extensions, file.extension().toLowerCase()), open, file -> {
if(!open){
cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension));
}else{
cons.get(file);
}
});
chooser = new FileChooser(title, file -> Structs.contains(extensions, file.extension().toLowerCase()), open, file -> {
if(!open){
cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension));
}else{
cons.get(file);
}
});

ArrayList<String> perms = new ArrayList<>();
if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
perms.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
perms.add(Manifest.permission.READ_EXTERNAL_STORAGE);
}
requestPermissions(perms.toArray(new String[0]), PERMISSION_REQUEST_CODE);
}else{
if(open){
new FileChooser(title, file -> Structs.contains(extensions, file.extension().toLowerCase()), true, cons).show();
ArrayList<String> perms = new ArrayList<>();
if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
perms.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
perms.add(Manifest.permission.READ_EXTERNAL_STORAGE);
}
requestPermissions(perms.toArray(new String[0]), PERMISSION_REQUEST_CODE);
}else{
super.showFileChooser(open, "@open", extension, cons);
if(open){
new FileChooser(title, file -> Structs.contains(extensions, file.extension().toLowerCase()), true, cons).show();
}else{
super.showFileChooser(open, "@open", extension, cons);
}
}
}catch(Throwable error){
Core.app.post(() -> Vars.ui.showException(error));
}
}

Expand All @@ -180,6 +186,7 @@ public void endForceLandscape(){
}, new AndroidApplicationConfiguration(){{
useImmersiveMode = true;
hideStatusBar = true;
useGL30 = true;
}});
checkFiles(getIntent());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,89 +851,6 @@ public void process(RoundEnvironment env) throws Exception{
for(TypeSpec.Builder b : baseClasses){
write(b, imports.toSeq());
}

//TODO nulls were an awful idea
//store nulls
TypeSpec.Builder nullsBuilder = TypeSpec.classBuilder("Nulls").addModifiers(Modifier.PUBLIC).addModifiers(Modifier.FINAL);
//TODO should be dynamic
ObjectSet<String> nullList = ObjectSet.with("unit");

//create mock types of all components
for(Stype interf : allInterfaces){
//indirect interfaces to implement methods for
Seq<Stype> dependencies = interf.allInterfaces().add(interf);
Seq<Smethod> methods = dependencies.flatMap(Stype::methods);
methods.sortComparing(Object::toString);

//optionally add superclass
Stype superclass = dependencies.map(this::interfaceToComp).find(s -> s != null && s.annotation(Component.class).base());
//use the base type when the interface being emulated has a base
TypeName type = superclass != null && interfaceToComp(interf).annotation(Component.class).base() ? tname(baseName(superclass)) : interf.tname();

//used method signatures
ObjectSet<String> signatures = new ObjectSet<>();

//create null builder
String baseName = interf.name().substring(0, interf.name().length() - 1);

//prevent Nulls bloat
if(!nullList.contains(Strings.camelize(baseName))){
continue;
}

String className = "Null" + baseName;
TypeSpec.Builder nullBuilder = TypeSpec.classBuilder(className)
.addModifiers(Modifier.FINAL);

skipDeprecated(nullBuilder);

nullBuilder.addSuperinterface(interf.tname());
if(superclass != null) nullBuilder.superclass(tname(baseName(superclass)));

for(Smethod method : methods){
String signature = method.toString();
if(!signatures.add(signature)) continue;

Stype compType = interfaceToComp(method.type());
MethodSpec.Builder builder = MethodSpec.overriding(method.e).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
int index = 0;
for(ParameterSpec spec : builder.parameters){
Reflect.set(spec, "name", "arg" + index++);
}
builder.addAnnotation(OverrideCallSuper.class); //just in case

if(!method.isVoid()){
String methodName = method.name();
switch(methodName){
case "isNull":
builder.addStatement("return true");
break;
case "id":
builder.addStatement("return -1");
break;
case "toString":
builder.addStatement("return $S", className);
break;
default:
Svar variable = compType == null || method.params().size > 0 ? null : compType.fields().find(v -> v.name().equals(methodName));
String desc = variable == null ? null : variable.descString();
if(variable == null || !varInitializers.containsKey(desc)){
builder.addStatement("return " + getDefault(method.ret().toString()));
}else{
String init = varInitializers.get(desc);
builder.addStatement("return " + (init.equals("{}") ? "new " + variable.mirror().toString() : "") + init);
}
}
}
nullBuilder.addMethod(builder.build());
}

nullsBuilder.addField(FieldSpec.builder(type, Strings.camelize(baseName)).initializer("new " + className + "()").addModifiers(Modifier.FINAL, Modifier.STATIC, Modifier.PUBLIC).build());

write(nullBuilder, imports.toSeq());
}

write(nullsBuilder);
}
}

Expand Down
Loading

0 comments on commit bbc24ab

Please sign in to comment.