Crash fix

This commit is contained in:
Anuken
2018-09-03 10:29:44 -04:00
parent 3d4c2a2c20
commit bb59f45ba6
2 changed files with 7 additions and 4 deletions

View File

@@ -199,8 +199,10 @@ public class NetClient extends Module{
@Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true) @Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true)
public static void onSnapshot(byte[] chunk, int snapshotID, short chunkID, int totalLength, int base){ public static void onSnapshot(byte[] chunk, int snapshotID, short chunkID, int totalLength, int base){
int totalChunks = Mathf.ceil((float) totalLength / NetServer.maxSnapshotSize);
if(NetServer.debugSnapshots) if(NetServer.debugSnapshots)
Log.info("Recieved snapshot: len {0} ID {1} chunkID {2} totalLength {3} base {4} client-base {5}", chunk.length, snapshotID, chunkID, totalLength, base, netClient.lastSnapshotBaseID); Log.info("Recieved snapshot: len {0} ID {1} chunkID {2} / "+totalChunks+" totalLength {3} base {4} client-base {5}", chunk.length, snapshotID, chunkID, totalLength, base, netClient.lastSnapshotBaseID);
//skip snapshot IDs that have already been recieved OR snapshots that are too far in front //skip snapshot IDs that have already been recieved OR snapshots that are too far in front
if(base != -1 && (snapshotID < netClient.lastSnapshotBaseID || !netClient.recievedSnapshots.containsKey(base))){ if(base != -1 && (snapshotID < netClient.lastSnapshotBaseID || !netClient.recievedSnapshots.containsKey(base))){
@@ -214,7 +216,6 @@ public class NetClient extends Module{
//total length exceeds that needed to hold one snapshot, therefore, it is split into chunks //total length exceeds that needed to hold one snapshot, therefore, it is split into chunks
if(totalLength > NetServer.maxSnapshotSize){ if(totalLength > NetServer.maxSnapshotSize){
//total amount of chunks to recieve //total amount of chunks to recieve
int totalChunks = Mathf.ceil((float) totalLength / NetServer.maxSnapshotSize);
//reset status when a new snapshot sending begins //reset status when a new snapshot sending begins
if(netClient.currentSnapshotID != snapshotID || netClient.recievedChunks == null || netClient.recievedChunks.length != totalChunks){ if(netClient.currentSnapshotID != snapshotID || netClient.recievedChunks == null || netClient.recievedChunks.length != totalChunks){

View File

@@ -132,8 +132,10 @@ public class KryoServer implements ServerProvider {
//this only opens the default port due to security concerns (?) //this only opens the default port due to security concerns (?)
if(port == Vars.port){ if(port == Vars.port){
async(() -> { async(() -> {
if(!UPnP.isMappedTCP(port)) UPnP.openPortTCP(port); try{
if(!UPnP.isMappedUDP(port)) UPnP.openPortUDP(port); if(!UPnP.isMappedTCP(port)) UPnP.openPortTCP(port);
if(!UPnP.isMappedUDP(port)) UPnP.openPortUDP(port);
}catch(Throwable ignored){}
}); });
} }