chiark / gitweb /
sgt-puzzles.git
18 years agoOne more fix from Ben H. Also switched round the arena colour
Simon Tatham [Fri, 29 Jul 2005 16:45:52 +0000 (16:45 +0000)]
One more fix from Ben H. Also switched round the arena colour
selection in the redraw function, so that locked squares are no
longer displayed once the game is at an end. (It looked untidy and
disorienting for lighter-coloured locked squares to suddenly become
darker when the box was opened. You can still flip back and forth to
your previous game state using undo/redo if you want to compare the
results against your lock pattern.)

[originally from svn r6150]

18 years agoVarious fixes and cleanups suggested by Ben Hutchings:
Simon Tatham [Fri, 29 Jul 2005 12:07:10 +0000 (12:07 +0000)]
Various fixes and cleanups suggested by Ben Hutchings:
 - clarified wording of messages in validate_params(), including in
   particular a correction from `< 255' to `<= 255'
 - fixed random_upto() in game generation which caused the maximum
   number of balls never to be used when there was uncertainty
 - fixed widespread miscalculation of rectangular-array indices
   (multiplication by h instead of w, which would have broken
   non-square grids rather profoundly)
 - corrected an ANSI namespace violation
 - removed real functionality from the inside of assert()
   statements, so that the game should still work when compiled
   -DNDEBUG
 - couple of unnecessary linear-time loops removed.

[originally from svn r6149]

18 years agoBen Hutchings reports that gcc 4 gives an optimiser warning because
Simon Tatham [Fri, 29 Jul 2005 11:34:02 +0000 (11:34 +0000)]
Ben Hutchings reports that gcc 4 gives an optimiser warning because
it can't tell that one branch of a particular switch is always
taken. Adding a default clause with an automatic assertion failure
apparently fixes it.

[originally from svn r6148]

18 years agoPatches from Ben Hutchings to fix failures of sscanf error checking.
Simon Tatham [Fri, 29 Jul 2005 11:24:55 +0000 (11:24 +0000)]
Patches from Ben Hutchings to fix failures of sscanf error checking.

[originally from svn r6147]

18 years agoTweak a paragraph after discussion with Simon.
Jacob Nevins [Fri, 29 Jul 2005 08:20:40 +0000 (08:20 +0000)]
Tweak a paragraph after discussion with Simon.

[originally from svn r6144]

18 years agoShiny new developer documentation to replace the old sketchy HACKING
Simon Tatham [Thu, 28 Jul 2005 17:12:18 +0000 (17:12 +0000)]
Shiny new developer documentation to replace the old sketchy HACKING
guide.

[originally from svn r6142]

18 years agoThe very core of cross() is capable of suffering integer overflow on
Simon Tatham [Sun, 24 Jul 2005 10:39:33 +0000 (10:39 +0000)]
The very core of cross() is capable of suffering integer overflow on
large puzzles. Resort to hand-hacked 64-bit arithmetic for doing dot
products; everything else remains in `long' for the moment.

(Ideally I'd auto-detect the presence of `long long' and use it in
place of my cheap plastic imitation where possible, but since I
currently don't have a configure mechanism that'll have to wait.)

[originally from svn r6137]

18 years agoAnother diagnostic mode for Untangle: if compiled with
Simon Tatham [Sun, 24 Jul 2005 10:09:04 +0000 (10:09 +0000)]
Another diagnostic mode for Untangle: if compiled with
`-DSHOW_CROSSINGS', it will show each edge in red if it is crossed
by anything, and in black otherwise. Distracting and not
particularly useful during play, but occasionally handy for
debugging cross().

[originally from svn r6136]

18 years ago(GTK only so far) Allow the argument passed to a game binary to be
Simon Tatham [Sun, 24 Jul 2005 10:05:11 +0000 (10:05 +0000)]
(GTK only so far) Allow the argument passed to a game binary to be
either a game ID or a save file name. (The former takes priority,
because you can usually find a synonym for the latter, such as by
prepending `./' or `$PWD/'.)

[originally from svn r6135]

18 years agoSolve animation (currently only in Untangle) was failing to set
Simon Tatham [Fri, 22 Jul 2005 12:07:56 +0000 (12:07 +0000)]
Solve animation (currently only in Untangle) was failing to set
me->anim_pos to zero, meaning that if it happened immediately after
a completion flash then anim_pos would start off half way through
its run.

[originally from svn r6127]

