diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 42ac96ece..af6195d10 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -220,6 +220,7 @@ MACRO_CONFIG_INT(SvSpecFrequency, sv_pause_frequency, 1, 0, 9999, CFGFLAG_SERVER MACRO_CONFIG_INT(SvInvite, sv_invite, 1, 0, 1, CFGFLAG_SERVER, "Whether players can invite other players to teams") MACRO_CONFIG_INT(SvInviteFrequency, sv_invite_frequency, 1, 0, 9999, CFGFLAG_SERVER, "The minimum allowed delay between invites") MACRO_CONFIG_INT(SvTeleOthersAuthLevel, sv_tele_others_auth_level, 1, 1, 3, CFGFLAG_SERVER, "The auth level you need to tele others") +MACRO_CONFIG_INT(SvRegionalRankings, sv_regional_rankings, 1, 0, 1, CFGFLAG_SERVER, "Display regional rankings in /rank and /top5") MACRO_CONFIG_INT(SvEmotionalTees, sv_emotional_tees, 1, -1, 1, CFGFLAG_SERVER, "Whether eye change of tees is enabled with emoticons = 1, not = 0, -1 not at all") MACRO_CONFIG_INT(SvEmoticonMsDelay, sv_emoticon_ms_delay, 3000, 20, 999999999, CFGFLAG_SERVER, "The time in ms a player has to wait before allowing the next over-head emoticons") diff --git a/src/game/server/scoreworker.cpp b/src/game/server/scoreworker.cpp index 11b0e09af..bd598f102 100644 --- a/src/game/server/scoreworker.cpp +++ b/src/game/server/scoreworker.cpp @@ -809,9 +809,17 @@ bool CScoreWorker::ShowRank(IDbConnection *pSqlServer, const ISqlData *pGameData pData->m_aName, aBuf, BetterThanPercent, pData->m_aRequestingPlayer); } - str_format(pResult->m_Data.m_aaMessages[1], sizeof(pResult->m_Data.m_aaMessages[1]), - "Global rank %d - %s %s", - Rank, pData->m_aServer, aRegionalRank); + if(g_Config.m_SvRegionalRankings) + { + str_format(pResult->m_Data.m_aaMessages[1], sizeof(pResult->m_Data.m_aaMessages[1]), + "Global rank %d - %s %s", + Rank, pData->m_aServer, aRegionalRank); + } + else + { + str_format(pResult->m_Data.m_aaMessages[1], sizeof(pResult->m_Data.m_aaMessages[1]), + "Global rank %d", Rank); + } } } else @@ -961,6 +969,9 @@ bool CScoreWorker::ShowTop(IDbConnection *pSqlServer, const ISqlData *pGameData, Line++; } + if(!g_Config.m_SvRegionalRankings) + return !End; + char aServerLike[16]; str_format(aServerLike, sizeof(aServerLike), "%%%s%%", pData->m_aServer); diff --git a/src/test/score.cpp b/src/test/score.cpp index 242fbd285..a57b76e64 100644 --- a/src/test/score.cpp +++ b/src/test/score.cpp @@ -143,8 +143,9 @@ struct SingleScore : public Score } }; -TEST_P(SingleScore, Top) +TEST_P(SingleScore, TopRegional) { + g_Config.m_SvRegionalRankings = true; ASSERT_FALSE(CScoreWorker::ShowTop(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; ExpectLines(m_pPlayerResult, {"------------ Global Top ------------", @@ -152,14 +153,32 @@ TEST_P(SingleScore, Top) "------------ GER Top ------------"}); } -TEST_P(SingleScore, Rank) +TEST_P(SingleScore, Top) { + g_Config.m_SvRegionalRankings = false; + ASSERT_FALSE(CScoreWorker::ShowTop(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; + ExpectLines(m_pPlayerResult, + {"------------ Global Top ------------", + "1. nameless tee Time: 01:40.00"}); +} + +TEST_P(SingleScore, RankRegional) +{ + g_Config.m_SvRegionalRankings = true; ASSERT_FALSE(CScoreWorker::ShowRank(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; ExpectLines(m_pPlayerResult, {"nameless tee - 01:40.00 - better than 100% - requested by brainless tee", "Global rank 1 - GER unranked"}, true); } -TEST_P(SingleScore, TopServer) +TEST_P(SingleScore, Rank) { + g_Config.m_SvRegionalRankings = false; + ASSERT_FALSE(CScoreWorker::ShowRank(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; + ExpectLines(m_pPlayerResult, {"nameless tee - 01:40.00 - better than 100% - requested by brainless tee", "Global rank 1"}, true); +} + +TEST_P(SingleScore, TopServerRegional) +{ + g_Config.m_SvRegionalRankings = true; str_copy(m_PlayerRequest.m_aServer, "USA", sizeof(m_PlayerRequest.m_aServer)); ASSERT_FALSE(CScoreWorker::ShowTop(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; ExpectLines(m_pPlayerResult, @@ -169,13 +188,32 @@ TEST_P(SingleScore, TopServer) "1. nameless tee Time: 01:40.00"}); } -TEST_P(SingleScore, RankServer) +TEST_P(SingleScore, TopServer) { + g_Config.m_SvRegionalRankings = false; + str_copy(m_PlayerRequest.m_aServer, "USA", sizeof(m_PlayerRequest.m_aServer)); + ASSERT_FALSE(CScoreWorker::ShowTop(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; + ExpectLines(m_pPlayerResult, + {"------------ Global Top ------------", + "1. nameless tee Time: 01:40.00"}); +} + +TEST_P(SingleScore, RankServerRegional) +{ + g_Config.m_SvRegionalRankings = true; str_copy(m_PlayerRequest.m_aServer, "USA", sizeof(m_PlayerRequest.m_aServer)); ASSERT_FALSE(CScoreWorker::ShowRank(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; ExpectLines(m_pPlayerResult, {"nameless tee - 01:40.00 - better than 100% - requested by brainless tee", "Global rank 1 - USA rank 1"}, true); } +TEST_P(SingleScore, RankServer) +{ + g_Config.m_SvRegionalRankings = false; + str_copy(m_PlayerRequest.m_aServer, "USA", sizeof(m_PlayerRequest.m_aServer)); + ASSERT_FALSE(CScoreWorker::ShowRank(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; + ExpectLines(m_pPlayerResult, {"nameless tee - 01:40.00 - better than 100% - requested by brainless tee", "Global rank 1"}, true); +} + TEST_P(SingleScore, LoadPlayerData) { InsertRank(120.0, true);