Skip to content

Commit

Permalink
Final changes if there are any
Browse files Browse the repository at this point in the history
  • Loading branch information
Shardul555 committed Aug 17, 2021
1 parent e814fd6 commit 45fb977
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 29 deletions.
23 changes: 10 additions & 13 deletions src/cheevos/Cheevos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/cheevos/Cheevos.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -73,7 +70,6 @@ class CCheevos
std::string m_richPresenceScript;
std::vector<char> m_richPresenceBuffer;


std::string m_hash;
std::string m_username;
std::string m_token;
Expand Down
9 changes: 4 additions & 5 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ GAME_ERROR CGameLibRetro::RunFrame()

m_client.retro_run();

CCheevos::Get().TestCheevoStatusPerFrame();
CCheevos::Get().TestCheevoStatusPerFrame();

CLibretroEnvironment::Get().OnFrameEnd();

Expand Down Expand Up @@ -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();
Expand Down
7 changes: 3 additions & 4 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit 45fb977

Please sign in to comment.