Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/User/Dummy/DummyAchievements.cpp
1168 views
1
#if RETRO_REV02
2
void DummyAchievements::TryUnlockAchievement(AchievementID *id)
3
{
4
if (enabled) {
5
PrintLog(PRINT_NORMAL, "DUMMY TryUnlockAchievement(%s)", id->identifier);
6
7
int32 i = 0;
8
for (; i < (int32)achievementList.size(); ++i) {
9
if (achievementList[i].identifier == id->identifier) {
10
if (!achievementList[i].achieved) {
11
achievementStack.push_back(i);
12
PrintLog(PRINT_NORMAL, "Unlocked Achievement: (%s, %d)", id->identifier, i);
13
achievementList[i].achieved = true;
14
SaveUserData();
15
}
16
break;
17
}
18
}
19
20
if (i == achievementList.size())
21
PrintLog(PRINT_NORMAL, "Failed to Unlock Achievement: (%s)", id->identifier);
22
}
23
else {
24
std::string str = __FILE__;
25
str += ": TryUnlockAchievement() # Tried to unlock achievement, but achievements are disabled. \r\n";
26
PrintLog(PRINT_NORMAL, str.c_str());
27
}
28
}
29
30
void DummyAchievements::SetAchievementNames(String **names, int32 count)
31
{
32
if (count <= 0)
33
return;
34
35
char nameBuffer[0x40];
36
GetCString(nameBuffer, names[0]);
37
achievementText = nameBuffer;
38
39
for (int32 i = 1; i < count && i < (int32)achievementList.size(); ++i) {
40
GetCString(nameBuffer, names[i]);
41
achievementList[i].name = nameBuffer;
42
}
43
}
44
45
String *DummyAchievements::GetAchievementString(String *string)
46
{
47
InitString(string, "Achievement!", 0);
48
return string;
49
}
50
String *DummyAchievements::GetAchievementName(String *name, uint32 id)
51
{
52
#if !RETRO_VER_EGS
53
id--;
54
#endif
55
if (id <= achievementList.size())
56
InitString(name, achievementList[id].name.c_str(), 0);
57
return name;
58
}
59
60
int32 DummyAchievements::GetNextAchievementID()
61
{
62
if (achievementStack.size() > 0)
63
return achievementStack[0] + 1;
64
else
65
return 0;
66
}
67
68
void DummyAchievements::RemoveLastAchievementID()
69
{
70
if (achievementStack.size() > 0)
71
achievementStack.erase(achievementStack.begin());
72
}
73
#endif
74