PC SDK provides API to integrate the Stove platform’s game support service into the game. The game support service supported by the PC SDK includes stats, achievements, and leaderboards. Each service is defined as follows:
In order to use the PC SDK game support service API, metadata registration for game support services must be conducted first through the studio.
For information on metadata management, refer to the Simple Console User Manual.
To communicate with the PC SDK using the game support service API, the game should define a callback function to connect to the callback pointer of the StovePCCallback
structure below.
struct StovePCCallback
{
void(*OnError)(const StovePCError error);
void(*OnInitComplete)();
void(*OnToken)(const StovePCToken token);
void(*OnUser)(const StovePCUser user);
void(*OnOwnership)(int size, StovePCOwnership* ownership);
// Callback that is called when GetStat has been completed
void(*OnStat)(const StovePCStat stat);
// Callback that is called when SetStat has been completed
void(*OnSetStat)(const StovePCStatValue statValue);
// Callback that is called when GetAchievement has been completed
void(*OnAchievement)(StovePCAchievement achievement);
// Callback that is called when GetAllAchievement has been completed
void(*OnAllAchievement)(int size, StovePCAchievement* achievement);
// Callback function pointer received when calling GetRank API
void(*OnRank)(int size, StovePCRank* rank, unsigned int rankTotalCount);
};
Connect the callback function to the callback of the StovePCCallback
structure as in Integration 1) Config, Callback Settings
.
// Create StovePCCallback structure instance
StovePCCallback callback;
// Initialize every function pointer with NULL
memset(&callback, 0, sizeof(StovePCCallback));
// Connect the implemented function pointer
callback.OnError = OnMyErrorCallback; /*Globally defined callback function*/
callback.OnInitComplete = OnMyInitCompleteCallback; /*Globally defined callback function*/
callback.OnToken = OnMyTokenCallback; /*Globally defined callback function*/
callback.OnUser = OnMyUserInfoCallback; /*Globally defined callback function*/
callback.OnOwnership = OnMyOwnershipCallback; /*Globally defined callback function*/
// Game support service
callback.OnStat = OnMyStat; /*Globally defined callback function*/
callback.OnSetStat = OnMySetStat; /*Globally defined callback function*/
callback.OnAchievement = OnMyAchievement; /*Globally defined callback function*/
callback.OnAllAchievement = OnMyAllAchievement; /*Globally defined callback function*/
callback.OnRank = OnMyRank; /*Globally defined callback function*/
You do not need to implement the callbacks other than OnStat
, OnSetStat
, OnAchievement
, OnAllAchievement
, and OnRank
.
You only need to implement and connect callback functions necessary for the game support service used in the game.
Update specific stats in the game for a logged in user with the StovePC_SetStat
function.
// Input parameters
// const char* statId : Stat identifier registered in the studio
// const int statValue : Stat value to be updated
StovePCResult result = StovePC_SetStat("STAT_ID", STAT_VALUE);
if(result == StovePCResult::STOVE_PC_NO_ERROR)
{
/*Processed as a success*/
}
The OnSetStat
callback is called when the StovePC_SetStat
function is processed properly.
The StovePCStatValue
structure delivered to the callback contains a flag indicating the current stat value, update status and error messages.
If the stat value is fully reflected and updated, the Updated field will contain ‘true’ and the ErrorMessage field will contain an empty string. If the stat value is partially updated, the Updated field will contain ‘true’ and the ErrorMessage field will contain a string such as “integer overflow”.
For example, assuming that the current stat value of the INCREMENT type is 2,147,483,000 and you try to add 1,000 through the StovePC_SetStat
API, it will become out of range of the values that the Int32 type can have, and when it is updated to 2,147,483,647 which is the maximum value of the Int32 type, reflecting only part of the value (1,000), the ErrorMessage field will contain a string such as “integer overflow”.