-
Notifications
You must be signed in to change notification settings - Fork 53
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
RetroPlayer: Add Achievements #126
Conversation
Sorry, I missed this PR when you opened it 6 days ago. Congratulations on the first PR of the summer, even if it is for debugging purposes! It helps greatly to see your progress as time goes on. It looks like you're on the right track. Let me know when you want more specific feedback on the code. |
Hey @garbear , I am facing an issue while building these functions in VS 2019, as soon as I am opening any game, Kodi execution is breaking. Because of it, I am not able to debug various changes done till now. |
I've had this happen before. The problem is a mismatch in the API used for game.libretro and the API used in Kodi. Kodi is definitely loading a stale version of game.libretro. When you add a function to the API, then the "ABI", application binary interface, is changed. Adding a function means you have to recompile against the correct headers. You're seeing Because adding a function breaks ABI in an incompatible way, to follow semver, you should change this version to 3.0.0: https://github.com/garbear/xbmc/blob/retroplayer-19.1/xbmc/addons/kodi-dev-kit/include/kodi/versions.h#L100. This change to 3.0.0 should appear in the diff of this PR. You know you bumped to 3.0.0 correctly when the generated addon.xml file replaces There are two ways to build binary add-ons for Windows, which way are you using to build game.libretro? One way is better suited for development - once you get that working, it'll be easier to keep game.libretro in sync. |
@garbear ,Firstly commenting on how I build game.libretro : I followed https://github.com/NikosSiak/game.libretro#developing-on-windows it for developing and after these commands one additional command: Now about changing version to 3.0.0, even after changing version to 3.0.0 and building it again, the generated addon.xml file in xbmc\cmake\addons\build\game.libretro\game.libretro location does not change as expected, it is same as previous.
|
@@ -97,7 +97,7 @@ | |||
#define ADDON_INSTANCE_VERSION_AUDIOENCODER_DEPENDS "c-api/addon-instance/audio_encoder.h" \ | |||
"addon-instance/AudioEncoder.h" | |||
|
|||
#define ADDON_INSTANCE_VERSION_GAME "2.1.0" | |||
#define ADDON_INSTANCE_VERSION_GAME "3.0.0" | |||
#define ADDON_INSTANCE_VERSION_GAME_MIN "2.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also change MIN to 3.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garbear , On changing min to 3.0.0, game.libretro addon is disabled, I have done this yesterday also. This was the screenshot of the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, we want old versions of game.libretro to be rejected (we require a compatible version, otherwise we get your segfault, and segfaults should be avoided). I'll fire up my windows PC later today and figure out where the game.libretro build should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm pressed hard at work and can't find a moment to spare for testing. From what I remember, the prepare
script runs the CMake command and generates VS project files. Instead of building with cmake --install
, open the .sln in VS, right click on the project, and compile it that way. Hunt down where it places the compiled files. Either copy them to addons/
, or to simplify your life, make a symlink. That should cause game.libretro dependent on 3.0.0 to appear in addons/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @garbear , I have not done exactly the same but done something which I think is working, First step I do was to change game version in file versions.h
to 3.0.0 from game.libetro.sln
(I have changed it in kodi.sln but I realize today that it was 2.1.0 here in game.libretro.sln
) then I have changed individual files at kodi-build/addons/game.libretro
by the files I obtained after building game.libretro.sln
. It seems to work right now, and if there will any problem I will comment here later on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @garbear , On adding one new function, again I realise that same problem is coming, Kodi was searching for stale version, so I have changed game versions to 3.1.1, also tried 3.2.0 but it is not working(game.libretro is disabled now),so is there any specific pattern to which these version should be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes there's a pattern, which is called "semver" or "semantic versioning". Semver defines the three numbers as major, minor, patch. Patch is no change to API, minor is backwards-compatible change, and major is backwards-incompatible change.
You can bump versions how you see fit for development, and we'll reset to 3.0 when we merge after the summer.
So you're still getting stale game.libretro? I hate that my workload is so high, I'd like to hop on windows and document how to make it not stale and always working. I'll do my best to get some documentation written after work tonight.
cc6171f
to
9c3ea01
Compare
@Shardul555 Can you hit "Edit" next to the PR title and change the base target branch to |
xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h
Outdated
Show resolved
Hide resolved
cheevoid_list.push_back(data[PATCH_DATA][ACHIEVEMENTS][i][CHEEVO_ID].asUnsignedInteger()); | ||
cheevo_memaddr.push_back(data[PATCH_DATA][ACHIEVEMENTS][i][MEM_ADDR].asString()); | ||
cheevo_title.push_back(data[PATCH_DATA][ACHIEVEMENTS][i][CHEEVO_TITLE].asString().c_str()); | ||
cheevo_badge.push_back(data[PATCH_DATA][ACHIEVEMENTS][i][BADGE_NAME].asString().c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should store the achievements in one unordered map with the cheevo_id as key and the whole achievement as a value so you won't do a for loop each time you want to access the achievement's data
if (cheevo_id !=0 && achievement_map.find(cheevo_id) == achievement_map.end()) | ||
{ | ||
achievement_map[cheevo_id] = "triggered"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you are searching the key twice (once with find
and once with []
, you could store the value before the if statement.
char url[URL_SIZE]; | ||
strcpy(url, achievement_url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you shouldn't use char arrays/pointers to store a string, you can use the string constructor which takes a char *
and copies its contents to a new string
@@ -12,6 +12,9 @@ | |||
|
|||
#include <map> | |||
#include <string> | |||
#include <vector> | |||
#include<unordered_map> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: add a space before <
@@ -12,6 +12,9 @@ | |||
|
|||
#include <map> | |||
#include <string> | |||
#include <vector> | |||
#include<unordered_map> | |||
using std::vector; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to avoid importing unrelated namespaces outside of the ones this class is declared within
vector<unsigned> cheevoid_list; | ||
vector<std::string> cheevo_memaddr; | ||
vector<const char*> cheevo_title; | ||
vector<const char*> cheevo_badge; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance variables must start with m_
prefix
9c3ea01
to
cc6171f
Compare
Sorry @garbear , I was not active on the github account so I missed this message , but yes I will do it till tomorrow |
@@ -14,11 +14,14 @@ function(generate_file file) | |||
if(CLANGFORMAT_FOUND) | |||
set(CLANG_FORMAT_COMMAND COMMAND ${CLANG_FORMAT_EXECUTABLE} ARGS -i ${CPP_FILE}) | |||
endif() | |||
if(Java_VERSION_MAJOR GREATER 8) | |||
set(JAVA_OPEN_OPTS --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be upstreamed?
@@ -98,7 +98,7 @@ IF "%store%" NEQ "" ( | |||
) | |||
|
|||
rem execute cmake to generate makefiles processable by nmake | |||
cmake "%ADDONS_PATH%" -G "NMake Makefiles" ^ | |||
cmake "%ADDONS_PATH%" -G "Visual Studio 16 2019" -A x64 ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: we'll drop this before merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've upstreamed this change as part of xbmc#20075
@Shardul555 Aside from the two files I commented on, can you squash everything into a single commit? Besides needing Kodi to compile between all commits for bisection, for major add-on version bumps, I try to keep all the code for a feature together. After squashing, I would expect the first commit to the feature addition, followed by the two commits I commented on. The expectation is that the "temporary" commits will be upstreamed or discarded before merge. Finally, your squashed commit should follow good commit message style. A possible commit title is |
Technically, review should have continued in this PR instead of creating a new, clean one, but it's not a problem because PRs can be linked. Can you close this PR and link to the new one? |
Any updates/news on kodi-game/game.libretro#73 and #126 or #127 now that kodi-game/game.libretro#67 has been merged? |
Keep an eye on master! |
Superseded by #127 |
Description
This Pull request adds support for Achievements in RetroPlayer, data fetched from RetroAchievements API have information about the achievements provided for a particular game, so we used that data for activating achievements, obtaining achievement state for every frame and then awarding it whenever it triggered.
User will be notified about an unlocked achievement through a pop-up notification and also through their RetroAchievement.org profile.
This PR will use kodi-game/game.libretro#73 for calling rcheevos functions.
Motivation and Context
Last year we have added support for RCheevos in RetroPlayer, so adding support for Achievements is one another task that was needed to be accomplished.
How Has This Been Tested?
Screenshots (if appropriate):
Notifying user through pop-up notification:
Information updated in RetroAchievements profile:
Types of change
Checklist: