mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
fixed the favorite button in the server info
This commit is contained in:
parent
388a04d957
commit
aee14baf8d
|
@ -849,6 +849,7 @@ static void client_process_packet(NETCHUNK *packet)
|
||||||
if(net_addr_comp(&server_address, &packet->address) == 0)
|
if(net_addr_comp(&server_address, &packet->address) == 0)
|
||||||
{
|
{
|
||||||
mem_copy(¤t_server_info, &info, sizeof(current_server_info));
|
mem_copy(¤t_server_info, &info, sizeof(current_server_info));
|
||||||
|
current_server_info.netaddr = server_address;
|
||||||
current_server_info_requesttime = -1;
|
current_server_info_requesttime = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -647,6 +647,18 @@ void client_serverbrowse_update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int client_serverbrowse_isfavorite(NETADDR addr)
|
||||||
|
{
|
||||||
|
/* search for the address */
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < num_favorite_servers; i++)
|
||||||
|
{
|
||||||
|
if(net_addr_comp(&addr, &favorite_servers[i]) == 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void client_serverbrowse_addfavorite(NETADDR addr)
|
void client_serverbrowse_addfavorite(NETADDR addr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -306,6 +306,18 @@ void client_serverbrowse_update();
|
||||||
*/
|
*/
|
||||||
int client_serverbrowse_lan();
|
int client_serverbrowse_lan();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: client_serverbrowse_isfavorite
|
||||||
|
Asks the server browser is a netaddr is in the favorite list
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
addr - Address of the server to ask about.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Returns zero if it's not in the list, non-zero if it is.
|
||||||
|
*/
|
||||||
|
int client_serverbrowse_isfavorite(NETADDR addr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: client_serverbrowse_addfavorite
|
Function: client_serverbrowse_addfavorite
|
||||||
Adds a server to the favorite list
|
Adds a server to the favorite list
|
||||||
|
|
|
@ -209,15 +209,15 @@ void MENUS::render_serverinfo(RECT main_view)
|
||||||
|
|
||||||
{
|
{
|
||||||
RECT button;
|
RECT button;
|
||||||
|
int is_favorite = client_serverbrowse_isfavorite(current_server_info.netaddr);
|
||||||
ui_hsplit_b(&serverinfo, 20.0f, &serverinfo, &button);
|
ui_hsplit_b(&serverinfo, 20.0f, &serverinfo, &button);
|
||||||
static int add_fav_button = 0;
|
static int add_fav_button = 0;
|
||||||
if (ui_do_button(&add_fav_button, "Favorite", current_server_info.favorite, &button, ui_draw_checkbox, 0))
|
if (ui_do_button(&add_fav_button, "Favorite", is_favorite, &button, ui_draw_checkbox, 0))
|
||||||
{
|
{
|
||||||
if(current_server_info.favorite)
|
if(is_favorite)
|
||||||
client_serverbrowse_removefavorite(current_server_info.netaddr);
|
client_serverbrowse_removefavorite(current_server_info.netaddr);
|
||||||
else
|
else
|
||||||
client_serverbrowse_addfavorite(current_server_info.netaddr);
|
client_serverbrowse_addfavorite(current_server_info.netaddr);
|
||||||
current_server_info.favorite = !current_server_info.favorite;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue