1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-22 13:57:46 +03:00

Fixed multiple crashes, fixed version mismatch showing as disconnect

This commit is contained in:
Anuken 2018-01-26 00:36:23 -05:00
parent 6abbc3eca7
commit 493af5e653
10 changed files with 30 additions and 21 deletions

View File

@ -21,7 +21,7 @@ allprojects {
appName = "Mindustry" appName = "Mindustry"
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
aiVersion = '1.8.1' aiVersion = '1.8.1'
uCoreVersion = '0eb75cc'; uCoreVersion = 'd5ca764';
} }
repositories { repositories {

View File

@ -122,6 +122,10 @@ public class Pathfind{
//go through each spawnpoint, and if it's not found a path yet, update it //go through each spawnpoint, and if it's not found a path yet, update it
for(SpawnPoint point : Vars.control.getSpawnPoints()){ for(SpawnPoint point : Vars.control.getSpawnPoints()){
if(point.request == null){
resetPathFor(point);
}
if(!point.request.pathFound){ if(!point.request.pathFound){
try{ try{
if(point.finder.search(point.request, maxTime)){ if(point.finder.search(point.request, maxTime)){
@ -161,17 +165,21 @@ public class Pathfind{
/**Reset and clear the paths.*/ /**Reset and clear the paths.*/
public void resetPaths(){ public void resetPaths(){
for(SpawnPoint point : Vars.control.getSpawnPoints()){ for(SpawnPoint point : Vars.control.getSpawnPoints()){
point.finder = new OptimizedPathFinder<>(graph); resetPathFor(point);
point.path.clear();
point.pathTiles = null;
point.request = new PathFinderRequest<>(point.start, Vars.control.getCore(), Vars.control.getDifficulty().heuristic, point.path);
point.request.statusChanged = true; //IMPORTANT!
} }
} }
private void resetPathFor(SpawnPoint point){
point.finder = new OptimizedPathFinder<>(graph);
point.path.clear();
point.pathTiles = null;
point.request = new PathFinderRequest<>(point.start, Vars.control.getCore(), Vars.control.getDifficulty().heuristic, point.path);
point.request.statusChanged = true; //IMPORTANT!
}
/**For an enemy that was just loaded from a save, find the node in the path it should be following.*/ /**For an enemy that was just loaded from a save, find the node in the path it should be following.*/
void findNode(Enemy enemy){ void findNode(Enemy enemy){
if(enemy.lane >= Vars.control.getSpawnPoints().size || enemy.lane < 0){ if(enemy.lane >= Vars.control.getSpawnPoints().size || enemy.lane < 0){

View File

@ -291,6 +291,7 @@ public class NetClient extends Module {
Net.disconnect(); Net.disconnect();
GameState.set(State.menu); GameState.set(State.menu);
Vars.ui.showError("$text.server.kicked." + packet.reason.name()); Vars.ui.showError("$text.server.kicked." + packet.reason.name());
Vars.ui.loadfrag.hide();
}); });
Net.handle(WeaponSwitchPacket.class, packet -> { Net.handle(WeaponSwitchPacket.class, packet -> {

View File

@ -257,6 +257,7 @@ public class BlockRenderer{
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){ for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){ for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
Tile tile = world.tile(tilex, tiley); Tile tile = world.tile(tilex, tiley);
if(tile == null) continue;
if(floor){ if(floor){
if(!(tile.block() instanceof StaticBlock)){ if(!(tile.block() instanceof StaticBlock)){
tile.floor().draw(tile); tile.floor().draw(tile);

View File

@ -6,8 +6,7 @@ import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.ObjectMap; import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.async.AsyncExecutor; import com.badlogic.gdx.utils.async.AsyncExecutor;
import io.anuke.mindustry.Mindustry; import io.anuke.mindustry.Mindustry;
import io.anuke.mindustry.net.Packets.Connect; import io.anuke.mindustry.net.Packet.ImportantPacket;
import io.anuke.mindustry.net.Packets.Disconnect;
import io.anuke.mindustry.net.Packets.KickReason; import io.anuke.mindustry.net.Packets.KickReason;
import io.anuke.mindustry.net.Streamable.StreamBegin; import io.anuke.mindustry.net.Streamable.StreamBegin;
import io.anuke.mindustry.net.Streamable.StreamBuilder; import io.anuke.mindustry.net.Streamable.StreamBuilder;
@ -20,7 +19,7 @@ import io.anuke.ucore.function.Consumer;
import java.io.IOException; import java.io.IOException;
public class Net{ public class Net{
public static final int version = 12; public static final int version = 13;
private static boolean server; private static boolean server;
private static boolean active; private static boolean active;
@ -152,7 +151,7 @@ public class Net{
handleClientReceived(builder.build()); handleClientReceived(builder.build());
} }
}else if(clientListeners.get(object.getClass()) != null){ }else if(clientListeners.get(object.getClass()) != null){
if(clientLoaded || object instanceof Connect || object instanceof Disconnect || object instanceof Streamable){ if(clientLoaded || object instanceof ImportantPacket){
clientListeners.get(object.getClass()).accept(object); clientListeners.get(object.getClass()).accept(object);
}else{ }else{
UCore.log("Recieved " + object, "but ignoring data, as client is not loaded."); UCore.log("Recieved " + object, "but ignoring data, as client is not loaded.");

View File

@ -15,12 +15,10 @@ import io.anuke.mindustry.world.WorldGenerator;
import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.Blocks;
import io.anuke.mindustry.world.blocks.types.BlockPart; import io.anuke.mindustry.world.blocks.types.BlockPart;
import io.anuke.mindustry.world.blocks.types.Rock; import io.anuke.mindustry.world.blocks.types.Rock;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.Entities; import io.anuke.ucore.entities.Entities;
import java.io.*; import java.io.*;
import java.nio.ByteBuffer;
public class NetworkIO { public class NetworkIO {

View File

@ -5,4 +5,6 @@ import java.nio.ByteBuffer;
public interface Packet { public interface Packet {
void read(ByteBuffer buffer); void read(ByteBuffer buffer);
void write(ByteBuffer buffer); void write(ByteBuffer buffer);
interface ImportantPacket{}
} }

View File

@ -2,6 +2,7 @@ package io.anuke.mindustry.net;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.SyncEntity; import io.anuke.mindustry.entities.SyncEntity;
import io.anuke.mindustry.net.Packet.ImportantPacket;
import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Item;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -9,12 +10,12 @@ import java.nio.ByteBuffer;
/**Class for storing all packets.*/ /**Class for storing all packets.*/
public class Packets { public class Packets {
public static class Connect{ public static class Connect implements ImportantPacket{
public int id; public int id;
public String addressTCP; public String addressTCP;
} }
public static class Disconnect { public static class Disconnect implements ImportantPacket{
public int id; public int id;
public String addressTCP; public String addressTCP;
} }
@ -382,7 +383,7 @@ public class Packets {
} }
} }
public static class KickPacket implements Packet{ public static class KickPacket implements Packet, ImportantPacket{
public KickReason reason; public KickReason reason;
@Override @Override

View File

@ -2,13 +2,14 @@ package io.anuke.mindustry.net;
import com.badlogic.gdx.utils.reflect.ClassReflection; import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.ReflectionException; import com.badlogic.gdx.utils.reflect.ReflectionException;
import io.anuke.mindustry.net.Packet.ImportantPacket;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
public class Streamable{ public class Streamable implements ImportantPacket{
public transient ByteArrayInputStream stream; public transient ByteArrayInputStream stream;
/**Marks the beginning of a stream.*/ /**Marks the beginning of a stream.*/

View File

@ -23,7 +23,6 @@ import io.anuke.mindustry.net.Streamable;
import io.anuke.mindustry.net.Streamable.StreamBegin; import io.anuke.mindustry.net.Streamable.StreamBegin;
import io.anuke.mindustry.net.Streamable.StreamChunk; import io.anuke.mindustry.net.Streamable.StreamChunk;
import io.anuke.ucore.UCore; import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Timers;
import org.java_websocket.WebSocket; import org.java_websocket.WebSocket;
import org.java_websocket.exceptions.WebsocketNotConnectedException; import org.java_websocket.exceptions.WebsocketNotConnectedException;
import org.java_websocket.handshake.ClientHandshake; import org.java_websocket.handshake.ClientHandshake;
@ -125,7 +124,6 @@ public class KryoServer implements ServerProvider {
p.reason = reason; p.reason = reason;
con.send(p, SendMode.tcp); con.send(p, SendMode.tcp);
Timers.runTask(1f, con::close);
} }
@Override @Override