Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Maple2.Server.World/Containers/ChannelClientLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public IEnumerable<int> Keys {
}

public (ushort gamePort, int grpcPort, int channel) FindOrCreateChannelByIp(string gameIp, string grpcGameIp, bool instancedContent) {
for (int i = 0; i < channels.Count; i++) {
channels.TryGetValue(i, out Channel? activeChannel);
if (activeChannel is null) {
continue;
}
if (activeChannel.Endpoint.Address.ToString() == gameIp && activeChannel.Status is ChannelStatus.Inactive && activeChannel.InstancedContent == instancedContent) {
return (activeChannel.GamePort, activeChannel.GrpcPort, activeChannel.Id);
}
// find the first channel that matches the ip, status and instanced content
Channel? activeChannel = channels.Values.FirstOrDefault(channel =>
channel.Endpoint.Address.ToString() == gameIp &&
channel.Status is ChannelStatus.Inactive &&
channel.InstancedContent == instancedContent);

if (activeChannel is not null) {
return (activeChannel.GamePort, activeChannel.GrpcPort, activeChannel.Id);
}

return AddChannel(gameIp, grpcGameIp, instancedContent);
Expand Down