ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.68k stars 624 forks source link

add current server #508

Closed MaximilianKohler closed 2 weeks ago

MaximilianKohler commented 11 years ago

This button doesn't do anything for me.

win7 x64

alfred-valve commented 11 years ago

What game?

di57inct commented 11 years ago

On both CS and CZ. It just isn't working(tested on XP SP3 a long time ago too).

xPaw commented 11 years ago

Yep, not working in CS and CZ here.

SowingSadness commented 11 years ago

+1

SamVanheer commented 5 years ago

This still happens.

I did a little research and i found that the problem appears to be a missing byte swap operation in CServerBrowserDialog::OnConnectToGame. The server browser stores off the connection data here, and adds it to the history list as well.

The data that is stored is taken directly from the given KeyValues data, but the IP address that gets passed to ISteamMatchmaking::AddFavoriteGame is byte swapped. If the IP address is invalid it might not be added to the list of favorites to begin with.

I did test to see if the button was not being initialized properly, but i ruled it out. Half-Life/platform/servers/InternetGamesPage.res contains the command used for the button, changing it to AddServerByName works.

I did notice that AddServerByName has both its own command handler and a case in OnCommand while AddCurrentServer is only handled in OnCommand, so if the byte swap thing isn't the cause of this, perhaps this is why it isn't working. Based on what i know about VGUI2 that shouldn't be the case though.

Addendum: When a server response is received this is how the IP address is formatted:

byte v95[ 4 ];
      *(_DWORD *)v95 = pServerItem->m_NetAdr.m_unIP;
      snprintf(
        &servernetadr_t::ToString(unsigned int,unsigned short)::sconst[64
                                                                     * servernetadr_t::ToString(unsigned int,unsigned short)::nBufconst],
        0x40u,
        "%u.%u.%u.%u:%i",
        v95[3],
        (unsigned __int8)(*(_DWORD *)v95 >> 16),
        v95[1],
        v95[0],
        v48);

So the IP address is stored in reverse order, at least on Linux.

More information from Source: https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/public/steam/matchmakingtypes.h#L158-L162 https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/public/tier1/netadr.h#L38 https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/tier1/NetAdr.cpp#L162-L165

shawns-valve commented 2 weeks ago

This should be resolved in the October 2, 2024 Half-Life Steam build.