show if servers use non-standard tuning and let serverbrowser filter for these; ticket #393

This commit is contained in:
Dominik Geyer 2008-10-05 09:57:46 +00:00
parent 42f661ae70
commit faa96f6d3a
8 changed files with 53 additions and 8 deletions

View file

@ -361,6 +361,7 @@ container.sprites.Add(Sprite("blank2", set_emoticons, 3, 3, 1, 1))
container.sprites.Add(Sprite("browse_lock", set_browseicons, 0,0,1,1)) container.sprites.Add(Sprite("browse_lock", set_browseicons, 0,0,1,1))
container.sprites.Add(Sprite("browse_heart", set_browseicons, 1,0,1,1)) container.sprites.Add(Sprite("browse_heart", set_browseicons, 1,0,1,1))
container.sprites.Add(Sprite("browse_tuned", set_browseicons, 2,0,1,1))
anim = Animation("base") anim = Animation("base")
anim.body.frames.Add(AnimKeyframe(0, 0, -4, 0)) anim.body.frames.Add(AnimKeyframe(0, 0, -4, 0))

View file

@ -162,7 +162,9 @@ static void client_serverbrowse_filter()
filtered = 1; filtered = 1;
else if(config.b_filter_full && serverlist[i]->info.num_players == serverlist[i]->info.max_players) else if(config.b_filter_full && serverlist[i]->info.num_players == serverlist[i]->info.max_players)
filtered = 1; filtered = 1;
else if(config.b_filter_pw && serverlist[i]->info.flags&1) else if(config.b_filter_pw && serverlist[i]->info.flags&SRVFLAG_PASSWORD)
filtered = 1;
else if(config.b_filter_tuned && serverlist[i]->info.flags&SRVFLAG_TUNED)
filtered = 1; filtered = 1;
else if(config.b_filter_ping < serverlist[i]->info.latency) else if(config.b_filter_ping < serverlist[i]->info.latency)
filtered = 1; filtered = 1;
@ -222,6 +224,7 @@ static int client_serverbrowse_sorthash()
i |= config.b_filter_pw<<6; i |= config.b_filter_pw<<6;
i |= config.b_sort_order<<7; i |= config.b_sort_order<<7;
i |= config.b_filter_compatversion<<8; i |= config.b_filter_compatversion<<8;
i |= config.b_filter_tuned<<9;
i |= config.b_filter_ping<<16; i |= config.b_filter_ping<<16;
return i; return i;
} }

View file

@ -19,6 +19,7 @@ MACRO_CONFIG_INT(b_filter_empty, 0, 0, 1)
MACRO_CONFIG_INT(b_filter_pw, 0, 0, 1) MACRO_CONFIG_INT(b_filter_pw, 0, 0, 1)
MACRO_CONFIG_INT(b_filter_ping, 999, 0, 999) MACRO_CONFIG_INT(b_filter_ping, 999, 0, 999)
MACRO_CONFIG_STR(b_filter_gametype, 128, "") MACRO_CONFIG_STR(b_filter_gametype, 128, "")
MACRO_CONFIG_INT(b_filter_tuned, 1, 0, 1)
MACRO_CONFIG_INT(b_filter_compatversion, 1, 0, 1) MACRO_CONFIG_INT(b_filter_compatversion, 1, 0, 1)
MACRO_CONFIG_INT(b_sort, 0, 0, 256) MACRO_CONFIG_INT(b_sort, 0, 0, 256)

View file

@ -165,4 +165,7 @@ const char *mods_version();
*/ */
void mods_message(int msg, int client_id); void mods_message(int msg, int client_id);
int mods_is_tuned();
#endif #endif

View file

@ -29,6 +29,13 @@ enum
MAX_NAME_LENGTH=32 MAX_NAME_LENGTH=32
}; };
enum
{
SRVFLAG_PASSWORD = 0x1,
SRVFLAG_TUNED = 0x2,
SRVFLAG_MOD = 0x4
};
/* /*
Structure: SNAP_ITEM Structure: SNAP_ITEM
*/ */

View file

@ -819,8 +819,10 @@ static void server_send_serverinfo(NETADDR *addr, int token)
/* flags */ /* flags */
i = 0; i = 0;
if(config.password[0]) if(config.password[0]) /* password set */
i |= 1; i |= SRVFLAG_PASSWORD;
if (mods_is_tuned()) /* is tuned */
i |= SRVFLAG_TUNED;
str_format(buf, sizeof(buf), "%d", i); str_format(buf, sizeof(buf), "%d", i);
packer_add_string(&p, buf, 2); packer_add_string(&p, buf, 2);

View file

