mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Fixed save incompatibility with missing types
This commit is contained in:
parent
b551af6bcf
commit
7ebe84cc0e
@ -37,6 +37,8 @@ public abstract class SaveFileReader{
|
||||
"command-center", "legacy-command-center"
|
||||
);
|
||||
|
||||
protected int lastRegionLength;
|
||||
|
||||
protected void region(String name, DataInput stream, CounterInputStream counter, IORunner<DataInput> cons) throws IOException{
|
||||
counter.resetCount();
|
||||
int length;
|
||||
@ -90,6 +92,7 @@ public abstract class SaveFileReader{
|
||||
/** Reads a chunk of some length. Use the runner for reading to catch more descriptive errors. */
|
||||
public int readChunk(DataInput input, boolean isShort, IORunner<DataInput> runner) throws IOException{
|
||||
int length = isShort ? input.readUnsignedShort() : input.readInt();
|
||||
lastRegionLength = length;
|
||||
runner.accept(input);
|
||||
return length;
|
||||
}
|
||||
|
@ -331,6 +331,11 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
for(int j = 0; j < amount; j++){
|
||||
readChunk(stream, true, in -> {
|
||||
byte typeid = in.readByte();
|
||||
if(EntityMapping.map(typeid) == null){
|
||||
in.skipBytes(lastRegionLength - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
Entityc entity = (Entityc)EntityMapping.map(typeid).get();
|
||||
entity.read(Reads.get(in));
|
||||
entity.add();
|
||||
|
Loading…
Reference in New Issue
Block a user