mirror of
				https://github.com/DarkflameUniverse/DarkflameServer.git
				synced 2025-10-31 12:41:55 +00:00 
			
		
		
		
	Merge branch 'main' into windows-clang-fixes
This commit is contained in:
		| @@ -41,6 +41,7 @@ public: | |||||||
| 	virtual void SaveScore(const uint32_t playerId, const uint32_t gameId, const Score& score) = 0; | 	virtual void SaveScore(const uint32_t playerId, const uint32_t gameId, const Score& score) = 0; | ||||||
| 	virtual void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) = 0; | 	virtual void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) = 0; | ||||||
| 	virtual void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) = 0; | 	virtual void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) = 0; | ||||||
|  | 	virtual void IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) = 0; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif  //!__ILEADERBOARD__H__ | #endif  //!__ILEADERBOARD__H__ | ||||||
|   | |||||||
| @@ -122,6 +122,7 @@ public: | |||||||
| 	void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override; | 	void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override; | ||||||
| 	std::optional<ILeaderboard::Score> GetPlayerScore(const uint32_t playerId, const uint32_t gameId) override; | 	std::optional<ILeaderboard::Score> GetPlayerScore(const uint32_t playerId, const uint32_t gameId) override; | ||||||
| 	void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) override; | 	void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) override; | ||||||
|  | 	void IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) override; | ||||||
| 	void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) override; | 	void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) override; | ||||||
| 	void DeleteUgcBuild(const LWOOBJID bigId) override; | 	void DeleteUgcBuild(const LWOOBJID bigId) override; | ||||||
| private: | private: | ||||||
|   | |||||||
| @@ -68,6 +68,10 @@ void MySQLDatabase::UpdateScore(const uint32_t playerId, const uint32_t gameId, | |||||||
| 		score.primaryScore, score.secondaryScore, score.tertiaryScore, playerId, gameId); | 		score.primaryScore, score.secondaryScore, score.tertiaryScore, playerId, gameId); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void MySQLDatabase::IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) { | ||||||
|  | 	ExecuteUpdate("UPDATE leaderboard SET timesPlayed = timesPlayed + 1 WHERE character_id = ? AND game_id = ?;", playerId, gameId); | ||||||
|  | } | ||||||
|  |  | ||||||
| std::optional<ILeaderboard::Score> MySQLDatabase::GetPlayerScore(const uint32_t playerId, const uint32_t gameId) { | std::optional<ILeaderboard::Score> MySQLDatabase::GetPlayerScore(const uint32_t playerId, const uint32_t gameId) { | ||||||
| 	std::optional<ILeaderboard::Score> toReturn = std::nullopt; | 	std::optional<ILeaderboard::Score> toReturn = std::nullopt; | ||||||
| 	auto res = ExecuteSelect("SELECT * FROM leaderboard WHERE character_id = ? AND game_id = ?;", playerId, gameId); | 	auto res = ExecuteSelect("SELECT * FROM leaderboard WHERE character_id = ? AND game_id = ?;", playerId, gameId); | ||||||
|   | |||||||
| @@ -99,6 +99,7 @@ class TestSQLDatabase : public GameDatabase { | |||||||
| 	void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override {}; | 	void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override {}; | ||||||
| 	std::optional<ILeaderboard::Score> GetPlayerScore(const uint32_t playerId, const uint32_t gameId) override { return {}; }; | 	std::optional<ILeaderboard::Score> GetPlayerScore(const uint32_t playerId, const uint32_t gameId) override { return {}; }; | ||||||
| 	void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) override {}; | 	void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) override {}; | ||||||
|  | 	void IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) override {}; | ||||||
| 	void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) override {}; | 	void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) override {}; | ||||||
| 	void DeleteUgcBuild(const LWOOBJID bigId) override {}; | 	void DeleteUgcBuild(const LWOOBJID bigId) override {}; | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -288,6 +288,8 @@ void LeaderboardManager::SaveScore(const LWOOBJID& playerID, const GameID activi | |||||||
|  |  | ||||||
| 		if (newHighScore) { | 		if (newHighScore) { | ||||||
| 			Database::Get()->UpdateScore(playerID, activityId, newScore); | 			Database::Get()->UpdateScore(playerID, activityId, newScore); | ||||||
|  | 		} else { | ||||||
|  | 			Database::Get()->IncrementTimesPlayed(playerID, activityId); | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
| 		Database::Get()->SaveScore(playerID, activityId, newScore); | 		Database::Get()->SaveScore(playerID, activityId, newScore); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jettford
					Jettford