18 years agoThe `Solve' operation now rotates and/or reflects the solution grid
Simon Tatham [Fri, 22 Jul 2005 11:55:50 +0000 (11:55 +0000)]
The `Solve' operation now rotates and/or reflects the solution grid
to bring it as close as possible to the current game state. This
means that if you request `Solve' after solving a puzzle yourself,
with the intention of finding out how similar your solution is to
the program's, then you will mostly see the differences in _shape_
rather than those being masked by the fact that yours happened to be
the other way up.

[originally from svn r6126]

18 years agoJames H profiled the new Same Game grid generator and discovered it
Simon Tatham [Fri, 22 Jul 2005 11:06:57 +0000 (11:06 +0000)]
James H profiled the new Same Game grid generator and discovered it
was spending 60% of its time in shuffle(). The purpose of the
shuffle() call was to go through a largish array in random order
until we found an element that worked, so there's no actual need to
shuffle the whole array every time and I only did it out of
laziness. So I now pick a random element each time I go round the
loop, meaning I save a lot of shuffling effort whenever the loop
terminates early (which is often). I get about a factor of two speed
improvement from this small change.

[originally from svn r6125]

18 years agoUntil now, Same Game has been the only puzzle in this collection
Simon Tatham [Thu, 21 Jul 2005 18:06:31 +0000 (18:06 +0000)]
Until now, Same Game has been the only puzzle in this collection
which is unable to guarantee that every grid it generates can be
solved. So I'm eliminating that exception: this checkin contains a
more sophisticated grid generator which does guarantee solubility.
It's a bit slow (most noticeably on the 15x10c3 preset), and the
quality of the generated grids is slightly weird (a tendency toward
small regions rather than large sweeping areas of contiguous
colour); however, I'm willing to see the latter as a feature for
now, since making the game more challenging while simultaneously
guaranteeing it to be possible sounds like an all-round win to me.

From now on I'm raising my standards for contributions to this
collection. I made this fix to Same Game because I heard a user
_automatically assume_ that any puzzle in my collection would not be
so uncouth as to generate an impossible grid; as of this checkin
that's actually true, and I intend to maintain that standard of
quality henceforth.

(Guaranteeing a _unique_ solution is more of an optional extra,
since there are many games for which it isn't a meaningful concept
or isn't particularly desirable. Which is not to say that _some_
games wouldn't be of unacceptably low quality if they failed to
guarantee uniqueness; it depends on the game.)

[originally from svn r6124]

18 years agoI've been meaning to do this for ages: all the Makefiles now give
Simon Tatham [Thu, 21 Jul 2005 17:26:46 +0000 (17:26 +0000)]
I've been meaning to do this for ages: all the Makefiles now give
$(XFLAGS) _after_ $(CFLAGS) on the compiler command lines, meaning
that you can provide options in XFLAGS on the makefile which will
override the ones in CFLAGS. For example, `make XFLAGS=-O0' to make
debugging easier.

[originally from svn r6123]

18 years agoSync with website
Jacob Nevins [Wed, 20 Jul 2005 23:35:43 +0000 (23:35 +0000)]
Sync with website

[originally from svn r6122]

18 years agoThe Untangle completion flash was weedy and anaemic; beef it up a
Simon Tatham [Wed, 20 Jul 2005 11:05:35 +0000 (11:05 +0000)]
The Untangle completion flash was weedy and anaemic; beef it up a
bit. In particular, it now flashes between _two_ specially picked
colours (white and mid-grey), meaning that it should be visible even
if your default background colour is white; and it also flashes
twice rather than once.

[originally from svn r6121]

