Platform: functions Master_GetInternetServers() and Master_GetLANServers() return cached values now to avoid the engine touching the cache which may drop servers.
This commit is contained in:
parent
0bf9374016
commit
0ea41d9304
2 changed files with 32 additions and 28 deletions
|
@ -33,6 +33,12 @@ float srv_fldPlayers;
|
||||||
float srv_fldMaxplayers;
|
float srv_fldMaxplayers;
|
||||||
float srv_fldMap;
|
float srv_fldMap;
|
||||||
float srv_fldGame;
|
float srv_fldGame;
|
||||||
|
float srv_fldServerInfo;
|
||||||
|
float srv_fldPlayer0;
|
||||||
|
|
||||||
|
/* We cache these, because the engine may purge our cache anyway */
|
||||||
|
int g_masterInternetServers;
|
||||||
|
int g_masterLANServers;
|
||||||
|
|
||||||
/** Returns IP of master server. */
|
/** Returns IP of master server. */
|
||||||
string Master_Resolve(void);
|
string Master_Resolve(void);
|
||||||
|
|
|
@ -45,45 +45,39 @@ Master_GetTotalServers(void)
|
||||||
int
|
int
|
||||||
Master_GetLANServers(void)
|
Master_GetLANServers(void)
|
||||||
{
|
{
|
||||||
int count = 0;
|
return g_masterLANServers;
|
||||||
int tcount = 0;
|
|
||||||
|
|
||||||
count = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
string address;
|
|
||||||
address = gethostcachestring(srv_fldAdress, i);
|
|
||||||
|
|
||||||
/* skip LAN */
|
|
||||||
if (!address || !Server_IsLan(address)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
tcount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tcount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Master_GetInternetServers(void)
|
Master_GetInternetServers(void)
|
||||||
{
|
{
|
||||||
int count = 0;
|
return g_masterInternetServers;
|
||||||
int tcount = 0;
|
}
|
||||||
|
|
||||||
count = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT);
|
void
|
||||||
|
Master_RecountServers(void)
|
||||||
|
{
|
||||||
|
int count = 0i;
|
||||||
|
g_masterInternetServers = 0i;
|
||||||
|
g_masterInternetServers = 0i;
|
||||||
|
|
||||||
|
count = (int)gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT);
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
string address;
|
string address;
|
||||||
address = gethostcachestring(srv_fldAdress, i);
|
address = gethostcachestring(srv_fldAdress, i);
|
||||||
|
|
||||||
/* skip LAN */
|
/* skip empty entries */
|
||||||
if (!address || Server_IsLan(address)) {
|
if not (address)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
tcount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tcount;
|
/* skip LAN */
|
||||||
|
if (Server_IsLan(address)) {
|
||||||
|
g_masterLANServers++;
|
||||||
|
} else {
|
||||||
|
g_masterInternetServers++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -95,7 +89,8 @@ Master_RefreshCache(void)
|
||||||
sethostcachesort(gethostcacheindexforkey("ping"), FALSE);
|
sethostcachesort(gethostcacheindexforkey("ping"), FALSE);
|
||||||
refreshhostcache(FALSE);
|
refreshhostcache(FALSE);
|
||||||
resorthostcache();
|
resorthostcache();
|
||||||
int a = gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT);
|
Master_RecountServers();
|
||||||
|
int a = Master_GetLANServers() + Master_GetInternetServers();
|
||||||
|
|
||||||
if (a) {
|
if (a) {
|
||||||
NSLog("Master reports a total of %i servers.", a);
|
NSLog("Master reports a total of %i servers.", a);
|
||||||
|
@ -111,7 +106,8 @@ Master_UpdateCache(void)
|
||||||
sethostcachesort(gethostcacheindexforkey("ping"), FALSE);
|
sethostcachesort(gethostcacheindexforkey("ping"), FALSE);
|
||||||
refreshhostcache(TRUE);
|
refreshhostcache(TRUE);
|
||||||
resorthostcache();
|
resorthostcache();
|
||||||
int a = gethostcachevalue(SLIST_HOSTCACHETOTALCOUNT);
|
Master_RecountServers();
|
||||||
|
int a = Master_GetLANServers() + Master_GetInternetServers();
|
||||||
|
|
||||||
if (a) {
|
if (a) {
|
||||||
NSLog("Master reports a total of %i servers.", a);
|
NSLog("Master reports a total of %i servers.", a);
|
||||||
|
@ -129,6 +125,8 @@ Master_ResortCache(void)
|
||||||
srv_fldMaxplayers = gethostcacheindexforkey("maxplayers");
|
srv_fldMaxplayers = gethostcacheindexforkey("maxplayers");
|
||||||
srv_fldMap = gethostcacheindexforkey("map");
|
srv_fldMap = gethostcacheindexforkey("map");
|
||||||
srv_fldGame = gethostcacheindexforkey("game");
|
srv_fldGame = gethostcacheindexforkey("game");
|
||||||
|
srv_fldServerInfo = gethostcacheindexforkey("serverinfo");
|
||||||
|
srv_fldPlayer0 = gethostcacheindexforkey("player");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue