From 37518c100d1b8748696e72c6529805e47c30f83e Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Sun, 2 Sep 2018 23:44:48 +0200 Subject: [PATCH] Includes player and dungeon level in steam leaderboards. - Intended for use in the in game leaderboard view once I make that. --- CMakeLists.txt | 2 +- src/main.c | 5 +++-- src/steam/steamworks_api_wrapper.c | 8 ++++---- src/steam/steamworks_api_wrapper.h | 4 ++-- steamworks_c_wrapper/src/steamworks_c_wrapper.cpp | 4 ++-- steamworks_c_wrapper/src/steamworks_c_wrapper.h | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90d7315..34a594c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project(breakhack C) set(breakhack_GAME_TITLE "BreakHack") set(breakhack_MAJOR_VERSION 1) set(breakhack_MINOR_VERSION 0) -set(breakhack_PATCH_VERSION 2) +set(breakhack_PATCH_VERSION 3) set(breakhack_RELEASE_TYPE "") include(FindLua) diff --git a/src/main.c b/src/main.c index c4cf3da..0fbadca 100644 --- a/src/main.c +++ b/src/main.c @@ -894,8 +894,9 @@ run_game(void) createInGameGameOverMenu(); hiscore_register(gPlayer, cLevel); #ifdef STEAM_BUILD - steam_register_score((int)hiscore_get_top_gold()); - steam_register_kills((int) gPlayer->stat_data.kills); + uint8_t details[4] = { (uint8_t) gPlayer->stats.lvl, (uint8_t) cLevel, 0, 0 }; + steam_register_score((int) gPlayer->gold, &details, 1); + steam_register_kills((int) gPlayer->stat_data.kills, (int32_t*) &details, 1); #endif // STEAM_BUILD } else { diff --git a/src/steam/steamworks_api_wrapper.c b/src/steam/steamworks_api_wrapper.c index 716cdde..05f1a51 100644 --- a/src/steam/steamworks_api_wrapper.c +++ b/src/steam/steamworks_api_wrapper.c @@ -111,16 +111,16 @@ void steam_set_achievement(EAchievement eAch) } } -void steam_register_score(Sint32 nScore) +void steam_register_score(Sint32 nScore, const int32_t *details, int32_t nDetails) { if (!m_hHighscoreLeaderboard) return; - c_SteamUserStats_UploadLeaderboardScore(m_hHighscoreLeaderboard, nScore); + c_SteamUserStats_UploadLeaderboardScore(m_hHighscoreLeaderboard, nScore, details, nDetails); } -void steam_register_kills(Sint32 nKills) +void steam_register_kills(Sint32 nKills, const int32_t *details, int32_t nDetails) { if (!m_hKillsLeaderboard) return; - c_SteamUserStats_UploadLeaderboardScore(m_hKillsLeaderboard, nKills); + c_SteamUserStats_UploadLeaderboardScore(m_hKillsLeaderboard, nKills, details, nDetails); } diff --git a/src/steam/steamworks_api_wrapper.h b/src/steam/steamworks_api_wrapper.h index 52ec293..9a3be52 100644 --- a/src/steam/steamworks_api_wrapper.h +++ b/src/steam/steamworks_api_wrapper.h @@ -31,6 +31,6 @@ void steam_run_callbacks(void); void steam_set_achievement(EAchievement eAch); -void steam_register_score(Sint32 nScore); +void steam_register_score(Sint32 nScore, const int32_t *details, int32_t nDetails); -void steam_register_kills(Sint32 nKills); +void steam_register_kills(Sint32 nKills, const int32_t *details, int32_t nDetails); diff --git a/steamworks_c_wrapper/src/steamworks_c_wrapper.cpp b/steamworks_c_wrapper/src/steamworks_c_wrapper.cpp index 3123c4f..66d2c2d 100644 --- a/steamworks_c_wrapper/src/steamworks_c_wrapper.cpp +++ b/steamworks_c_wrapper/src/steamworks_c_wrapper.cpp @@ -99,10 +99,10 @@ c_SteamUserStats_FindLeaderboard(const char * name) m_CallbackHandler->m_FindLeaderboardCallResult.Set(hSteamAPICall, m_CallbackHandler, &CallbackHandler::OnFindLeaderboard); } -extern "C" void c_SteamUserStats_UploadLeaderboardScore(int64_t hLeaderboard, int32_t nScore) +extern "C" void c_SteamUserStats_UploadLeaderboardScore(int64_t hLeaderboard, int32_t nScore, int32_t *details, int32_t nDetails) { if (!hLeaderboard || !m_Initiated) return; - SteamUserStats()->UploadLeaderboardScore(hLeaderboard, k_ELeaderboardUploadScoreMethodKeepBest, nScore, nullptr, 0); + SteamUserStats()->UploadLeaderboardScore(hLeaderboard, k_ELeaderboardUploadScoreMethodKeepBest, nScore, details, nDetails); } diff --git a/steamworks_c_wrapper/src/steamworks_c_wrapper.h b/steamworks_c_wrapper/src/steamworks_c_wrapper.h index 54b2a7c..d99b565 100644 --- a/steamworks_c_wrapper/src/steamworks_c_wrapper.h +++ b/steamworks_c_wrapper/src/steamworks_c_wrapper.h @@ -30,7 +30,7 @@ void c_SteamUserStats_FindLeaderboard(const char *name); void -c_SteamUserStats_UploadLeaderboardScore(int64_t hLeaderboard, int32_t nScore); +c_SteamUserStats_UploadLeaderboardScore(int64_t hLeaderboard, int32_t nScore, int32_t *details, int32_t nDetails); void -c_SteamAPI_Shutdown(void); \ No newline at end of file +c_SteamAPI_Shutdown(void);