18 years agoSome attempt to explain Dominosa for those unfamiliar with dominos. (Not sure
Jacob Nevins [Tue, 19 Jul 2005 19:33:49 +0000 (19:33 +0000)]
Some attempt to explain Dominosa for those unfamiliar with dominos. (Not sure
I've succeeded.)

[originally from svn r6120]

18 years agoAnother fix from Chris: Guess's allow-blanks mode wasn't allowing
Simon Tatham [Mon, 18 Jul 2005 19:07:36 +0000 (19:07 +0000)]
Another fix from Chris: Guess's allow-blanks mode wasn't allowing
blanks...

[originally from svn r6118]

18 years agoFix to Chris's patch in r6106 (also from Chris).
Simon Tatham [Mon, 18 Jul 2005 18:54:06 +0000 (18:54 +0000)]
Fix to Chris's patch in r6106 (also from Chris).

[originally from svn r6117]
[r6106 == a31934f233581da07153af6b4ee717f1e63387dd]

18 years agoSwitch Untangle to using `long' rather than `int' in its internal
Simon Tatham [Sun, 17 Jul 2005 17:12:21 +0000 (17:12 +0000)]
Switch Untangle to using `long' rather than `int' in its internal
rationals, for the sake of 16-bit-int platforms such as Palm. Thanks
to James H.

[originally from svn r6114]

18 years agoQuite a few instances of the Cardinal Error of Ctype were turned up
Simon Tatham [Sun, 17 Jul 2005 17:10:11 +0000 (17:10 +0000)]
Quite a few instances of the Cardinal Error of Ctype were turned up
by a grep I just did. Oops.

[originally from svn r6113]

18 years agoTwo tiny cleanup patches from James H.
Simon Tatham [Sun, 17 Jul 2005 14:49:13 +0000 (14:49 +0000)]
Two tiny cleanup patches from James H.

[originally from svn r6111]

18 years agoGet rid of the malloc in shuffle(), by defining a subfunction
Simon Tatham [Sun, 17 Jul 2005 12:12:16 +0000 (12:12 +0000)]
Get rid of the malloc in shuffle(), by defining a subfunction
memswap() which declares a fixed-size buffer on the stack and uses
it multiple times if necessary.

[originally from svn r6107]

18 years agoPatch from Chris Emerson: rather than dynamically calling
Simon Tatham [Sun, 17 Jul 2005 11:15:50 +0000 (11:15 +0000)]
Patch from Chris Emerson: rather than dynamically calling
get_correct() at (among other things) every redraw, we call it once
at the creation of a new game_state to save CPU.

[originally from svn r6106]

18 years agoBlack Box: fix "reveal" button location, explain what's meant by the
Jacob Nevins [Sun, 17 Jul 2005 10:33:40 +0000 (10:33 +0000)]
Black Box: fix "reveal" button location, explain what's meant by the
`firing range'

[originally from svn r6105]

18 years agoUse \q{} and \by in Black Box docs.
Jacob Nevins [Sun, 17 Jul 2005 10:13:41 +0000 (10:13 +0000)]
Use \q{} and \by in Black Box docs.

[originally from svn r6104]

18 years agoI keep forgetting to do things when adding a new puzzle, so here's a
Simon Tatham [Sun, 17 Jul 2005 09:35:01 +0000 (09:35 +0000)]
I keep forgetting to do things when adding a new puzzle, so here's a
checklist.

[originally from svn r6103]

18 years agoBah, there's always one: failed to `svn add' blackbox.c itself!
Simon Tatham [Sun, 17 Jul 2005 08:46:00 +0000 (08:46 +0000)]
Bah, there's always one: failed to `svn add' blackbox.c itself!

[originally from svn r6101]

18 years agoAnother game from James H: `Black Box'.
Simon Tatham [Sun, 17 Jul 2005 08:44:18 +0000 (08:44 +0000)]
Another game from James H: `Black Box'.

[originally from svn r6100]

18 years agoCleanups and memory leak fixes from James H.
Simon Tatham [Sat, 16 Jul 2005 20:06:37 +0000 (20:06 +0000)]
Cleanups and memory leak fixes from James H.

[originally from svn r6099]

18 years agoSanity-checking patch from Phil Bordelon: since Solo can't cope with
Simon Tatham [Sat, 16 Jul 2005 20:02:15 +0000 (20:02 +0000)]
Sanity-checking patch from Phil Bordelon: since Solo can't cope with
more than 36 distinct symbols (it runs out of alphanumerics), check
this in validate_params. I hate to do this, since I like puzzle
sizes to at least be open-ended in _principle_, but in this case
there's a fundamental UI limitation which won't be fixed by getting
a faster CPU.

[originally from svn r6098]

18 years agoNew puzzle: `Untangle', cloned (with the addition of random grid
Simon Tatham [Sat, 16 Jul 2005 19:51:53 +0000 (19:51 +0000)]
New puzzle: `Untangle', cloned (with the addition of random grid
generation) from a simple but rather fun Flash game I saw this
morning.

Small infrastructure change for this puzzle: while most game
backends find the midend's assumption that Solve moves are never
animated to be a convenience absolving them of having to handle the
special case themselves, this one actually needs Solve to be
animated. Rather than break that convenience for the other puzzles,
I've introduced a flag bit (which I've shoved in mouse_priorities
for the moment, shamefully without changing its name).

[originally from svn r6097]

18 years agoImprove speed of grid generation: I've found something simple I can
Simon Tatham [Fri, 15 Jul 2005 16:43:02 +0000 (16:43 +0000)]
Improve speed of grid generation: I've found something simple I can
do during construction which massively increases (by over a factor
of four with default parameters) the probability that any given
randomly generated grid will be uniquely solvable.

[originally from svn r6096]

18 years agoAdd Dominosa printout support.
Jacob Nevins [Thu, 14 Jul 2005 22:50:58 +0000 (22:50 +0000)]
Add Dominosa printout support.

[originally from svn r6094]

18 years agoCleanups to Solo:
Simon Tatham [Thu, 14 Jul 2005 18:15:23 +0000 (18:15 +0000)]
Cleanups to Solo:
 - use the new `shuffle' utility function in a couple of places
 - remove the random_state parameter from solver(). It was there
   because I initially wanted to use the same solver for grid
   generation, but since I had to abandon that plan the solver now
   doesn't have any need for randomness at all.

[originally from svn r6093]

18 years agoNew puzzle: Dominosa.
Simon Tatham [Thu, 14 Jul 2005 17:42:01 +0000 (17:42 +0000)]
New puzzle: Dominosa.

[originally from svn r6091]

18 years agoIntroduce a `shuffle' utility function.
Simon Tatham [Thu, 14 Jul 2005 17:37:05 +0000 (17:37 +0000)]
Introduce a `shuffle' utility function.

[originally from svn r6090]

18 years agogame_timing_state() now has access to the game_ui. This means that
Simon Tatham [Sun, 10 Jul 2005 10:17:13 +0000 (10:17 +0000)]
game_timing_state() now has access to the game_ui. This means that
whether the timer is currently going is no longer solely dependent
on the current game_state: it can be dependent on more persistent
information stored in the game_ui. In particular, Mines now freezes
the timer permanently once you complete a grid for the first time,
so that you can then backtrack through your solution process without
destroying the information about how long it took you the first time
through.

[originally from svn r6088]

18 years agoChange of policy on game_changed_state(). Originally, it was called
Simon Tatham [Sun, 10 Jul 2005 10:06:04 +0000 (10:06 +0000)]
Change of policy on game_changed_state(). Originally, it was called
by the midend every time the game state changed _other_ than as a
result of make_move(), on the basis that when the game state changed
due to make_move() the game backend had probably noticed anyway.
However, when make_move() split up, this became more fiddly: if the
game_ui had to be updated based on some property of the final game
state, then execute_move() couldn't do it because it didn't have a
pointer to the game_ui, but it was fiddly to do it in
interpret_move() because that didn't directly have a copy of the
finished game state to examine. Same Game (the only game to be
affected) had to deal with this by actually having interpret_move()
_call_ execute_move() to construct a temporary new game state,
update the UI, and then throw it away.

So now, game_changed_state() is called _every_ time the current game
state changes, which means that if anything needs doing to the
game_ui as a result of examining the new game state, it can be done
there and save a lot of effort.

[originally from svn r6087]

18 years agoSubtle UI change to Mines. Although I mostly find the unified left-
Simon Tatham [Sun, 10 Jul 2005 09:27:08 +0000 (09:27 +0000)]
Subtle UI change to Mines. Although I mostly find the unified left-
button interface (same button to open a closed square or to clear
around an open one) to be a massive help, there is one circumstance
in which it frequently kills me: if I click down on an open square I
want to clear around, then the mouse pointer accidentally drifts
over on to the nearest closed square before I release, I'll end up
opening that square instead and (usually) dying. So this checkin
causes Mines to note which type of square I left-clicked on, and to
do nothing if the button release is on the other type.

[originally from svn r6086]

18 years agoAlter the `Octagon' board preset so that instead of presenting you
Simon Tatham [Sat, 9 Jul 2005 10:19:41 +0000 (10:19 +0000)]
Alter the `Octagon' board preset so that instead of presenting you
with the obvious central hole it presents you with a randomly chosen
one of twelve other holes. The reason is, the central-hole starting
position is provably insoluble (proof given in comments), so instead
we pick from the ones that are actually possible.

[originally from svn r6083]

18 years agoMissing quit on error was leading to an assertion failure on some
Simon Tatham [Wed, 6 Jul 2005 21:24:28 +0000 (21:24 +0000)]
Missing quit on error was leading to an assertion failure on some
types of incorrectly formatted save file.

[originally from svn r6079]

18 years agoMove various printf()s after declarations.
Jacob Nevins [Wed, 6 Jul 2005 20:10:03 +0000 (20:10 +0000)]
Move various printf()s after declarations.

[originally from svn r6078]

18 years agoUnify the two solvers in Solo. nsolve has now had recursion
Simon Tatham [Wed, 6 Jul 2005 18:36:20 +0000 (18:36 +0000)]
Unify the two solvers in Solo. nsolve has now had recursion
capability added to it, to be used only when all else fails, and is
simply called `solver'. This means that:

 - solving of 5x5 Trivial grids using the `Solve' function, which
   previously hung for ages because rsolve happened to take a wrong
   turning at the start, is now zippy
 - solosolver doesn't require the confusing -r and -n options
 - solosolver can show its working even for Unreasonable grids.

Unfortunately, the new unified solver still isn't suitable for grid
generation. After it proved to be so much faster at solving 5x5s, I
hoped to be able to substitute it for rsolve during generation and
gain additional speed in 5x5 generation too; but no luck, because
it's slower _per recursion level_, and although during solving it
makes up for this by needing very few levels, there is a lot of
_unavoidable_ recursion during generation, especially at 5x5. A
hybrid strategy which starts off with rsolve and switches to the
unified solver at a critical point proved unsatisfactory as well,
because the critical point changes depending on the vagaries of the
recursion and can't be pinpointed easily. So rsolve is still in
there, only renamed `gridgen' because that's now all it's good for.

[originally from svn r6077]

18 years agoRefactoring from James H: the highlight and lowlight colour setup
Simon Tatham [Wed, 6 Jul 2005 18:27:40 +0000 (18:27 +0000)]
Refactoring from James H: the highlight and lowlight colour setup
common to Fifteen, Sixteen, Twiddle and Pegs is now a utility
function in misc.c.

[originally from svn r6076]

