Bugfixes
This commit is contained in:
@@ -115,13 +115,13 @@ public class BlockIndexer{
|
|||||||
if(structQuadrants == null) return;
|
if(structQuadrants == null) return;
|
||||||
|
|
||||||
//go through every tile... ouch
|
//go through every tile... ouch
|
||||||
for(Tile tile : world.tiles){
|
world.tiles.each(tile -> {
|
||||||
if(tile.team() == team){
|
if(tile.team() == team){
|
||||||
int quadrantX = tile.x / quadrantSize;
|
int quadrantX = tile.x / quadrantSize;
|
||||||
int quadrantY = tile.y / quadrantSize;
|
int quadrantY = tile.y / quadrantSize;
|
||||||
structQuadrant(team).set(quadrantX, quadrantY);
|
structQuadrant(team).set(quadrantX, quadrantY);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return whether this item is present on this map.*/
|
/** @return whether this item is present on this map.*/
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import mindustry.world.blocks.defense.*;
|
|||||||
import mindustry.world.blocks.defense.turrets.*;
|
import mindustry.world.blocks.defense.turrets.*;
|
||||||
import mindustry.world.blocks.distribution.*;
|
import mindustry.world.blocks.distribution.*;
|
||||||
import mindustry.world.blocks.environment.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
import mindustry.world.blocks.legacy.*;
|
||||||
import mindustry.world.blocks.liquid.*;
|
import mindustry.world.blocks.liquid.*;
|
||||||
import mindustry.world.blocks.logic.*;
|
import mindustry.world.blocks.logic.*;
|
||||||
import mindustry.world.blocks.power.*;
|
import mindustry.world.blocks.power.*;
|
||||||
@@ -1863,6 +1864,12 @@ public class Blocks implements ContentList{
|
|||||||
consumes.power(0.05f);
|
consumes.power(0.05f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
//region legacy
|
||||||
|
|
||||||
|
//looked up by name, no ref needed
|
||||||
|
new LegacyMechPad("legacy-mech-pad");
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import mindustry.maps.filters.*;
|
|||||||
import mindustry.maps.filters.GenerateFilter.*;
|
import mindustry.maps.filters.GenerateFilter.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.legacy.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -172,6 +173,12 @@ public class World{
|
|||||||
prepareTiles(tiles);
|
prepareTiles(tiles);
|
||||||
|
|
||||||
for(Tile tile : tiles){
|
for(Tile tile : tiles){
|
||||||
|
//remove legacy blocks; they need to stop existing
|
||||||
|
if(tile.block() instanceof LegacyBlock){
|
||||||
|
tile.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
tile.updateOcclusion();
|
tile.updateOcclusion();
|
||||||
|
|
||||||
if(tile.entity != null){
|
if(tile.entity != null){
|
||||||
@@ -447,8 +454,8 @@ public class World{
|
|||||||
|
|
||||||
private class Context implements WorldContext{
|
private class Context implements WorldContext{
|
||||||
@Override
|
@Override
|
||||||
public Tile tile(int x, int y){
|
public Tile tile(int index){
|
||||||
return tiles.get(x, y);
|
return tiles.geti(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -292,8 +292,8 @@ public class MapEditor{
|
|||||||
|
|
||||||
class Context implements WorldContext{
|
class Context implements WorldContext{
|
||||||
@Override
|
@Override
|
||||||
public Tile tile(int x, int y){
|
public Tile tile(int index){
|
||||||
return world.tile(x, y);
|
return world.tiles.geti(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
|||||||
|
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
//unit block update
|
//unit block update
|
||||||
if(tile.entity != null){
|
if(tile.entity != null && isGrounded()){
|
||||||
tile.entity.unitOn(this);
|
tile.entity.unitOn(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ public class MapIO{
|
|||||||
@Override public void end(){}
|
@Override public void end(){}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tile tile(int x, int y){
|
public Tile tile(int index){
|
||||||
tile.x = (short)x;
|
tile.x = (short)(index % map.width);
|
||||||
tile.y = (short)y;
|
tile.y = (short)(index / map.width);
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,15 @@ public abstract class SaveFileReader{
|
|||||||
protected final ReusableByteOutStream byteOutputSmall = new ReusableByteOutStream();
|
protected final ReusableByteOutStream byteOutputSmall = new ReusableByteOutStream();
|
||||||
protected final DataOutputStream dataBytesSmall = new DataOutputStream(byteOutputSmall);
|
protected final DataOutputStream dataBytesSmall = new DataOutputStream(byteOutputSmall);
|
||||||
protected final ObjectMap<String, String> fallback = ObjectMap.of(
|
protected final ObjectMap<String, String> fallback = ObjectMap.of(
|
||||||
"dart-mech-pad", "dart-ship-pad"
|
"dart-mech-pad", "legacy-mech-pad",
|
||||||
|
"dart-ship-pad", "legacy-mech-pad",
|
||||||
|
"javelin-ship-pad", "legacy-mech-pad",
|
||||||
|
"trident-ship-pad", "legacy-mech-pad",
|
||||||
|
"glaive-ship-pad", "legacy-mech-pad",
|
||||||
|
"alpha-mech-pad", "legacy-mech-pad",
|
||||||
|
"tau-mech-pad", "legacy-mech-pad",
|
||||||
|
"omega-mech-pad", "legacy-mech-pad",
|
||||||
|
"delta-mech-pad", "legacy-mech-pad"
|
||||||
);
|
);
|
||||||
|
|
||||||
protected void region(String name, DataInput stream, CounterInputStream counter, IORunner<DataInput> cons) throws IOException{
|
protected void region(String name, DataInput stream, CounterInputStream counter, IORunner<DataInput> cons) throws IOException{
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
for(int i = 0; i < width * height; i++){
|
for(int i = 0; i < width * height; i++){
|
||||||
int x = i % width, y = i / width;
|
int x = i % width, y = i / width;
|
||||||
Block block = content.block(stream.readShort());
|
Block block = content.block(stream.readShort());
|
||||||
Tile tile = context.tile(x, y);
|
Tile tile = context.tile(i);
|
||||||
if(block == null) block = Blocks.air;
|
if(block == null) block = Blocks.air;
|
||||||
boolean isCenter = true;
|
boolean isCenter = true;
|
||||||
|
|
||||||
@@ -214,8 +214,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
int consecutives = stream.readUnsignedByte();
|
int consecutives = stream.readUnsignedByte();
|
||||||
|
|
||||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||||
int newx = j % width, newy = j / width;
|
context.tile(j).setBlock(block);
|
||||||
context.tile(newx, newy).setBlock(block);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i += consecutives;
|
i += consecutives;
|
||||||
|
|||||||
@@ -49,13 +49,12 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
|||||||
|
|
||||||
//read blocks
|
//read blocks
|
||||||
for(int i = 0; i < width * height; i++){
|
for(int i = 0; i < width * height; i++){
|
||||||
int x = i % width, y = i / width;
|
|
||||||
Block block = content.block(stream.readShort());
|
Block block = content.block(stream.readShort());
|
||||||
Tile tile = context.tile(x, y);
|
Tile tile = context.tile(i);
|
||||||
if(block == null) block = Blocks.air;
|
if(block == null) block = Blocks.air;
|
||||||
|
|
||||||
//occupied by multiblock part
|
//occupied by multiblock part
|
||||||
boolean occupied = tile.entity != null && !tile.isCenter();
|
boolean occupied = tile.entity != null && !tile.isCenter() && (tile.entity.block() == block || block == Blocks.air);
|
||||||
|
|
||||||
//do not override occupied cells
|
//do not override occupied cells
|
||||||
if(!occupied){
|
if(!occupied){
|
||||||
@@ -92,8 +91,7 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
|||||||
//air is a waste of time and may mess up multiblocks
|
//air is a waste of time and may mess up multiblocks
|
||||||
if(block != Blocks.air){
|
if(block != Blocks.air){
|
||||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||||
int newx = j % width, newy = j / width;
|
context.tile(j).setBlock(block);
|
||||||
context.tile(newx, newy).setBlock(block);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.io.*;
|
|||||||
import static mindustry.Vars.content;
|
import static mindustry.Vars.content;
|
||||||
|
|
||||||
public class Save3 extends LegacySaveVersion{
|
public class Save3 extends LegacySaveVersion{
|
||||||
|
|
||||||
public Save3(){
|
public Save3(){
|
||||||
super(3);
|
super(3);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,6 +173,8 @@ public class Tile implements Position{
|
|||||||
if(block.isMultiblock()){
|
if(block.isMultiblock()){
|
||||||
int offsetx = -(block.size - 1) / 2;
|
int offsetx = -(block.size - 1) / 2;
|
||||||
int offsety = -(block.size - 1) / 2;
|
int offsety = -(block.size - 1) / 2;
|
||||||
|
Tilec entity = this.entity;
|
||||||
|
Block block = this.block;
|
||||||
|
|
||||||
//two passes: first one clears, second one sets
|
//two passes: first one clears, second one sets
|
||||||
for(int pass = 0; pass < 2; pass++){
|
for(int pass = 0; pass < 2; pass++){
|
||||||
@@ -198,6 +200,9 @@ public class Tile implements Position{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.entity = entity;
|
||||||
|
this.block = block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,8 +65,18 @@ public class Tiles implements Iterable<Tile>{
|
|||||||
return get(Point2.x(pos), Point2.y(pos));
|
return get(Point2.x(pos), Point2.y(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void each(Cons<Tile> cons){
|
||||||
|
for(Tile tile : array){
|
||||||
|
cons.get(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Tile> iterator(){
|
public Iterator<Tile> iterator(){
|
||||||
|
if(iterator.index != 0 && iterator.index != array.length){
|
||||||
|
iterator.index = 0;
|
||||||
|
throw new IllegalArgumentException("Double iteration. " + iterator.index + " != " + array.length);
|
||||||
|
}
|
||||||
iterator.index = 0;
|
iterator.index = 0;
|
||||||
return iterator;
|
return iterator;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package mindustry.world;
|
|||||||
public interface WorldContext{
|
public interface WorldContext{
|
||||||
|
|
||||||
/** Return a tile in the tile array.*/
|
/** Return a tile in the tile array.*/
|
||||||
Tile tile(int x, int y);
|
Tile tile(int index);
|
||||||
|
|
||||||
/** Create the tile array.*/
|
/** Create the tile array.*/
|
||||||
void resize(int width, int height);
|
void resize(int width, int height);
|
||||||
|
|||||||
@@ -118,11 +118,15 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
|
|
||||||
int blendbits;
|
int blendbits;
|
||||||
int blendsclx, blendscly;
|
int blendsclx, blendscly;
|
||||||
|
boolean everupdated = false;
|
||||||
|
|
||||||
float clogHeat = 0f;
|
float clogHeat = 0f;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
|
if(!everupdated){
|
||||||
|
Log.info("--DID NOT UPDATE {0}", tile);
|
||||||
|
}
|
||||||
byte rotation = tile.rotation();
|
byte rotation = tile.rotation();
|
||||||
int frame = clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * timeScale())) % 4) : 0;
|
int frame = clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * timeScale())) % 4) : 0;
|
||||||
Draw.rect(regions[Mathf.clamp(blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], x, y,
|
Draw.rect(regions[Mathf.clamp(blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], x, y,
|
||||||
@@ -142,6 +146,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
blendbits = bits[0];
|
blendbits = bits[0];
|
||||||
blendsclx = bits[1];
|
blendsclx = bits[1];
|
||||||
blendscly = bits[2];
|
blendscly = bits[2];
|
||||||
|
everupdated = true;
|
||||||
|
|
||||||
if(tile.front() != null && tile.front() != null){
|
if(tile.front() != null && tile.front() != null){
|
||||||
next = tile.front();
|
next = tile.front();
|
||||||
|
|||||||
11
core/src/mindustry/world/blocks/legacy/LegacyBlock.java
Normal file
11
core/src/mindustry/world/blocks/legacy/LegacyBlock.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package mindustry.world.blocks.legacy;
|
||||||
|
|
||||||
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
/** Any subclass of this will be removed upon world load. */
|
||||||
|
public class LegacyBlock extends Block{
|
||||||
|
|
||||||
|
public LegacyBlock(String name){
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
core/src/mindustry/world/blocks/legacy/LegacyMechPad.java
Normal file
25
core/src/mindustry/world/blocks/legacy/LegacyMechPad.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package mindustry.world.blocks.legacy;
|
||||||
|
|
||||||
|
import arc.util.io.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
public class LegacyMechPad extends Block{
|
||||||
|
|
||||||
|
public LegacyMechPad(String name){
|
||||||
|
super(name);
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LegacyMechPadEntity extends TileEntity{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(Reads read, byte revision){
|
||||||
|
super.read(read, revision);
|
||||||
|
//read 3 floats for pad data, and discard them
|
||||||
|
read.f();
|
||||||
|
read.f();
|
||||||
|
read.f();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -204,7 +204,7 @@ public class Drill extends Block{
|
|||||||
float progress;
|
float progress;
|
||||||
int index;
|
int index;
|
||||||
float warmup;
|
float warmup;
|
||||||
float drillTime;
|
float timeDrilled;
|
||||||
float lastDrillSpeed;
|
float lastDrillSpeed;
|
||||||
|
|
||||||
int dominantItems;
|
int dominantItems;
|
||||||
@@ -249,7 +249,7 @@ public class Drill extends Block{
|
|||||||
dump(dominantItem);
|
dump(dominantItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
drillTime += warmup * delta();
|
timeDrilled += warmup * delta();
|
||||||
|
|
||||||
if(items.total() < itemCapacity && dominantItems > 0 && consValid()){
|
if(items.total() < itemCapacity && dominantItems > 0 && consValid()){
|
||||||
|
|
||||||
@@ -263,8 +263,7 @@ public class Drill extends Block{
|
|||||||
|
|
||||||
lastDrillSpeed = (speed * dominantItems * warmup) / (drillTime + hardnessDrillMultiplier * dominantItem.hardness);
|
lastDrillSpeed = (speed * dominantItems * warmup) / (drillTime + hardnessDrillMultiplier * dominantItem.hardness);
|
||||||
warmup = Mathf.lerpDelta(warmup, speed, warmupSpeed);
|
warmup = Mathf.lerpDelta(warmup, speed, warmupSpeed);
|
||||||
progress += delta()
|
progress += delta() * dominantItems * speed * warmup;
|
||||||
* dominantItems * speed * warmup;
|
|
||||||
|
|
||||||
if(Mathf.chance(Time.delta() * updateEffectChance * warmup))
|
if(Mathf.chance(Time.delta() * updateEffectChance * warmup))
|
||||||
updateEffect.at(getX() + Mathf.range(size * 2f), getY() + Mathf.range(size * 2f));
|
updateEffect.at(getX() + Mathf.range(size * 2f), getY() + Mathf.range(size * 2f));
|
||||||
@@ -305,7 +304,7 @@ public class Drill extends Block{
|
|||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.rect(rotatorRegion, x, y, drillTime * rotateSpeed);
|
Draw.rect(rotatorRegion, x, y, timeDrilled * rotateSpeed);
|
||||||
|
|
||||||
Draw.rect(topRegion, x, y);
|
Draw.rect(topRegion, x, y);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=3c2fae9b66b6affc1ba6701cce19ca9625c5e1b1
|
archash=3a72937157113d8a5cd44bcc0b296c50e316c941
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ task debug(dependsOn: classes, type: JavaExec){
|
|||||||
task dist(type: Jar){
|
task dist(type: Jar){
|
||||||
from files(sourceSets.main.output.classesDirs)
|
from files(sourceSets.main.output.classesDirs)
|
||||||
from files(sourceSets.main.output.resourcesDir)
|
from files(sourceSets.main.output.resourcesDir)
|
||||||
from{ configurations.compile.collect{ zipTree(it) } }
|
from {configurations.compile.collect{ it.isDirectory() ? it : zipTree(it) }}
|
||||||
from files(project.assetsDir)
|
from files(project.assetsDir)
|
||||||
exclude("sprites/**")
|
exclude("sprites/**")
|
||||||
exclude("music/**")
|
exclude("music/**")
|
||||||
|
|||||||
Reference in New Issue
Block a user