mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-09 07:17:36 +07:00
Better error handling on Steam
This commit is contained in:
@ -1365,7 +1365,6 @@ public class UnitTypes implements ContentList{
|
||||
trailX = 5.5f;
|
||||
trailY = -4f;
|
||||
trailScl = 1.9f;
|
||||
rotateShooting = false;
|
||||
|
||||
abilities.add(new StatusFieldAbility(StatusEffects.overclock, 60f * 6, 60f * 6f, 60f));
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class ArcNetProvider implements NetProvider{
|
||||
try{
|
||||
net.handleClientReceived(object);
|
||||
}catch(Throwable e){
|
||||
handleException(e);
|
||||
net.handleException(e);
|
||||
}
|
||||
});
|
||||
|
||||
@ -144,14 +144,14 @@ public class ArcNetProvider implements NetProvider{
|
||||
try{
|
||||
client.run();
|
||||
}catch(Exception e){
|
||||
if(!(e instanceof ClosedSelectorException)) handleException(e);
|
||||
if(!(e instanceof ClosedSelectorException)) net.handleException(e);
|
||||
}
|
||||
});
|
||||
|
||||
client.connect(5000, ip, port, port);
|
||||
success.run();
|
||||
}catch(Exception e){
|
||||
handleException(e);
|
||||
net.handleException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -269,16 +269,6 @@ public class ArcNetProvider implements NetProvider{
|
||||
return null;
|
||||
}
|
||||
|
||||
void handleException(Throwable e){
|
||||
if(e instanceof ArcNetException){
|
||||
Core.app.post(() -> net.showError(new IOException("mismatch")));
|
||||
}else if(e instanceof ClosedChannelException){
|
||||
Core.app.post(() -> net.showError(new IOException("alreadyconnected")));
|
||||
}else{
|
||||
Core.app.post(() -> net.showError(e));
|
||||
}
|
||||
}
|
||||
|
||||
class ArcConnection extends NetConnection{
|
||||
public final Connection connection;
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package mindustry.net;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.util.*;
|
||||
import arc.net.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.net.Packets.*;
|
||||
@ -13,6 +14,7 @@ import net.jpountz.lz4.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
import java.nio.channels.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@ -36,6 +38,16 @@ public class Net{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public void handleException(Throwable e){
|
||||
if(e instanceof ArcNetException){
|
||||
Core.app.post(() -> showError(new IOException("mismatch")));
|
||||
}else if(e instanceof ClosedChannelException){
|
||||
Core.app.post(() -> showError(new IOException("alreadyconnected")));
|
||||
}else{
|
||||
Core.app.post(() -> showError(e));
|
||||
}
|
||||
}
|
||||
|
||||
/** Display a network error. Call on the graphics thread. */
|
||||
public void showError(Throwable e){
|
||||
|
||||
|
@ -79,10 +79,14 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
||||
Log.err(e);
|
||||
}
|
||||
}else if(currentServer != null && fromID == currentServer.getAccountID()){
|
||||
net.handleClientReceived(output);
|
||||
try{
|
||||
net.handleClientReceived(output);
|
||||
}catch(Throwable t){
|
||||
net.handleException(t);
|
||||
}
|
||||
}
|
||||
}catch(SteamException e){
|
||||
e.printStackTrace();
|
||||
Log.err(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user