Compatibility level is now passed from server to client - and

the client tracks it. This means certain packet changes can be made
without breaking comms, hopefully
This commit is contained in:
Christian committed 2012-09-07 19:32:36 -04:00
1 parent 4f70d23d0e
commit 16fe495d18
5 files changed
+54 -8

No files matched your search

@@ -409,4 +409,10 @@ public class FMLClientHandler implements IFMLSidedHandler
{
((NetClientHandler)handler).fmlPacket131Callback(mapData);
}
@Override
public void setCompatibilityLevel(NetHandler netHandler, byte compatibilityLevel)
{
((NetClientHandler)netHandler).setConnectionCompatibilityLevel(compatibilityLevel);
}
}
@@ -37,4 +37,6 @@ public interface IFMLSidedHandler
void displayMissingMods(ModMissingPacket modMissingPacket);
void handleTinyPacket(NetHandler handler, Packet131MapData mapData);
void setCompatibilityLevel(NetHandler netHandler, byte compatibilityLevel);
}
@@ -18,6 +18,7 @@ import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
@@ -25,6 +26,7 @@ import cpw.mods.fml.common.ModContainer;
public class ModListRequestPacket extends FMLPacket
{
private List<String> sentModList;
private byte compatibilityLevel;
public ModListRequestPacket()
{
@@ -41,6 +43,7 @@ public class ModListRequestPacket extends FMLPacket
{
dat.writeUTF(mc.getModId());
}
dat.writeByte(FMLNetworkHandler.getCompatibilityLevel());
return dat.toByteArray();
}
@@ -54,6 +57,14 @@ public class ModListRequestPacket extends FMLPacket
{
sentModList.add(in.readUTF());
}
try
{
compatibilityLevel = in.readByte();
}
catch (IllegalArgumentException e)
{
FMLLog.fine("No compatibility byte found - the server is too old");
}
return this;
}
@@ -99,6 +110,11 @@ public class ModListRequestPacket extends FMLPacket
}
}
if (compatibilityLevel != 0)
{
FMLLog.fine("The server has compatibility level %d", compatibilityLevel);
FMLCommonHandler.instance().getSidedDelegate().setCompatibilityLevel(netHandler, compatibilityLevel);
}
Packet250CustomPayload pkt = new Packet250CustomPayload();
pkt.field_73630_a = "FML";
pkt.field_73629_c = FMLPacket.makePacket(MOD_LIST_RESPONSE, modVersions, missingMods);
@@ -163,4 +163,9 @@ public class FMLServerHandler implements IFMLSidedHandler
{
// NOOP on server
}
@Override
public void setCompatibilityLevel(NetHandler netHandler, byte compatibilityLevel)
{
// NOOP on server
}
}
@@ -9,7 +9,14 @@
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -42,6 +44,7 @@
@@ -37,11 +39,14 @@
public int field_72556_d = 20;
Random field_72557_e = new Random();
+ public int connectionCompatibilityLevel;
+
public NetClientHandler(Minecraft p_i3103_1_, String p_i3103_2_, int p_i3103_3_) throws IOException
{
this.field_72563_h = p_i3103_1_;
Socket var4 = new Socket(InetAddress.getByName(p_i3103_2_), p_i3103_3_);
this.field_72555_g = new TcpConnection(var4, "Client", this);
@@ -17,7 +24,7 @@
}
public NetClientHandler(Minecraft p_i3104_1_, IntegratedServer p_i3104_2_) throws IOException
@@ -49,6 +52,7 @@
@@ -49,6 +54,7 @@
this.field_72563_h = p_i3104_1_;
this.field_72555_g = new MemoryConnection(this);
p_i3104_2_.func_71343_a().func_71754_a((MemoryConnection)this.field_72555_g, p_i3104_1_.field_71449_j.field_74286_b);
@@ -25,7 +32,7 @@
}
public void func_72547_c()
@@ -119,6 +123,7 @@
@@ -119,6 +125,7 @@
public void func_72513_a(Packet252SharedKey p_72513_1_)
{
@@ -33,7 +40,7 @@
this.func_72552_c(new Packet205ClientCommand(0));
}
@@ -134,6 +139,7 @@
@@ -134,6 +141,7 @@
this.field_72563_h.field_71439_g.field_70157_k = p_72455_1_.field_73561_a;
this.field_72556_d = p_72455_1_.field_73562_h;
this.field_72563_h.field_71442_b.func_78746_a(p_72455_1_.field_73557_d);
@@ -41,7 +48,7 @@
this.func_72552_c(new Packet204ClientInfo(this.field_72563_h.field_71474_y.field_74363_ab, this.field_72563_h.field_71474_y.field_74339_e, this.field_72563_h.field_71474_y.field_74343_n, this.field_72563_h.field_71474_y.field_74344_o, this.field_72563_h.field_71474_y.field_74318_M));
}
@@ -605,6 +611,7 @@
@@ -605,6 +613,7 @@
public void func_72481_a(Packet3Chat p_72481_1_)
{
@@ -49,7 +56,7 @@
this.field_72563_h.field_71456_v.func_73827_b().func_73765_a(p_72481_1_.field_73476_b);
}
@@ -1066,6 +1073,11 @@
@@ -1066,6 +1075,11 @@
public void func_72494_a(Packet131MapData p_72494_1_)
{
@@ -61,7 +68,7 @@
if (p_72494_1_.field_73438_a == Item.field_77744_bd.field_77779_bT)
{
ItemMap.func_77874_a(p_72494_1_.field_73436_b, this.field_72563_h.field_71441_e).func_76192_a(p_72494_1_.field_73437_c);
@@ -1166,6 +1178,11 @@
@@ -1166,6 +1180,11 @@
}
public void func_72501_a(Packet250CustomPayload p_72501_1_)
@@ -73,7 +80,7 @@
{
if ("MC|TPack".equals(p_72501_1_.field_73630_a))
{
@@ -1211,4 +1228,10 @@
@@ -1211,4 +1230,20 @@
{
return this.field_72555_g;
}
@@ -82,5 +89,15 @@
+ public EntityPlayer getPlayer()
+ {
+ return field_72563_h.field_71439_g;
+ }
+
+ public void setConnectionCompatibilityLevel(int connectionCompatibilityLevel)
+ {
+ this.connectionCompatibilityLevel = connectionCompatibilityLevel;
+ }
+
+ public int getConnectionCompatibilityLevel()
+ {
+ return connectionCompatibilityLevel;
+ }
}