- Last Updated
Migrating from the Legacy C++ API to the New C API
This document is a reference for games already integrated with the C++ API of 3.4.x or earlier (Stove::PCSDK namespace, Base_* · IAP_* · Ownership_* families) that are moving their code to the new C API (Stove_* family) introduced in 3.5.0.
You do not have to migrate to the new API. Since the 3.4.x API will continue to be supported, you can leave your existing integration code as is and simply replace the deployment files with the 3.5.0 version. This document is only necessary if you decide to migrate your code to the new API.
Please read in the following order.
- First, review the basic structure of the new API. (Chapter 1)
- Check what the functions and structures you are currently using will be replaced with. (Chapters 2 and 3)
- Check to see if you are using any features that are not available in the new API. (Chapter 4)
- When modifying the code, check for any changes in the calling syntax. (Chapter 5)
1. Basic Structure of the New API
The rules for the new interface are outlined in the "Basic Integration Guide" at the beginning of the Reference Guide. This chapter briefly summarizes only the information you need to know when migrating your code.
The number of deployment files is reduced to one.
With the new API, there is only BaseSDK.dll file that needs to be deployed along with the game. You no longer need to include files such as IAPSDK.dll, ViewSDK.dll, and PCBangSDK.dll, which used to be deployed for each module. This is because all features have been integrated into a single binary.
For games integrated with the existing 3.4.x API, please keep your deployment configuration as is. Regardless of whether the binaries are bundled, you must continue to include the individual module files as you have been doing. The number of deployment files will be reduced to one only if you have migrated to the new API.
The module categories have been removed.
The procedure for initializing each module has been removed. Calling Stove_Initialize once enables all payment, pop-up, PC Bang, and log functions, and you only need to call Stove_Uninitialize once to exit.
The module name has also been removed from function names. The prefix has been standardized to Stove_.
Base_GetUser -> Stove_GetUser
IAP_StartPurchase -> Stove_StartPurchase
View_AutoPopup -> Stove_AutoPopup
We use interface pointers instead of structures.
The old API directly declared and exchanged value structures (such as StovePCUser). The new API treats all objects as IStove* pointers and retrieves values using accessors.
// Old C++
StovePCUser user;
Base_GetUser(&user);
const wchar_t* nickname = user.GetNickname();
The new API is available in two forms: C functions and C++ methods, and they behave exactly the same. You can choose the form that best suits your project environment.
IStoveUser* user = nullptr;
Stove_GetUser(&user);
const wchar_t* nickName = Stove_IStoveUser_GetNickName(user);
The naming convention for C functions follows a consistent pattern, such as Stove_<Interface>_<Member>. Since SDK functions (such as Stove_GetUser) are free functions, they are called in the same way in both formats.
Parameters are also created as objects.
Parameters passed to the call are also created using a factory, rather than by declaring a structure. The value EStove<Module>TypeKind specifies which parameter to create.
IStoveInitializeParam* initParam =
(IStoveInitializeParam*)Stove_CreateParam(k_EStoveBaseTypeKind_InitializeParam);
Stove_IStoveInitializeParam_SetShopKey(initParam, L"YOUR_SHOP_KEY");
Objects that have been passed in must be released.
Objects created by the SDK should be released after use. Use ShouldDestroy to determine whether an object needs to be released.
if (Stove_IStoveTypeBase_ShouldDestroy(obj))
Stove_IStoveTypeBase_Destroy(obj);
Since this is a rule that did not exist in the old API, it is the part most often overlooked when porting code. This is explained in more detail in Chapter 5.
It is available in both C and C++ versions
Headers are divided into four types for each module, and stove_api.h is also provided, which allows you to include all of them on a single line.
| Header | Role |
|---|---|
<module>_api.h | SDK Function Declarations (e.g., Stove_Initialize) |
<module>_types.h | Interface definition. In a C++ environment, these are pure virtual functions; in a C environment, they are opaque types. |
<module>_flat_api.h | C Functions That Access Interface Members (Stove_<Interface>_<Member>) |
<module>_misc.h | Enumeration Definitions |
2. Function Correspondence
Initialization and Termination
The functions for initialization, termination, and version lookup for each module are not included in the new API. They have been consolidated into three functions.
| Old C++ | New C | Changes |
|---|---|---|
Base_Initialize · Base_InitializeEx | Stove_Initialize | Module-specific initialization has been removed. |
IAP_Initialize · IAP_InitializeWithWndInfo | Stove_Initialize | Set the window handle to IStoveInitializeParam. |
View_Initialize · View_InitializeWithWndInfo | Stove_Initialize | |
PCBang_Initialize · Log_Initialize · GamingServices_Initialize | Stove_Initialize | |
Base_UnInitialize and *_UnInitialize by module | Stove_Uninitialize | The capitalization has been changed to Uninitialize. |
Base_GetVersion and *_GetVersion by module | Stove_GetVersion | |
Base_RestartAppIfNecessary · Base_RestartAppIfNecessaryAsync · ~AsyncEx · ~AsyncEx2 | Stove_RestartAppIfNecessary | Four functions have been combined into one. |
Base_RunCallback | Stove_RunCallback | |
Base_RunCallbackWithTimeout | Stove_RunCallbackWithTimeout |
User Information and Environment
| Old C++ | New C |
|---|---|
Base_GetUser | Stove_GetUser |
Base_GetSignin | Stove_GetSignin |
Base_GetGds | Stove_GetGds |
Base_GetAccessToken | Stove_GetAccessToken |
Base_AccessTokenRenewed | Stove_AccessTokenRenewed |
Base_SetGameProfile | Stove_SetGameProfile |
Base_SetLanguage · Base_SetLanguageEx | Stove_SetLanguage |
Base_OpenExternalUrl | Stove_OpenExternalUrl |
Regulatory Compliance Notice
| Old C++ | New C |
|---|---|
Base_ShutdownNotification | Stove_ShutdownNotification |
Base_OverImmersionNotification | Stove_OverImmersionNotification |
Base_VietnamAgeRatingNotification | Stove_VietnamAgeRatingNotification |
Base_VietnamOverimmersionNotification | Stove_VietnamOverimmersionNotification |
Payment
| Old C++ | New C | Changes |
|---|---|---|
IAP_FetchProducts · IAP_FetchProductsEx | Stove_FetchProducts | The "availability" code provided by the Ex function is included in the default results. |
IAP_FetchShopCategories | Stove_FetchShopCategories | |
IAP_FetchInventory | Stove_FetchInventory | |
IAP_StartPurchase · IAP_StartPurchaseEx | Stove_StartPurchase | The callback that is called when the popup closes is included in the default arguments. |
IAP_ConfirmPurchase | Stove_ConfirmPurchase | |
IAP_FetchTermsAgreement · IAP_FetchTermsAgreementEx | Stove_FetchTermsAgreement | |
IAP_WithdrawGame | Stove_WithdrawGame | |
IAP_CloseAllPopups | Stove_CloseAllPopups | It has been integrated with the pop-up feature. |
Pop-up
| Old C++ | New C | Changes |
|---|---|---|
View_AutoPopup · View_AutoPopupEx | Stove_AutoPopup | The callback that is called when the popup closes is included in the default arguments. |
View_ManualPopup · View_ManualPopupEx | Stove_ManualPopup | |
View_NewsPopup · View_NewsPopupEx | Stove_NewsPopup | |
View_CouponPopup · View_CouponPopupEx | Stove_CouponPopup | |
View_VerifyIdentificationPopup | Stove_VerifyIdentificationPopup | |
View_SetPopupDisallowed | Stove_SetPopupDisallowed | |
View_CloseAllPopups | Stove_CloseAllPopups | It has been integrated with the payment feature. |
PC Bang
| Old C++ | New C |
|---|---|
PCBang_CheckPCBangStatus | Stove_PCBangCheckStatus |
PCBang_UserLogin | Stove_PCBangLogin |
PCBang_UserLogout | Stove_PCBangLogout |
Log
| Old C++ | New C |
|---|---|
Log_Send | Stove_SendLog |
3. Correspondence Between Structures and Enumerations
General
| Old C++ | New C | Changes |
|---|---|---|
Result | IStoveResult | It's a pointer, not a value. Free it when you're done using it. |
CallbackResult | IStoveCallbackResult | |
SDKResultCode (These existed separately for each module) | EStoveCommonResultCode · EStoveResultCode | This is explained in Section 5.6. |
SDKMethod (These existed separately for each module) | EStove<Module>MethodCode | |
| None | EStove<Module>TypeKind | Newly added. Identifies the concrete type of the object. |
| None | IStoveTypeBase | Newly added. This is the top-level interface for all objects and is responsible for deallocation. |
User Information and Environment
| Old C++ | New C |
|---|---|
StovePCUser | IStoveUser |
StovePCSignin | IStoveSignin |
StovePCGds | IStoveGds |
StovePCToken | IStoveAccessToken |
StovePCInitializeParam · StovePCInitializeParamEx2 | IStoveInitializeParam · IStoveRestartAppIfNecessaryParam |
StovePCGameProfile | IStoveSetGameProfileParam |
StoveLanguage | Pass the language code string without using an enumeration |
Regulatory Compliance Notice
| Old C++ | New C |
|---|---|
StovePCShutdown | IStoveShutdownInfo |
StovePCOverImmersion | IStoveOverImmersionInfo |
StovePCVietnamAgeRatingInfo | IStoveVietnamAgeRatingInfo |
StovePCVietnamOverimmersionInfo | IStoveVietnamOverimmersionInfo |
StoveOverlayState | EStoveOverlayMode |
Payment
| Old C++ | New C | Changes |
|---|---|---|
StovePCProduct · StovePCProductEx | IStoveProduct | They have been consolidated into one. |
| Product Layout and Quantity | IStoveProductList | It has been changed to an object that holds a list. |
StovePCShopCategory | IStoveShopCategory · IStoveShopCategoryList | |
StovePCInventoryItem | IStoveInventoryItem · IStoveInventoryList | |
StovePCPurchasedProduct | IStovePurchasedProduct | |
StovePCChargeInfo | IStoveChargeInfo | |
StovePCOrderProduct | IStoveOrderProductParam | |
StovePCStartPurchaseParam | IStoveStartPurchaseParam | |
StovePCPurchaseOption | IStovePurchaseParam | |
StovePCPurchaseResult | IStoveStartPurchaseOutcome | |
StovePCFetchProductParam | IStoveFetchProductsParam | |
StovePCTermsOption | IStoveFetchTermsAgreementParam | |
| Results of Terms and Conditions Agreement | IStoveTermsAgreementOutcome | A new object for holding results has been added. |
| Purchase Confirmation Requests and Results | IStoveConfirmPurchaseParam · IStoveConfirmPurchaseOutcome | |
StovePCWithdrawGameOption | IStoveWithdrawGameParam · IStoveWithdrawGameOutcome | |
DiscountType | EStoveDiscountType | |
ProductTypeCode | EStoveProductTypeCode | |
PurchaseLimitTypeCode | EStovePurchaseLimitTypeCode | |
PurchaseProgress | EStovePurchaseProgress | |
StovePCPurchaseOperation | EStovePurchaseOperation | |
StovePCTermsOperation | EStoveTermsOperation |
Pop-up
| Old C++ | New C | Changes |
|---|---|---|
| Pop-up Options | IStovePopupParam | Automatic, News, and Coupon pop-ups are used in all cases. |
| Manual Pop-up Option | IStoveManualPopupParam | |
StovePCPopupDisallowed | IStoveSetPopupDisallowedParam | |
| User Authentication Pop-up Options | IStoveVerifyIdentificationPopupParam · IStoveVerifyIdentificationPopupDestroyInfo | |
| WebView Position and Size Fields | IStoveWebViewLayoutParam | The parameters used with WebView are shared. |
WebViewMode | EStoveWebViewMode |
PC Bang and the log
| Old C++ | New C |
|---|---|
StovePCBangStatus | IStovePCBangStatus |
StovePCBangUserLogin | IStovePCBangLoginOutcome |
StovePCRefreshUserBenefits | IStovePCBangBenefitInfo |
PCBangPremium | EStovePCBangPremium |
StovePCLogSendParam | IStoveSendLogParam |
4. Features Not Available in the New API
The following items do not have corresponding functions or structures in the new C API. If you are using these features, you should determine an alternative approach before porting your code.
Function
| Old C++ | Information |
|---|---|
Base_GetShutdown | The value is passed via the Stove_ShutdownNotification callback without being looked up directly. |
Base_GetOverImmersion | Stove_OverImmersionNotification is passed via a callback |
Base_GetRenewToken | Stove_AccessTokenRenewed is passed via a callback |
Base_GetTraceHint | There is no corresponding function. This feature was already scheduled for removal. |
IAP_StartPayment · IAP_StartPaymentEx | Payments will be consolidated under Stove_StartPurchase. |
IAP_FetchVoidedPurchases · IAP_FetchVoidedPurchasesEx | There is no corresponding function. This feature was already scheduled for removal. |
View_FetchWebOpenKey | There is no corresponding function. This feature was already scheduled for removal. |
GamingServices_FetchCharacter | This is an interface specific to certain developers, such as Epic Seven, and is scheduled to be deprecated in the future; therefore, it is not available in the new interface. If you need this functionality, you must continue using the existing C++ interface as is or switch to calling the platform API directly. |
Structures and Enumerations
| Old C++ | Information |
|---|---|
StovePCTraceHint | It was removed along with Base_GetTraceHint |
StovePCVoidedPurchase · StovePCVoidedPurchasesEx · StovePCVoidedPurchasesMarketType | It has been removed along with the refund history lookup feature. |
StovePCPaymentOption · StovePCPaymentOperation | It was removed along with IAP_StartPayment. |
CloseButtonType | There is no corresponding enumeration. This feature was already scheduled for removal. |
A Method That No Longer Exists
Ex·Ex2Extension Functions: The new API does not provide separate extension functions. The functionality previously handled by the existingExseries—namely, the callback triggered when the popup closes, the added response fields, and the extended parameters—is now all included in a single default function.- Module-by-Module Initialization: The process of individually initializing modules to use payment or pop-up features has been eliminated.
- Results Code by Module: The
SDKResultCodecode that existed in each module has been organized into two categories: common code and function-specific code.
5. Changes Made When Modifying the Code
Simply changing the name won't make the build succeed, because the calling syntax changes as well. The following six areas are where you actually need to modify the code.
5.1 Synchronous functions return their results as pointers.
The old API returned the value Result, and the result structure was declared by the caller, who then passed its address. The new API returns IStoveResult*, and the result object is passed as a double pointer.
// Old C++
StovePCUser user;
Result result = Base_GetUser(&user);
if (result.IsSuccessful())
{
const wchar_t* nickname = user.GetNickname();
}
IStoveUser* user = nullptr;
IStoveResult* result = Stove_GetUser(&user);
if (Stove_IStoveResult_IsSuccessful(result))
{
const wchar_t* nickName = Stove_IStoveUser_GetNickName(user);
Stove_IStoveTypeBase_Destroy((IStoveTypeBase*)user);
}
Stove_IStoveTypeBase_Destroy((IStoveTypeBase*)result);
- Check
IsSuccessful()to see if it was successful. Do not usetry-catch. - Check the result code at
GetResultCode(), and check which function generated the result atGetMethodCode().
5.2 Release any objects that were passed in
In the old API, value structures were automatically cleaned up when they went out of scope. In the new API, objects created by the SDK must be released by the caller.
if (Stove_IStoveTypeBase_ShouldDestroy(obj))
Stove_IStoveTypeBase_Destroy(obj);
- The returned
IStoveResult*will be released. - Parameters created using
Stove_CreateParam()are also released once the call is complete. - Check the memory management table for each document to see which objects were passed to the callback. Some objects are owned by the SDK and must not be released.
- If it's difficult to verify in the document, you can determine it as
ShouldDestroy, as shown above.
5.3 Parameters are created using the Factory pattern
// Old C++
StovePCInitializeParam initParam;
initParam.SetShopKey(L"YOUR_SHOP_KEY");
Base_Initialize(&initParam, OnInitializeFinished);
IStoveInitializeParam* initParam =
(IStoveInitializeParam*)Stove_CreateParam(k_EStoveBaseTypeKind_InitializeParam);
Stove_IStoveInitializeParam_SetShopKey(initParam, L"YOUR_SHOP_KEY");
IStoveResult* result = Stove_Initialize(initParam);
// Check the results.
Stove_IStoveTypeBase_Destroy((IStoveTypeBase*)result);
Stove_IStoveTypeBase_Destroy((IStoveTypeBase*)initParam);
The value passed to Stove_CreateParam() is the TypeKind of the parameter you want to create. The value to be passed is specified in each parameter's documentation.
5.4 The initialization process is shorter.
Old C++ : Base_RestartAppIfNecessaryAsync -> Base_Initialize
-> IAP_Initialize -> View_Initialize -> PCBang_Initialize -> Log_Initialize
New C : Stove_RestartAppIfNecessary -> Stove_Initialize
- Remove all module-specific initialization calls. If you leave them in, the build will fail.
- Call
Stove_Uninitializeonly once when exiting as well. Please note that the notation has changed fromUnInitializetoUninitialize. Stove_Initializeis an asynchronous function. It immediately returns a value indicating whether the operation succeeded, without waiting for the completion callback.
5.5 A user data argument has been added to callbacks
Asynchronous functions receive void* userData along with a callback. You can use this value instead of a global variable in the callback when you need to locate the game object again.
// Old C++
void IAP_StartPurchase(const StovePCStartPurchaseParam* params,
OnStartPurchaseFinished onFinished);
// New C
void Stove_StartPurchase(const IStoveStartPurchaseParam* params,
OnStartPurchaseCallback onFinished,
OnIAPPopupDestroyCallback onDestroy,
void* userData1, void* userData2);
- Since SDK functions are free functions, their declarations are the same in both C and C++ environments.
- The function that opens a popup takes both a completion callback and a callback that is called when the popup closes. This corresponds to the part of the old API that used the
Exfunction. - If a close callback is not required, pass
nullptr. - The callback is executed at the same time as before. Since it runs on the thread that called
Stove_RunCallback(), you must continue to call it from within the game loop.
5.6 The code structure has changed.
The old API had a separate SDKResultCode for each module. The new API has been consolidated into two.
| Scope | Enumeration | Included code |
|---|---|---|
| 0 ~ 299 | EStoveCommonResultCode | Code shared by all features |
| 300 or more | EStoveResultCode | Code Categorized by Function |
- If you have code that compares values numerically, check each one against the new enumeration. The same number may have a different meaning.
- The names of enumeration values follow the format
k_E<Enum><Value>. "Success" isk_EStoveCommonResultCode_Success. - You can check the table in each result code document to see if the code requires a guidance screen to be displayed to the user.
6. Order of Transfer
Instead of making all the changes at once, it’s easier to check how things work along the way if you break the process down into the following steps.
- First, replace the header and linker settings. This involves removing the old API headers and replacing them with the new API headers, as explained in detail in Section 6.1.
- Modify the initialization and shutdown code. Remove the module-specific initialization, reorganize the code as shown in
Stove_InitializeandStove_Uninitialize, and then verify that the game runs. - Modify the variable lookup function. Start by moving functions that return values directly, such as
Stove_GetUserandStove_GetGds, to get used to the rule of releasing objects. - Update the asynchronous functions. Move features that use callbacks—such as payment, pop-ups, and PC Bang—to the new functions. For sections that previously used the
Exfunction, reorganize them to use the closure callback argument. - Review the code branches. Replace the sections that used numerical comparisons and module-specific code with a new enumeration.
- Clean up the deployment configuration. Change it so that only
BaseSDK.dllis included and the module-specific files are dropped. - Review Chapter 4 again. Do a final check to see if there are any features that still require workarounds.
6.1 Replacing Headers and Modifying include Statements
The headers for the old API are located in the Include folder of the distribution package, with one per module, while enumerations, structures, and callback declarations are located in the Include/Misc folder. The headers for the new API are located in the Public/C folder for each module and are divided into four categories.
| Category | Legacy API | New API |
|---|---|---|
| Header location | {SDK_Root}/Include/ and {SDK_Root}/Include/Misc/ | Per-module Public/C/ |
| Module headers | BaseSDK.h · IAPSDK.h · ViewSDK.h · PCBangSDK.h · LogSDK.h | base_api.h · iap_api.h · view_api.h · pcbang_api.h · log_api.h (four types per module) |
| Umbrella header | None | stove_api.h |
In the project settings, remove the header path for the old API, add the header path for the new API to the directory, and then update the include statements in the source code.
// Old C++
#include "BaseSDK.h"
#include "IAPSDK.h"
#include "ViewSDK.h"
#include "PCBangSDK.h"
The simplest method is to replace it with a single unified header. Since the four types of headers from all modules are included together, C accessors can be used immediately.
// New: The unified header includes all modules in a single line.
#include "stove_api.h"
You can also choose to include only the modules you need. In this case, to access interface members in a C environment, you must also include <module>_flat_api.h.
// New: When selecting and including a module
#include "base_api.h"
#include "base_flat_api.h"
#include "iap_api.h"
#include "iap_flat_api.h"
#include "view_api.h"
#include "view_flat_api.h"
<module>_api.hincludes<module>_types.h, and<module>_types.hincludes<module>_misc.h. Therefore, there is no need to add the enumeration and structure headers separately.- If you are only using the C++ method form, you do not need to include
<module>_flat_api.h. - If you have any code that directly includes the header
Include/Miscfrom the old API, remove it as well. The new API does not have a header with that name. - If you have listed the module-specific lib files as additional dependencies for the linker, organize them according to the
Libfolder structure of the distribution package. There is only one binaryBaseSDK.dlldistributed with the game.