Fixed IO issues

This commit is contained in:
Anuken
2020-02-13 22:26:24 -05:00
parent 09c57c32d6
commit c4464e67fd
5 changed files with 12 additions and 9 deletions

View File

@@ -328,14 +328,14 @@ public class EntityProcess extends BaseProcessor{
//SPECIAL CASE: I/O code //SPECIAL CASE: I/O code
//note that serialization is generated even for non-serializing entities for manual usage //note that serialization is generated even for non-serializing entities for manual usage
if((first.name().equals("read") || first.name().equals("write")) && ann.genio()){ if((first.name().equals("read") || first.name().equals("write")) && ann.genio()){
Array<FieldSpec> fields = Array.with(builder.fieldSpecs).select(spec -> !spec.hasModifier(Modifier.TRANSIENT) && !spec.hasModifier(Modifier.STATIC) && !spec.hasModifier(Modifier.FINAL));
fields.sortComparing(f -> f.name); //sort to keep order
EntityIO writer = new EntityIO(mbuilder, first.name().equals("write")); EntityIO writer = new EntityIO(mbuilder, first.name().equals("write"));
//subclasses *have* to call this method //subclasses *have* to call this method
mbuilder.addAnnotation(CallSuper.class); mbuilder.addAnnotation(CallSuper.class);
//write or read each non-transient field //write or read each non-transient field
for(FieldSpec spec : builder.fieldSpecs){ for(FieldSpec spec : fields){
if(!spec.hasModifier(Modifier.TRANSIENT) && !spec.hasModifier(Modifier.STATIC) && !spec.hasModifier(Modifier.FINAL)){ writer.io(spec.type, "this." + spec.name);
writer.io(spec.type, "this." + spec.name);
}
} }
} }

View File

@@ -18,8 +18,12 @@ abstract class HitboxComp implements Posc, QuadTreeObject{
@Override @Override
public void add(){ public void add(){
lastX = x; updateLastPosition();
lastY = y; }
@Override
public void afterRead(){
updateLastPosition();
} }
void updateLastPosition(){ void updateLastPosition(){

View File

@@ -20,7 +20,7 @@ import mindustry.ui.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@EntityDef({Playerc.class}) @EntityDef(value = {Playerc.class}, serialize = false)
@Component @Component
abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
@NonNull @ReadOnly Unitc unit = Nulls.unit; @NonNull @ReadOnly Unitc unit = Nulls.unit;

View File

@@ -247,7 +247,6 @@ public abstract class SaveVersion extends SaveFileReader{
} }
} }
int amount = stream.readInt(); int amount = stream.readInt();
for(int j = 0; j < amount; j++){ for(int j = 0; j < amount; j++){
readChunk(stream, true, in -> { readChunk(stream, true, in -> {

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=9a946c98476bfbae80840608862e934f4c66b6cd archash=899ab293f6f7bab4deadec06fac7a666028edf15