Fixed rare network error
This commit is contained in:
@@ -27,7 +27,7 @@ public class UnitBlock extends PayloadAcceptor{
|
|||||||
|
|
||||||
@Remote(called = Loc.server)
|
@Remote(called = Loc.server)
|
||||||
public static void unitBlockSpawn(Tile tile){
|
public static void unitBlockSpawn(Tile tile){
|
||||||
if(!(tile.build instanceof UnitBuild build)) return;
|
if(tile == null || !(tile.build instanceof UnitBuild build)) return;
|
||||||
build.spawned();
|
build.spawned();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=afbb1f5080df42d0629d5997a3f1b14dafc467bf
|
archash=eac865a8a0f4fde121fdcd8850d9f039f725b546
|
||||||
|
|||||||
@@ -31,64 +31,66 @@ public class BindingsGenerator{
|
|||||||
|
|
||||||
for(Class<?> type : classes){
|
for(Class<?> type : classes){
|
||||||
String name = type.getCanonicalName();
|
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())){
|
|
||||||
result.append(" proc `").append(field.getName()).append("`*");
|
|
||||||
result.append(": ").append(str(field.getType()));
|
|
||||||
result.append(" {.prop");
|
|
||||||
if(Modifier.isStatic(field.getModifiers())) result.append(", `static`");
|
|
||||||
if(Modifier.isStatic(field.getModifiers())) result.append(", `final`");
|
|
||||||
result.append(".}\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Seq<Executable> exec = new Seq<>();
|
Seq<Executable> exec = new Seq<>();
|
||||||
|
|
||||||
exec.addAll(type.getDeclaredMethods());
|
exec.addAll(type.getDeclaredMethods());
|
||||||
exec.addAll(type.getDeclaredConstructors());
|
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");
|
||||||
|
if(Modifier.isStatic(field.getModifiers())) result.append(", `static`");
|
||||||
|
if(Modifier.isStatic(field.getModifiers())) result.append(", `final`");
|
||||||
|
result.append(".}\n");
|
||||||
|
}
|
||||||
|
|
||||||
for(Executable method : exec){
|
for(Executable method : exec){
|
||||||
if(Modifier.isPublic(method.getModifiers())){
|
String mname = method.getName().equals("<init>") || method.getName().equals(type.getCanonicalName()) ? "new" : method.getName();
|
||||||
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){
|
if(method.getParameterCount() > 0){
|
||||||
result.append("(");
|
result.append("(");
|
||||||
|
|
||||||
for(int i = 0; i < method.getParameterCount(); i++){
|
for(int i = 0; i < method.getParameterCount(); i++){
|
||||||
Class p = method.getParameterTypes()[i];
|
Class p = method.getParameterTypes()[i];
|
||||||
|
|
||||||
result.append(method.getParameters()[i].getName()).append(": ").append(str(p));
|
result.append(method.getParameters()[i].getName()).append(": ").append(str(p));
|
||||||
|
|
||||||
if(i != method.getParameterCount() - 1){
|
if(i != method.getParameterCount() - 1){
|
||||||
result.append(", ");
|
result.append(", ");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result.append(")");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(method instanceof Method){
|
|
||||||
Method m = (Method)method;
|
|
||||||
if(!m.getReturnType().equals(void.class)){
|
|
||||||
result.append(": ").append(str(m.getReturnType()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//result.append(" {.");
|
result.append(")");
|
||||||
//if(Modifier.isStatic(field.getModifiers())) result.append(", `static`");
|
|
||||||
//if(Modifier.isStatic(field.getModifiers())) result.append(", `final`");
|
|
||||||
//result.append(".}\n");
|
|
||||||
result.append("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(method instanceof Method){
|
||||||
|
Method m = (Method)method;
|
||||||
|
if(!m.getReturnType().equals(void.class)){
|
||||||
|
result.append(": ").append(str(m.getReturnType()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//result.append(" {.");
|
||||||
|
//if(Modifier.isStatic(field.getModifiers())) result.append(", `static`");
|
||||||
|
//if(Modifier.isStatic(field.getModifiers())) result.append(", `final`");
|
||||||
|
//result.append(".}\n");
|
||||||
|
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);
|
Log.info(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user