From 45fb977c26a84d993c8ebee610bcfcf06fdc600d Mon Sep 17 00:00:00 2001 From: Shardul555 Date: Tue, 17 Aug 2021 18:14:28 +0530 Subject: [PATCH] Final changes if there are any --- src/cheevos/Cheevos.cpp | 23 ++++++++++------------- src/cheevos/Cheevos.h | 10 +++------- src/client.cpp | 9 ++++----- src/client.h | 7 +++---- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/cheevos/Cheevos.cpp b/src/cheevos/Cheevos.cpp index f4046500..72142b43 100644 --- a/src/cheevos/Cheevos.cpp +++ b/src/cheevos/Cheevos.cpp @@ -50,7 +50,7 @@ CCheevos& CCheevos::Get(void) bool CCheevos::GenerateHashFromFile(char* hash, int consoleID, const char* filePath) { - int res=rc_hash_generate_from_file(hash, consoleID, filePath); + int res = rc_hash_generate_from_file(hash, consoleID, filePath); m_hash = hash; return res != 0; } @@ -74,6 +74,7 @@ void CCheevos::SetRetroAchievementsCredentials(const char* username, const char* m_username = username; m_token = token; } + bool CCheevos::PostRichPresenceUrl(char* url, size_t urlSize, char* postData, @@ -102,23 +103,20 @@ void CCheevos::EvaluateRichPresence(char* evaluation, size_t size) rc_evaluate_richpresence(m_richPresence, evaluation, size, PeekInternal, this, NULL); } -void CCheevos::ActivateAchievement(unsigned cheevo_id, const char* memaddr) +void CCheevos::ActivateAchievement(unsigned cheevo_id, const char* memaddr) { rc_runtime_activate_achievement(&m_runtime, cheevo_id, memaddr, NULL, 0); // it will return integer value 0 in case achivement is activated successfully. } -bool CCheevos::AwardAchievement(char* url, - size_t size, - unsigned cheevo_id, - int hardcore, - const char* game_hash) +bool CCheevos::AwardAchievement( + char* url, size_t size, unsigned cheevo_id, int hardcore, const char* game_hash) { - return rc_url_award_cheevo(url, size, m_username.c_str(), m_token.c_str(), cheevo_id, 0, game_hash)>=0; - + return rc_url_award_cheevo(url, size, m_username.c_str(), m_token.c_str(), cheevo_id, 0, + game_hash) >= 0; } -void CCheevos::GetCheevo_URL_ID(void (*Callback)(const char* achievement_url,unsigned cheevo_id)) +void CCheevos::GetCheevo_URL_ID(void (*Callback)(const char* achievement_url, unsigned cheevo_id)) { this->Callback = Callback; } @@ -127,11 +125,10 @@ void CCheevos::DeactivateTriggeredAchievement(unsigned cheevo_id) { rc_runtime_deactivate_achievement(&m_runtime, cheevo_id); char url[URL_SIZE]; - if (AwardAchievement(url, URL_SIZE, cheevo_id, 0, - m_hash.c_str())) + if (AwardAchievement(url, URL_SIZE, cheevo_id, 0, m_hash.c_str())) { std::string achievement_url = url; - this->Callback(url,cheevo_id); + this->Callback(url, cheevo_id); } } diff --git a/src/cheevos/Cheevos.h b/src/cheevos/Cheevos.h index 7d8fa608..3310810d 100644 --- a/src/cheevos/Cheevos.h +++ b/src/cheevos/Cheevos.h @@ -30,9 +30,9 @@ class CCheevos void ResetRuntime(); bool GenerateHashFromFile(char* hash, int consoleID, const char* filePath); bool GetGameIDUrl(char* url, size_t size, const char* hash); + void SetRetroAchievementsCredentials(const char* username, const char* token); bool GetPatchFileUrl( char* url, size_t size, const char* username, const char* token, unsigned gameID); - void SetRetroAchievementsCredentials(const char* username, const char* token); bool PostRichPresenceUrl(char* url, size_t urlSize, char* postData, @@ -44,11 +44,8 @@ class CCheevos void EnableRichPresence(const char* script); void EvaluateRichPresence(char* evaluation, size_t size); void ActivateAchievement(unsigned cheevo_id, const char* memaddr); - bool AwardAchievement(char* url, - size_t size, - unsigned cheevo_id, - int hardcore, - const char* game_hash); + bool AwardAchievement( + char* url, size_t size, unsigned cheevo_id, int hardcore, const char* game_hash); void DeactivateTriggeredAchievement(unsigned cheevo_id); void TestCheevoStatusPerFrame(); unsigned int Peek(unsigned int address, unsigned int numBytes); @@ -73,7 +70,6 @@ class CCheevos std::string m_richPresenceScript; std::vector m_richPresenceBuffer; - std::string m_hash; std::string m_username; std::string m_token; diff --git a/src/client.cpp b/src/client.cpp index d3216724..4c315ab5 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -279,7 +279,7 @@ GAME_ERROR CGameLibRetro::RunFrame() m_client.retro_run(); - CCheevos::Get().TestCheevoStatusPerFrame(); + CCheevos::Get().TestCheevoStatusPerFrame(); CLibretroEnvironment::Get().OnFrameEnd(); @@ -534,18 +534,17 @@ GAME_ERROR CGameLibRetro::GetRichPresenceEvaluation(char* evaluation, size_t siz GAME_ERROR CGameLibRetro::ActivateAchievement(unsigned cheevo_id, const char* memaddr) { CCheevos::Get().ActivateAchievement(cheevo_id, memaddr); - - return GAME_ERROR_NO_ERROR; + return GAME_ERROR_NO_ERROR; } -GAME_ERROR CGameLibRetro::GetCheevo_URL_ID(void (*Callback)(const char* achievement_url, unsigned cheevo_id)) +GAME_ERROR CGameLibRetro::GetCheevo_URL_ID(void (*Callback)(const char* achievement_url, + unsigned cheevo_id)) { CCheevos::Get().GetCheevo_URL_ID(Callback); return GAME_ERROR_NO_ERROR; } - GAME_ERROR CGameLibRetro::RCResetRuntime() { CCheevos::Get().ResetRuntime(); diff --git a/src/client.h b/src/client.h index d680df11..f56baf67 100644 --- a/src/client.h +++ b/src/client.h @@ -78,8 +78,7 @@ class ATTRIBUTE_HIDDEN CGameLibRetro const char* username, const char* token, unsigned gameID) override; - GAME_ERROR SetRetroAchievementsCredentials(const char* username, - const char* token); + GAME_ERROR SetRetroAchievementsCredentials(const char* username, const char* token); GAME_ERROR RCPostRichPresenceUrl(char* url, size_t urlSize, char* postData, @@ -92,8 +91,8 @@ class ATTRIBUTE_HIDDEN CGameLibRetro GAME_ERROR GetRichPresenceEvaluation(char* evaluation, size_t size) override; GAME_ERROR ActivateAchievement(unsigned cheevo_id, const char* memaddr) override; GAME_ERROR RCResetRuntime() override; - GAME_ERROR GetCheevo_URL_ID(void (*Callback)(const char* achievement_url, unsigned cheevo_id)) override; - + GAME_ERROR GetCheevo_URL_ID(void (*Callback)(const char* achievement_url, + unsigned cheevo_id)) override; private: GAME_ERROR AudioAvailable();