Fixed #10329 by timing out when UDP snapshots are not received
This commit is contained in:
@@ -301,6 +301,7 @@ disconnect.error = Connection error.
|
|||||||
disconnect.closed = Connection closed.
|
disconnect.closed = Connection closed.
|
||||||
disconnect.timeout = Timed out.
|
disconnect.timeout = Timed out.
|
||||||
disconnect.data = Failed to load world data!
|
disconnect.data = Failed to load world data!
|
||||||
|
disconnect.snapshottimeout = Timed out while receiving UDP snapshots.\nThis may be caused by an unstable network or connection.
|
||||||
cantconnect = Unable to join game ([accent]{0}[]).
|
cantconnect = Unable to join game ([accent]{0}[]).
|
||||||
connecting = [accent]Connecting...
|
connecting = [accent]Connecting...
|
||||||
reconnecting = [accent]Reconnecting...
|
reconnecting = [accent]Reconnecting...
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ import mindustry.gen.*;
|
|||||||
public class MissileAI extends AIController{
|
public class MissileAI extends AIController{
|
||||||
public @Nullable Unit shooter;
|
public @Nullable Unit shooter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void resetTimers(){
|
||||||
|
timer.reset(timerTarget, Mathf.random(3f));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMovement(){
|
public void updateMovement(){
|
||||||
unloadPayloads();
|
unloadPayloads();
|
||||||
|
|||||||
@@ -4127,7 +4127,7 @@ public class Blocks{
|
|||||||
hitEffect = despawnEffect = Fx.hitSquaresColor;
|
hitEffect = despawnEffect = Fx.hitSquaresColor;
|
||||||
buildingDamageMultiplier = 0.2f;
|
buildingDamageMultiplier = 0.2f;
|
||||||
}},
|
}},
|
||||||
Items.silicon, new BasicBulletType(8f, 34){{
|
Items.silicon, new BasicBulletType(8f, 35){{
|
||||||
knockback = 3f;
|
knockback = 3f;
|
||||||
width = 25f;
|
width = 25f;
|
||||||
hitSize = 7f;
|
hitSize = 7f;
|
||||||
@@ -4980,7 +4980,7 @@ public class Blocks{
|
|||||||
fragLifeMin = 0.1f;
|
fragLifeMin = 0.1f;
|
||||||
fragBullets = 5;
|
fragBullets = 5;
|
||||||
fragRandomSpread = 0f;
|
fragRandomSpread = 0f;
|
||||||
fragSpread = 37f;
|
fragSpread = 30f;
|
||||||
fragBullet = new BulletType(){{
|
fragBullet = new BulletType(){{
|
||||||
shootEffect = Fx.shootBig;
|
shootEffect = Fx.shootBig;
|
||||||
smokeEffect = Fx.shootSmokeMissileColor;
|
smokeEffect = Fx.shootSmokeMissileColor;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import java.util.zip.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class NetClient implements ApplicationListener{
|
public class NetClient implements ApplicationListener{
|
||||||
|
private static final long entitySnapshotTimeout = 1000 * 20;
|
||||||
private static final float dataTimeout = 60 * 30;
|
private static final float dataTimeout = 60 * 30;
|
||||||
/** ticks between syncs, e.g. 5 means 60/5 = 12 syncs/sec*/
|
/** ticks between syncs, e.g. 5 means 60/5 = 12 syncs/sec*/
|
||||||
private static final float playerSyncTime = 4;
|
private static final float playerSyncTime = 4;
|
||||||
@@ -50,6 +51,8 @@ public class NetClient implements ApplicationListener{
|
|||||||
private boolean quietReset = false;
|
private boolean quietReset = false;
|
||||||
/** Counter for data timeout. */
|
/** Counter for data timeout. */
|
||||||
private float timeoutTime = 0f;
|
private float timeoutTime = 0f;
|
||||||
|
/** Timestamp for last UDP state snapshot received. */
|
||||||
|
private long lastSnapshotTimestamp;
|
||||||
/** Last sent client snapshot ID. */
|
/** Last sent client snapshot ID. */
|
||||||
private int lastSent;
|
private int lastSent;
|
||||||
|
|
||||||
@@ -478,6 +481,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
@Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true)
|
@Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true)
|
||||||
public static void entitySnapshot(short amount, byte[] data){
|
public static void entitySnapshot(short amount, byte[] data){
|
||||||
try{
|
try{
|
||||||
|
netClient.lastSnapshotTimestamp = Time.millis();
|
||||||
netClient.byteStream.setBytes(data);
|
netClient.byteStream.setBytes(data);
|
||||||
DataInputStream input = netClient.dataStream;
|
DataInputStream input = netClient.dataStream;
|
||||||
|
|
||||||
@@ -575,7 +579,18 @@ public class NetClient implements ApplicationListener{
|
|||||||
if(!net.client()) return;
|
if(!net.client()) return;
|
||||||
|
|
||||||
if(state.isGame()){
|
if(state.isGame()){
|
||||||
if(!connecting) sync();
|
if(!connecting){
|
||||||
|
sync();
|
||||||
|
|
||||||
|
//timeout if UDP snapshot packets are not received for a while
|
||||||
|
if(lastSnapshotTimestamp > 0 && Time.timeSinceMillis(lastSnapshotTimestamp) > entitySnapshotTimeout){
|
||||||
|
Log.err("Timed out after not received UDP snapshots.");
|
||||||
|
quiet = true;
|
||||||
|
ui.showErrorMessage("@disconnect.snapshottimeout");
|
||||||
|
net.disconnect();
|
||||||
|
lastSnapshotTimestamp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}else if(!connecting){
|
}else if(!connecting){
|
||||||
net.disconnect();
|
net.disconnect();
|
||||||
}else{ //...must be connecting
|
}else{ //...must be connecting
|
||||||
@@ -612,6 +627,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
Core.app.post(Call::connectConfirm);
|
Core.app.post(Call::connectConfirm);
|
||||||
Time.runTask(40f, platform::updateRPC);
|
Time.runTask(40f, platform::updateRPC);
|
||||||
Core.app.post(ui.loadfrag::hide);
|
Core.app.post(ui.loadfrag::hide);
|
||||||
|
lastSnapshotTimestamp = Time.millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reset(){
|
private void reset(){
|
||||||
@@ -622,6 +638,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
quietReset = false;
|
quietReset = false;
|
||||||
quiet = false;
|
quiet = false;
|
||||||
lastSent = 0;
|
lastSent = 0;
|
||||||
|
lastSnapshotTimestamp = 0;
|
||||||
|
|
||||||
Groups.clear();
|
Groups.clear();
|
||||||
ui.chatfrag.clearMessages();
|
ui.chatfrag.clearMessages();
|
||||||
|
|||||||
@@ -1082,7 +1082,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
try{
|
try{
|
||||||
writeEntitySnapshot(player);
|
writeEntitySnapshot(player);
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
e.printStackTrace();
|
Log.err(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,12 @@ public class AIController implements UnitController{
|
|||||||
protected Teamc target;
|
protected Teamc target;
|
||||||
|
|
||||||
{
|
{
|
||||||
timer.reset(0, Mathf.random(40f));
|
resetTimers();
|
||||||
timer.reset(1, Mathf.random(60f));
|
}
|
||||||
|
|
||||||
|
protected void resetTimers(){
|
||||||
|
timer.reset(timerTarget, Mathf.random(40f));
|
||||||
|
timer.reset(timerTarget2, Mathf.random(60f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user