18 years agoSome patches from James H:
Simon Tatham [Wed, 6 Jul 2005 11:06:17 +0000 (11:06 +0000)]
Some patches from James H:
 - reinstate the initialisation of ds->w and ds->h in guess.c, which
   I'd accidentally removed during game_size() refactoring
 - reorganise Net's interpret_move() so that my uncommitted patch
   for drag-based UI (which he uses on the Palm port) will apply
   more easily
 - the interpret_move() changes make it easy to have a single move
   type which rotates a tile by 180 degrees, so this is now provided
   via the `F' key (but there's no spare button available to provide
   it via the mouse).

[originally from svn r6070]

18 years agoRevert the code that assumed that incoming parameters used a random generation
Jacob Nevins [Tue, 5 Jul 2005 21:40:29 +0000 (21:40 +0000)]
Revert the code that assumed that incoming parameters used a random generation
scheme in r6068, since this messed up the non-permanency of the non-limited
parameter.

[originally from svn r6069]
[r6068 == f3c95109c7b905f74b5f149eea21f68444c31ef7]

18 years agoAdd a `full' parameter to validate_params(), analogous to the one in
Jacob Nevins [Tue, 5 Jul 2005 21:27:19 +0000 (21:27 +0000)]
Add a `full' parameter to validate_params(), analogous to the one in
encode_params(). This is necessary for cases where generation-time parameters
that are normally omitted from descriptive IDs can place restrictions on other
parameters; in particular, when the default value of a relevant generation-time
parameter is not the one used to generate the descriptive ID, validation could
reject self-generated IDs (e.g., Net `5x2w:56182ae7c2', and some cases in
`Pegs').

[originally from svn r6068]

18 years agoEnhancements to mkfiles.pl and Recipe to arrange for the auxiliary
Simon Tatham [Tue, 5 Jul 2005 19:40:32 +0000 (19:40 +0000)]
Enhancements to mkfiles.pl and Recipe to arrange for the auxiliary
command-line programs (solosolver, patternsolver, mineobfusc) to be
built as part of the normal Makefiles. This means mkfiles.pl now has
the capability to compile a source file more than once with
different #defines. Also, fixes for those auxiliary programs and one
fix in midend.c which the Borland compiler objected to while I was
testing its makefile generation.

[originally from svn r6066]

18 years agoIt's been a new year for a while now.
Jacob Nevins [Tue, 5 Jul 2005 19:38:27 +0000 (19:38 +0000)]
It's been a new year for a while now.

[originally from svn r6065]

18 years agorevert supposed typo -- I have no brain
Jacob Nevins [Tue, 5 Jul 2005 19:12:56 +0000 (19:12 +0000)]
revert supposed typo -- I have no brain

[originally from svn r6064]

18 years agoAdd HACKING to main doc build.
Jacob Nevins [Tue, 5 Jul 2005 19:11:51 +0000 (19:11 +0000)]
Add HACKING to main doc build.

[originally from svn r6063]

18 years agotypo
Jacob Nevins [Tue, 5 Jul 2005 19:10:26 +0000 (19:10 +0000)]
typo

[originally from svn r6062]

18 years agoAdd a completion flash when you get down to a single peg.
Jacob Nevins [Tue, 5 Jul 2005 18:57:34 +0000 (18:57 +0000)]
Add a completion flash when you get down to a single peg.

[originally from svn r6061]

18 years agoRefactored the game_size() interface, which was getting really
Simon Tatham [Tue, 5 Jul 2005 18:13:31 +0000 (18:13 +0000)]
Refactored the game_size() interface, which was getting really
unpleasant and requiring lots of special cases to be taken care of
by every single game. The new interface exposes an integer `tile
size' or `scale' parameter to the midend and provides two much
simpler routines: one which computes the pixel window size given a
game_params and a tile size, and one which is given a tile size and
must set up a drawstate appropriately. All the rest of the
complexity is handled in the midend, mostly by binary search, so
grubby special cases only have to be dealt with once.

[originally from svn r6059]

18 years agoJames Harvey points out a missing ifdef.
Simon Tatham [Tue, 5 Jul 2005 12:03:56 +0000 (12:03 +0000)]
James Harvey points out a missing ifdef.

[originally from svn r6058]

18 years agoClarify that diagonal moves are not permitted in Pegs.
Jacob Nevins [Mon, 4 Jul 2005 21:07:40 +0000 (21:07 +0000)]
Clarify that diagonal moves are not permitted in Pegs.

[originally from svn r6057]

18 years agoAdd WinHelp topic.
Jacob Nevins [Mon, 4 Jul 2005 20:06:35 +0000 (20:06 +0000)]
Add WinHelp topic.

[originally from svn r6056]

18 years agoThere's always one. Forgot to add Pegs to `make install'.
Simon Tatham [Mon, 4 Jul 2005 19:55:10 +0000 (19:55 +0000)]
There's always one. Forgot to add Pegs to `make install'.

[originally from svn r6054]

18 years agoDocumentation for Pegs.
Simon Tatham [Mon, 4 Jul 2005 19:53:36 +0000 (19:53 +0000)]
Documentation for Pegs.

[originally from svn r6053]

18 years agoPeg Solitaire implementation, complete with a random board
Simon Tatham [Mon, 4 Jul 2005 19:42:55 +0000 (19:42 +0000)]
Peg Solitaire implementation, complete with a random board
generator. The generator is lacking in almost any kind of finesse,
but it produces puzzles which at least _I_ find plausibly puzzling.

[originally from svn r6052]

18 years agoDocument keyboard controls for Flip
Jacob Nevins [Mon, 4 Jul 2005 14:35:14 +0000 (14:35 +0000)]
Document keyboard controls for Flip

[originally from svn r6051]

