Skip to content

Commit

Permalink
Fixed #10436
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Jan 19, 2025
1 parent 224e74c commit 34cc625
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions core/src/mindustry/world/DirectionalItemBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,21 @@ public void write(Writes write){
}

public void read(Reads read){
read(read, false);
}

public void read(Reads read, boolean legacy){
for(int i = 0; i < 4; i++){
indexes[i] = read.b();
byte length = read.b();
for(int j = 0; j < length; j++){
long value = read.l();

if(legacy){
//read value as the old format with 1-byte items, and create a new one with the new 2-byte format
value = BufferItem.get(BufferItemLegacy.item(value), BufferItemLegacy.time(value));
}

if(j < buffers[i].length){
buffers[i][j] = value;
}
Expand All @@ -71,4 +81,10 @@ class BufferItemStruct{
short item;
float time;
}

@Struct
class BufferItemLegacyStruct{
byte item;
float time;
}
}
7 changes: 6 additions & 1 deletion core/src/mindustry/world/blocks/distribution/Junction.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public boolean acceptItem(Building source, Item item){
return to != null && to.team == team;
}

@Override
public byte version(){
return 1;
}

@Override
public void write(Writes write){
super.write(write);
Expand All @@ -88,7 +93,7 @@ public void write(Writes write){
@Override
public void read(Reads read, byte revision){
super.read(read, revision);
buffer.read(read);
buffer.read(read, revision == 0);
}
}
}

0 comments on commit 34cc625

Please sign in to comment.