Skip to content

Commit

Permalink
ServerBrowser: mark legacy servers with different color, fix legacy s…
Browse files Browse the repository at this point in the history
…ervers ping
  • Loading branch information
mittorn committed Feb 4, 2019
1 parent 8068ee1 commit 33e6e58
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions menus/ServerBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct server_t
char clientsstr[64];
char pingstr[64];
bool havePassword;
bool isLegacy;

static int NameCmpAscend( const void *_a, const void *_b )
{
Expand Down Expand Up @@ -127,6 +128,19 @@ class CMenuGameListModel : public CMenuBaseModel
default: return NULL;
}
}
bool GetCellColors(int line, int column, unsigned int &textColor, bool &force) const override
{
if( servers[line].isLegacy )
{
CColor color = uiPromptTextColor;
color.a = color.a * 0.7;
textColor = color;
force = true;
return true;
}
return false;
}

void OnActivateEntry(int line) override;

void Flush()
Expand Down Expand Up @@ -253,14 +267,9 @@ void CMenuGameListModel::Update( void )
snprintf( servers[i].pingstr, 64, "%.f ms", servers[i].ping * 1000 );

const char *passwd = Info_ValueForKey( info, "password" );
if( passwd[0] && !stricmp( passwd, "1") )
{
servers[i].havePassword = true;
}
else
{
servers[i].havePassword = false;
}
servers[i].havePassword = passwd[0] && !stricmp( passwd, "1");
const char *legacy = Info_ValueForKey( info, "legacy" );
servers[i].isLegacy = legacy[0] && !stricmp( legacy, "1");
}

if( servers.Count() )
Expand Down Expand Up @@ -298,11 +307,15 @@ void CMenuGameListModel::AddServerToList(netadr_t adr, const char *info)
Q_strncpy( server.name, Info_ValueForKey( info, "host" ), 64 );
Q_strncpy( server.mapname, Info_ValueForKey( info, "map" ), 64 );
snprintf( server.clientsstr, 64, "%s\\%s", Info_ValueForKey( info, "numcl" ), Info_ValueForKey( info, "maxcl" ) );
snprintf( server.pingstr, 64, "%.f ms", server.ping * 1000 );


const char *passwd = Info_ValueForKey( info, "password" );
server.havePassword = passwd[0] && !stricmp( passwd, "1");

const char *legacy = Info_ValueForKey( info, "legacy" );
server.isLegacy = legacy[0] && !stricmp( legacy, "1");
if( server.isLegacy )
server.ping /= 2;
snprintf( server.pingstr, 64, "%.f ms", server.ping * 1000 );
servers.AddToTail( server );

if( m_iSortingColumn != -1 )
Expand Down

0 comments on commit 33e6e58

Please sign in to comment.