Skip to content

Commit

Permalink
Remove static method for awarding achievements
Browse files Browse the repository at this point in the history
  • Loading branch information
NikosSiak committed Feb 6, 2023
1 parent 24b2266 commit 3d008ca
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
11 changes: 4 additions & 7 deletions src/cheevos/Cheevos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "Cheevos.h"

#include "libretro/FrontendBridge.h"
#include "libretro/libretro.h"
#include "libretro/LibretroEnvironment.h"
#include "libretro/MemoryMap.h"
#include "rcheevos/rconsoles.h"
Expand Down Expand Up @@ -148,16 +150,11 @@ bool CCheevos::AwardAchievement(
game_hash.c_str()) >= 0;
}

void CCheevos::GetCheevo_URL_ID(void (*callback)(const char* achievement_url, unsigned cheevo_id))
{
m_callback = callback;
}

void CCheevos::DeactivateTriggeredAchievement(unsigned cheevo_id)
void CCheevos::DeactivateTriggeredAchievement(unsigned cheevoId)
{
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, cheevoId, 0, m_hash.c_str()))
{
std::string achievement_url = url;
m_callback(url, cheevo_id);
Expand Down
3 changes: 0 additions & 3 deletions src/cheevos/Cheevos.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class CCheevos
void DeactivateTriggeredAchievement(unsigned cheevo_id);
void TestCheevoStatusPerFrame();
unsigned int Peek(unsigned int address, unsigned int numBytes);
void GetCheevo_URL_ID(void (*callback)(const char* achievement_url, unsigned cheevo_id));

private:
const uint8_t* FixupFind(unsigned address, CMemoryMap& mmap, int consolecheevos);
Expand All @@ -60,8 +59,6 @@ class CCheevos
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);

int m_consoleID;

rc_runtime_t m_runtime;
Expand Down
7 changes: 0 additions & 7 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,6 @@ GAME_ERROR CGameLibRetro::ActivateAchievement(unsigned cheevo_id, const char* me
return GAME_ERROR_NO_ERROR;
}

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
2 changes: 0 additions & 2 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class ATTR_DLL_LOCAL CGameLibRetro
GAME_ERROR RCGetRichPresenceEvaluation(std::string& evaluation, unsigned int consoleID) 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;

private:
GAME_ERROR AudioAvailable();
Expand Down
8 changes: 8 additions & 0 deletions src/libretro/FrontendBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ float CFrontendBridge::SensorGetInput(unsigned port, unsigned id)
return axisState;
}

void CFrontendBridge::AwardAchievement(const char* achievementUrl, unsigned cheevoId)
{
if (!CLibretroEnvironment::Get().GetAddon())
return;

CLibretroEnvironment::Get().GetAddon()->AwardAchievement(achievementUrl, cheevoId);
}

bool CFrontendBridge::StartCamera(void)
{
return false; // Not implemented
Expand Down
1 change: 1 addition & 0 deletions src/libretro/FrontendBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace LIBRETRO
static void LedSetState(int led, int state);
static bool SensorSetState(unsigned port, retro_sensor_action action, unsigned rate);
static float SensorGetInput(unsigned port, unsigned id);
static void AwardAchievement(const char* achievementUrl, unsigned cheevoId);
static bool StartCamera(void);
static void StopCamera(void);
static retro_time_t PerfGetTimeUsec(void);
Expand Down

0 comments on commit 3d008ca

Please sign in to comment.