Skip to content

Commit

Permalink
Server packet priority fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Jan 23, 2025
1 parent 6c42b30 commit 8f5ecca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/src/mindustry/core/NetClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public static void connect(String ip, int port){
ui.join.connect(ip, port);
}

@Remote(targets = Loc.client)
@Remote(targets = Loc.client, priority = PacketPriority.high)
public static void ping(Player player, long time){
Call.pingResponse(player.con, time);
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/mindustry/core/NetServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ private static boolean invalid(float f){
return Float.isInfinite(f) || Float.isNaN(f);
}

@Remote(targets = Loc.client, unreliable = true)
@Remote(targets = Loc.client, unreliable = true, priority = PacketPriority.high)
public static void clientSnapshot(
Player player,
int snapshotID,
Expand Down Expand Up @@ -830,7 +830,7 @@ public static void adminRequest(Player player, Player other, AdminAction action,
}
}

@Remote(targets = Loc.client)
@Remote(targets = Loc.client, priority = PacketPriority.high)
public static void connectConfirm(Player player){
if(player.con.kicked) return;

Expand Down
15 changes: 9 additions & 6 deletions core/src/mindustry/net/Net.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,17 @@ public void handleClientReceived(Packet object){
* Call to handle a packet being received for the server.
*/
public void handleServerReceived(NetConnection connection, Packet object){
object.handled();

try{
//handle object normally
if(serverListeners.get(object.getClass()) != null){
serverListeners.get(object.getClass()).get(connection, object);
}else{
object.handleServer(connection);
if(connection.hasConnected || object.getPriority() == Packet.priorityHigh){
object.handled();

//handle object normally
if(serverListeners.get(object.getClass()) != null){
serverListeners.get(object.getClass()).get(connection, object);
}else{
object.handleServer(connection);
}
}
}catch(ValidateException e){
//ignore invalid actions
Expand Down
5 changes: 5 additions & 0 deletions core/src/mindustry/net/Packets.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,10 @@ public void read(Reads buffer){
mods.add(TypeIO.readString(buffer));
}
}

@Override
public int getPriority(){
return priorityHigh;
}
}
}

0 comments on commit 8f5ecca

Please sign in to comment.