Compare commits

..

13 Commits

Author SHA1 Message Date
Anuken
63b92e6dd6 Better caching 2024-01-28 12:54:16 -05:00
Anuken
3be67aa52a No main executor call 2024-01-28 11:31:03 -05:00
Anuken
a73b783d98 SRV support 2024-01-27 17:46:52 -05:00
Anuken
db4c861dde AAAA record support 2024-01-27 12:50:26 -05:00
Anuken
c7a35ae789 IPv6 address support 2024-01-27 11:15:58 -05:00
Anuken
3e5ad07e8c Merge branch 'master' of https://github.com/Anuken/Mindustry into async-ping
 Conflicts:
	core/src/mindustry/net/ArcNetProvider.java
	gradle.properties
2024-01-27 10:11:09 -05:00
Anuken
584b22300d a few comments 2023-05-09 16:45:46 -04:00
Anuken
6eb049c419 Merge branch 'master' of https://github.com/Anuken/Mindustry into async-ping 2023-05-09 16:45:42 -04:00
Anuken
6be497878c cleanup 2023-02-26 15:44:51 -05:00
Anuken
8e9b409b63 cleanup 2023-02-26 15:41:49 -05:00
Anuken
b496e8457c it works minus SRV 2023-02-26 15:32:35 -05:00
Anuken
41b87b9345 static 2023-02-26 12:06:06 -05:00
Anuken
84e52bdee3 async UDP ping 2023-02-26 11:40:53 -05:00
1236 changed files with 22571 additions and 50736 deletions

View File

@@ -72,5 +72,3 @@ 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

View File

@@ -73,7 +73,7 @@ jobs:
cd ../MindustryBuilds
echo "Updating version to ${RELEASE_VERSION:1}"
BNUM=$(($GITHUB_RUN_NUMBER + 1000))
echo versionName=8-fdroid-${RELEASE_VERSION:1}$'\n'versionCode=${BNUM} > version_fdroid.txt
echo versionName=7-fdroid-${RELEASE_VERSION:1}$'\n'versionCode=${BNUM} > version_fdroid.txt
git add .
git commit -m "Updating to build ${RELEASE_VERSION:1}"
git push https://Anuken:${{ secrets.API_TOKEN_GITHUB }}@github.com/Anuken/MindustryBuilds

View File

@@ -1,10 +0,0 @@
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

View File

@@ -18,11 +18,11 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run unit tests
run: ./gradlew tests:test --stacktrace --rerun
run: ./gradlew clean cleanTest test --stacktrace
- name: Run unit tests and build JAR
run: ./gradlew desktop:dist
- name: Upload desktop JAR for testing
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v2
with:
name: Desktop JAR (zipped)
path: desktop/build/libs/Mindustry.jar

View File

