Added backwards compatibility for legacy saves
@@ -1,5 +1,6 @@
|
|||||||
package mindustry.annotations.entity;
|
package mindustry.annotations.entity;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
@@ -166,6 +167,7 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
String name = "DrawLayer" + Strings.capitalize(layer.name()) + "c";
|
String name = "DrawLayer" + Strings.capitalize(layer.name()) + "c";
|
||||||
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(name)
|
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(name)
|
||||||
.addSuperinterface(tname(packageName + ".Entityc"))
|
.addSuperinterface(tname(packageName + ".Entityc"))
|
||||||
|
.addSuperinterface(tname(packageName + ".Drawc"))
|
||||||
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
|
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
|
||||||
inter.addMethod(MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())).addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT).build());
|
inter.addMethod(MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())).addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT).build());
|
||||||
write(inter);
|
write(inter);
|
||||||
@@ -370,8 +372,9 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//add free code to remove methods - always at the end
|
//add free code to remove methods - always at the end
|
||||||
|
//this only gets called next frame.
|
||||||
if(first.name().equals("remove") && ann.pooled()){
|
if(first.name().equals("remove") && ann.pooled()){
|
||||||
mbuilder.addStatement("$T.free(this)", Pools.class);
|
mbuilder.addStatement("$T.app.post(() -> $T.free(this))", Core.class, Pools.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.addMethod(mbuilder.build());
|
builder.addMethod(mbuilder.build());
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 768 B After Width: | Height: | Size: 768 B |
|
Before Width: | Height: | Size: 688 KiB After Width: | Height: | Size: 688 KiB |
|
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 262 KiB After Width: | Height: | Size: 262 KiB |
|
Before Width: | Height: | Size: 900 KiB After Width: | Height: | Size: 901 KiB |
@@ -152,7 +152,7 @@ public class Vars implements Loadable{
|
|||||||
/** list of all locales that can be switched to */
|
/** list of all locales that can be switched to */
|
||||||
public static Locale[] locales;
|
public static Locale[] locales;
|
||||||
|
|
||||||
public static FileTree tree;
|
public static FileTree tree = new FileTree();
|
||||||
public static Net net;
|
public static Net net;
|
||||||
public static ContentLoader content;
|
public static ContentLoader content;
|
||||||
public static GameState state;
|
public static GameState state;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class WaveSpawner{
|
|||||||
|
|
||||||
/** @return true if the player is near a ground spawn point. */
|
/** @return true if the player is near a ground spawn point. */
|
||||||
public boolean playerNear(){
|
public boolean playerNear(){
|
||||||
return groundSpawns.contains(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x(), player.y()) < state.rules.dropZoneRadius && player.team() != state.rules.waveTeam);
|
return !player.dead() && groundSpawns.contains(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x(), player.y()) < state.rules.dropZoneRadius && player.team() != state.rules.waveTeam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnEnemies(){
|
public void spawnEnemies(){
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public class FileTree implements FileHandleResolver{
|
|||||||
return files.get(path);
|
return files.get(path);
|
||||||
}else if(files.containsKey("/" + path)){
|
}else if(files.containsKey("/" + path)){
|
||||||
return files.get("/" + path);
|
return files.get("/" + path);
|
||||||
|
}else if(Core.files == null){ //headless
|
||||||
|
return Fi.get(path);
|
||||||
}else{
|
}else{
|
||||||
return Core.files.internal(path);
|
return Core.files.internal(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
Log.warn("Missing entity at {0}. Skipping block snapshot.", tile);
|
Log.warn("Missing entity at {0}. Skipping block snapshot.", tile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tile.entity.read(Reads.get(input), tile.entity.version());
|
tile.entity.readAll(Reads.get(input), tile.entity.version());
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -715,7 +715,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
sent ++;
|
sent ++;
|
||||||
|
|
||||||
dataStream.writeInt(entity.tile().pos());
|
dataStream.writeInt(entity.tile().pos());
|
||||||
entity.write(Writes.get(dataStream));
|
entity.writeAll(Writes.get(dataStream));
|
||||||
|
|
||||||
if(syncStream.size() > maxSnapshotSize){
|
if(syncStream.size() > maxSnapshotSize){
|
||||||
dataStream.close();
|
dataStream.close();
|
||||||
|
|||||||
@@ -62,4 +62,8 @@ public class Fires{
|
|||||||
public static void remove(Tile tile){
|
public static void remove(Tile tile){
|
||||||
map.remove(tile.pos());
|
map.remove(tile.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void register(Firec fire){
|
||||||
|
map.put(fire.tile().pos(), fire);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ public class Puddles{
|
|||||||
map.remove(tile.pos());
|
map.remove(tile.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void register(Puddlec puddle){
|
||||||
|
map.put(puddle.tile().pos(), puddle);
|
||||||
|
}
|
||||||
|
|
||||||
/** Reacts two liquids together at a location. */
|
/** Reacts two liquids together at a location. */
|
||||||
private static float reactPuddle(Liquid dest, Liquid liquid, float amount, Tile tile, float x, float y){
|
private static float reactPuddle(Liquid dest, Liquid liquid, float amount, Tile tile, float x, float y){
|
||||||
if((dest.flammability > 0.3f && liquid.temperature > 0.7f) ||
|
if((dest.flammability > 0.3f && liquid.temperature > 0.7f) ||
|
||||||
|
|||||||
@@ -95,4 +95,8 @@ abstract class FireComp implements Timedc, Posc, Firec{
|
|||||||
Fires.remove(tile);
|
Fires.remove(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterRead(){
|
||||||
|
Fires.register(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ abstract class HealthComp implements Entityc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean damaged(){
|
boolean damaged(){
|
||||||
return health <= maxHealth - 0.0001f;
|
return health < maxHealth - 0.001f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void damage(float amount){
|
void damage(float amount){
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import static mindustry.entities.Puddles.maxLiquid;
|
|||||||
|
|
||||||
@EntityDef(value = {Puddlec.class}, pooled = true)
|
@EntityDef(value = {Puddlec.class}, pooled = true)
|
||||||
@Component
|
@Component
|
||||||
abstract class PuddleComp implements Posc, DrawLayerFloorOverc{
|
abstract class PuddleComp implements Posc, DrawLayerFloorOverc, Puddlec{
|
||||||
private static final int maxGeneration = 2;
|
private static final int maxGeneration = 2;
|
||||||
private static final Color tmp = new Color();
|
private static final Color tmp = new Color();
|
||||||
private static final Rect rect = new Rect();
|
private static final Rect rect = new Rect();
|
||||||
@@ -112,8 +112,18 @@ abstract class PuddleComp implements Posc, DrawLayerFloorOverc{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float clipSize(){
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(){
|
public void remove(){
|
||||||
Puddles.remove(tile);
|
Puddles.remove(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterRead(){
|
||||||
|
Puddles.register(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CallSuper
|
public final void writeBase(Writes write){
|
||||||
public void write(Writes write){
|
|
||||||
write.f(health());
|
write.f(health());
|
||||||
write.b(tile.rotation());
|
write.b(tile.rotation());
|
||||||
write.b(tile.getTeamID());
|
write.b(tile.getTeamID());
|
||||||
@@ -72,22 +71,38 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
|||||||
if(cons != null) cons.write(write);
|
if(cons != null) cons.write(write);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CallSuper
|
public final void readBase(Reads read){
|
||||||
@Override
|
|
||||||
public void read(Reads read, byte revision){
|
|
||||||
health(read.f());
|
health(read.f());
|
||||||
byte rotation = read.b();
|
tile.rotation(read.b());
|
||||||
byte team = read.b();
|
tile.setTeam(Team.get(read.b()));
|
||||||
|
|
||||||
tile.setTeam(Team.get(team));
|
|
||||||
tile.rotation(rotation);
|
|
||||||
|
|
||||||
if(items != null) items.read(read);
|
if(items != null) items.read(read);
|
||||||
if(power != null) power.read(read);
|
if(power != null) power.read(read);
|
||||||
if(liquids != null) liquids.read(read);
|
if(liquids != null) liquids.read(read);
|
||||||
if(cons != null) cons.read(read);
|
if(cons != null) cons.read(read);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void writeAll(Writes write){
|
||||||
|
writeBase(write);
|
||||||
|
write(write);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readAll(Reads read, byte revision){
|
||||||
|
readBase(read);
|
||||||
|
read(read, revision);
|
||||||
|
}
|
||||||
|
|
||||||
|
@CallSuper
|
||||||
|
@Override
|
||||||
|
public void write(Writes write){
|
||||||
|
//overriden by subclasses!
|
||||||
|
}
|
||||||
|
|
||||||
|
@CallSuper
|
||||||
|
@Override
|
||||||
|
public void read(Reads read, byte revision){
|
||||||
|
//overriden by subclasses!
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyBoost(float intensity, float duration){
|
public void applyBoost(float intensity, float duration){
|
||||||
timeScale = Math.max(timeScale, intensity);
|
timeScale = Math.max(timeScale, intensity);
|
||||||
@@ -144,7 +159,6 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the version of this TileEntity IO code.*/
|
/** Returns the version of this TileEntity IO code.*/
|
||||||
//TODO implement
|
|
||||||
@Override
|
@Override
|
||||||
public byte version(){
|
public byte version(){
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package mindustry.io;
|
package mindustry.io;
|
||||||
|
|
||||||
import arc.struct.ObjectMap;
|
import arc.struct.*;
|
||||||
import arc.struct.ObjectMap.Entry;
|
import arc.struct.ObjectMap.*;
|
||||||
import arc.struct.StringMap;
|
import arc.util.io.*;
|
||||||
import arc.util.io.CounterInputStream;
|
import mindustry.world.*;
|
||||||
import arc.util.io.ReusableByteOutStream;
|
|
||||||
import mindustry.world.WorldContext;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import arc.files.Fi;
|
|||||||
import arc.util.io.CounterInputStream;
|
import arc.util.io.CounterInputStream;
|
||||||
import arc.util.io.FastDeflaterOutputStream;
|
import arc.util.io.FastDeflaterOutputStream;
|
||||||
import mindustry.Vars;
|
import mindustry.Vars;
|
||||||
|
import mindustry.io.legacy.*;
|
||||||
import mindustry.io.versions.*;
|
import mindustry.io.versions.*;
|
||||||
import mindustry.world.WorldContext;
|
import mindustry.world.WorldContext;
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ public class SaveIO{
|
|||||||
/** Format header. This is the string 'MSAV' in ASCII. */
|
/** Format header. This is the string 'MSAV' in ASCII. */
|
||||||
public static final byte[] header = {77, 83, 65, 86};
|
public static final byte[] header = {77, 83, 65, 86};
|
||||||
public static final IntMap<SaveVersion> versions = new IntMap<>();
|
public static final IntMap<SaveVersion> versions = new IntMap<>();
|
||||||
public static final Array<SaveVersion> versionArray = Array.with(new Save1(), new Save2(), new Save3());
|
public static final Array<SaveVersion> versionArray = Array.with(new Save1(), new Save2(), new Save3(), new Save4());
|
||||||
|
|
||||||
static{
|
static{
|
||||||
for(SaveVersion version : versionArray){
|
for(SaveVersion version : versionArray){
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
if(tile.entity != null){
|
if(tile.entity != null){
|
||||||
writeChunk(stream, true, out -> {
|
writeChunk(stream, true, out -> {
|
||||||
out.writeByte(tile.entity.version());
|
out.writeByte(tile.entity.version());
|
||||||
tile.entity.write(Writes.get(out));
|
tile.entity.writeAll(Writes.get(out));
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
//write consecutive non-entity blocks
|
//write consecutive non-entity blocks
|
||||||
@@ -188,7 +188,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
try{
|
try{
|
||||||
readChunk(stream, true, in -> {
|
readChunk(stream, true, in -> {
|
||||||
byte revision = in.readByte();
|
byte revision = in.readByte();
|
||||||
tile.entity.read(Reads.get(in), revision);
|
tile.entity.readAll(Reads.get(in), revision);
|
||||||
});
|
});
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
throw new IOException("Failed to read tile entity of block: " + block, e);
|
throw new IOException("Failed to read tile entity of block: " + block, e);
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package mindustry.io.legacy;
|
||||||
|
|
||||||
|
import arc.util.*;
|
||||||
|
import arc.util.io.*;
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.game.*;
|
||||||
|
import mindustry.io.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.content;
|
||||||
|
|
||||||
|
public abstract class LegacySaveVersion extends SaveVersion{
|
||||||
|
|
||||||
|
public LegacySaveVersion(int version){
|
||||||
|
super(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readMap(DataInput stream, WorldContext context) throws IOException{
|
||||||
|
int width = stream.readUnsignedShort();
|
||||||
|
int height = stream.readUnsignedShort();
|
||||||
|
|
||||||
|
boolean generating = context.isGenerating();
|
||||||
|
|
||||||
|
if(!generating) context.begin();
|
||||||
|
try{
|
||||||
|
|
||||||
|
context.resize(width, height);
|
||||||
|
|
||||||
|
//read floor and create tiles first
|
||||||
|
for(int i = 0; i < width * height; i++){
|
||||||
|
int x = i % width, y = i / width;
|
||||||
|
short floorid = stream.readShort();
|
||||||
|
short oreid = stream.readShort();
|
||||||
|
int consecutives = stream.readUnsignedByte();
|
||||||
|
if(content.block(floorid) == Blocks.air) floorid = Blocks.stone.id;
|
||||||
|
|
||||||
|
context.create(x, y, floorid, oreid, (short)0);
|
||||||
|
|
||||||
|
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||||
|
int newx = j % width, newy = j / width;
|
||||||
|
context.create(newx, newy, floorid, oreid, (short)0);
|
||||||
|
}
|
||||||
|
|
||||||
|
i += consecutives;
|
||||||
|
}
|
||||||
|
|
||||||
|
//read blocks
|
||||||
|
for(int i = 0; i < width * height; i++){
|
||||||
|
int x = i % width, y = i / width;
|
||||||
|
Block block = content.block(stream.readShort());
|
||||||
|
Tile tile = context.tile(x, y);
|
||||||
|
if(block == null) block = Blocks.air;
|
||||||
|
tile.setBlock(block);
|
||||||
|
|
||||||
|
if(tile.entity != null){
|
||||||
|
try{
|
||||||
|
readChunk(stream, true, in -> {
|
||||||
|
byte version = in.readByte();
|
||||||
|
//legacy impl of TileEntity#read()
|
||||||
|
tile.entity.health(stream.readUnsignedShort());
|
||||||
|
byte packedrot = stream.readByte();
|
||||||
|
byte team = Pack.leftByte(packedrot) == 8 ? stream.readByte() : Pack.leftByte(packedrot);
|
||||||
|
byte rotation = Pack.rightByte(packedrot);
|
||||||
|
|
||||||
|
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.cons() != null) tile.entity.cons().read(Reads.get(stream));
|
||||||
|
|
||||||
|
//read only from subclasses!
|
||||||
|
tile.entity.read(Reads.get(in), version);
|
||||||
|
});
|
||||||
|
}catch(Exception e){
|
||||||
|
throw new IOException("Failed to read tile entity of block: " + block, e);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
int consecutives = stream.readUnsignedByte();
|
||||||
|
|
||||||
|
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||||
|
int newx = j % width, newy = j / width;
|
||||||
|
context.tile(newx, newy).setBlock(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
i += consecutives;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}finally{
|
||||||
|
if(!generating) context.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readLegacyEntities(DataInput stream) throws IOException{
|
||||||
|
byte groups = stream.readByte();
|
||||||
|
|
||||||
|
for(int i = 0; i < groups; i++){
|
||||||
|
int amount = stream.readInt();
|
||||||
|
for(int j = 0; j < amount; j++){
|
||||||
|
//simply skip all the entities
|
||||||
|
skipRegion(stream, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.io.versions;
|
package mindustry.io.legacy;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Latest data: [build 81]
|
Latest data: [build 81]
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package mindustry.io.legacy;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class Save1 extends LegacySaveVersion{
|
||||||
|
|
||||||
|
public Save1(){
|
||||||
|
super(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readEntities(DataInput stream) throws IOException{
|
||||||
|
readLegacyEntities(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package mindustry.io.legacy;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class Save2 extends LegacySaveVersion{
|
||||||
|
|
||||||
|
public Save2(){
|
||||||
|
super(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readEntities(DataInput stream) throws IOException{
|
||||||
|
readLegacyEntities(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package mindustry.io.legacy;
|
||||||
|
|
||||||
|
import mindustry.game.*;
|
||||||
|
import mindustry.game.Teams.*;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.content;
|
||||||
|
|
||||||
|
public class Save3 extends LegacySaveVersion{
|
||||||
|
public Save3(){
|
||||||
|
super(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readEntities(DataInput stream) throws IOException{
|
||||||
|
int teamc = stream.readInt();
|
||||||
|
for(int i = 0; i < teamc; i++){
|
||||||
|
Team team = Team.get(stream.readInt());
|
||||||
|
TeamData data = team.data();
|
||||||
|
int blocks = stream.readInt();
|
||||||
|
for(int j = 0; j < blocks; j++){
|
||||||
|
data.brokenBlocks.addLast(new BrokenBlock(stream.readShort(), stream.readShort(), stream.readShort(), content.block(stream.readShort()).id, stream.readInt()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readLegacyEntities(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package mindustry.io.versions;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class Save1 extends Save2{
|
|
||||||
|
|
||||||
public Save1(){
|
|
||||||
version = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readEntities(DataInput stream) throws IOException{
|
|
||||||
//TODO implement
|
|
||||||
//Prov[] table = LegacyTypeTable.getTable(lastReadBuild);
|
|
||||||
|
|
||||||
byte groups = stream.readByte();
|
|
||||||
|
|
||||||
for(int i = 0; i < groups; i++){
|
|
||||||
int amount = stream.readInt();
|
|
||||||
for(int j = 0; j < amount; j++){
|
|
||||||
readChunk(stream, true, in -> {
|
|
||||||
byte typeid = in.readByte();
|
|
||||||
byte version = in.readByte();
|
|
||||||
//SaveTrait trait = (SaveTrait)table[typeid].get();
|
|
||||||
//trait.readSave(in, version);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package mindustry.io.versions;
|
|
||||||
|
|
||||||
import mindustry.io.*;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class Save2 extends SaveVersion{
|
|
||||||
|
|
||||||
public Save2(){
|
|
||||||
super(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readEntities(DataInput stream) throws IOException{
|
|
||||||
//TODO implement
|
|
||||||
byte groups = stream.readByte();
|
|
||||||
|
|
||||||
for(int i = 0; i < groups; i++){
|
|
||||||
int amount = stream.readInt();
|
|
||||||
for(int j = 0; j < amount; j++){
|
|
||||||
//TODO throw exception on read fail
|
|
||||||
readChunk(stream, true, in -> {
|
|
||||||
byte typeid = in.readByte();
|
|
||||||
byte version = in.readByte();
|
|
||||||
//SaveTrait trait = (SaveTrait)content.<TypeID>getByID(ContentType.typeid, typeid).constructor.get();
|
|
||||||
//trait.readSave(in, version);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package mindustry.io.versions;
|
|
||||||
|
|
||||||
import mindustry.io.*;
|
|
||||||
|
|
||||||
public class Save3 extends SaveVersion{
|
|
||||||
public Save3(){
|
|
||||||
super(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package mindustry.io.versions;
|
||||||
|
|
||||||
|
import mindustry.io.*;
|
||||||
|
|
||||||
|
public class Save4 extends SaveVersion{
|
||||||
|
|
||||||
|
public Save4(){
|
||||||
|
super(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,7 +53,7 @@ public class Planet extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//TODO crash instead - this is a critical error!
|
//TODO crash instead - this is a critical error!
|
||||||
Log.err("Planet {0} is missing its data file.");
|
Log.err("Planet {0} is missing its data file.", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
package mindustry.world.blocks.defense;
|
package mindustry.world.blocks.defense;
|
||||||
|
|
||||||
import arc.Core;
|
import arc.*;
|
||||||
import arc.struct.IntSet;
|
import arc.graphics.*;
|
||||||
import arc.graphics.Color;
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.Mathf;
|
import arc.math.*;
|
||||||
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.content.Fx;
|
import mindustry.content.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class MendProjector extends Block{
|
public class MendProjector extends Block{
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
package mindustry.world.blocks.defense;
|
package mindustry.world.blocks.defense;
|
||||||
|
|
||||||
import arc.Core;
|
import arc.*;
|
||||||
import arc.struct.IntSet;
|
import arc.graphics.*;
|
||||||
import arc.graphics.Color;
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.Mathf;
|
import arc.math.*;
|
||||||
import arc.util.Time;
|
import arc.struct.*;
|
||||||
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class OverdriveProjector extends Block{
|
public class OverdriveProjector extends Block{
|
||||||
@@ -90,7 +88,7 @@ public class OverdriveProjector extends Block{
|
|||||||
float realBoost = (speedBoost + entity.phaseHeat * speedBoostPhase) * entity.efficiency();
|
float realBoost = (speedBoost + entity.phaseHeat * speedBoostPhase) * entity.efficiency();
|
||||||
|
|
||||||
entity.charge = 0f;
|
entity.charge = 0f;
|
||||||
indexer.eachBlock(entity, realRange, other -> other.entity.timeScale() <= realBoost, other -> other.entity.applyBoost(realBoost, reload + 1f));
|
indexer.eachBlock(entity, realRange, other -> other.entity.timeScale() < realBoost, other -> other.entity.applyBoost(realBoost, reload + 1f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,23 @@
|
|||||||
package mindustry.world.blocks.defense.turrets;
|
package mindustry.world.blocks.defense.turrets;
|
||||||
|
|
||||||
import arc.Core;
|
import arc.*;
|
||||||
import arc.audio.*;
|
import arc.audio.*;
|
||||||
import arc.struct.Array;
|
import arc.func.*;
|
||||||
import arc.struct.EnumSet;
|
import arc.graphics.*;
|
||||||
import arc.func.Cons2;
|
|
||||||
import arc.graphics.Blending;
|
|
||||||
import arc.graphics.Color;
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.Angles;
|
import arc.math.*;
|
||||||
import arc.math.Mathf;
|
import arc.math.geom.*;
|
||||||
import arc.math.geom.Vec2;
|
import arc.struct.*;
|
||||||
import arc.util.Time;
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.content.Fx;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.bullet.BulletType;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.Block;
|
import mindustry.world.*;
|
||||||
import mindustry.world.Tile;
|
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
import static mindustry.Vars.tilesize;
|
import static mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public abstract class Turret extends Block{
|
public abstract class Turret extends Block{
|
||||||
@@ -330,8 +324,10 @@ public abstract class Turret extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public void read(Reads read, byte revision){
|
public void read(Reads read, byte revision){
|
||||||
super.read(read, revision);
|
super.read(read, revision);
|
||||||
reload = read.f();
|
if(revision == 1){
|
||||||
rotation = read.f();
|
reload = read.f();
|
||||||
|
rotation = read.f();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||