diff options
| author | oy <Tom_Adams@web.de> | 2011-06-29 22:27:32 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-06-29 22:27:32 +0200 |
| commit | 123eab41c8e201da58ffbb6bb215716334bec652 (patch) | |
| tree | 833b3e608d243f72e23fa7eacd5ccd980021fad0 /src/engine | |
| parent | 8035e022fdefbf5ebbdd9a92d79fe7c3f1a76bdb (diff) | |
| download | zcatch-123eab41c8e201da58ffbb6bb215716334bec652.tar.gz zcatch-123eab41c8e201da58ffbb6bb215716334bec652.zip | |
made it possible to filter by player country in the server browser. Closes #654
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/client.h | 1 | ||||
| -rw-r--r-- | src/engine/client/client.cpp | 2 | ||||
| -rw-r--r-- | src/engine/client/serverbrowser.cpp | 68 | ||||
| -rw-r--r-- | src/engine/shared/config_variables.h | 2 |
4 files changed, 46 insertions, 27 deletions
diff --git a/src/engine/client.h b/src/engine/client.h index 78741018..65ab761e 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -159,7 +159,6 @@ public: virtual int OnSnapInput(int *pData) = 0; virtual const char *GetItemName(int Type) = 0; - virtual int GetCountryIndex(int Code) = 0; virtual const char *Version() = 0; virtual const char *NetVersion() = 0; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index ad51c1ad..90cb2011 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1149,7 +1149,7 @@ void CClient::ProcessConnlessPacket(CNetChunk *pPacket) { str_copy(Info.m_aClients[i].m_aName, Up.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), sizeof(Info.m_aClients[i].m_aName)); str_copy(Info.m_aClients[i].m_aClan, Up.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), sizeof(Info.m_aClients[i].m_aClan)); - Info.m_aClients[i].m_Country = GameClient()->GetCountryIndex(str_toint(Up.GetString())); + Info.m_aClients[i].m_Country = str_toint(Up.GetString()); Info.m_aClients[i].m_Score = str_toint(Up.GetString()); Info.m_aClients[i].m_Player = str_toint(Up.GetString()) != 0 ? true : false; } diff --git a/src/engine/client/serverbrowser.cpp b/src/engine/client/serverbrowser.cpp index c3ada10e..ddfc7597 100644 --- a/src/engine/client/serverbrowser.cpp +++ b/src/engine/client/serverbrowser.cpp @@ -186,40 +186,57 @@ void CServerBrowser::Filter() Filtered = 1; else if(!g_Config.m_BrFilterGametypeStrict && g_Config.m_BrFilterGametype[0] && !str_find_nocase(m_ppServerlist[i]->m_Info.m_aGameType, g_Config.m_BrFilterGametype)) Filtered = 1; - else if(g_Config.m_BrFilterString[0] != 0) + else { - int MatchFound = 0; - - m_ppServerlist[i]->m_Info.m_QuickSearchHit = 0; - - // match against server name - if(str_find_nocase(m_ppServerlist[i]->m_Info.m_aName, g_Config.m_BrFilterString)) + if(g_Config.m_BrFilterCountry) { - MatchFound = 1; - m_ppServerlist[i]->m_Info.m_QuickSearchHit |= IServerBrowser::QUICK_SERVERNAME; + Filtered = 1; + // match against player country + for(p = 0; p < m_ppServerlist[i]->m_Info.m_NumClients; p++) + { + if(m_ppServerlist[i]->m_Info.m_aClients[p].m_Country == g_Config.m_BrFilterCountryIndex) + { + Filtered = 0; + break; + } + } } - // match against players - for(p = 0; p < m_ppServerlist[i]->m_Info.m_NumClients; p++) + if(!Filtered && g_Config.m_BrFilterString[0] != 0) { - if(str_find_nocase(m_ppServerlist[i]->m_Info.m_aClients[p].m_aName, g_Config.m_BrFilterString) || - str_find_nocase(m_ppServerlist[i]->m_Info.m_aClients[p].m_aClan, g_Config.m_BrFilterString)) + int MatchFound = 0; + + m_ppServerlist[i]->m_Info.m_QuickSearchHit = 0; + + // match against server name + if(str_find_nocase(m_ppServerlist[i]->m_Info.m_aName, g_Config.m_BrFilterString)) { MatchFound = 1; - m_ppServerlist[i]->m_Info.m_QuickSearchHit |= IServerBrowser::QUICK_PLAYER; - break; + m_ppServerlist[i]->m_Info.m_QuickSearchHit |= IServerBrowser::QUICK_SERVERNAME; } - } - // match against map - if(str_find_nocase(m_ppServerlist[i]->m_Info.m_aMap, g_Config.m_BrFilterString)) - { - MatchFound = 1; - m_ppServerlist[i]->m_Info.m_QuickSearchHit |= IServerBrowser::QUICK_MAPNAME; - } + // match against players + for(p = 0; p < m_ppServerlist[i]->m_Info.m_NumClients; p++) + { + if(str_find_nocase(m_ppServerlist[i]->m_Info.m_aClients[p].m_aName, g_Config.m_BrFilterString) || + str_find_nocase(m_ppServerlist[i]->m_Info.m_aClients[p].m_aClan, g_Config.m_BrFilterString)) + { + MatchFound = 1; + m_ppServerlist[i]->m_Info.m_QuickSearchHit |= IServerBrowser::QUICK_PLAYER; + break; + } + } - if(!MatchFound) - Filtered = 1; + // match against map + if(str_find_nocase(m_ppServerlist[i]->m_Info.m_aMap, g_Config.m_BrFilterString)) + { + MatchFound = 1; + m_ppServerlist[i]->m_Info.m_QuickSearchHit |= IServerBrowser::QUICK_MAPNAME; + } + + if(!MatchFound) + Filtered = 1; + } } if(Filtered == 0) @@ -252,7 +269,8 @@ int CServerBrowser::SortHash() const i |= g_Config.m_BrFilterPure<<11; i |= g_Config.m_BrFilterPureMap<<12; i |= g_Config.m_BrFilterGametypeStrict<<13; - i |= g_Config.m_BrFilterPing<<18; + i |= g_Config.m_BrFilterCountry<<14; + i |= g_Config.m_BrFilterPing<<15; return i; } diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 4c90a547..31a8128a 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -32,6 +32,8 @@ MACRO_CONFIG_INT(BrFilterFull, br_filter_full, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLI MACRO_CONFIG_INT(BrFilterEmpty, br_filter_empty, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Filter out empty server in browser") MACRO_CONFIG_INT(BrFilterSpectators, br_filter_spectators, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Filter out spectators from player numbers") MACRO_CONFIG_INT(BrFilterFriends, br_filter_friends, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Filter out servers with no friends") +MACRO_CONFIG_INT(BrFilterCountry, br_filter_country, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Filter out servers with non-matching player country") +MACRO_CONFIG_INT(BrFilterCountryIndex, br_filter_country_index, -1, -1, 999, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Player country to filter by in the server browser") MACRO_CONFIG_INT(BrFilterPw, br_filter_pw, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Filter out password protected servers in browser") MACRO_CONFIG_INT(BrFilterPing, br_filter_ping, 999, 0, 999, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Ping to filter by in the server browser") MACRO_CONFIG_STR(BrFilterGametype, br_filter_gametype, 128, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Game types to filter") |