18 years agoFix bounds checking for Flip cursor control.
Jacob Nevins [Mon, 4 Jul 2005 11:21:50 +0000 (11:21 +0000)]
Fix bounds checking for Flip cursor control.

[originally from svn r6050]

18 years agoJames H's patch for a keyboard-controlled cursor in Flip.
Simon Tatham [Sun, 3 Jul 2005 14:49:00 +0000 (14:49 +0000)]
James H's patch for a keyboard-controlled cursor in Flip.

[originally from svn r6049]

18 years agoAllow game backends to use even special keystrokes such as N and Q;
Simon Tatham [Sun, 3 Jul 2005 11:45:49 +0000 (11:45 +0000)]
Allow game backends to use even special keystrokes such as N and Q;
they will only be processed as special by the midend if unwanted by
the backend. This causes 5x5 Solo to become just about playable,
because you can now click in a square and type `n'. However, typing
`n' when a square is not selected will revert to the normal
behaviour of starting a new game.

(This isn't particularly ideal, I know, but it's better than
nothing.)

[originally from svn r6048]

18 years agodraw_polygon() and draw_circle() have always had a portability
Simon Tatham [Sun, 3 Jul 2005 09:35:29 +0000 (09:35 +0000)]
draw_polygon() and draw_circle() have always had a portability
constraint: because some front ends interpret `draw filled shape' to
mean `including its boundary' while others interpret it to mean `not
including its boundary' (and X seems to vacillate between the two
opinions as it moves around the shape!), you MUST NOT draw a filled
shape only. You can fill in one colour and outline in another, you
can fill or outline in the same colour, or you can just outline, but
just filling is a no-no.

This leads to a _lot_ of double calls to these functions, so I've
changed the interface. draw_circle() and draw_polygon() now each
take two colour arguments, a fill colour (which can be -1 for none)
and an outline colour (which must be valid). This should simplify
code in the game back ends, while also reducing the possibility for
coding error.

[originally from svn r6047]

18 years agoJames Harvey points out that entering an invalid game ID can affect
Simon Tatham [Fri, 1 Jul 2005 16:50:49 +0000 (16:50 +0000)]
James Harvey points out that entering an invalid game ID can affect
the current midend state even if you don't subsequently enter a
valid one. Reorganise midend_game_id_int() so that (just like
midend_deserialise()) it does all its error checking before altering
anything in the midend's persistent data, so that it either succeeds
completely or fails before doing anything at all.

[originally from svn r6045]

18 years agoPrevent drags from being started outside the playing area, which was
Simon Tatham [Thu, 30 Jun 2005 18:11:41 +0000 (18:11 +0000)]
Prevent drags from being started outside the playing area, which was
causing invalid move descriptions to be returned from
interpret_move() and then failing an assertion when execute_move()
refused them.

[originally from svn r6044]

18 years agoPreset names retrieved from the environment must be dupstr()ed. How
Simon Tatham [Thu, 30 Jun 2005 18:11:02 +0000 (18:11 +0000)]
Preset names retrieved from the environment must be dupstr()ed. How
did I miss this before? It just caused a segfault for me, which is
entirely fair enough, but I've no idea why it didn't fail before!

[originally from svn r6043]

18 years agoLoad and Save are now supported on all three desktop platforms, and
Simon Tatham [Thu, 30 Jun 2005 18:00:37 +0000 (18:00 +0000)]
Load and Save are now supported on all three desktop platforms, and
documented. (This means the GTK temporary dependency on an
environment variable is now gone.)

[originally from svn r6042]

18 years agoGeneral robustness patch from James Harvey:
Simon Tatham [Thu, 30 Jun 2005 09:07:00 +0000 (09:07 +0000)]
General robustness patch from James Harvey:
 - most game_size() functions now work in doubles internally and
   round to nearest, meaning that they have less tendency to try to
   alter a size they returned happily from a previous call
 - couple of fiddly fixes (memory leaks, precautionary casts in
   printf argument lists)
 - midend_deserialise() now constructs an appropriate drawstate,
   which I can't think how I overlooked myself since I _thought_ I
   went through the entire midend structure field by field!

[originally from svn r6041]

18 years agoAttempting to begin a drag from (i.e. just click on) the hint pegs
Simon Tatham [Thu, 30 Jun 2005 08:25:47 +0000 (08:25 +0000)]
Attempting to begin a drag from (i.e. just click on) the hint pegs
for a past guess caused strangeness up to and including segfault,
thanks to bad bounds checking. Well spotted John Sullivan.

[originally from svn r6040]

18 years agoAdd a cast whose absence was causing a (-Werror-exacerbated) compile
Simon Tatham [Wed, 29 Jun 2005 16:32:53 +0000 (16:32 +0000)]
Add a cast whose absence was causing a (-Werror-exacerbated) compile
warning on OS X.

[originally from svn r6037]

18 years agoValidation of random-state-type game descriptions was broken. This
Simon Tatham [Wed, 29 Jun 2005 12:19:08 +0000 (12:19 +0000)]
Validation of random-state-type game descriptions was broken. This
meant that a Mines game saved before the first click had taken place
could not be successfully reloaded.

[originally from svn r6036]

