From 9be7db547aa2eba68492dc3326ea36ebeeb63505 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 13 Feb 2023 23:22:59 +0000 Subject: Add a game_state argument to decode_ui() Some games would like a way to check that the parameters in the encoded UI string are consistent with the game parameters. Since this might depend on the current state of the game (this being what changed_state() is for), implement this by adding a game_state parameter to decode_ui(). Nothing currently uses it, though Guess usefully could. --- devel.but | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'devel.but') diff --git a/devel.but b/devel.but index 9ce8eee..ae0a84d 100644 --- a/devel.but +++ b/devel.but @@ -890,14 +890,17 @@ this function it can just set the pointer to \cw{NULL}. \S{backend-decode-ui} \cw{decode_ui()} -\c void (*decode_ui)(game_ui *ui, const char *encoding); +\c void (*decode_ui)(game_ui *ui, const char *encoding, +\c const game_state *state); This function parses a string previously output by \cw{encode_ui()}, and writes the decoded data back into the freshly-created \c{game_ui} structure provided. If the string is invalid, the function should do the best it can, which might just mean not changing the \c{game_ui} structure at all. This might happen if a save file is corrupted, or -simply from a newer version that encodes more \c{game_ui} data. +simply from a newer version that encodes more \c{game_ui} data. The +current \c{game_state} is provided in case the function needs to +refer to it for validation. Like \cw{encode_ui()}, \cw{decode_ui()} is optional. If a back-end doesn't need this function it can just set the pointer to \cw{NULL}. -- cgit v1.1