mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-10 02:08:20 +00:00
more const and views
This commit is contained in:
parent
7b1626901a
commit
f5f599764d
@ -149,7 +149,7 @@ void Leaderboard::QueryToLdf(std::unique_ptr<sql::ResultSet>& rows) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::string_view Leaderboard::GetColumns(Leaderboard::Type leaderboardType) {
|
const std::string_view Leaderboard::GetColumns(Leaderboard::Type leaderboardType) {
|
||||||
std::string columns;
|
const char* columns;
|
||||||
switch (leaderboardType) {
|
switch (leaderboardType) {
|
||||||
case Type::ShootingGallery:
|
case Type::ShootingGallery:
|
||||||
columns = "hitPercentage, score, streak";
|
columns = "hitPercentage, score, streak";
|
||||||
@ -157,12 +157,11 @@ const std::string_view Leaderboard::GetColumns(Leaderboard::Type leaderboardType
|
|||||||
case Type::Racing:
|
case Type::Racing:
|
||||||
columns = "bestLapTime, bestTime, numWins";
|
columns = "bestLapTime, bestTime, numWins";
|
||||||
break;
|
break;
|
||||||
|
case Type::Donations:
|
||||||
case Type::UnusedLeaderboard4:
|
case Type::UnusedLeaderboard4:
|
||||||
columns = "score";
|
columns = "score";
|
||||||
break;
|
break;
|
||||||
case Type::MonumentRace:
|
case Type::MonumentRace:
|
||||||
columns = "bestTime";
|
|
||||||
break;
|
|
||||||
case Type::FootRace:
|
case Type::FootRace:
|
||||||
columns = "bestTime";
|
columns = "bestTime";
|
||||||
break;
|
break;
|
||||||
@ -172,9 +171,6 @@ const std::string_view Leaderboard::GetColumns(Leaderboard::Type leaderboardType
|
|||||||
case Type::SurvivalNS:
|
case Type::SurvivalNS:
|
||||||
columns = "bestTime, score";
|
columns = "bestTime, score";
|
||||||
break;
|
break;
|
||||||
case Type::Donations:
|
|
||||||
columns = "score";
|
|
||||||
break;
|
|
||||||
case Type::None:
|
case Type::None:
|
||||||
// This type is included here simply to resolve a compiler warning on mac about unused enum types
|
// This type is included here simply to resolve a compiler warning on mac about unused enum types
|
||||||
break;
|
break;
|
||||||
@ -183,7 +179,7 @@ const std::string_view Leaderboard::GetColumns(Leaderboard::Type leaderboardType
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::string_view Leaderboard::GetInsertFormat(Leaderboard::Type leaderboardType) {
|
const std::string_view Leaderboard::GetInsertFormat(Leaderboard::Type leaderboardType) {
|
||||||
std::string columns;
|
const char* columns;
|
||||||
switch (leaderboardType) {
|
switch (leaderboardType) {
|
||||||
case Type::ShootingGallery:
|
case Type::ShootingGallery:
|
||||||
columns = "score=%i, hitPercentage=%i, streak=%i";
|
columns = "score=%i, hitPercentage=%i, streak=%i";
|
||||||
@ -191,12 +187,11 @@ const std::string_view Leaderboard::GetInsertFormat(Leaderboard::Type leaderboar
|
|||||||
case Type::Racing:
|
case Type::Racing:
|
||||||
columns = "bestLapTime=%i, bestTime=%i, numWins=numWins + %i";
|
columns = "bestLapTime=%i, bestTime=%i, numWins=numWins + %i";
|
||||||
break;
|
break;
|
||||||
|
case Type::Donations:
|
||||||
case Type::UnusedLeaderboard4:
|
case Type::UnusedLeaderboard4:
|
||||||
columns = "score=%i";
|
columns = "score=%i";
|
||||||
break;
|
break;
|
||||||
case Type::MonumentRace:
|
case Type::MonumentRace:
|
||||||
columns = "bestTime=%i";
|
|
||||||
break;
|
|
||||||
case Type::FootRace:
|
case Type::FootRace:
|
||||||
columns = "bestTime=%i";
|
columns = "bestTime=%i";
|
||||||
break;
|
break;
|
||||||
@ -206,9 +201,6 @@ const std::string_view Leaderboard::GetInsertFormat(Leaderboard::Type leaderboar
|
|||||||
case Type::SurvivalNS:
|
case Type::SurvivalNS:
|
||||||
columns = "bestTime=%i, score=%i";
|
columns = "bestTime=%i, score=%i";
|
||||||
break;
|
break;
|
||||||
case Type::Donations:
|
|
||||||
columns = "score=%i";
|
|
||||||
break;
|
|
||||||
case Type::None:
|
case Type::None:
|
||||||
// This type is included here simply to resolve a compiler warning on mac about unused enum types
|
// This type is included here simply to resolve a compiler warning on mac about unused enum types
|
||||||
break;
|
break;
|
||||||
@ -217,7 +209,7 @@ const std::string_view Leaderboard::GetInsertFormat(Leaderboard::Type leaderboar
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::string_view Leaderboard::GetOrdering(Leaderboard::Type leaderboardType) {
|
const std::string_view Leaderboard::GetOrdering(Leaderboard::Type leaderboardType) {
|
||||||
std::string orderBase;
|
const char* orderBase;
|
||||||
switch (leaderboardType) {
|
switch (leaderboardType) {
|
||||||
case Type::ShootingGallery:
|
case Type::ShootingGallery:
|
||||||
orderBase = "score DESC, streak DESC, hitPercentage DESC";
|
orderBase = "score DESC, streak DESC, hitPercentage DESC";
|
||||||
@ -225,6 +217,7 @@ const std::string_view Leaderboard::GetOrdering(Leaderboard::Type leaderboardTyp
|
|||||||
case Type::Racing:
|
case Type::Racing:
|
||||||
orderBase = "bestTime ASC, bestLapTime ASC, numWins DESC";
|
orderBase = "bestTime ASC, bestLapTime ASC, numWins DESC";
|
||||||
break;
|
break;
|
||||||
|
case Type::Donations:
|
||||||
case Type::UnusedLeaderboard4:
|
case Type::UnusedLeaderboard4:
|
||||||
orderBase = "score DESC";
|
orderBase = "score DESC";
|
||||||
break;
|
break;
|
||||||
@ -240,9 +233,6 @@ const std::string_view Leaderboard::GetOrdering(Leaderboard::Type leaderboardTyp
|
|||||||
case Type::SurvivalNS:
|
case Type::SurvivalNS:
|
||||||
orderBase = "bestTime DESC, score DESC";
|
orderBase = "bestTime DESC, score DESC";
|
||||||
break;
|
break;
|
||||||
case Type::Donations:
|
|
||||||
orderBase = "score DESC";
|
|
||||||
break;
|
|
||||||
case Type::None:
|
case Type::None:
|
||||||
// This type is included here simply to resolve a compiler warning on mac about unused enum types
|
// This type is included here simply to resolve a compiler warning on mac about unused enum types
|
||||||
break;
|
break;
|
||||||
@ -352,7 +342,7 @@ void Leaderboard::SetupLeaderboard(uint32_t resultStart, uint32_t resultEnd) {
|
|||||||
QueryToLdf(result);
|
QueryToLdf(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Leaderboard::Send(LWOOBJID targetID) {
|
void Leaderboard::Send(const LWOOBJID targetID) const {
|
||||||
auto* player = EntityManager::Instance()->GetEntity(relatedPlayer);
|
auto* player = EntityManager::Instance()->GetEntity(relatedPlayer);
|
||||||
if (player != nullptr) {
|
if (player != nullptr) {
|
||||||
GameMessages::SendActivitySummaryLeaderboardData(targetID, this, player->GetSystemAddress());
|
GameMessages::SendActivitySummaryLeaderboardData(targetID, this, player->GetSystemAddress());
|
||||||
@ -465,7 +455,7 @@ Leaderboard::Type LeaderboardManager::GetLeaderboardType(const GameID gameID) {
|
|||||||
|
|
||||||
auto* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
|
auto* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
|
||||||
std::vector<CDActivities> activities = activitiesTable->Query([=](const CDActivities& entry) {
|
std::vector<CDActivities> activities = activitiesTable->Query([=](const CDActivities& entry) {
|
||||||
return (entry.ActivityID == gameID);
|
return entry.ActivityID == gameID;
|
||||||
});
|
});
|
||||||
auto type = !activities.empty() ? static_cast<Leaderboard::Type>(activities.at(0).leaderboardType) : Leaderboard::Type::None;
|
auto type = !activities.empty() ? static_cast<Leaderboard::Type>(activities.at(0).leaderboardType) : Leaderboard::Type::None;
|
||||||
leaderboardCache.insert_or_assign(gameID, type);
|
leaderboardCache.insert_or_assign(gameID, type);
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Sends the leaderboard to the client specified by targetID.
|
* Sends the leaderboard to the client specified by targetID.
|
||||||
*/
|
*/
|
||||||
void Send(LWOOBJID targetID);
|
void Send(const LWOOBJID targetID) const;
|
||||||
|
|
||||||
// Helper functions to get the columns, ordering and insert format for a leaderboard
|
// Helper functions to get the columns, ordering and insert format for a leaderboard
|
||||||
static const std::string_view GetColumns(Type leaderboardType);
|
static const std::string_view GetColumns(Type leaderboardType);
|
||||||
|
@ -1639,7 +1639,7 @@ void GameMessages::HandleActivitySummaryLeaderboardData(RakNet::BitStream* instr
|
|||||||
Game::logger->Log("AGS", "We got mail!");
|
Game::logger->Log("AGS", "We got mail!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, Leaderboard* leaderboard, const SystemAddress& sysAddr) {
|
void GameMessages::SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, const Leaderboard* leaderboard, const SystemAddress& sysAddr) {
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
CMSGHEADER;
|
CMSGHEADER;
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ namespace GameMessages {
|
|||||||
void SendUpdateReputation(const LWOOBJID objectId, const int64_t reputation, const SystemAddress& sysAddr);
|
void SendUpdateReputation(const LWOOBJID objectId, const int64_t reputation, const SystemAddress& sysAddr);
|
||||||
|
|
||||||
// Leaderboards
|
// Leaderboards
|
||||||
void SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, Leaderboard* leaderboard,
|
void SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, const Leaderboard* leaderboard,
|
||||||
const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
void HandleActivitySummaryLeaderboardData(RakNet::BitStream* instream, Entity* entity, const SystemAddress& sysAddr);
|
void HandleActivitySummaryLeaderboardData(RakNet::BitStream* instream, Entity* entity, const SystemAddress& sysAddr);
|
||||||
void SendRequestActivitySummaryLeaderboardData(const LWOOBJID& objectID, const LWOOBJID& targetID,
|
void SendRequestActivitySummaryLeaderboardData(const LWOOBJID& objectID, const LWOOBJID& targetID,
|
||||||
|
Loading…
Reference in New Issue
Block a user