18 years agoWhen serialising this game, it's probably better to keep the
Simon Tatham [Wed, 29 Jun 2005 08:20:49 +0000 (08:20 +0000)]
When serialising this game, it's probably better to keep the
half-finished guess in the game_ui rather than throwing it away.

[originally from svn r6033]

18 years agoMake peg removal accessible from the keyboard.
Jacob Nevins [Tue, 28 Jun 2005 18:10:20 +0000 (18:10 +0000)]
Make peg removal accessible from the keyboard.

[originally from svn r6032]

18 years agoNew {en,de}code_ui functions should be static. Oops.
Simon Tatham [Tue, 28 Jun 2005 17:43:50 +0000 (17:43 +0000)]
New {en,de}code_ui functions should be static. Oops.

[originally from svn r6031]

18 years agoActually implemented the serialise/deserialise functions in
Simon Tatham [Tue, 28 Jun 2005 17:05:05 +0000 (17:05 +0000)]
Actually implemented the serialise/deserialise functions in
midend.c. Also I've added an experimental front end in gtk.c only:
`Save' and `Load' options on the Game menu, which don't even show up
unless you define the magic environment variable
PUZZLES_EXPERIMENTAL_SAVE. Once I'm reasonably confident that the
whole edifice is plausibly stable, I'll take that out and turn it
into a supported feature (and also implement it in OS X and Windows
and write documentation).

[originally from svn r6030]

18 years agoMore serialisation changes: the game_aux_info structure has now been
Simon Tatham [Tue, 28 Jun 2005 11:14:09 +0000 (11:14 +0000)]
More serialisation changes: the game_aux_info structure has now been
retired, and replaced with a simple string. Most of the games which
use it simply encode the string in the same way that the Solve move
will also be encoded, i.e. solve_game() simply returns
dupstr(aux_info). Again, this is a better approach than writing
separate game_aux_info serialise/deserialise functions because doing
it this way is self-testing (the strings are created and parsed
during the course of any Solve operation at all).

[originally from svn r6029]

18 years agoRogue diagnostic!
Simon Tatham [Tue, 28 Jun 2005 08:35:55 +0000 (08:35 +0000)]
Rogue diagnostic!

[originally from svn r6028]

18 years agoMove a rogue declaration to the top of its block.
Simon Tatham [Tue, 28 Jun 2005 08:06:56 +0000 (08:06 +0000)]
Move a rogue declaration to the top of its block.

[originally from svn r6027]

18 years agoAnother function pair required for serialisation; these ones save
Simon Tatham [Tue, 28 Jun 2005 07:33:49 +0000 (07:33 +0000)]
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]

18 years agoAnnoying special cases for Mines.
Simon Tatham [Tue, 28 Jun 2005 06:59:27 +0000 (06:59 +0000)]
Annoying special cases for Mines.

Firstly, the `Restart' function now reconstructs an initial game
state from the game description rather than dup_game(states[0]).
This means that Restart in a game of Mines restarts to just _after_
the initial click, so you can resume the puzzle-solving part without
having to remember where you placed that click.

Secondly, the midend now contains a second `private' game desc,
which is guaranteed to actually reconstruct the initial game_state
correctly (which Mines's publicly visible game descs tend not to,
since they describe a state which has already had the first click).
This should make serialising of Mines more sensible.

[originally from svn r6025]

18 years agoRe-architecting of the game backend interface. make_move() has been
Simon Tatham [Mon, 27 Jun 2005 19:34:54 +0000 (19:34 +0000)]
Re-architecting of the game backend interface. make_move() has been
split into two functions. The first, interpret_move(), takes all the
arguments that make_move() used to get and may have the usual side
effects of modifying the game_ui, but instead of returning a
modified game_state it instead returns a string description of the
move to be made. This string description is then passed to a second
function, execute_move(), together with an input game_state, which
is responsible for actually producing the new state. (solve_game()
also returns a string to be passed to execute_move().)

The point of this is to work towards being able to serialise the
whole of a game midend into a byte stream such as a disk file, which
will eventually support save and load functions in the desktop
puzzles, as well as restoring half-finished games after a quit and
restart in James Harvey's Palm port. Making each game supply a
convert-to-string function for its game_state format would have been
an unreliable way to do this, since those functions would not have
been used in normal play, so they'd only have been tested when you
actually tried to save and load - a recipe for latent bugs if ever I
heard one. This way, you won't even be able to _make_ a move if
execute_move() doesn't work properly, which means that if you can
play a game at all I can have pretty high confidence that
serialising it will work first time.

This is only the groundwork; there will be more checkins to come on
this theme. But the major upheaval should now be done, and as far as
I can tell everything's still working normally.

[originally from svn r6024]

18 years agoFix GTK casts to restore correct compilation on GTK 2.0 after r6022.
Simon Tatham [Sun, 26 Jun 2005 13:12:34 +0000 (13:12 +0000)]
Fix GTK casts to restore correct compilation on GTK 2.0 after r6022.

[originally from svn r6023]
[r6022 == e1c84c9a4ea9e74c128c28a77ea08336350991e3]

18 years agoUnder Gtk 1.2 (at least on Debian woody), a config or preset change that would
Jacob Nevins [Sun, 26 Jun 2005 12:54:08 +0000 (12:54 +0000)]
Under Gtk 1.2 (at least on Debian woody), a config or preset change that would
otherwise not cause the window size to change caused it to become very small
indeed. This change from Simon fixes that behaviour; I haven't tested it with
Gtk 2.

[originally from svn r6022]

18 years agoAdd debugging support.
Jacob Nevins [Sat, 25 Jun 2005 17:24:03 +0000 (17:24 +0000)]
Add debugging support.

[originally from svn r6018]

18 years agoFurther additions to the Guess docs.
Jacob Nevins [Sat, 25 Jun 2005 13:52:52 +0000 (13:52 +0000)]
Further additions to the Guess docs.

[originally from svn r6014]

18 years agoMake the keyboard-control cursors visible whenever a keyboard control is
Jacob Nevins [Sat, 25 Jun 2005 13:43:45 +0000 (13:43 +0000)]
Make the keyboard-control cursors visible whenever a keyboard control is
activated.

[originally from svn r6013]

18 years agoThe AngleArc() function that was being used to draw circles on Windows turns
Jacob Nevins [Sat, 25 Jun 2005 13:24:19 +0000 (13:24 +0000)]
The AngleArc() function that was being used to draw circles on Windows turns
out to be unsupported on the Win9x/Me series. Use Arc() instead (tested on
Win98 and Win2K).

[originally from svn r6012]

18 years agoCouple of presets.
Simon Tatham [Fri, 24 Jun 2005 16:35:42 +0000 (16:35 +0000)]
Couple of presets.

[originally from svn r6011]

18 years agoMore patches from James Harvey: enforce a maximum brightness in the
Simon Tatham [Fri, 24 Jun 2005 16:35:27 +0000 (16:35 +0000)]
More patches from James Harvey: enforce a maximum brightness in the
background colour (to ensure white pegs show up against it), and
convert the keyboard-control cursor into a rectangle when it's over
the hint pegs (otherwise it looks rather silly for numbers of pegs
above 4).

[originally from svn r6010]

18 years agoFix another display/UI glitch which triggered if you filled a row
Simon Tatham [Fri, 24 Jun 2005 12:30:30 +0000 (12:30 +0000)]
Fix another display/UI glitch which triggered if you filled a row
(so that the hint pegs lit up as `ready') and then pressed Undo: the
markable flag would remain set and the redrawing wouldn't darken the
pegs again.

[originally from svn r6009]

18 years agoTurn off the keyboard-control cursor when the user reverts to mouse
Simon Tatham [Fri, 24 Jun 2005 11:13:08 +0000 (11:13 +0000)]
Turn off the keyboard-control cursor when the user reverts to mouse
control.

[originally from svn r6008]

18 years agoChange the preprocessor symbol `DEBUG' to `DEBUGGING', since the
Simon Tatham [Fri, 24 Jun 2005 11:05:43 +0000 (11:05 +0000)]
Change the preprocessor symbol `DEBUG' to `DEBUGGING', since the
former is automatically defined by Cygwin.

[originally from svn r6007]

18 years agoMy background-erasing changes in r5996/r5997 caused trouble with the
Simon Tatham [Fri, 24 Jun 2005 11:03:20 +0000 (11:03 +0000)]
My background-erasing changes in r5996/r5997 caused trouble with the
keyboard-control cursors, and when I tried to fix those more
wallpaper bubbles popped up elsewhere. Here's what I think is a
proper fix: a comprehensive overhaul of the redraw code such that,
instead of tracking the cursor positions explicitly in the
drawstate, we instead track for each peg position whether or not a
cursor is currently displayed at that position. So cursor erasing
and cursor drawing become part of the main draw loop rather than a
separate bit on the end.

[originally from svn r6006]
[r5996 == 3d58feb561ef09cf977f710d69a3562529e23f0f]
[r5997 == a46e3266558eaf5cd18ac2a6322af65c196c3655]

18 years agoArray overflow fix from James Harvey.
Simon Tatham [Thu, 23 Jun 2005 23:11:59 +0000 (23:11 +0000)]
Array overflow fix from James Harvey.

[originally from svn r6005]

18 years agoMake the `hold marker' in Guess accessible from the keyboard (`H' key, for want
Jacob Nevins [Thu, 23 Jun 2005 22:01:17 +0000 (22:01 +0000)]
Make the `hold marker' in Guess accessible from the keyboard (`H' key, for want
of a better idea).

[originally from svn r6004]

18 years agoFactual and other corrections/additions to the Guess docs.
Jacob Nevins [Thu, 23 Jun 2005 21:47:55 +0000 (21:47 +0000)]
Factual and other corrections/additions to the Guess docs.

[originally from svn r6003]

18 years agoReinstate WinHelp topic now we have a manual chapter.
Jacob Nevins [Thu, 23 Jun 2005 21:37:05 +0000 (21:37 +0000)]
Reinstate WinHelp topic now we have a manual chapter.

[originally from svn r6002]