Only add \0FML\0 to the IP if forgeinfo is not null (+ whitespace fixes)

This commit is contained in:
Pokechu22 2015-10-24 22:56:35 -07:00
parent 77277bcf84
commit b746b5612b
2 changed files with 4 additions and 4 deletions

View file

@ -38,7 +38,7 @@ namespace MinecraftClient.Protocol.Handlers.Forge
/// <param name="data">The modinfo JSON tag.</param> /// <param name="data">The modinfo JSON tag.</param>
internal ForgeInfo(Json.JSONData data) internal ForgeInfo(Json.JSONData data)
{ {
// Example ModInfo (with spacing): // Example ModInfo (with spacing):
// "modinfo": { // "modinfo": {
// "type": "FML", // "type": "FML",

View file

@ -223,7 +223,7 @@ namespace MinecraftClient.Protocol.Handlers
if (channel == "FML|HS") if (channel == "FML|HS")
{ {
FMLHandshakeDiscriminator discriminator = (FMLHandshakeDiscriminator)readNextByte(ref packetData); FMLHandshakeDiscriminator discriminator = (FMLHandshakeDiscriminator)readNextByte(ref packetData);
if (discriminator == FMLHandshakeDiscriminator.HandshakeReset) if (discriminator == FMLHandshakeDiscriminator.HandshakeReset)
{ {
fmlHandshakeState = FMLHandshakeClientState.START; fmlHandshakeState = FMLHandshakeClientState.START;
@ -259,7 +259,7 @@ namespace MinecraftClient.Protocol.Handlers
ForgeInfo.ForgeMod mod = forgeInfo.Mods[i]; ForgeInfo.ForgeMod mod = forgeInfo.Mods[i];
mods[i] = concatBytes(getString(mod.ModID), getString(mod.Version)); mods[i] = concatBytes(getString(mod.ModID), getString(mod.Version));
} }
SendForgeHandshakePacket(FMLHandshakeDiscriminator.ModList, SendForgeHandshakePacket(FMLHandshakeDiscriminator.ModList,
concatBytes(getVarInt(forgeInfo.Mods.Count), concatBytes(mods))); concatBytes(getVarInt(forgeInfo.Mods.Count), concatBytes(mods)));
fmlHandshakeState = FMLHandshakeClientState.WAITINGSERVERDATA; fmlHandshakeState = FMLHandshakeClientState.WAITINGSERVERDATA;
@ -694,7 +694,7 @@ namespace MinecraftClient.Protocol.Handlers
public bool Login() public bool Login()
{ {
byte[] protocol_version = getVarInt(protocolversion); byte[] protocol_version = getVarInt(protocolversion);
byte[] server_adress_val = Encoding.UTF8.GetBytes(handler.GetServerHost() + "\0FML\0"); byte[] server_adress_val = Encoding.UTF8.GetBytes(handler.GetServerHost() + (forgeInfo != null ? "\0FML\0" : ""));
byte[] server_adress_len = getVarInt(server_adress_val.Length); byte[] server_adress_len = getVarInt(server_adress_val.Length);
byte[] server_port = BitConverter.GetBytes((ushort)handler.GetServerPort()); Array.Reverse(server_port); byte[] server_port = BitConverter.GetBytes((ushort)handler.GetServerPort()); Array.Reverse(server_port);
byte[] next_state = getVarInt(2); byte[] next_state = getVarInt(2);