Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reconnecting dummy by redirecting to same port #9482

Merged
merged 1 commit into from
Jan 5, 2025
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
25 changes: 20 additions & 5 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1768,11 +1768,26 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
{
return;
}
char aAddr[NETADDR_MAXSTRSIZE];
NETADDR ServerAddr = ServerAddress();
ServerAddr.port = RedirectPort;
net_addr_str(&ServerAddr, aAddr, sizeof(aAddr), true);
Connect(aAddr);
if(Conn == CONN_MAIN)
{
NETADDR ServerAddr = ServerAddress();
ServerAddr.port = RedirectPort;
char aAddr[NETADDR_MAXSTRSIZE];
net_addr_str(&ServerAddr, aAddr, sizeof(aAddr), true);
Connect(aAddr);
}
else
{
DummyDisconnect(nullptr);
if(ServerAddress().port != RedirectPort)
{
// Only allow redirecting to the same port to reconnect. The dummy
// should not be connected to a different server than the main, as
// the client assumes that main and dummy use the same map.
return;
}
DummyConnect();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this fix. It accurately represents the dummy as a secondary player that still disconnects on a redirect packet but does not cause a desync.

Could you maybe add a message that simply reconnects without taking a port so we can move away from this "hack" of using the redirect function in some time?

}
else if(Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_ADD)
{
Expand Down
Loading