Serialization operations
Serialization operation parts in interface:
Copy this to your project and extend with your parts or leave functions complete away where not used or supported.
◆ SerializeSize()
| virtual size_t SerializeSize |
( |
| ) |
|
|
inlinevirtual |
Get the number of bytes required to serialize the game.
- Returns
- The number of bytes, or 0 if serialization is not supported
◆ Serialize()
| virtual GAME_ERROR Serialize |
( |
uint8_t * | data, |
|
|
size_t | size ) |
|
inlinevirtual |
Serialize the state of the game.
- Parameters
-
| [in] | data | The buffer receiving the serialized game data |
| [in] | size | The size of the buffer |
- Returns
- The error, or GAME_ERROR_NO_ERROR if the game was serialized into the buffer
◆ Deserialize()
| virtual GAME_ERROR Deserialize |
( |
const uint8_t * | data, |
|
|
size_t | size ) |
|
inlinevirtual |
Deserialize the game from the given state.
- Parameters
-
| [in] | data | A buffer containing the game's new state |
| [in] | size | The size of the buffer |
- Returns
- The error, or GAME_ERROR_NO_ERROR if the game deserialized
◆ AchievementStateSize()
| virtual size_t AchievementStateSize |
( |
| ) |
|
|
inlinevirtual |
How many bytes the achievement runtime's state needs right now.
Asked each time rather than reserved once, so it grows with the runtime.
- Returns
- The size, or 0 when there is nothing to save
- Note
- Added in Game API 8.0.0
◆ SerializeAchievements()
| virtual GAME_ERROR SerializeAchievements |
( |
uint8_t * | data, |
|
|
size_t | size ) |
|
inlinevirtual |
Write the achievement runtime's state.
Kept beside the emulator's state, not inside it: a savestate whose emulator memory does not match what the core reports is refused before the core sees it.
- Note
- Added in Game API 8.0.0
◆ DeserializeAchievements()
| virtual GAME_ERROR DeserializeAchievements |
( |
const uint8_t * | data, |
|
|
size_t | size ) |
|
inlinevirtual |
Restore achievement state written by SerializeAchievements()
Called for every savestate load, including ones that carry no achievement state: a savestate written by a build without it, or while signed out. In that case data is nullptr and size is 0, and the runtime must be reset rather than left as it is. Emulator memory has jumped, so every hit count and prior value the runtime holds describes a moment that no longer follows from it, and leaving them could award an achievement the player did not earn.
- Parameters
-
| [in] | data | The state, or nullptr if the savestate carries none |
| [in] | size | The size of data, or 0 if the savestate carries none |
- Note
- Added in Game API 8.0.0