Skip to content

Commit

Permalink
Support redirect (only if server implements too)
Browse files Browse the repository at this point in the history
  • Loading branch information
fokkonaut committed Jun 30, 2024
1 parent ff97a90 commit 69a6038
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,19 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
CMsgPacker Msg(NETMSG_PING_REPLY, true);
SendMsg(&Msg, 0);
}
else if(Msg == NETMSG_REDIRECT)
{
int RedirectPort = Unpacker.GetInt();
if(Unpacker.Error())
{
return;
}
char aAddr[NETADDR_MAXSTRSIZE];
NETADDR ServerAddr = *m_NetClient[CLIENT_MAIN].m_Connection.PeerAddress();
ServerAddr.port = RedirectPort;
net_addr_str(&ServerAddr, aAddr, sizeof(aAddr), true);
Connect(aAddr);
}
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_ADD)
{
if (!Config()->m_ClDummy)
Expand Down
3 changes: 2 additions & 1 deletion src/engine/shared/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ class CNetConsole
// client side
class CNetClient : public CNetBase
{
CNetConnection m_Connection;
CNetRecvUnpacker m_RecvUnpacker;

CNetTokenCache m_TokenCache;
Expand All @@ -541,6 +540,8 @@ class CNetClient : public CNetBase
int m_Flags;

public:
CNetConnection m_Connection;

// openness
bool Open(NETADDR BindAddr, class CConfig *pConfig, class IConsole *pConsole, class IEngine *pEngine, int Flags);
void Close();
Expand Down
1 change: 1 addition & 0 deletions src/engine/shared/protocol_ex_msgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ UUID(NETMSG_ITIS, "it-is@ddnet.tw")
UUID(NETMSG_IDONTKNOW, "i-dont-know@ddnet.tw")
UUID(NETMSG_CAPABILITIES, "capabilities@ddnet.tw")
UUID(NETMSG_CLIENTVER, "clientver@ddnet.tw")
UUID(NETMSG_REDIRECT, "redirect@ddnet.org")
6 changes: 3 additions & 3 deletions src/game/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef GAME_VERSION_H
#define GAME_VERSION_H
#define GAME_VERSION "0.7.5, 3.3.1"
#define GAME_VERSION "0.7.5, 3.4"
#define GAME_NETVERSION "0.7 802f1be60a05665f"
#define CLIENT_VERSION 0x0f3031
#define PREV_CLIENT_VERSION 0x0f3030
#define CLIENT_VERSION 0x0f3040
#define PREV_CLIENT_VERSION 0x0f3031
#define CLIENT_DDNET_VERSION 15050
#define GAME_NAME "F-Client"
#define SETTINGS_FILENAME "settings_fclient"
Expand Down

0 comments on commit 69a6038

Please sign in to comment.