Fixed bugs with router clogging and save loading

This commit is contained in:
Anuken 2017-11-23 23:05:19 -05:00
parent f5583f6bc8
commit 56113cd1de
5 changed files with 16 additions and 16 deletions

View File

@ -92,13 +92,6 @@ public class Pathfind{
}
}
//TODO make this work?
/*
PathFinderRequest<Tile> request = new PathFinderRequest<Tile>();
request.startNode = World.spawnpoints.get(0);
request.endNode = World.core;
passpathfinder.search(request, 1000); */
for(int i = 0; i < paths.size; i ++){
SmoothGraphPath path = paths.get(i);

View File

@ -76,13 +76,17 @@ public class LoadDialog extends FloatingDialog{
hide();
try{
SaveIO.loadFromSlot(slot);
GameState.set(State.playing);
Vars.ui.hideMenu();
}catch(Exception e){
e.printStackTrace();
Vars.ui.hideMenu();
GameState.set(State.menu);
Vars.control.reset();
Vars.ui.showError("[orange]Save file corrupted or invalid!");
return;
}
Vars.ui.hideMenu();
GameState.set(State.playing);
}
}, 3f/60f);
}

View File

@ -79,14 +79,14 @@ public class Conveyor extends Block{
for(int j = 0; j < entity.convey.size; j ++){
ItemPos other = pos2.set(entity.convey.get(j));
if(other.y > pos.y && other.y - pos.y < 0.14){
if(other.y > pos.y && other.y - pos.y < 0.14 * Timers.delta()){
canmove = false;
break;
}
}
if(canmove){
pos.y += speed * Timers.delta();
pos.y += Math.max(speed * Timers.delta(), 1f/252f); //TODO fix precision issues?
pos.x = MathUtils.lerp(pos.x, 0, 0.06f * Timers.delta());
}else{
pos.x = MathUtils.lerp(pos.x, pos.seed/128f/3f, 0.1f * Timers.delta());
@ -138,7 +138,7 @@ public class Conveyor extends Block{
* Conveyor data format:
* [0] item ordinal
* [1] x: byte ranging from -128 to 127, scaled should be at [-1, 1], corresponds to relative X from the conveyor middle
* [2] y: byte ranging from 0 to 127, scaled should be at [0, 1], corresponds to relative Y from the conveyor start
* [2] y: byte ranging from -128 to 127, scaled should be at [0, 1], corresponds to relative Y from the conveyor start
* [3] seed: -128 to 127, unscaled
* Size is 4 bytes, or one int.
*/
@ -178,7 +178,7 @@ public class Conveyor extends Block{
byte[] values = Bits.getBytes(value);
item = items[values[0]];
x = values[1] / 127f;
y = ((int)values[2]) / 127f;
y = ((int)values[2] + 128) / 255f;
seed = values[3];
return this;
}
@ -191,7 +191,7 @@ public class Conveyor extends Block{
byte[] bytes = Bits.getBytes(0);
bytes[0] = (byte)item.ordinal();
bytes[1] = (byte)(x*127);
bytes[2] = (byte)(y*127);
bytes[2] = (byte)(y*255-128);
bytes[3] = seed;
//UCore.log("Packing item: ", item, x, y, seed, "\n", Arrays.toString(bytes));
//UCore.log(Arrays.toString(Bits.getBytes(Bits.packInt(bytes))));

View File

@ -9,6 +9,7 @@ import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Mathf;
public class Router extends Block{
private ObjectMap<Tile, Byte> lastmap = new ObjectMap<>();
@ -34,8 +35,10 @@ public class Router extends Block{
@Override
public void update(Tile tile){
if(Timers.get(tile, "dump", 2) && tile.entity.totalItems() > 0){
if(lastmap.get(tile, (byte)-1) != tile.rotation)
if(lastmap.get(tile, (byte)-1) != tile.rotation
|| Mathf.chance(0.3)){ //sometimes dump backwards at a 1/4 chance... this somehow works?
tryDump(tile, tile.rotation, null);
}
tile.rotation ++;
tile.rotation %= 4;

View File

@ -17,7 +17,7 @@ public class DesktopLauncher {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setTitle("Mindustry");
config.setMaximized(true);
//config.useVsync(false);
config.useVsync(false);
config.setWindowedMode(800, 600);
config.setWindowIcon("sprites/icon.png");