@ -46,6 +46,7 @@ void MENUS::render_serverbrowser_serverlist(RECT view)
SPACER=2, SPACER=2,
COL_FLAG_LOCK=0, COL_FLAG_LOCK=0,
COL_FLAG_TUNED,
COL_FLAG_FAV, COL_FLAG_FAV,
COL_NAME, COL_NAME,
COL_GAMETYPE, COL_GAMETYPE,
@ -59,6 +60,7 @@ void MENUS::render_serverbrowser_serverlist(RECT view)
static column cols[] = { static column cols[] = {
{-1, -1, " ", -1, 2.0f, 0, {0}, {0}}, {-1, -1, " ", -1, 2.0f, 0, {0}, {0}},
{COL_FLAG_LOCK, -1, " ", -1, 14.0f, 0, {0}, {0}}, {COL_FLAG_LOCK, -1, " ", -1, 14.0f, 0, {0}, {0}},
{COL_FLAG_TUNED, -1, " ", -1, 14.0f, 0, {0}, {0}},
{COL_FLAG_FAV, -1, " ", -1, 14.0f, 0, {0}, {0}}, {COL_FLAG_FAV, -1, " ", -1, 14.0f, 0, {0}, {0}},
{COL_NAME, BROWSESORT_NAME, "Name", 0, 300.0f, 0, {0}, {0}}, {COL_NAME, BROWSESORT_NAME, "Name", 0, 300.0f, 0, {0}, {0}},
{COL_GAMETYPE, BROWSESORT_GAMETYPE, "Type", 1, 50.0f, 0, {0}, {0}}, {COL_GAMETYPE, BROWSESORT_GAMETYPE, "Type", 1, 50.0f, 0, {0}, {0}},
@ -221,9 +223,14 @@ void MENUS::render_serverbrowser_serverlist(RECT view)
if(id == COL_FLAG_LOCK) if(id == COL_FLAG_LOCK)
{ {
if(item->flags&1) if(item->flags & SRVFLAG_PASSWORD)
ui_draw_browse_icon(SPRITE_BROWSE_LOCK, &button); ui_draw_browse_icon(SPRITE_BROWSE_LOCK, &button);
} }
else if(id == COL_FLAG_TUNED)
{
if(item->flags & SRVFLAG_TUNED)
ui_draw_browse_icon(SPRITE_BROWSE_TUNED, &button);
}
else if(id == COL_FLAG_FAV) else if(id == COL_FLAG_FAV)
{ {
if(item->favorite) if(item->favorite)
@ -346,6 +353,10 @@ void MENUS::render_serverbrowser_filters(RECT view)
if (ui_do_button((char *)&config.b_filter_compatversion, "Compatible Version", config.b_filter_compatversion, &button, ui_draw_checkbox, 0)) if (ui_do_button((char *)&config.b_filter_compatversion, "Compatible Version", config.b_filter_compatversion, &button, ui_draw_checkbox, 0))
config.b_filter_compatversion ^= 1; config.b_filter_compatversion ^= 1;
ui_hsplit_t(&view, 20.0f, &button, &view);
if (ui_do_button((char *)&config.b_filter_tuned, "No tuned", config.b_filter_tuned, &button, ui_draw_checkbox, 0))
config.b_filter_tuned ^= 1;
ui_hsplit_t(&view, 20.0f, &button, &view); ui_hsplit_t(&view, 20.0f, &button, &view);
ui_do_label(&button, "Game types: ", 14.0f, -1); ui_do_label(&button, "Game types: ", 14.0f, -1);
ui_vsplit_l(&button, 95.0f, 0, &button); ui_vsplit_l(&button, 95.0f, 0, &button);
@ -383,6 +394,7 @@ void MENUS::render_serverbrowser_filters(RECT view)
config.b_filter_ping = 999; config.b_filter_ping = 999;
config.b_filter_gametype[0] = 0; config.b_filter_gametype[0] = 0;
config.b_filter_compatversion = 1; config.b_filter_compatversion = 1;
config.b_filter_tuned = 1;
config.b_filter_string[0] = 0; config.b_filter_string[0] = 0;
} }
} }
@ -415,7 +427,7 @@ void MENUS::render_serverbrowser_serverdetail(RECT view)
if (selected_server) if (selected_server)
{ {
RECT row; RECT row;
static const char *labels[] = { "Version:", "Game Type:", "Progression:", "Ping:" }; static const char *labels[] = { "Version:", "Game Type:", "Tuning:", "Progression:", "Ping:" };
RECT left_column; RECT left_column;
RECT right_column; RECT right_column;
@ -438,7 +450,7 @@ void MENUS::render_serverbrowser_serverdetail(RECT view)
ui_vsplit_l(&server_details, 5.0f, 0x0, &server_details); ui_vsplit_l(&server_details, 5.0f, 0x0, &server_details);
ui_vsplit_l(&server_details, 80.0f, &left_column, &right_column); ui_vsplit_l(&server_details, 80.0f, &left_column, &right_column);
for (int i = 0; i < 4; i++) for (unsigned int i = 0; i < sizeof(labels) / sizeof(labels[0]); i++)
{ {
ui_hsplit_t(&left_column, 15.0f, &row, &left_column); ui_hsplit_t(&left_column, 15.0f, &row, &left_column);
ui_do_label(&row, labels[i], font_size, -1); ui_do_label(&row, labels[i], font_size, -1);
@ -452,6 +464,12 @@ void MENUS::render_serverbrowser_serverdetail(RECT view)
char temp[16]; char temp[16];
str_format(temp, sizeof(temp), "%s", selected_server->flags & SRVFLAG_TUNED ? "non-standard" : "standard");
ui_hsplit_t(&right_column, 15.0f, &row, &right_column);
ui_do_label(&row, temp, font_size, -1);
if(selected_server->progression < 0) if(selected_server->progression < 0)
str_format(temp, sizeof(temp), "N/A"); str_format(temp, sizeof(temp), "N/A");
else else

View file

@ -33,6 +33,16 @@ void send_tuning_params(int cid)
*/ */
} }
int mods_is_tuned()
{
TUNING_PARAMS standard_tuning;
if (memcmp(&standard_tuning, &tuning, sizeof(TUNING_PARAMS)) != 0)
return 1;
else
return 0;
}
// Server hooks // Server hooks
void mods_client_direct_input(int client_id, void *input) void mods_client_direct_input(int client_id, void *input)
{ {