mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-30 14:47:57 +03:00
Improve the server list count
This commit is contained in:
parent
8aa1ebef5f
commit
41fb354308
2 changed files with 29 additions and 14 deletions
|
@ -132,7 +132,12 @@ qboolean g_NeedAdditionalLANSearch = qfalse;
|
||||||
qboolean g_bDoneUpdating[2];
|
qboolean g_bDoneUpdating[2];
|
||||||
ServerListInstance g_ServerListInst[2];
|
ServerListInstance g_ServerListInst[2];
|
||||||
|
|
||||||
void UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, void *param1, void *param2);
|
// Fixed in OPM
|
||||||
|
// It was a static vaariable inside UpdateServerListCallBack
|
||||||
|
// that was set to 0 when the mode changed. This caused some issues
|
||||||
|
static int g_iServerQueryCount = 0;
|
||||||
|
static int g_iServerTotalCount = 0;
|
||||||
|
|
||||||
static void AddFilter(char *filter, const char *value);
|
static void AddFilter(char *filter, const char *value);
|
||||||
|
|
||||||
FAKKServerListItem::FAKKServerListItem(
|
FAKKServerListItem::FAKKServerListItem(
|
||||||
|
@ -713,6 +718,9 @@ void UIFAKKServerList::NewServerList(void)
|
||||||
iNumConcurrent = 15;
|
iNumConcurrent = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_iServerQueryCount = 0;
|
||||||
|
g_iServerTotalCount = 0;
|
||||||
|
|
||||||
if (com_target_game->integer < target_game_e::TG_MOHTT) {
|
if (com_target_game->integer < target_game_e::TG_MOHTT) {
|
||||||
game_name = GS_GetCurrentGameName();
|
game_name = GS_GetCurrentGameName();
|
||||||
secret_key = GS_GetCurrentGameKey();
|
secret_key = GS_GetCurrentGameKey();
|
||||||
|
@ -1021,7 +1029,7 @@ void UIFAKKServerList::SortByColumn(int column)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, void *param1, void *param2)
|
void UIFAKKServerList::UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, void *param1, void *param2)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int iPort, iGameSpyPort;
|
int iPort, iGameSpyPort;
|
||||||
|
@ -1029,8 +1037,6 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, v
|
||||||
str sAddress;
|
str sAddress;
|
||||||
GServer server;
|
GServer server;
|
||||||
FAKKServerListItem *pNewServerItem;
|
FAKKServerListItem *pNewServerItem;
|
||||||
static int iServerQueryCount = 0;
|
|
||||||
static int iServerTotalCount = 0;
|
|
||||||
UIFAKKServerList *uiServerList;
|
UIFAKKServerList *uiServerList;
|
||||||
int iServerType;
|
int iServerType;
|
||||||
// filters
|
// filters
|
||||||
|
@ -1073,7 +1079,10 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, v
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cvar_Set("dm_serverstatusbar", va("%i", (int)(uintptr_t)param2));
|
//Cvar_Set("dm_serverstatusbar", va("%i", (int)(uintptr_t)param2));
|
||||||
|
// Fixed in OPM
|
||||||
|
// As both lists are combined, show the correct percentage
|
||||||
|
Cvar_Set("dm_serverstatusbar", va("%i", 100 * g_iServerQueryCount / g_iServerTotalCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg == LIST_PROGRESS) {
|
if (msg == LIST_PROGRESS) {
|
||||||
|
@ -1163,8 +1172,8 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, v
|
||||||
pNewServerItem->SetQueried(true);
|
pNewServerItem->SetQueried(true);
|
||||||
pNewServerItem->SetNumPlayers(ServerGetIntValue(server, "numplayers", 0));
|
pNewServerItem->SetNumPlayers(ServerGetIntValue(server, "numplayers", 0));
|
||||||
|
|
||||||
iServerQueryCount++;
|
g_iServerQueryCount++;
|
||||||
Cvar_Set("dm_servercount", va("%d/%d", iServerQueryCount, iServerTotalCount));
|
Cvar_Set("dm_servercount", va("%d/%d", g_iServerQueryCount, g_iServerTotalCount));
|
||||||
|
|
||||||
uiServerList->SortByLastSortColumn();
|
uiServerList->SortByLastSortColumn();
|
||||||
} else if (msg == LIST_STATECHANGED) {
|
} else if (msg == LIST_STATECHANGED) {
|
||||||
|
@ -1203,7 +1212,6 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, v
|
||||||
uiServerList->m_bGettingList[1] = false;
|
uiServerList->m_bGettingList[1] = false;
|
||||||
}
|
}
|
||||||
uiServerList->m_bUpdatingList = true;
|
uiServerList->m_bUpdatingList = true;
|
||||||
iServerQueryCount = 0;
|
|
||||||
return;
|
return;
|
||||||
case GServerListState::sl_lanlist:
|
case GServerListState::sl_lanlist:
|
||||||
Cvar_Set("dm_serverstatus", "Searching LAN.");
|
Cvar_Set("dm_serverstatus", "Searching LAN.");
|
||||||
|
@ -1212,18 +1220,22 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, v
|
||||||
case GServerListState::sl_querying:
|
case GServerListState::sl_querying:
|
||||||
Cvar_Set("dm_serverstatus", "Querying Servers.");
|
Cvar_Set("dm_serverstatus", "Querying Servers.");
|
||||||
uiServerList->m_bUpdatingList = true;
|
uiServerList->m_bUpdatingList = true;
|
||||||
iServerQueryCount = 0;
|
|
||||||
iServerTotalCount = 0;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uiServerList->m_bGettingList[0] && !uiServerList->m_bGettingList[1]) {
|
//if (!uiServerList->m_bGettingList[0] && !uiServerList->m_bGettingList[1]) {
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
|
|
||||||
iServerTotalCount += ServerListCount(serverlist);
|
// Rebuild the number of servers
|
||||||
|
g_iServerTotalCount = 0;
|
||||||
|
for(i = 0; i < ARRAY_LEN(uiServerList->m_serverList); i++) {
|
||||||
|
if (uiServerList->m_bGettingList[i] && uiServerList->m_serverList[i]) {
|
||||||
|
g_iServerTotalCount += ServerListCount(uiServerList->m_serverList[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Removed in 2.0
|
// Removed in 2.0
|
||||||
// Only add entries for servers that are queried successfully
|
// Only add entries for servers that are queried successfully
|
||||||
|
|
|
@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../gamespy/goaceng.h"
|
||||||
|
|
||||||
class UIFAKKServerList : public UIListCtrl {
|
class UIFAKKServerList : public UIListCtrl {
|
||||||
protected:
|
protected:
|
||||||
// need a new struct instead of gamespy
|
// need a new struct instead of gamespy
|
||||||
|
@ -47,6 +49,7 @@ protected:
|
||||||
void MakeLANListing( Event *ev );
|
void MakeLANListing( Event *ev );
|
||||||
void UpdateServer( Event *ev );
|
void UpdateServer( Event *ev );
|
||||||
static int ServerCompareFunction( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname );
|
static int ServerCompareFunction( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname );
|
||||||
|
static void UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, void *param1, void *param2);
|
||||||
public:
|
public:
|
||||||
UIFAKKServerList();
|
UIFAKKServerList();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue