From 418cb3a5671404d2d91bf221887df2be2ae2654f Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 13 Feb 2023 22:41:40 +0000 Subject: Make encode_ui() and decode_ui() optional in back-ends The majority of back-ends define encode_ui() to return NULL and decode_ui() to do nothing. This commit allows them to instead specify the relevant function pointers as NULL, in which case the mid-end won't try to call them. I'm planning to add a parameter to decode_ui(), and if I'm going to have to touch every back-end's version of decode_ui(), I may as well ensure that most of them never need to be touched again. And obviously encode_ui() should go the same way for symmetry. --- midend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'midend.c') diff --git a/midend.c b/midend.c index e66d15a..2e49e8d 100644 --- a/midend.c +++ b/midend.c @@ -2204,7 +2204,7 @@ void midend_serialise(midend *me, /* * Any required serialisation of the game_ui. */ - if (me->ui) { + if (me->ui && me->ourgame->encode_ui) { char *s = me->ourgame->encode_ui(me->ui); if (s) { wr("UI", s); @@ -2541,7 +2541,7 @@ static const char *midend_deserialise_internal( } data.ui = me->ourgame->new_ui(data.states[0].state); - if (data.uistr) + if (data.uistr && me->ourgame->decode_ui) me->ourgame->decode_ui(data.ui, data.uistr); /* -- cgit v1.1