@@ -34,7 +34,6 @@ jobs:
if [ -n "$(git status --porcelain)" ]; then
git config --global user.name "Github Actions"
git config --global user.email "actions@github.com"
git add core/assets/bundles/*
git commit -m "Automatic bundle update"
git push
@@ -43,7 +42,7 @@ jobs:
if: ${{ github.repository == 'Anuken/Mindustry' }}
run: |
git config --global user.name "Github Actions"
git config --global user.email "actions@github.com"
git config --global user.email "cli@github.com"
cd ../
cp -r ./Mindustry ./MindustryJitpack
cd MindustryJitpack
@@ -58,4 +57,4 @@ jobs:
git push https://Anuken:${{ secrets.API_TOKEN_GITHUB }}@github.com/Anuken/MindustryJitpack
cd ../Mindustry
- name: Run unit tests
run: ./gradlew tests:test --rerun --stacktrace
run: ./gradlew clean cleanTest test --stacktrace

4
.gitignore vendored
View File

@@ -23,7 +23,6 @@ ios/libs/
/tools/build/
/tests/build/
/server/build/
ios/libs/
changelog
saves/
/core/assets-raw/fontgen/out/
@@ -168,6 +167,3 @@ android/libs/
# ignored due to frequent branch conflicts.
core/assets/logicids.dat
# project files for the sectors
core/assets-raw/sprites/ui/sectors/*.json

View File

@@ -13,13 +13,11 @@ If you are submitting a new block, make sure it has a name and description, and
### Do not make large changes before discussing them first.
If you are interested in adding a large mechanic/feature or changing large amounts of code, first contact me (Anuken) via [Discord](https://discord.gg/mindustry) - either via PM or by posting in the `#pulls` channel.
For most changes, this should not be necessary. I just want to know if you're doing something big, so I can offer advice and/or make sure you're not wasting your time on it.
For most changes, this should not be necessary. I just want to know if you're doing something big so I can offer advice and/or make sure you're not wasting your time on it.
### Do not make formatting or "cleanup" PRs.
### Do not make formatting PRs.
Yes, there are occurrences of trailing spaces, extra newlines, empty indents, and other tiny errors. No, I don't want to merge, view, or get notified by your 1-line PR fixing it. If you're implementing a PR with modification of *actual code*, feel free to fix formatting in the general vicinity of your changes, but please don't waste everyone's time with pointless changes.
I **especially** do not want to see PRs that apply any kind of automated analysis to the source code to "optimize" anything - my IDE can do that already. If the PR doesn't actually change anything useful, I'm not going to review or merge it.
## Style Guidelines
### Follow the formatting guidelines.
@@ -36,7 +34,7 @@ This means:
Import [this style file](.github/Mindustry-CodeStyle-IJ.xml) into IntelliJ to get correct formatting when developing Mindustry.
### Do not use incompatible Java features (java.util.function, java.awt, java.lang.Objects).
### Do not use incompatible Java features (java.util.function, java.awt).
Android and RoboVM (iOS) do not support many of Java 8's features, such as the packages `java.util.function`, `java.util.stream` or `forEach` in collections. Do not use these in your code.
If you need to use functional interfaces, use the ones in `arc.func`, which are more or less the same with different naming schemes.
@@ -68,7 +66,7 @@ Otherwise, use the `Tmp` variables for things like vector/shape operations, or c
If using a list, make it a static variable and clear it every time it is used. Re-use as much as possible.
### Avoid bloated code and unnecessary getters/setters.
This is situational, but in essence, what it means is to avoid using any sort of getters and setters unless absolutely necessary. Public or protected fields should suffice for most things.
This is situational, but in essence what it means is to avoid using any sort of getters and setters unless absolutely necessary. Public or protected fields should suffice for most things.
If something needs to be encapsulated in the future, IntelliJ can handle it with a few clicks.

View File

@@ -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 17](https://adoptium.net/temurin/releases/?os=any&arch=any&version=17) 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 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:
### Windows
@@ -53,16 +53,6 @@ To debug the application on a connected device/emulator, run `gradlew android:in
If the terminal returns `Permission denied` or `Command not found` on Mac/Linux, run `chmod +x ./gradlew` before running `./gradlew`. *This is a one-time procedure.*
#### Where is the `mindustry.gen` package?
As the name implies, `mindustry.gen` is generated *at build time* based on other code. You will not find source code for this package in the repository, and it should not be edited by hand.
The following is a non-exhaustive list of the "source" of generated code in `mindustry.gen`:
- `Call`, `*Packet` classes: Generated from methods marked with `@Remote`.
- All entity classes (`Unit`, `EffectState`, `Posc`, etc): Generated from component classes in the `mindustry.entities.comp` package, and combined using definitions in `mindustry.content.UnitTypes`.
- `Sounds`, `Musics`, `Tex`, `Icon`, etc: Generated based on files in the respective asset folders.
---
Gradle may take up to several minutes to download files. Be patient. <br>

View File

@@ -1,3 +1,30 @@
# Note: The v7 server list is frozen. No new servers will be accepted. All v8 server PRs should be made [here](https://github.com/Anuken/MindustryServerList).
### Adding a server to the list
*PRs to edit addresses of existing servers will still be accepted, although very infrequently.*
Mindustry now has a public list of servers that everyone can see and connect to.
This is done by letting clients `GET` a [JSON list of servers](https://github.com/Anuken/Mindustry/blob/master/servers_v7.json) in this repository.
You may want to add your server to this list. The steps for getting this done are as follows:
0. **Take note of the fact that modded servers are not allowed on this list.** Such servers confuse users, and there's currently no easy way to fix mod incompatibilities after a failed connection.
1. **Ensure your server is properly moderated.** For the most part, this applies to survival servers, but PvP servers can be affected as well.
You'll need to either hire some moderators, or make use of (currently non-existent) anti-grief and anti-curse plugins.
*Consider enabling a rate limit:* `config messageRateLimit 2` will make it so that players can only send messages every 2 seconds, for example.
2. Make sure that your server is able to handle inappropriate content - this includes NSFW display/sorter art and abusive messages. **Servers that allow such content will be removed immediately.** Consider banning display blocks if it is a problem for your server: `rules add bannedBlocks ["canvas", "logic-display", "large-logic-display"]`.
3. **Set an appropriate MOTD, name and description.** This is set with `config <name/desc/motd> <value>`. "Appropriate" means that:
- Your name or description must reflect the type of server you're hosting.
Since new players may be exposed to the server list early on, put in a phrase like "Co-op survival" or "PvP" so players know what they're getting into. Yes, this is also displayed in the server mode info text, but having extra info in the name doesn't hurt.
- Make sure players know where to refer to for server support. It should be fairly clear that the server owner is not me, but you.
- Try to be professional in your text; use common sense.
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:
```json
{
"address": "example.com:6000"
}
```
> 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.

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.anuke.mindustry">
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-feature android:name="android.hardware.type.pc" android:required="false" />
@@ -17,8 +18,7 @@
android:usesCleartextTraffic="true"
android:appCategory="game"
android:label="@string/app_name"
android:fullBackupContent="@xml/backup_rules"
android:largeHeap="true">
android:fullBackupContent="@xml/backup_rules">
<meta-data android:name="android.max_aspect" android:value="2.1"/>
<activity
android:name="mindustry.android.AndroidLauncher"

View File

@@ -7,7 +7,7 @@ buildscript{
}
dependencies{
classpath 'com.android.tools.build:gradle:8.2.2'
classpath 'com.android.tools.build:gradle:7.2.1'
}
}
@@ -29,9 +29,8 @@ task deploy(type: Copy){
}
android{
namespace = "io.anuke.mindustry"
buildToolsVersion = '34.0.0'
compileSdk = 34
buildToolsVersion '33.0.2'
compileSdkVersion 33
sourceSets{
main{
manifest.srcFile 'AndroidManifest.xml'
@@ -57,7 +56,7 @@ android{
applicationId "io.anuke.mindustry"
minSdkVersion 14
targetSdkVersion 34
targetSdkVersion 33
versionName versionNameResult
versionCode = vcode
@@ -66,8 +65,6 @@ android{
props['androidBuildCode'] = (vcode + 1).toString()
}
props.store(file('../core/assets/version.properties').newWriter(), null)
multiDexEnabled true
}
compileOptions{
@@ -75,7 +72,7 @@ android{
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions = ["google"]
flavorDimensions "google"
signingConfigs{
release{

View File

@@ -1,13 +1,11 @@
-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.** { *; }
-keep class com.android.dx.** { *; }
-keepattributes Signature,*Annotation*,InnerClasses,EnclosingMethod
-dontwarn javax.naming.**
#-printusage out.txt

View File

@@ -38,7 +38,7 @@ public class AndroidLauncher extends AndroidApplication{
UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler((thread, error) -> {
CrashHandler.log(error);
CrashSender.log(error);
//try to forward exception to system handler
if(handler != null){
@@ -72,9 +72,6 @@ public class AndroidLauncher extends AndroidApplication{
@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
try{
jar.file().setReadOnly();
return new DexClassLoader(jar.file().getPath(), getFilesDir().getPath(), null, parent){
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException{
@@ -96,34 +93,6 @@ public class AndroidLauncher extends AndroidApplication{
return loadedClass;
}
};
}catch(SecurityException e){
//`setReadOnly` to jar file in `/sdcard/Android/data/...` does not work on some Android 14 device
//But in `/data/...` it works
if(Build.VERSION.SDK_INT < VERSION_CODES.O_MR1){
throw e;
}
Fi cacheDir = new Fi(getCacheDir()).child("mods");
cacheDir.mkdirs();
//long file name support
Fi modCacheDir = cacheDir.child(jar.nameWithoutExtension());
Fi modCache = modCacheDir.child(Long.toHexString(jar.lastModified()) + ".zip");
if(modCacheDir.equals(jar.parent())){
//should not reach here, just in case
throw e;
}
//Cache will be deleted when mod is removed
if(!modCache.exists() || jar.length() != modCache.length()){
modCacheDir.mkdirs();
jar.copyTo(modCache);
}
modCache.file().setReadOnly();
return loadJar(modCache, parent);
}
}
@Override
@@ -132,14 +101,12 @@ public class AndroidLauncher extends AndroidApplication{
}
void showFileChooser(boolean open, String title, Cons<Fi> cons, String... extensions){
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" : "*/*");
intent.putExtra(Intent.EXTRA_TITLE, "export." + extension);
addResultListener(i -> startActivityForResult(intent, i), (code, in) -> {
if(code == Activity.RESULT_OK && in != null && in.getData() != null){
@@ -193,9 +160,6 @@ public class AndroidLauncher extends AndroidApplication{
super.showFileChooser(open, "@open", extension, cons);
}
}
}catch(Throwable error){
Core.app.post(() -> Vars.ui.showException(error));
}
}
@Override
@@ -216,7 +180,6 @@ public class AndroidLauncher extends AndroidApplication{
}, new AndroidApplicationConfiguration(){{
useImmersiveMode = true;
hideStatusBar = true;
useGL30 = true;
}});
checkFiles(getIntent());

