Skip to content

Commit

Permalink
修复服务端无法运行
Browse files Browse the repository at this point in the history
  • Loading branch information
way-zer committed Dec 12, 2024
1 parent 083f9c7 commit 8dd1d76
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions patches/client/0066-HC-v146-protocol-compatible-mode-v146.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Content-Transfer-Encoding: 8bit

---
core/src/mindustry/core/NetClient.java | 2 +-
core/src/mindustry/net/Net.java | 35 +++++++++++++++++++++++---
core/src/mindustry/net/NetworkIO.java | 12 +++++++++
core/src/mindustry/net/Net.java | 38 ++++++++++++++++++++++++--
core/src/mindustry/net/NetworkIO.java | 12 ++++++++
core/src/mindustry/net/Packets.java | 2 +-
4 files changed, 46 insertions(+), 5 deletions(-)
4 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java
index 0d27fbfb034eea3fc39258b8350c28aa4eb69a62..fa656d977e05461ea63cad51e6679485fa41b781 100644
Expand All @@ -29,10 +29,18 @@ index 0d27fbfb034eea3fc39258b8350c28aa4eb69a62..fa656d977e05461ea63cad51e6679485
break;
}
diff --git a/core/src/mindustry/net/Net.java b/core/src/mindustry/net/Net.java
index aaaf83f6e49bd78a88ada08471c53229fc478ac7..bfb6614ff479fcbbb1dadf0c6ee1080124c7b6a8 100644
index aaaf83f6e49bd78a88ada08471c53229fc478ac7..84bac2a6ad4800f78a129e884c53a88694e639e9 100644
--- a/core/src/mindustry/net/Net.java
+++ b/core/src/mindustry/net/Net.java
@@ -19,7 +19,7 @@ import java.nio.*;
@@ -1,6 +1,7 @@
package mindustry.net;

import arc.*;
+import arc.files.*;
import arc.func.*;
import arc.net.*;
import arc.net.Server.*;
@@ -19,7 +20,7 @@ import java.nio.*;
import java.nio.channels.*;
import java.util.concurrent.*;

Expand All @@ -41,7 +49,7 @@ index aaaf83f6e49bd78a88ada08471c53229fc478ac7..bfb6614ff479fcbbb1dadf0c6ee10801
import static mindustry.Vars.*;

@SuppressWarnings("unchecked")
@@ -27,6 +27,9 @@ public class Net{
@@ -27,6 +28,9 @@ public class Net{
private static Seq<Prov<? extends Packet>> packetProvs = new Seq<>();
private static Seq<Class<? extends Packet>> packetClasses = new Seq<>();
private static ObjectIntMap<Class<?>> packetToId = new ObjectIntMap<>();
Expand All @@ -51,11 +59,13 @@ index aaaf83f6e49bd78a88ada08471c53229fc478ac7..bfb6614ff479fcbbb1dadf0c6ee10801

private boolean server;
private boolean active;
@@ -49,6 +52,22 @@ public class Net{
@@ -49,6 +53,24 @@ public class Net{

//register generated packet classes
Call.registerPackets();
+ oldMappings.addAll(Core.files.internal("packetsV146").readString().split(System.lineSeparator()));
+
+ Fi fi = Core.files != null ? Core.files.internal("packetsV146") : new Fi("packetsV146", Files.FileType.internal);
+ oldMappings.addAll(fi.readString().split(System.lineSeparator()));
+ for(String name : oldMappings){
+ oldPacketToId.put(name, oldPacketToId.size);
+ }
Expand All @@ -74,7 +84,7 @@ index aaaf83f6e49bd78a88ada08471c53229fc478ac7..bfb6614ff479fcbbb1dadf0c6ee10801
}

/** Registers a new packet type for serialization. */
@@ -60,12 +79,16 @@ public class Net{
@@ -60,12 +82,16 @@ public class Net{
}

public static byte getPacketId(Packet packet){
Expand All @@ -92,15 +102,15 @@ index aaaf83f6e49bd78a88ada08471c53229fc478ac7..bfb6614ff479fcbbb1dadf0c6ee10801
return ((Prov<T>)packetProvs.get(id & 0xff)).get();
}

@@ -200,6 +223,7 @@ public class Net{
@@ -200,6 +226,7 @@ public class Net{
}

public void disconnect(){
+ content.setTemporaryMapper(null);
if(active && !server){
Log.info("Disconnecting.");
}
@@ -269,7 +293,12 @@ public class Net{
@@ -269,7 +296,12 @@ public class Net{
* Call to handle a packet being received for the client.
*/
public void handleClientReceived(Packet object){
Expand Down

0 comments on commit 8dd1d76

Please sign in to comment.