Skip to content

Commit

Permalink
Version 1.3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
EssentialGGBot committed Aug 8, 2024
1 parent 6ae6376 commit f12f815
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
6 changes: 6 additions & 0 deletions changelog/release-1.3.3.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Title: Bug Patch
Summary: Minor bug fixes

## Bug Fixes
- Fixed 1.21.1 crashing on boot
- Fixed game freezing when Cancel is pressed while joining a hosted world
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ org.gradle.configureondemand=true
org.gradle.parallel.threads=128
org.gradle.jvmargs=-Xmx16G
minecraftVersion=11202
version=1.3.3
version=1.3.3.1
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ abstract class IceManagerImpl(
private val stunManager = StunManager(connectionsScope)
private var candidateManager: SharedCandidateManager? = null

private var outgoingConnection: IceConnection? = null
private val incomingConnections = mutableMapOf<UUID, IceConnection>()
private val connections = mutableMapOf<UUID, IceConnection>()

protected abstract var integratedServerVoicePort: Int

Expand Down Expand Up @@ -144,7 +143,7 @@ abstract class IceManagerImpl(

private fun handlePacket(packet: IceSessionPacket) {
val user = packet.user
val outgoingConnection = outgoingConnection?.takeIf { it.user == user }
val outgoingConnection = connections[user]?.takeIf { it.job.isActive && !it.remoteCreds.isCompleted }
if (outgoingConnection != null) {
outgoingConnection.remoteCreds.complete(Pair(packet.ufrag, packet.password.encodeToByteArray()))
} else if (isInvited(user)) {
Expand All @@ -156,7 +155,7 @@ abstract class IceManagerImpl(

private fun handlePacket(packet: IceCandidatePacket) {
val user = packet.user
val connection = outgoingConnection?.takeIf { it.user == user } ?: incomingConnections[user]
val connection = connections[user]
if (connection == null) {
LOGGER.debug("Ignoring candidate from {} because they have no active session.", user)
return
Expand Down Expand Up @@ -187,9 +186,10 @@ abstract class IceManagerImpl(
}
}

outgoingConnection?.job?.cancel()
connections.forEach { it.value.job.cancel() }
connections.clear()
val connection = createIceConnection(connectionsScope, user, true, Telemetry.None)
outgoingConnection = connection
connections[user] = connection

connection.connectJob.await()
}
Expand All @@ -205,9 +205,9 @@ abstract class IceManagerImpl(
): Deferred<McConnectionArgs> {
LOGGER.info("Creating server-side ICE agent at request from {} (ufrag: {}, pwd: {})", user, ufrag, password)

incomingConnections.remove(user)?.job?.cancel()
connections.remove(user)?.job?.cancel()
val connection = createIceConnection(scope, user, false, telemetry)
incomingConnections[user] = connection
connections[user] = connection

connection.remoteCreds.complete(Pair(ufrag, password.encodeToByteArray()))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.local.LocalChannel;
import kotlin.coroutines.EmptyCoroutineContext;
import kotlinx.coroutines.Dispatchers;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.network.NetworkManager;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -29,6 +32,7 @@

import java.io.IOException;
import java.net.InetAddress;
import java.net.SocketAddress;
import java.util.UUID;

import static gg.essential.network.connectionmanager.ice.IceManager.ICE_CLIENT_EVENT_LOOP_GROUP;
Expand Down Expand Up @@ -84,7 +88,17 @@ private static ChannelFuture injectLocalChannel(Bootstrap bootstrap, InetAddress
if (user != null) {
// ICE connection
IIceManager iceManager = Essential.getInstance().getConnectionManager().getIceManager();
return bootstrap.connect(iceManager.createClientAgent(user));
Channel channel = bootstrap.register().syncUninterruptibly().channel();
ChannelPromise connectPromise = channel.newPromise();
Dispatchers.getIO().dispatch(EmptyCoroutineContext.INSTANCE, () -> {
try {
SocketAddress iceAddress = iceManager.createClientAgent(user);
channel.eventLoop().execute(() -> channel.connect(iceAddress, connectPromise));
} catch (Throwable t) {
connectPromise.setFailure(t);
}
});
return connectPromise;
}

// regular connection
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/essential/commit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4e48bf7f22
90976ad318
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class ChannelData(val channelId: UShort, val data: ByteArray) {
fun tryDecode(bytes: ByteArray): ChannelData? {
if (bytes.size < HEADER_SIZE) return null

val channelId = bytes[0].toUInt().shl(8).or(bytes[1].toUInt()).toUShort()
val channelId = bytes[0].toUByte().toUInt().shl(8).or(bytes[1].toUByte().toUInt()).toUShort()
if (channelId !in 0x4000u until 0x5000u) return null

val len = bytes[2].toInt().shl(8).or(bytes[3].toInt())
val len = bytes[2].toUByte().toInt().shl(8).or(bytes[3].toUByte().toInt())
if (HEADER_SIZE + len > bytes.size) return null

return ChannelData(channelId, bytes.sliceArray(HEADER_SIZE until HEADER_SIZE + len))
Expand Down
2 changes: 1 addition & 1 deletion versions/aliases.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1.21.1-fabric 1.20-fabric
1.21.1-fabric 1.21-fabric
1.18-fabric 1.18.1-fabric
1.19.1-fabric 1.19.2-fabric
1.16.5-forge 1.16.2-forge
Expand Down

0 comments on commit f12f815

Please sign in to comment.