Fixed various bugs and crashes

This commit is contained in:
Anuken
2018-07-03 15:53:06 -04:00
parent 4d600f973a
commit 359a392cca
15 changed files with 166 additions and 156 deletions

View File

@@ -108,8 +108,8 @@ public class Recipes implements ContentList{
new Recipe(distribution, StorageBlocks.vault, new ItemStack(Items.carbide, 500), new ItemStack(Items.thorium, 350));
//DRILLS, PRODUCERS
new Recipe(production, ProductionBlocks.tungstenDrill, new ItemStack(Items.tungsten, 30));
new Recipe(production, ProductionBlocks.carbideDrill, new ItemStack(Items.tungsten, 60), new ItemStack(Items.carbide, 60));
new Recipe(production, ProductionBlocks.tungstenDrill, new ItemStack(Items.tungsten, 25));
new Recipe(production, ProductionBlocks.carbideDrill, new ItemStack(Items.tungsten, 50), new ItemStack(Items.carbide, 60));
new Recipe(production, ProductionBlocks.laserdrill, new ItemStack(Items.tungsten, 90), new ItemStack(Items.carbide, 110), new ItemStack(Items.silicon, 70), new ItemStack(Items.titanium, 80));
new Recipe(production, ProductionBlocks.waterextractor, new ItemStack(Items.tungsten, 50), new ItemStack(Items.carbide, 50), new ItemStack(Items.lead, 40));

View File

@@ -18,7 +18,7 @@ public class ProductionBlocks extends BlockList implements ContentList {
public void load() {
tungstenDrill = new Drill("tungsten-drill") {{
tier = 2;
drillTime = 360;
drillTime = 340;
}};
carbideDrill = new Drill("carbide-drill") {{

View File

@@ -21,11 +21,12 @@ public class TurretBlocks extends BlockList implements ContentList {
ammoTypes = new AmmoType[]{AmmoTypes.bulletTungsten, AmmoTypes.bulletLead, AmmoTypes.bulletCarbide, AmmoTypes.bulletPyratite, AmmoTypes.bulletSilicon};
reload = 25f;
restitution = 0.03f;
range = 80f;
range = 90f;
shootCone = 15f;
ammoUseEffect = ShootFx.shellEjectSmall;
health = 80;
inaccuracy = 3f;
inaccuracy = 2f;
rotatespeed = 10f;
}};
/*
scatter = new BurstTurret("scatter") {{
@@ -52,10 +53,10 @@ public class TurretBlocks extends BlockList implements ContentList {
scorch = new LiquidTurret("scorch") {{
ammoTypes = new AmmoType[]{AmmoTypes.basicFlame};
recoil = 0f;
reload = 5f;
reload = 4f;
shootCone = 50f;
ammoUseEffect = ShootFx.shellEjectSmall;
health = 140;
health = 160;
drawer = (tile, entity) -> Draw.rect(entity.target != null ? name + "-shoot" : name, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
}};

View File

@@ -301,7 +301,7 @@ public class NetClient extends Module {
length = snapshot.length;
netClient.lastSnapshotBase = Arrays.copyOf(snapshot, snapshot.length);
} else { //otherwise, last snapshot must not be null, decode it
if(NetServer.showSnapshotSize) Log.info("Base size: {0} Path size: {1}", netClient.lastSnapshotBase.length, snapshot.length);
if(NetServer.showSnapshotSize) Log.info("Base size: {0} Patch size: {1}", netClient.lastSnapshotBase.length, snapshot.length);
netClient.decoder.init(netClient.lastSnapshotBase, snapshot);
result = netClient.decoder.decode();
length = netClient.decoder.getDecodedLength();

View File

@@ -74,6 +74,7 @@ public class NetServer extends Module{
if(player != null){
onDisconnect(player);
}
connections.remove(id);
});
Net.handleServer(ConnectPacket.class, (id, packet) -> {
@@ -406,18 +407,25 @@ public class NetServer extends Module{
byte[] bytes = syncStream.toByteArray();
connection.lastSentRawSnapshot = bytes;
if(connection.currentBaseID == -1){
//assign to last sent snapshot so that there is only ever one unique snapshot with ID 0
if(connection.lastSentSnapshot != null){
bytes = connection.lastSentSnapshot;
}else{
connection.lastSentRawSnapshot = bytes;
connection.lastSentSnapshot = bytes;
}
if(showSnapshotSize) Log.info("Sent raw snapshot: {0} bytes.", bytes.length);
///Nothing to diff off of in this case, send the whole thing, but increment the counter
connection.lastSentSnapshot = bytes;
///Nothing to diff off of in this case, send the whole thing
sendSplitSnapshot(connection.id, bytes, 0, -1);
}else{
connection.lastSentRawSnapshot = bytes;
//send diff, otherwise
byte[] diff = ByteDeltaEncoder.toDiff(new ByteMatcherHash(connection.currentBaseSnapshot, bytes), encoder);
if(showSnapshotSize) Log.info("Shrank snapshot: {0} -> {1}, Base {2} ID {3}", bytes.length, diff.length, connection.currentBaseID, connection.lastSentSnapshotID);
sendSplitSnapshot(connection.id, diff, connection.lastSentSnapshotID + 1, connection.currentBaseID);
if(showSnapshotSize) Log.info("Shrank snapshot: {0} -> {1}, Base {2} ID {3} base length = {4}", bytes.length, diff.length, connection.currentBaseID, connection.currentBaseID + 1, connection.currentBaseSnapshot.length);
sendSplitSnapshot(connection.id, diff, connection.currentBaseID + 1, connection.currentBaseID);
connection.lastSentSnapshot = diff;
connection.lastSentSnapshotID = connection.currentBaseID + 1;
connection.lastSentBase = connection.currentBaseID;
@@ -432,7 +440,6 @@ public class NetServer extends Module{
/**Sends a raw byte[] snapshot to a client, splitting up into chunks when needed.*/
private static void sendSplitSnapshot(int userid, byte[] bytes, int snapshotID, int base){
if(bytes.length < maxSnapshotSize){
if(showSnapshotSize) Log.info("Raw send() snapshot call: {0} bytes, sID {1}", bytes.length, snapshotID);
Call.onSnapshot(userid, bytes, snapshotID, (short)0, (short)bytes.length, base);
}else{
int remaining = bytes.length;

View File

@@ -9,6 +9,7 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.content.blocks.StorageBlocks;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.io.Map;
@@ -587,7 +588,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
for(Block block : Block.all()){
TextureRegion[] regions = block.getCompactIcon();
if((block.synthetic() && (Recipe.getByResult(block) == null || !control.database().isUnlocked(Recipe.getByResult(block)))) && !debug) continue;
if((block.synthetic() && (Recipe.getByResult(block) == null || !control.database().isUnlocked(Recipe.getByResult(block)))) && !debug && block != StorageBlocks.core) continue;
if(regions.length == 0 || regions[0] == Draw.region("jjfgj")) continue;

View File

@@ -250,6 +250,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
@Override
public void removed() {
dropCarryLocal();
TileEntity core = getClosestCore();
if(core != null && ((CoreEntity)core).currentUnit == this){
((CoreEntity)core).currentUnit = null;
}
}
@Override

View File

@@ -28,7 +28,6 @@ import io.anuke.ucore.entities.trait.TimeTrait;
import io.anuke.ucore.entities.trait.VelocityTrait;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Pooling;
import java.io.DataInput;
import java.io.DataOutput;
@@ -48,7 +47,7 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
private float sinktime;
public static ItemDrop create(Item item, int amount, float x, float y, float angle){
ItemDrop drop = Pooling.obtain(ItemDrop.class);
ItemDrop drop = new ItemDrop();
drop.item = item;
drop.amount = amount;
drop.velocity.set(4f, 0f).rotate(angle);
@@ -188,11 +187,6 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
}
}
@Override
public void removed() {
Pooling.free(this);
}
@Override
public void reset() {
time = 0f;

View File

@@ -91,6 +91,8 @@ public class BreakBlock extends Block {
Shaders.blockbuild.color = Palette.remove;
if(entity.previous == null) return;
for(TextureRegion region : entity.previous.getBlockIcon()){
Shaders.blockbuild.region = region;
Shaders.blockbuild.progress = (float)(1f-entity.progress); //progress reversed

View File

@@ -29,9 +29,9 @@ public class BurstTurret extends ItemTurret {
entity.recoil = recoil;
tr.trns(entity.rotation, size * tilesize / 2, Mathf.range(xRand));
useAmmo(tile);
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
effects(tile);
useAmmo(tile);
});
}
}

View File

@@ -272,7 +272,7 @@ public class CoreBlock extends StorageBlock {
}
public class CoreEntity extends TileEntity{
Unit currentUnit;
public Unit currentUnit;
int droneID = -1;
boolean solid = true;
float warmup;