argh
This commit is contained in:
@@ -140,26 +140,26 @@ public class TypeIO{
|
||||
return noMounts;
|
||||
}
|
||||
|
||||
public static void writeUnit(Writes write, Unitc unit){
|
||||
public static void writeUnit(Writes write, Unit unit){
|
||||
write.b(unit.isNull() ? 0 : unit instanceof BlockUnitc ? 1 : 2);
|
||||
//block units are special
|
||||
if(unit instanceof BlockUnitc){
|
||||
write.i(((BlockUnitc)unit).tile().pos());
|
||||
}else{
|
||||
write.i(unit.id());
|
||||
write.i(unit.id);
|
||||
}
|
||||
}
|
||||
|
||||
public static Unitc readUnit(Reads read){
|
||||
public static Unit readUnit(Reads read){
|
||||
byte type = read.b();
|
||||
int id = read.i();
|
||||
//nothing
|
||||
if(type == 0) return Nulls.unit;
|
||||
if(type == 2){ //standard unit
|
||||
Unitc unit = Groups.unit.getByID(id);
|
||||
Unit unit = Groups.unit.getByID(id);
|
||||
return unit == null ? Nulls.unit : unit;
|
||||
}else if(type == 1){ //block
|
||||
Tilec tile = world.ent(id);
|
||||
Building tile = world.ent(id);
|
||||
return tile instanceof ControlBlock ? ((ControlBlock)tile).unit() : Nulls.unit;
|
||||
}
|
||||
return Nulls.unit;
|
||||
@@ -173,11 +173,11 @@ public class TypeIO{
|
||||
return (T)Groups.all.getByID(read.i());
|
||||
}
|
||||
|
||||
public static void writeTilec(Writes write, Tilec tile){
|
||||
public static void writeBuilding(Writes write, Building tile){
|
||||
write.i(tile == null ? -1 : tile.pos());
|
||||
}
|
||||
|
||||
public static Tilec readTilec(Reads read){
|
||||
public static Building readBuilding(Reads read){
|
||||
return world.ent(read.i());
|
||||
}
|
||||
|
||||
@@ -264,9 +264,9 @@ public class TypeIO{
|
||||
|
||||
public static void writeController(Writes write, UnitController control){
|
||||
//no real unit controller state is written, only the type
|
||||
if(control instanceof Playerc){
|
||||
if(control instanceof Player){
|
||||
write.b(0);
|
||||
write.i(((Playerc)control).id());
|
||||
write.i(((Player)control).id());
|
||||
}else if(control instanceof FormationAI){
|
||||
write.b(1);
|
||||
write.i(((FormationAI)control).leader.id());
|
||||
@@ -279,7 +279,7 @@ public class TypeIO{
|
||||
byte type = read.b();
|
||||
if(type == 0){ //is player
|
||||
int id = read.i();
|
||||
Playerc player = Groups.player.getByID(id);
|
||||
Player player = Groups.player.getByID(id);
|
||||
//make sure player exists
|
||||
if(player == null) return prev;
|
||||
return player;
|
||||
|
||||
@@ -65,7 +65,7 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
||||
try{
|
||||
readChunk(stream, true, in -> {
|
||||
byte version = in.readByte();
|
||||
//legacy impl of TileEntity#read()
|
||||
//legacy impl of Building#read()
|
||||
tile.entity.health(stream.readUnsignedShort());
|
||||
byte packedrot = stream.readByte();
|
||||
byte team = Pack.leftByte(packedrot) == 8 ? stream.readByte() : Pack.leftByte(packedrot);
|
||||
@@ -74,9 +74,9 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
||||
tile.setTeam(Team.get(team));
|
||||
tile.rotation(rotation);
|
||||
|
||||
if(tile.entity.items() != null) tile.entity.items().read(Reads.get(stream));
|
||||
if(tile.entity.power() != null) tile.entity.power().read(Reads.get(stream));
|
||||
if(tile.entity.liquids() != null) tile.entity.liquids().read(Reads.get(stream));
|
||||
if(tile.entity.items != null) tile.entity.items.read(Reads.get(stream));
|
||||
if(tile.entity.power != null) tile.entity.power.read(Reads.get(stream));
|
||||
if(tile.entity.liquids != null) tile.entity.liquids.read(Reads.get(stream));
|
||||
if(tile.entity.cons() != null) tile.entity.cons().read(Reads.get(stream));
|
||||
|
||||
//read only from subclasses!
|
||||
|
||||
@@ -73,7 +73,7 @@ public class LegacyTypeTable{
|
||||
13 = Revenant
|
||||
|
||||
private static final Prov[] build81Table = {
|
||||
Playerc::new,
|
||||
Player::new,
|
||||
Fire::new,
|
||||
Puddle::new,
|
||||
MinerDrone::new,
|
||||
@@ -90,7 +90,7 @@ public class LegacyTypeTable{
|
||||
};
|
||||
|
||||
private static final Prov[] build80Table = {
|
||||
Playerc::new,
|
||||
Player::new,
|
||||
Fire::new,
|
||||
Puddle::new,
|
||||
Bullet::new,
|
||||
@@ -109,7 +109,7 @@ public class LegacyTypeTable{
|
||||
};
|
||||
|
||||
private static final Prov[] build79Table = {
|
||||
Playerc::new,
|
||||
Player::new,
|
||||
Fire::new,
|
||||
Puddle::new,
|
||||
Bullet::new,
|
||||
|
||||
Reference in New Issue
Block a user