Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to ping servers imediately, ignoring waiting for serverupdateinterval #1569

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions config/ui/game/online.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ gameui_online_ver_check = [
]

gameui_online_update = [
if (>=f $gameui_panel_anim 1) [
updateservers
if (> $_lastping 0) [
if (>=f $gameui_panel_anim 1) [
updateservers
]
] [
updateservers 1
]

]

ui_gameui_online_connect_on_close = [
Expand Down Expand Up @@ -203,7 +208,7 @@ ui_gameui_online_entry_mapshot = [
uipad 0.02 0 0 0 [
uialign -1
uicolour 0 0.2 $_size [
if (>= $_lastping 0) [
if (>= $+++++ 0) [
uitext "?" 4
uicroppedimage (concatword "maps/" $_mapname) 0xffffff 0 0.2 $_size 0 (+f (*f $_size -2.5) 0.5) 1 (divf $_size 0.2) [
uispace 0 0.01 [
Expand Down
10 changes: 5 additions & 5 deletions src/engine/serverbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void checkpings()

static inline int serverinfocompare(serverinfo *a, serverinfo *b) { return client::servercompare(a, b) < 0; }

void refreshservers()
void refreshservers(const int update_now = 0)
{
static int lastrefresh = 0;
if(lastrefresh == totalmillis) return;
Expand All @@ -403,7 +403,7 @@ void refreshservers()

checkresolver();
checkpings();
if(totalmillis - lastinfo >= (serverupdateinterval*1000)/(maxservpings ? max(1, (servers.length() + maxservpings - 1) / maxservpings) : 1)) pingservers();
if(totalmillis - lastinfo >= (serverupdateinterval*1000)/(maxservpings ? max(1, (servers.length() + maxservpings - 1) / maxservpings) : 1) || update_now = 1) pingservers();
}

bool reqmaster = false;
Expand Down Expand Up @@ -499,14 +499,14 @@ void updatefrommaster()
else conoutf(colourgrey, "Retrieved list from master successfully");
}
else conoutf(colourred, "Master server not replying");
refreshservers();
refreshservers(1);
}
COMMAND(IDF_NOECHO, updatefrommaster, "");

void updateservers()
void updateservers(const int update_now = 0)
{
if(!reqmaster) updatefrommaster();
refreshservers();
refreshservers(update_now);
if(autosortservers && !pausesortservers) sortservers();
intret(servers.length());
}
Expand Down