Improved snapshot netcode

This commit is contained in:
Anuken
2018-12-29 22:46:46 -05:00
parent 7c35b6e95a
commit d01b8c7ad1
17 changed files with 99 additions and 216 deletions

View File

@@ -864,7 +864,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
}
@Override
public void read(DataInput buffer, long time) throws IOException{
public void read(DataInput buffer) throws IOException{
float lastx = x, lasty = y, lastrot = rotation;
super.readSave(buffer);
name = TypeIO.readStringData(buffer);
@@ -880,7 +880,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
readBuilding(buffer, !isLocal);
interpolator.read(lastx, lasty, x, y, time, rotation, baseRotation);
interpolator.read(lastx, lasty, x, y, rotation, baseRotation);
rotation = lastrot;
if(isLocal){

View File

@@ -158,7 +158,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
}
@Override
public void read(DataInput data, long time) throws IOException{
public void read(DataInput data) throws IOException{
x = data.readFloat();
y = data.readFloat();
velocity.x = data.readFloat();

View File

@@ -177,7 +177,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
}
@Override
public void read(DataInput data, long time) throws IOException{
public void read(DataInput data) throws IOException{
x = data.readFloat();
y = data.readFloat();
}

View File

@@ -108,7 +108,7 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time
public void write(DataOutput data){}
@Override
public void read(DataInput data, long time){}
public void read(DataInput data){}
@Override
public float lifetime(){

View File

@@ -301,7 +301,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
}
@Override
public void read(DataInput data, long time) throws IOException{
public void read(DataInput data) throws IOException{
x = data.readFloat();
y = data.readFloat();
liquid = content.liquid(data.readByte());

View File

@@ -66,5 +66,5 @@ public interface SyncTrait extends Entity, TypeTrait{
//Read and write sync data, usually position
void write(DataOutput data) throws IOException;
void read(DataInput data, long time) throws IOException;
void read(DataInput data) throws IOException;
}

View File

@@ -13,7 +13,6 @@ import io.anuke.arc.math.geom.Geometry;
import io.anuke.arc.math.geom.Rectangle;
import io.anuke.arc.util.Interval;
import io.anuke.arc.util.Time;
import io.anuke.arc.util.Timer;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.fx.ExplosionFx;
import io.anuke.mindustry.entities.Damage;
@@ -398,12 +397,12 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
}
@Override
public void read(DataInput data, long time) throws IOException{
public void read(DataInput data) throws IOException{
float lastx = x, lasty = y, lastrot = rotation;
super.readSave(data);
this.type = content.getByID(ContentType.unit, data.readByte());
interpolator.read(lastx, lasty, x, y, time, rotation);
interpolator.read(lastx, lasty, x, y, rotation);
rotation = lastrot;
}

View File

@@ -219,8 +219,8 @@ public abstract class GroundUnit extends BaseUnit{
}
@Override
public void read(DataInput data, long time) throws IOException{
super.read(data, time);
public void read(DataInput data) throws IOException{
super.read(data);
weapon = content.getByID(ContentType.weapon, data.readByte());
}

View File

@@ -99,8 +99,8 @@ public class AlphaDrone extends FlyingUnit {
}
@Override
public void read(DataInput stream, long time) throws IOException {
super.read(stream, time);
public void read(DataInput stream) throws IOException {
super.read(stream);
leader = Vars.playerGroup.getByID(stream.readInt());
}

View File

@@ -362,8 +362,8 @@ public class Drone extends FlyingUnit implements BuilderTrait{
}
@Override
public void read(DataInput data, long time) throws IOException{
super.read(data, time);
public void read(DataInput data) throws IOException{
super.read(data);
int mined = data.readInt();
int repairing = data.readInt();