Skip to content

Commit

Permalink
Fix Highscores and new Query
Browse files Browse the repository at this point in the history
New Boss Points Highscore Query. Now the query avoid all the characters from account 1. Removing all the Sample from highscores or Characters on account id 1
  • Loading branch information
TheGlitchLab committed Jan 20, 2025
1 parent 66495a8 commit 3e8a788
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,11 @@ Game::Game() {
{ static_cast<uint8_t>(LOYALTY_POINTS), "Loyalty Points" },
{ static_cast<uint8_t>(MAGIC_LEVEL), "Magic Level" },
{ static_cast<uint8_t>(SHIELDING), "Shielding" },
{ static_cast<uint8_t>(HighscoreCategories_t::SWORD_FIGHTING), "Sword Fighting" },
{ static_cast<uint8_t>(SWORD_FIGHTING), "Sword Fighting" },
};

m_highscoreCategories = {
HighscoreCategory("Boss Points", static_cast<uint8_t>(HighscoreCategories_t::BOSS_POINTS)),
HighscoreCategory("Experience Points", static_cast<uint8_t>(HighscoreCategories_t::EXPERIENCE)),
HighscoreCategory("Fist Fighting", static_cast<uint8_t>(HighscoreCategories_t::FIST_FIGHTING)),
HighscoreCategory("Club Fighting", static_cast<uint8_t>(HighscoreCategories_t::CLUB_FIGHTING)),
Expand Down Expand Up @@ -8571,9 +8572,8 @@ std::string Game::generateHighscoreQueryForEntries(const std::string &categoryNa

query << "SELECT *, @row AS `entries`, " << page << " AS `page` FROM (SELECT *, (@row := @row + 1) AS `rn` FROM (SELECT `id`, `name`, `level`, `vocation`, `"
<< categoryName << "` AS `points`, @curRank := IF(@prevRank = `" << categoryName << "`, @curRank, IF(@prevRank := `" << categoryName
<< "`, @curRank + 1, @curRank + 1)) AS `rank` FROM `players` `p`, (SELECT @curRank := 0, @prevRank := NULL, @row := 0) `r` WHERE `group_id` < "
<< static_cast<int>(GROUP_TYPE_GAMEMASTER) << " ORDER BY `" << categoryName << "` DESC) `t`";

<< "`, @curRank + 1, @curRank + 1)) AS `rank` FROM `players` `p`, (SELECT @curRank := 0, @prevRank := NULL, @row := 0) `r` WHERE `account_id` != "
<< 1 << " ORDER BY `" << categoryName << "` DESC) `t`";
if (vocation != 0xFFFFFFFF) {
query << generateVocationConditionHighscore(vocation);
}
Expand All @@ -8588,9 +8588,8 @@ std::string Game::generateHighscoreQueryForOurRank(const std::string &categoryNa

query << "SELECT *, @row AS `entries`, (@ourRow DIV " << entriesStr << ") + 1 AS `page` FROM (SELECT *, (@row := @row + 1) AS `rn`, @ourRow := IF(`id` = "
<< playerGUID << ", @row - 1, @ourRow) AS `rw` FROM (SELECT `id`, `name`, `level`, `vocation`, `" << categoryName << "` AS `points`, @curRank := IF(@prevRank = `"
<< categoryName << "`, @curRank, IF(@prevRank := `" << categoryName << "`, @curRank + 1, @curRank + 1)) AS `rank` FROM `players` `p`, (SELECT @curRank := 0, @prevRank := NULL, @row := 0, @ourRow := 0) `r` WHERE `group_id` < "
<< static_cast<int>(GROUP_TYPE_GAMEMASTER) << " ORDER BY `" << categoryName << "` DESC) `t`";

<< categoryName << "`, @curRank, IF(@prevRank := `" << categoryName << "`, @curRank + 1, @curRank + 1)) AS `rank` FROM `players` `p`, (SELECT @curRank := 0, @prevRank := NULL, @row := 0, @ourRow := 0) `r` WHERE `account_id` != "
<< 1 << " ORDER BY `" << categoryName << "` DESC) `t`";
if (vocation != 0xFFFFFFFF) {
query << generateVocationConditionHighscore(vocation);
}
Expand Down

0 comments on commit 3e8a788

Please sign in to comment.