View File

@@ -54,8 +54,6 @@ public class Annotations{
/** Whether to generate a base class for this components.
* An entity cannot have two base classes, so only one component can have base be true. */
boolean base() default false;
/** Whether to generate a proper interface for this component class. */
boolean genInterface() default true;
}
/** Indicates that a method is implemented by the annotation processor. */
@@ -184,16 +182,18 @@ public class Annotations{
/** A set of two booleans, one specifying server and one specifying client. */
public enum Loc{
/** Server only. */
/** Method can only be invoked on the client from the server. */
server(true, false),
/** Client only. */
/** Method can only be invoked on the server from the client. */
client(false, true),
/** Both server and client. */
/** Method can be invoked from anywhere */
both(true, true),
/** Neither server nor client. */
none(false, false);
/** If true, this method can be invoked ON clients FROM servers. */
public final boolean isServer;
/** If true, this method can be invoked ON servers FROM clients. */
public final boolean isClient;
Loc(boolean server, boolean client){
@@ -222,16 +222,16 @@ public class Annotations{
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.SOURCE)
public @interface Remote{
/** Specifies the locations from which this method can cause remote invocations (This -> Remote) [Default: Server -> Client]. */
/** Specifies the locations from which this method can be invoked. */
Loc targets() default Loc.server;
/** Specifies which methods are generated. Only affects server-to-client methods (Server -> Client(s)) [Default: Server -> Client & Server -> All Clients]. */
/** Specifies which methods are generated. Only affects server-to-client methods. */
Variant variants() default Variant.all;
/** The locations where this method is called locally, when invoked locally (This -> This) [Default: No local invocations]. */
/** The local locations where this method is called locally, when invoked. */
Loc called() default Loc.none;
/** Whether the server should forward this packet to all other clients upon receival from a client (Client -> Server -> Other Clients). [Default: Don't Forward Client Invocations] */
/** Whether to forward this packet to all other clients upon receival. Client only. */
boolean forward() default false;
/**

View File

@@ -19,7 +19,6 @@ import javax.annotation.processing.*;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
import java.lang.annotation.*;
import java.util.*;
@SupportedAnnotationTypes({
"mindustry.annotations.Annotations.EntityDef",
@@ -98,8 +97,6 @@ public class EntityProcess extends BaseProcessor{
//create component interfaces
for(Stype component : allComponents){
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(interfaceName(component))
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
@@ -119,7 +116,6 @@ public class EntityProcess extends BaseProcessor{
inter.addSuperinterface(ClassName.get(packageName, interfaceName(type)));
}
if(component.annotation(Component.class).genInterface()){
ObjectSet<String> signatures = new ObjectSet<>();
//add utility methods to interface
@@ -161,7 +157,6 @@ public class EntityProcess extends BaseProcessor{
.select(a -> a.toString().contains("Null") || a.toString().contains("Deprecated")).map(AnnotationSpec::get)).build()).build());
}
}
}
write(inter);
@@ -421,34 +416,19 @@ public class EntityProcess extends BaseProcessor{
//add all methods from components
for(ObjectMap.Entry<String, Seq<Smethod>> entry : methods){
//there are multiple @Replace implementations, or multiple non-void implementations.
if(entry.value.size > 1 && (entry.value.contains(m -> m.has(Replace.class)) || entry.value.count(m -> !m.isAny(Modifier.NATIVE, Modifier.ABSTRACT) && !m.isVoid()) > 1)){
//remove clutter
entry.value.removeAll(s -> s.is(Modifier.ABSTRACT));
Comparator<Smethod> comp = Structs.comps(
Structs.comps(
//highest priority first
Structs.comparingFloat(m -> m.has(MethodPriority.class) ? m.annotation(MethodPriority.class).value() : 0f),
//replacement means priority
Structs.comparingBool(m -> m.has(Replace.class))
),
//otherwise, the 'highest' subclass (most dependencies)
Structs.comparingInt(m -> getDependencies(m.type()).size)
);
Smethod best = entry.value.max(comp);
if(entry.value.contains(s -> best != s && comp.compare(s, best) == 0)){
err("Type " + type + " has multiple components implementing method " + entry.value.first() + " in an ambiguous way. Use MethodPriority to designate which one should be used. Implementations: " +
entry.value.map(s -> s.descString()));
if(entry.value.contains(m -> m.has(Replace.class))){
//check replacements
if(entry.value.count(m -> m.has(Replace.class)) > 1){
err("Type " + type + " has multiple components replacing method " + entry.key + ".");
}
Smethod base = entry.value.find(m -> m.has(Replace.class));
entry.value.clear();
entry.value.add(base);
}
entry.value.clear();
entry.value.add(best);
//check multi return
if(entry.value.count(m -> !m.isAny(Modifier.NATIVE, Modifier.ABSTRACT) && !m.isVoid()) > 1){
err("Type " + type + " has multiple components implementing non-void method " + entry.key + ".");
}
entry.value.sort(Structs.comps(Structs.comparingFloat(m -> m.has(MethodPriority.class) ? m.annotation(MethodPriority.class).value() : 0), Structs.comparing(s -> s.up().getSimpleName().toString())));
@@ -465,7 +445,6 @@ public class EntityProcess extends BaseProcessor{
MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC);
//if(isFinal || entry.value.contains(s -> s.has(Final.class))) mbuilder.addModifiers(Modifier.FINAL);
if(entry.value.contains(s -> s.has(CallSuper.class))) mbuilder.addAnnotation(CallSuper.class); //add callSuper here if necessary
if(first.has(Nullable.class)) mbuilder.addAnnotation(Nullable.class);
if(first.is(Modifier.STATIC)) mbuilder.addModifiers(Modifier.STATIC);
mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get));
mbuilder.returns(first.retn());
@@ -872,6 +851,89 @@ public class EntityProcess extends BaseProcessor{
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);
}
}

View File

@@ -57,9 +57,6 @@ public class AssetsProcess extends BaseProcessor{
ichtype.addField(FieldSpec.builder(ParameterizedTypeName.get(ObjectIntMap.class, String.class),
"codes", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("new ObjectIntMap<>()").build());
ichtype.addField(FieldSpec.builder(ParameterizedTypeName.get(IntMap.class, String.class),
"codeToName", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("new IntMap<>()").build());
ObjectSet<String> used = new ObjectSet<>();
for(Jval val : icons.get("glyphs").asArray()){
@@ -70,9 +67,7 @@ public class AssetsProcess extends BaseProcessor{
int code = val.getInt("code", 0);
iconcAll.append((char)code);
ichtype.addField(FieldSpec.builder(char.class, name, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).addJavadoc(String.format("\\u%04x", code)).initializer("'" + ((char)code) + "'").build());
ichinit.addStatement("codes.put($S, $L)", name, code);
ichinit.addStatement("codeToName.put($L, $S)", code, name);
ictype.addField(TextureRegionDrawable.class, name + "Small", Modifier.PUBLIC, Modifier.STATIC);
icload.addStatement(name + "Small = mindustry.ui.Fonts.getGlyph(mindustry.ui.Fonts.def, (char)" + code + ")");

View File

@@ -102,7 +102,7 @@ public class StructProcess extends BaseProcessor{
//bools: single bit, needs special case to clear things
setter.beginControlFlow("if(value)");
setter.addStatement("return ($T)($L | (1L << $LL))", structType, structParam, offset);
setter.addStatement("return ($T)(($L & ~(1L << $LL)) | (1L << $LL))", structType, structParam, offset, offset);
setter.nextControlFlow("else");
setter.addStatement("return ($T)(($L & ~(1L << $LL)))", structType, structParam, offset);
setter.endControlFlow();

View File

@@ -28,10 +28,6 @@ public class Stype extends Selement<TypeElement>{
return interfaces().flatMap(s -> s.allInterfaces().add(s)).distinct();
}
public boolean isInterface(){
return e.getKind() == ElementKind.INTERFACE;
}
public Seq<Stype> superclasses(){
return Seq.with(BaseProcessor.typeu.directSupertypes(mirror())).map(Stype::of);
}

View File

@@ -1,5 +1,3 @@
import java.text.SimpleDateFormat
buildscript{
ext{
arcHash = property("archash")
@@ -28,8 +26,8 @@ buildscript{
}
plugins{
id "org.jetbrains.kotlin.jvm" version "2.1.10"
id "org.jetbrains.kotlin.kapt" version "2.1.10"
id "org.jetbrains.kotlin.jvm" version "1.6.0"
id "org.jetbrains.kotlin.kapt" version "1.6.0"
}
allprojects{
@@ -39,8 +37,8 @@ allprojects{
group = 'com.github.Anuken'
ext{
versionNumber = '8'
if(!project.hasProperty("versionModifier")) versionModifier = 'beta'
versionNumber = '7'
if(!project.hasProperty("versionModifier")) versionModifier = 'release'
if(!project.hasProperty("versionType")) versionType = 'official'
appName = 'Mindustry'
steamworksVersion = '0b86023401880bb5e586bc404bedbaae9b1f1c94'
@@ -91,10 +89,6 @@ allprojects{
return project.getProperties()["buildversion"]
}
getCommitHash = {
return 'git rev-parse --verify --short HEAD'.execute().text.trim()
}
getPackage = {
return project.ext.mainClassName.substring(0, project.ext.mainClassName.indexOf("desktop") - 1)
}
@@ -117,7 +111,7 @@ allprojects{
output += name.substring("bundle".length() + 1, name.lastIndexOf('.')) + "\n"
}
new File(project(':core').projectDir, 'assets/locales').text = output
new File(project(':core').projectDir, 'assets/basepartnames').text = new File(project(':core').projectDir, 'assets/baseparts/').list().sort().findAll{f -> f.endsWith(".msch")}.join("\n")
new File(project(':core').projectDir, 'assets/basepartnames').text = new File(project(':core').projectDir, 'assets/baseparts/').list().sort().join("\n")
}
writeVersion = {
@@ -139,11 +133,6 @@ allprojects{
props["number"] = versionNumber
props["modifier"] = versionModifier
props["build"] = buildid
props["buildDate"] = new SimpleDateFormat("MMMM d, yyyy HH:mm a", Locale.getDefault()).format(new Date())
props["commitHash"] = "unknown"
if(project.hasProperty("showCommitHash")){
props["commitHash"] = getCommitHash()
}
props.store(pfile.newWriter(), "Autogenerated file. Do not modify.")
}
@@ -231,7 +220,7 @@ configure(subprojects - project(":annotations")){
tasks.withType(Javadoc){
options{
addStringOption('Xdoclint:none', '-quiet')
addStringOption('-release', '17')
addStringOption('-release', '16')
encoding('UTF-8')
}
}
@@ -244,9 +233,7 @@ project(":desktop"){
dependencies{
implementation project(":core")
implementation arcModule("extensions:profiling")
implementation arcModule("extensions:discord")
implementation arcModule("natives:natives-filedialogs")
implementation arcModule("natives:natives-desktop")
implementation arcModule("natives:natives-freetype-desktop")
@@ -255,7 +242,6 @@ project(":desktop"){
implementation "com.github.Anuken:steamworks4j:$steamworksVersion"
implementation arcModule("backends:backend-sdl")
annotationProcessor 'com.github.Anuken:jabel:0.9.0'
}
}
@@ -266,7 +252,7 @@ project(":core"){
kapt{
javacOptions{
option("-source", "17")
option("-source", "16")
option("-target", "1.8")
}
}
@@ -313,7 +299,7 @@ project(":core"){
task assetsJar(type: Jar, dependsOn: ":tools:pack"){
archiveClassifier = 'assets'
from files("assets"){
exclude "config", "cache", "music", "sounds", "sprites/fallback"
exclude "config", "cache", "music", "sounds"
}
}
@@ -334,7 +320,6 @@ project(":core"){
api arcModule("extensions:g3d")
api arcModule("extensions:fx")
api arcModule("extensions:arcnet")
implementation arcModule("extensions:filedialogs")
api "com.github.Anuken:rhino:$rhinoVersion"
if(localArc && debugged()) api arcModule("extensions:recorder")
if(localArc) api arcModule(":extensions:packer")
@@ -370,6 +355,7 @@ project(":core"){
//these are completely unnecessary
tasks.kaptGenerateStubsKotlin.onlyIf{ false }
tasks.compileKotlin.onlyIf{ false }
tasks.inspectClassesForKotlinIC.onlyIf{ false }
}
//comp** classes are only used for code generation
@@ -384,7 +370,6 @@ project(":server"){
dependencies{
implementation project(":core")
implementation arcModule("backends:backend-headless")
annotationProcessor 'com.github.Anuken:jabel:0.9.0'
}
}
@@ -421,9 +406,6 @@ project(":tools"){
implementation arcModule("natives:natives-desktop")
implementation arcModule("natives:natives-freetype-desktop")
implementation arcModule("backends:backend-headless")
implementation("com.google.guava:guava:33.3.1-jre")
annotationProcessor 'com.github.Anuken:jabel:0.9.0'
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

Some files were not shown because too many files have changed in this diff Show More