Fixed rare network error

This commit is contained in:
Anuken
2021-02-12 14:54:10 -05:00
parent abd07e1525
commit 146b2589e2
3 changed files with 43 additions and 41 deletions

View File

@ -27,7 +27,7 @@ public class UnitBlock extends PayloadAcceptor{
@Remote(called = Loc.server)
public static void unitBlockSpawn(Tile tile){
if(!(tile.build instanceof UnitBuild build)) return;
if(tile == null || !(tile.build instanceof UnitBuild build)) return;
build.spawned();
}

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=afbb1f5080df42d0629d5997a3f1b14dafc467bf
archash=eac865a8a0f4fde121fdcd8850d9f039f725b546

View File

@ -31,11 +31,20 @@ public class BindingsGenerator{
for(Class<?> type : classes){
String name = type.getCanonicalName();
result.append("jclass ").append(name).append("* of ")
.append(type.getSuperclass() == null ? "JVMObject" : type.getSuperclass().getSimpleName()).append(":\n");
for(Field field : type.getFields()){
if(Modifier.isPublic(field.getModifiers())){
Seq<Executable> exec = new Seq<>();
exec.addAll(type.getDeclaredMethods());
exec.addAll(type.getDeclaredConstructors());
exec.removeAll(e -> !Modifier.isPublic(e.getModifiers()));
Seq<Field> fields = Seq.select(type.getDeclaredFields(), f -> Modifier.isPublic(f.getModifiers()));
result.append("jclass ").append(name).append(" of `")
.append(type.getSuperclass() == null ? "JVMObject" : type.getSuperclass().getSimpleName()).append("`").append(exec.size + fields.size > 0 ? ":" : "").append("\n");
for(Field field : fields){
result.append(" proc `").append(field.getName()).append("`*");
result.append(": ").append(str(field.getType()));
result.append(" {.prop");
@ -43,17 +52,10 @@ public class BindingsGenerator{
if(Modifier.isStatic(field.getModifiers())) result.append(", `final`");
result.append(".}\n");
}
}
Seq<Executable> exec = new Seq<>();
exec.addAll(type.getDeclaredMethods());
exec.addAll(type.getDeclaredConstructors());
for(Executable method : exec){
if(Modifier.isPublic(method.getModifiers())){
String mname = method.getName().equals("<init>") || method.getName().equals(type.getCanonicalName()) ? "new" : method.getName();
result.append(" proc `").append(mname).append("`*");
result.append(" proc `").append(mname).append("`");
if(method.getParameterCount() > 0){
result.append("(");
@ -84,11 +86,11 @@ public class BindingsGenerator{
//result.append(".}\n");
result.append("\n");
}
}
result.append("\n");
}
Fi.get(OS.userhome).child("mindustry.nim").writeString(result.toString());
Fi.get("/home/anuke/Projects/Nimdustry-java/mindustry_bindings.nim").writeString(result.toString());
//Fi.get(OS.userhome).child("mindustry.nim").writeString(result.toString());
Log.info(result);
}