diff options
| author | Simon Tatham <anakin@pobox.com> | 2005-06-28 07:33:49 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2005-06-28 07:33:49 +0000 |
| commit | cdb8433c0a5bf546ae2f4c55bad1be064d05df3b (patch) | |
| tree | 3e6026b5dde0edba0477de9d714b46c0f687e6cf /mines.c | |
| parent | 08410651e05b0723073d53e7d75174767633bf87 (diff) | |
| download | puzzles-cdb8433c0a5bf546ae2f4c55bad1be064d05df3b.zip puzzles-cdb8433c0a5bf546ae2f4c55bad1be064d05df3b.tar.gz puzzles-cdb8433c0a5bf546ae2f4c55bad1be064d05df3b.tar.bz2 puzzles-cdb8433c0a5bf546ae2f4c55bad1be064d05df3b.tar.xz | |
Another function pair required for serialisation; these ones save
and restore anything vitally important in the game_ui. Most of the
game_ui is expected to be stuff about cursor positions and currently
active mouse drags, so it absolutely _doesn't_ want to be preserved
over a serialisation; but one or two things would be disorienting or
outright wrong to reset, such as the Net origin position and the
Mines death counter.
[originally from svn r6026]
Diffstat (limited to 'mines.c')
| -rw-r--r-- | mines.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -2357,6 +2357,21 @@ static void free_ui(game_ui *ui) sfree(ui); } +char *encode_ui(game_ui *ui) +{ + char buf[80]; + /* + * The deaths counter needs preserving across a serialisation. + */ + sprintf(buf, "D%d", ui->deaths); + return dupstr(buf); +} + +void decode_ui(game_ui *ui, char *encoding) +{ + sscanf(encoding, "D%d", &ui->deaths); +} + static void game_changed_state(game_ui *ui, game_state *oldstate, game_state *newstate) { @@ -3039,6 +3054,8 @@ const struct game thegame = { TRUE, game_text_format, new_ui, free_ui, + encode_ui, + decode_ui, game_changed_state, interpret_move, execute_move, |