Mines now follows the conventional approach of offering a completely
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 30 May 2005 13:10:37 +0000 (13:10 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 30 May 2005 13:10:37 +0000 (13:10 +0000)
commitc380832d0b832bcfbd16e760ade393f9adab02b6
tree694f7c69c03cf131f09e97550db4adbf235a4779
parent08781119281c4c144ba167e87476429b0aae20b4
Mines now follows the conventional approach of offering a completely
blank grid until you make the first click; to ensure solubility, it
does not generate the mine layout until that click, and then ensures
it is solvable starting from that position.

This has involved three infrastructure changes:

 - random.c now offers functions to encode and decode an entire
   random_state as a string
 - each puzzle's new_game() is now passed a pointer to the midend
   itself, which most of them ignore
 - there's a function in the midend which a game can call back to
   _rewrite_ its current game description.

So Mines now has two entirely separate forms of game ID. One
contains the generation-time parameters (n and unique) plus an
encoding of a random_state; the other actually encodes the grid once
it's been generated, and also contains the initial click position.
When called with the latter, new_game() does plausibly normal stuff.
When called with the former, it notes down all the details and waits
until the first square is opened, and _then_ does the grid
generation and updates the game description in the midend. So if,
_after_ your first click, you decide you want to share this
particular puzzle with someone else, you can do that fine.

Also in this checkin, the mine layout is no longer _copied_ between
all the game_states on the undo chain. Instead, it's in a separate
structure and all game_states share a pointer to it - and the
structure is reference-counted to ensure deallocation.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5862 cda61777-01e9-0310-a592-d414129be87e
14 files changed:
cube.c
fifteen.c
midend.c
mines.c
net.c
netslide.c
nullgame.c
pattern.c
puzzles.h
random.c
rect.c
sixteen.c
solo.c
twiddle.c