Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game API v4.0.0: Achievement support for RetroPlayer #104

Open
wants to merge 1 commit into
base: Omega
Choose a base branch
from

Conversation

Shardul555
Copy link

This PR implement support for Achievements in ReteroPlayer. This PR is based on #67 , for adding support of RCheevos.
This PR is used by garbear/xbmc#126 for implementing Achievements.

@@ -42,7 +43,13 @@ class CCheevos
const std::string& richPresence);
void EnableRichPresence(const std::string& script);
void EvaluateRichPresence(std::string& evaluation, unsigned int consoleID);
void ActivateAchievement(unsigned cheevo_id, const char* memaddr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the param name to cheevoId to match the code style. This applies for the other methods as well

@@ -51,6 +58,9 @@ class CCheevos
size_t Reduce(size_t addr, size_t mask);

static unsigned int PeekInternal(unsigned address, unsigned num_bytes, void* ud);
static void RuntimeEventHandler(const rc_runtime_event_t* runtime_event);

void (*m_callback)(const char* achievement_url, unsigned cheevo_id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why but I remember that we wanted to remove this, I had open this PR Shardul555#1 I just rebased it on this PR.

@garbear can you check it if you remember why we wanted this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want a static function in RetroPlayer.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should add a check here instead of a comment like we do in the other methods

@garbear
Copy link
Member

garbear commented Mar 26, 2023

I had to make the following change to update for upstream changes:

diff --git a/src/client.cpp b/src/client.cpp
index 86376d1..f9ec5be 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -504,7 +504,8 @@ GAME_ERROR CGameLibRetro::RCGetPatchFileUrl(std::string& url,
   return GAME_ERROR_NO_ERROR;
 }
 
-GAME_ERROR CGameLibRetro::SetRetroAchievementsCredentials(const char* username, const char* token)
+GAME_ERROR CGameLibRetro::SetRetroAchievementsCredentials(const std::string& username,
+                                                          const std::string& token)
 {
   CCheevos::Get().SetRetroAchievementsCredentials(username, token);
   return GAME_ERROR_NO_ERROR;
diff --git a/src/client.h b/src/client.h
index d06e4b6..f2e84f4 100644
--- a/src/client.h
+++ b/src/client.h
@@ -78,7 +78,8 @@ public:
                                const std::string& username,
                                const std::string& token,
                                unsigned int gameID) override;
-  GAME_ERROR SetRetroAchievementsCredentials(const char* username, const char* token);
+  GAME_ERROR SetRetroAchievementsCredentials(const std::string& username,
+                                             const std::string& token) override;
   GAME_ERROR RCPostRichPresenceUrl(std::string& url,
                                    std::string& postData,
                                    const std::string& username,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants