diff --git a/src/game/server/scoreworker.cpp b/src/game/server/scoreworker.cpp index a77dadd936d..7f825a71edd 100644 --- a/src/game/server/scoreworker.cpp +++ b/src/game/server/scoreworker.cpp @@ -322,7 +322,7 @@ bool CScoreWorker::MapVote(IDbConnection *pSqlServer, const ISqlData *pGameData, "FROM %s_maps " "WHERE Map LIKE %s " "ORDER BY " - " CASE WHEN Map = ? THEN 0 ELSE 1 END, " + " CASE WHEN LOWER(Map) = LOWER(?) THEN 0 ELSE 1 END, " " CASE WHEN Map LIKE ? THEN 0 ELSE 1 END, " " LENGTH(Map), Map " "LIMIT 1", @@ -395,7 +395,7 @@ bool CScoreWorker::MapInfo(IDbConnection *pSqlServer, const ISqlData *pGameData, " SELECT * FROM %s_maps " " WHERE Map LIKE %s " " ORDER BY " - " CASE WHEN Map = ? THEN 0 ELSE 1 END, " + " CASE WHEN LOWER(Map) = LOWER(?) THEN 0 ELSE 1 END, " " CASE WHEN Map LIKE ? THEN 0 ELSE 1 END, " " LENGTH(Map), " " Map " diff --git a/src/test/score.cpp b/src/test/score.cpp index d24b52fb1dc..9099eca3caf 100644 --- a/src/test/score.cpp +++ b/src/test/score.cpp @@ -42,7 +42,7 @@ struct Score : public testing::TestWithParam { Connect(); LoadBestTime(); - InsertMap(); + InsertMap("Kobra 3", "Zerodin", "Novice", 5, 5); } ~Score() @@ -75,15 +75,15 @@ struct Score : public testing::TestWithParam ASSERT_FALSE(CScoreWorker::LoadBestTime(m_pConn, &loadBestTimeReq, m_aError, sizeof(m_aError))) << m_aError; } - void InsertMap() + void InsertMap(const char *pName, const char *pMapper, const char *pServer, int Points, int Stars) { char aTimestamp[32]; str_timestamp_format(aTimestamp, sizeof(aTimestamp), FORMAT_SPACE); char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%s into %s_maps(Map, Server, Mapper, Points, Stars, Timestamp) " - "VALUES (\"Kobra 3\", \"Novice\", \"Zerodin\", 5, 5, %s)", - m_pConn->InsertIgnore(), m_pConn->GetPrefix(), m_pConn->InsertTimestampAsUtc()); + "VALUES (\"%s\", \"%s\", \"%s\", %d, %d, %s)", + m_pConn->InsertIgnore(), m_pConn->GetPrefix(), pName, pServer, pMapper, Points, Stars, m_pConn->InsertTimestampAsUtc()); ASSERT_FALSE(m_pConn->PrepareStatement(aBuf, m_aError, sizeof(m_aError))) << m_aError; m_pConn->BindString(1, aTimestamp); int NumInserted = 0; @@ -418,6 +418,21 @@ TEST_P(MapInfo, Fuzzy) } } +TEST_P(MapInfo, FuzzyCase) +{ + InsertMap("Reflect", "DarkOort", "Dummy", 20, 3); + InsertMap("reflects", "Ninjed & Pipou", "Solo", 16, 4); + str_copy(m_PlayerRequest.m_aName, "reflect", sizeof(m_PlayerRequest.m_aName)); + ASSERT_FALSE(CScoreWorker::MapInfo(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; + + EXPECT_EQ(m_pPlayerResult->m_MessageKind, CScorePlayerResult::DIRECT); + EXPECT_THAT(m_pPlayerResult->m_Data.m_aaMessages[0], testing::MatchesRegex("\"Reflect\" by DarkOort on Dummy, ★★★✰✰, 20 points, released .* ago, 0 finishes by 0 tees")); + for(int i = 1; i < CScorePlayerResult::MAX_MESSAGES; i++) + { + EXPECT_STREQ(m_pPlayerResult->m_Data.m_aaMessages[i], ""); + } +} + TEST_P(MapInfo, DoesntExit) { str_copy(m_PlayerRequest.m_aName, "f", sizeof(m_PlayerRequest.m_aName)); @@ -453,6 +468,18 @@ TEST_P(MapVote, Fuzzy) EXPECT_STREQ(m_pPlayerResult->m_Data.m_MapVote.m_aServer, "novice"); } +TEST_P(MapVote, FuzzyCase) +{ + InsertMap("Reflect", "DarkOort", "Dummy", 20, 3); + InsertMap("reflects", "Ninjed & Pipou", "Solo", 16, 4); + str_copy(m_PlayerRequest.m_aName, "reflect", sizeof(m_PlayerRequest.m_aName)); + ASSERT_FALSE(CScoreWorker::MapVote(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError; + EXPECT_EQ(m_pPlayerResult->m_MessageKind, CScorePlayerResult::MAP_VOTE); + EXPECT_STREQ(m_pPlayerResult->m_Data.m_MapVote.m_aMap, "Reflect"); + EXPECT_STREQ(m_pPlayerResult->m_Data.m_MapVote.m_aReason, "/map"); + EXPECT_STREQ(m_pPlayerResult->m_Data.m_MapVote.m_aServer, "dummy"); +} + TEST_P(MapVote, DoesntExist) { str_copy(m_PlayerRequest.m_aName, "f", sizeof(m_PlayerRequest.m_aName));