chiark / gitweb /
sgt-puzzles.git
9 years agoRemove the MD5-based manifest file system.
Simon Tatham [Wed, 24 Sep 2014 10:33:22 +0000 (10:33 +0000)]
Remove the MD5-based manifest file system.

A long time ago, it seemed like a good idea to arrange that binaries
of my puzzles would automatically cease to identify themselves as a
particular upstream version number if any changes were made to the
source code, so that if someone made a local tweak and distributed the
result then I wouldn't get blamed for the results. Since then I've
decided the whole idea is more trouble than it's worth, so I'm
retiring it completely.

[originally from svn r10264]

9 years agoRemove dependencies on Subversion.
Simon Tatham [Wed, 24 Sep 2014 10:33:21 +0000 (10:33 +0000)]
Remove dependencies on Subversion.

I'm going through all my projects and reworking them to avoid
depending on the monotonic integer-valued source control revision
identifier provided by Subversion, so I can migrate everything to git
without my builds and versioning breaking.

Puzzles's version number is now of the form YYYYMMDD.vvvvvv, where
vvvvvv is some string of source control information (currently still
the SVN-style "rNNNNN", but free to change in future). The date
provides monotonicity between my official automated builds, and the
second component is the one I'll be most interested in when people
send bug reports.

[originally from svn r10263]

9 years agoImprove connectedness-error highlighting in Singles.
Simon Tatham [Sun, 21 Sep 2014 15:33:01 +0000 (15:33 +0000)]
Improve connectedness-error highlighting in Singles.

Using exactly the same policy as I did for Range the other day: if
multiple regions exist, then one is taken to be canonical and all the
others are marked as errors.

[originally from svn r10233]

9 years agoImprove connectedness-error highlighting in Range.
Simon Tatham [Tue, 9 Sep 2014 14:20:10 +0000 (14:20 +0000)]
Improve connectedness-error highlighting in Range.

The previous approach of scanning the grid by depth-first search was
fine for deciding whether it was connected, but not so good for
pointing out where the mistake was in the grid. Replaced that code
with a dsf-based version, which identifies all connected components so
that an easy followup pass can highlight all but the largest as
erroneous.

[originally from svn r10223]

9 years agoFix vertically misaligned text in Javascript puzzles.
Simon Tatham [Sat, 21 Jun 2014 17:40:29 +0000 (17:40 +0000)]
Fix vertically misaligned text in Javascript puzzles.

When I constructed my test canvas to measure the vertical extent of a
text string for ALIGN_VCENTRE, I forgot to ensure that the 'width'
variable was an integer, as a result of which the loop over canvas
pixels kept trying to use fractional array indices and returning
undefined :-)

[originally from svn r10196]

10 years agoChange our method of calling main() in emccpre.js.
Simon Tatham [Sun, 20 Apr 2014 08:47:27 +0000 (08:47 +0000)]
Change our method of calling main() in emccpre.js.

I've just upgraded to emcc 1.16.0, in which something fiddly has
happened to the semantics of Module.run() vs noInitialRun - now
setting the latter seems to cause the former to do everything except
calling main(), and then refuse to ever do anything again. So now I
have to use Module.callMain() in place of Module.run() when I finally
do get round to wanting to call main().

[originally from svn r10180]

10 years agoAdd a missing #include.
Simon Tatham [Sun, 20 Apr 2014 08:47:25 +0000 (08:47 +0000)]
Add a missing #include.

[originally from svn r10179]

10 years agoReinstate the Mac OS build step.
Simon Tatham [Sun, 30 Mar 2014 15:19:30 +0000 (15:19 +0000)]
Reinstate the Mac OS build step.

Now I've got a working Mac, I can build it again.

[originally from svn r10167]

10 years agoFix the Automake makefile for automake 1.14.
Simon Tatham [Sat, 22 Feb 2014 18:19:05 +0000 (18:19 +0000)]
Fix the Automake makefile for automake 1.14.

This is a combination of PuTTY r10142 and the relevant pieces of
r10141: we now enable the 'subdir-objects' mode in Makefile.am, and
stop using $(subdir) in source file paths.

(As a consequence of the latter the automake machinery now cannot live
anywhere but at the top level of the source tree, but since that's
where it was already, this is less of an upheaval here than it was for
PuTTY!)

[originally from svn r10146]
[r10141 == a947c49bec36957cb5d38e1dc2e22dc0e3465849 in putty repository]
[r10142 == 0da225829234744b1141aea3a7c54ad7d74679a7 in putty repository]

10 years agoContinue the tradition of only remembering to update the copyright year
Jacob Nevins [Thu, 16 Jan 2014 01:03:58 +0000 (01:03 +0000)]
Continue the tradition of only remembering to update the copyright year
every other year.

[originally from svn r10116]

10 years agoPosition the monster counts more sensibly.
Simon Tatham [Tue, 7 Jan 2014 18:21:24 +0000 (18:21 +0000)]
Position the monster counts more sensibly.

Now they're centred within the spare grid cell at the top of the
playing area, rather than being too far down so that the bottoms of
the monster drawings collide with the background of the path clues at
large magnification. Also, while I'm here, I've simplified the code
that draws the monster counts, by moving duplicated parts out of the
branches of the 'if'.

(In fact, almost all of this patch is cleanup; the only substantive
change is the one that changes dy from TILESIZE/2 to TILESIZE/4.)

[originally from svn r10108]

10 years agoFix a printf 64-bit-cleanness error.
Simon Tatham [Thu, 28 Nov 2013 18:32:29 +0000 (18:32 +0000)]
Fix a printf 64-bit-cleanness error.

[originally from svn r10098]

10 years agoFix an edge case of divider-obsoletion in Group.
Simon Tatham [Wed, 9 Oct 2013 20:44:51 +0000 (20:44 +0000)]
Fix an edge case of divider-obsoletion in Group.

When you drag group elements around, previous dividers are meant to
dissolve whenever the same two elements are no longer on each side of
it. One case in which this didn't happen was that of dragging an
element from the left of a divider to the far right column - the
divider became invisible, but would then startlingly reappear if you
drag that element back to the left of whatever it was left of before.

[originally from svn r10051]

10 years agoFaintly highlight the leading diagonal of Group's grid.
Simon Tatham [Wed, 9 Oct 2013 20:44:50 +0000 (20:44 +0000)]
Faintly highlight the leading diagonal of Group's grid.

This makes it easier to spot elements whose square is known, which is
useful in turn for identifying subgroups.

[originally from svn r10050]

10 years agoDocument 'Unique rows and columns' option in Unruly, plus formatting tweaks
Jacob Nevins [Thu, 29 Aug 2013 09:27:34 +0000 (09:27 +0000)]
Document 'Unique rows and columns' option in Unruly, plus formatting tweaks
elsewhere.

[originally from svn r10035]

10 years agoFix a failure to warn about non-unique rows/columns in non-square Unruly grids, repor...
Jacob Nevins [Tue, 30 Jul 2013 20:18:14 +0000 (20:18 +0000)]
Fix a failure to warn about non-unique rows/columns in non-square Unruly grids, reported in Debian bug #718354.

[originally from svn r9976]

10 years agoStop using a zero precision specifier with sprintf ("%.0d") to cause
Simon Tatham [Fri, 5 Jul 2013 21:54:45 +0000 (21:54 +0000)]
Stop using a zero precision specifier with sprintf ("%.0d") to cause
zero to be generated as the empty string rather than "0". Instead, do
the job by the obvious approach of not calling sprintf at all if the
number is zero. Works around a bug in Emscripten's C library, whose
sprintf doesn't correctly handle that corner case.

[originally from svn r9893]

10 years agoMake svn-based version identification still work in VPATH builds.
Simon Tatham [Tue, 2 Jul 2013 07:04:04 +0000 (07:04 +0000)]
Make svn-based version identification still work in VPATH builds.

[originally from svn r9891]

10 years agoFix small bugs in the automake construction which were preventing the
Simon Tatham [Tue, 2 Jul 2013 06:48:26 +0000 (06:48 +0000)]
Fix small bugs in the automake construction which were preventing the
revision number from being automatically baked into the automake-built
binaries.

[originally from svn r9890]

10 years agoAdd a check in the new configure script to enable lots of gcc warning
Simon Tatham [Sun, 30 Jun 2013 10:51:31 +0000 (10:51 +0000)]
Add a check in the new configure script to enable lots of gcc warning
flags if gcc is in use - but _only_ if they don't lead to problems in
a test compile which includes all the system and GTK headers I'm going
to want. Ubuntu 13.04 includes a version of Pango which breaks at
-Werror -pedantic, so I can't unconditionally enable all the warning
flags I might want without breaking the build in ways beyond my
control.

[originally from svn r9888]

10 years agoAdd a mechanism to the automake system to allow 'make install' to only
Simon Tatham [Sun, 30 Jun 2013 10:16:57 +0000 (10:16 +0000)]
Add a mechanism to the automake system to allow 'make install' to only
install the actual games, not the auxiliary binaries or nullgame.

[originally from svn r9887]

10 years agoSupport building via autoconf and automake. mkfiles.pl now outputs a
Simon Tatham [Sun, 30 Jun 2013 08:58:45 +0000 (08:58 +0000)]
Support building via autoconf and automake. mkfiles.pl now outputs a
Makefile.am, and there's a new mkauto.sh which builds a corresponding
configure script.

The old makefile has been renamed from 'Makefile' to 'Makefile.gtk',
indicating that the intended new _default_ approach is to use the
autoconf world. Makefile.gtk is provided as an emergency fallback in
case anything fails with the new stuff that used to work with it.

The new configure script does not support the same $(BINPREFIX) system
as the old Makefile did. However, as I understand it, it should be
possible to configure using --program-prefix="sgt-" (for example) and
then the binaries should all be renamed appropriately at install time.

The Makefile.am is quite painful. The Puzzles codebase relies heavily
on compiling individual object files multiple times with different the
cpp flags per build deliverable (program or library) and not per
source file. Solution: anything built with non-default compile options
has to go in its own little library. But that doesn't work either in
the general case, because as soon as you have more than one such
library linked into an application, Unix ld semantics bite you if the
objects in the libraries both refer to each other. So I ended up
building all those little libraries but not _using_ them - instead the
link commands for the programs needing those objects refer to the
objects directly, under the silly names that automake gives them.
(That's less fragile than it sounds, because it does _document_ the
names of the intermediate object files. But still, yuck.)

[originally from svn r9886]

10 years agoAdjust the build script to turn the NestedVM build into a delegation,
Simon Tatham [Thu, 27 Jun 2013 21:17:04 +0000 (21:17 +0000)]
Adjust the build script to turn the NestedVM build into a delegation,
so that not every machine on which I want to run the full Puzzles
build will have to have a local NestedVM installation.

[originally from svn r9882]

10 years agoRemove stray bashisms from the NestedVM makefile.
Simon Tatham [Wed, 19 Jun 2013 19:21:36 +0000 (19:21 +0000)]
Remove stray bashisms from the NestedVM makefile.

[originally from svn r9872]

10 years agoRemove spurious "unfinished/" that appeared at the start of the
Simon Tatham [Sat, 8 Jun 2013 16:55:33 +0000 (16:55 +0000)]
Remove spurious "unfinished/" that appeared at the start of the
unfinished puzzles' gamedesc.txt lines due to a Perl error. Ahem.

[originally from svn r9861]

10 years agoAdd comment to remind myself (and anyone else) how to refresh the XFCE
Simon Tatham [Sat, 8 Jun 2013 16:53:57 +0000 (16:53 +0000)]
Add comment to remind myself (and anyone else) how to refresh the XFCE
menu.

[originally from svn r9860]

10 years agoScript to read the new gamedesc.txt and create .desktop files. My
Simon Tatham [Sat, 8 Jun 2013 16:50:28 +0000 (16:50 +0000)]
Script to read the new gamedesc.txt and create .desktop files. My
immediate intention is to run this locally so that my XFCE main menu
acquires shortcuts for my locally compiled puzzle binaries, but I
expect the script could probably be adapted for systemwide
distribution use if any distribution hasn't already done this job in
their own way by now.

[originally from svn r9859]

10 years agoRename wingames.lst to gamedesc.txt, and add a couple of extra fields
Simon Tatham [Sat, 8 Jun 2013 16:29:15 +0000 (16:29 +0000)]
Rename wingames.lst to gamedesc.txt, and add a couple of extra fields
to it giving each game's "internal" name (as seen in the source file,
.R etc) and also a brief description of the game. The idea of the
latter is that it should be usable as a comment field in .desktop
files and similar.

[originally from svn r9858]

11 years agoFix grid generation crashes at Penrose 3x3 sizes. What seemed to be
Simon Tatham [Fri, 10 May 2013 17:56:00 +0000 (17:56 +0000)]
Fix grid generation crashes at Penrose 3x3 sizes. What seemed to be
happening was that at the point of calling grid_make_consistent, the
grid had no faces or vertices, probably because grid_trim_vigorously
had removed them all, causing grid_make_consistent to try to allocate
a negative amount of memory and die in snewn.

Fixed by detecting this case in new_desc_penrose and retrying until
generation is successful. (It wasn't happening 100% of the time, just
_most_ of the time.) The same verification step is also used in
validate_desc_penrose in case a user manages to manually construct a
set of parameters leading to this failure mode.

[originally from svn r9840]

11 years agoCorrect the comment at the top of unruly.c, which is out of date as of
Simon Tatham [Sun, 5 May 2013 22:27:20 +0000 (22:27 +0000)]
Correct the comment at the top of unruly.c, which is out of date as of
r9837.

[originally from svn r9838]
[r9837 == 2f7831bb1626d82baff706e507d61a820ad84df1]

11 years agoNew configuration option in Unruly, to enable a mode in which no two
Simon Tatham [Sun, 5 May 2013 20:21:50 +0000 (20:21 +0000)]
New configuration option in Unruly, to enable a mode in which no two
rows are permitted to have exactly the same pattern, and likewise
columns. (A row and a column can match, though.) This rule is
sometimes used, but not always; http://www.binarypuzzle.com/ in
particular has it (as a user just pointed out).

Since the filled-grid-generation stage of Unruly is implemented by
repeatedly choosing a square and then calling the solver to fill in
all its consequences, simply adding a solver mode conditional on this
flag is sufficient to do the whole of the interesting part of the job.

[originally from svn r9837]

11 years agoD'oh, forgot to adjust devel.but for the const changes.
Simon Tatham [Sat, 13 Apr 2013 10:51:53 +0000 (10:51 +0000)]
D'oh, forgot to adjust devel.but for the const changes.

[originally from svn r9835]

11 years agoGiant const patch of doom: add a 'const' to every parameter in every
Simon Tatham [Sat, 13 Apr 2013 10:37:32 +0000 (10:37 +0000)]
Giant const patch of doom: add a 'const' to every parameter in every
puzzle backend function which ought to have it, and propagate those
consts through to per-puzzle subroutines as needed.

I've recently had to do that to a few specific parameters which were
being misused by particular puzzles (r9657, r9830), which suggests
that it's probably a good idea to do the whole lot pre-emptively
before the next such problem shows up.

[originally from svn r9832]
[r9657 == 3b250baa02a7332510685948bf17576c397b8ceb]
[r9830 == 0b93de904a98f119b1a95d3a53029f1ed4bfb9b3]

11 years agoFix a memory management bug in Filling: in some situations its
Simon Tatham [Sat, 13 Apr 2013 10:37:27 +0000 (10:37 +0000)]
Fix a memory management bug in Filling: in some situations its
solve_game() was returning its aux parameter un-dupstr()ed, which is
wrong. Also clarified the developer docs on that function to make it
clearer that the returned string should be dynamic.

[originally from svn r9831]

11 years agoAdd 'const' to the game_params arguments in validate_desc and
Simon Tatham [Fri, 12 Apr 2013 17:11:49 +0000 (17:11 +0000)]
Add 'const' to the game_params arguments in validate_desc and
new_desc. Oddities in the 'make test' output brought to my attention
that a few puzzles have been modifying their input game_params for
various reasons; they shouldn't do that, because that's the
game_params held permanently by the midend and it will affect
subsequent game generations if they modify it. So now those arguments
are const, and all the games which previously modified their
game_params now take a copy and modify that instead.

[originally from svn r9830]

11 years agoPatch from Rogier Goossens to speed up the Pattern solver.
Simon Tatham [Fri, 12 Apr 2013 16:28:55 +0000 (16:28 +0000)]
Patch from Rogier Goossens to speed up the Pattern solver.

do_recurse() now prunes early whenever it encounters a branch of the
search tree inconsistent with existing grid data (rather than the
previous naive approach of proceeding to enumerate all possibilities
anyway and then ruling them out one by one); do_recurse also tries to
split the row up into independent sections where possible; finally the
main solver loop (all three copies of which have now been factored out
into a new solve_puzzle function), instead of simply looping round and
round over all the rows and columns, heuristically looks at the ones
most changed since the last time deduction was attempted on them, on
the basis that that will probably yield the most information the
fastest.

[originally from svn r9828]

11 years agoAdjust Keen's grid generation to constrain the maximum size of clue
Simon Tatham [Fri, 12 Apr 2013 16:28:53 +0000 (16:28 +0000)]
Adjust Keen's grid generation to constrain the maximum size of clue
blocks, because 'make test' showed up very large blocks as an
occasional slowdown factor in game generation (takes too long to
iterate over all possibilities). This is a good idea in any case,
because really big multiplicative clue numbers have trouble fitting in
the square.

[originally from svn r9827]

11 years agoApply some optimisation to Undead's get_unique() function, which was
Simon Tatham [Fri, 12 Apr 2013 16:28:52 +0000 (16:28 +0000)]
Apply some optimisation to Undead's get_unique() function, which was
not only enumerating all possible arrangements of monsters along a
sight-line in O(3^n) time, but also allocated memory for them all and
then does a quadratic-time loop over that list to find arrangements
with a unique visibility count from both ends. Spotted by the new
'make test', which observed that 7x7dn#517035041807425 took 45 seconds
to generate.

This revised version still does the initial O(3^n) enumeration, which
can probably be got rid of as well with a bit more thought, but it now
doesn't allocate nearly so much memory and it spots uniques
efficiently. The above random seed now generates the same game ID in
less than a second, which drops this puzzle off the 'make test' hit
list of things most obviously needing speedup.

[originally from svn r9826]

11 years agoIntroduce some extra testing and benchmarking command-line options to
Simon Tatham [Thu, 11 Apr 2013 12:51:06 +0000 (12:51 +0000)]
Introduce some extra testing and benchmarking command-line options to
the GTK front end, plus a 'make test' target in the GTK makefile which
uses them to automatically generate 100 puzzles for each game at each
preset configuration, test-run them back through the solver without
their aux_info to ensure that can cope, and produce an HTML box plot
of game generation times for each preset.

As part of this work I've removed the TESTSOLVE mechanism from r9549,
since the new --test-solve option does the same thing better (in that
when something goes wrong it prints the random seed that caused the
problem).

[originally from svn r9825]
[r9549 == 5a095b8a08fa9f087b93c86aea0fa027138b028d]

11 years agoRevamp the triangular grid generation in Loopy, which I've been
Simon Tatham [Thu, 11 Apr 2013 12:51:05 +0000 (12:51 +0000)]
Revamp the triangular grid generation in Loopy, which I've been
meaning to revisit for a while. The new version generates more nicely
symmetric grids (best at even heights, but still improved even at odd
heights), and avoids any 'ears' on the grid (triangles at the corners
connected to only one other triangle, which tend to be boringly easy
places to start solving).

I've reused the grid-description-string mechanism invented for the
Penrose tilings as a versioning mechanism for the triangular grids, so
that old game descriptions should still be valid, and new triangular-
grid game descriptions begin with an "0_" prefix to indicate that they
are based on the new-style construction.

[originally from svn r9824]

11 years agoSplit Untangle's background colour into two. COL_BACKGROUND is still
Simon Tatham [Sun, 7 Apr 2013 10:44:56 +0000 (10:44 +0000)]
Split Untangle's background colour into two. COL_BACKGROUND is still
defined the same way and used to draw the normal background of the
puzzle, but there's a new slightly darker COL_SYSBACKGROUND which is
not used for anything at all in the puzzle backend but which occupies
colour slot #0 so that the system will use it to fill around the
playable area if the puzzle is imprecisely resized.

This doesn't _sensibly fix_ the annoyance in Untangle where a non-
square window gives rise to unusable dead space, but it at least works
around it by making the dead space obviously something to stay away
from.

[originally from svn r9823]

11 years agoAdd a draggable resize handle to the JS puzzles.
Simon Tatham [Sun, 7 Apr 2013 10:24:37 +0000 (10:24 +0000)]
Add a draggable resize handle to the JS puzzles.

Rather than design an ersatz 'window frame' surrounding the puzzle
canvas, I've simply overlaid the resize handle on the corner of the
puzzle itself (canvas or status bar, depending on whether the latter
exists), trusting that all games in my collection provide a reasonable
border within their drawing area. (OS X already does this with its
resize handle, so it's not as if there's no precedent.)

Unlike the desktop versions, I control the resize behaviour completely
in this environment, so I can constrain the canvas to only ever be
sensible sizes with no dead space round the edges (and, in particular,
preserve the aspect ratio).

Right-clicking the resize handle will restore the puzzle's default
tile size. I had intended to implement a maximise-to-browser-window
button too, but was annoyingly foiled by scrollbars - if you maximise
to the current window width, and as a result the text below the puzzle
scrolls off the bottom, then a vertical scrollbar appears and eats
into the width you just maximised to. Gah.

[originally from svn r9822]

11 years agoFix a typo I noticed in passing.
Simon Tatham [Sun, 7 Apr 2013 10:24:36 +0000 (10:24 +0000)]
Fix a typo I noticed in passing.

[originally from svn r9821]

11 years agoAdd a new midend function to reset the tile size to the puzzle's
Simon Tatham [Sun, 7 Apr 2013 10:24:35 +0000 (10:24 +0000)]
Add a new midend function to reset the tile size to the puzzle's
default (but still counting the <puzzle>_TILESIZE user preference
environment variables, where available).

[originally from svn r9820]

11 years agoSmall refactor to relative_mouse_coords: now the functionality which
Simon Tatham [Sun, 7 Apr 2013 10:24:34 +0000 (10:24 +0000)]
Small refactor to relative_mouse_coords: now the functionality which
returns an element's absolute position on the web page is split out
into a subfunction that can be called directly.

[originally from svn r9819]

11 years agoFix the 'puzzle doesn't work' apology, which I'd accidentally moved
Simon Tatham [Sat, 6 Apr 2013 12:28:21 +0000 (12:28 +0000)]
Fix the 'puzzle doesn't work' apology, which I'd accidentally moved
inside the top-level display:none puzzle container as a side effect of
r9809.

Also, while I'm at it, reword the apology to mention typed arrays as
the most likely cause of failure (AFAIK that's the most modern feature
required by the JS front end), and fix indecision between singular and
plural ('this puzzle' doesn't work, perhaps a feature 'they depend on'
is missing).

[originally from svn r9818]
[r9809 == 5dc559c8be1b8f6ed15f560433f25c952c874f93]

11 years agoDon't forget to NULL out the new game id notification callback, or
Simon Tatham [Sat, 6 Apr 2013 08:08:15 +0000 (08:08 +0000)]
Don't forget to NULL out the new game id notification callback, or
else it might start off accidentally initialised to nonsense in front
ends which don't use it.

[originally from svn r9817]

11 years agoMention Safari in the list of tested browsers.
Simon Tatham [Fri, 5 Apr 2013 19:27:55 +0000 (19:27 +0000)]
Mention Safari in the list of tested browsers.

[originally from svn r9816]

11 years agoUpdate the list of tested browsers.
Simon Tatham [Fri, 5 Apr 2013 15:49:31 +0000 (15:49 +0000)]
Update the list of tested browsers.

[originally from svn r9812]

11 years agoRegretfully remove my trickery with a hidden <option> element inside
Simon Tatham [Fri, 5 Apr 2013 15:49:29 +0000 (15:49 +0000)]
Regretfully remove my trickery with a hidden <option> element inside
the game-type <select>, since IE turns out to ignore display:none on
options. Oh well.

Instead I now do a more transparent thing: when custom game params are
in use, there's a "Custom" option selected in the dropdown, and a
separate 'Re-customise' option which brings the config box back up.
When an ordinary preset is selected, the Custom option is missing, and
there's just a 'Customise'.

In the process I've tinkered a bit to arrange that the custom 'preset'
is always represented by a negative number rather than one past the
last real preset; that seems more consistent overall.

[originally from svn r9811]

11 years agoRewrite the JS keyboard handling to cope with IE and Chrome.
Simon Tatham [Fri, 5 Apr 2013 15:49:27 +0000 (15:49 +0000)]
Rewrite the JS keyboard handling to cope with IE and Chrome.

Unlike Firefox, IE and Chrome don't generate keypress events at all if
you suppress the default handling of keydowns. Therefore, we have to
figure out everything from the keydown event, because if we unsuppress
the default handling of any keydowns then we'll get annoyances like ^R
going back to meaning reload-page rather than redo-move.

[originally from svn r9810]

11 years agoAssorted HTML/CSS fiddlings to make things work better in IE. I've
Simon Tatham [Fri, 5 Apr 2013 15:49:25 +0000 (15:49 +0000)]
Assorted HTML/CSS fiddlings to make things work better in IE. I've
added a trivial doctype (IE complained without it), but that caused a
gap to appear between the puzzle and the status bar, so I tinkered a
bit more and ended up removing the <table> completely (no great loss)
as well as adding display:block to the canvas and explicitly setting
the width of not only the status bar div but also its parent div.
Meanwhile, I'm putting the "px" on the end of a lot of properties I
set from JS, because IE complains about that too if I don't.

[originally from svn r9809]

11 years agoStop accidentally subtracting onscreen_canvas.offset{Left,Top} from
Simon Tatham [Fri, 5 Apr 2013 15:49:24 +0000 (15:49 +0000)]
Stop accidentally subtracting onscreen_canvas.offset{Left,Top} from
the return value of relative_mouse_coords! I only got away with that
error because the canvas was at offset zero compared to its immediate
parent element.

[originally from svn r9808]

11 years agoImplement debug_printf() in the Emscripten front end, since that's the
Simon Tatham [Fri, 5 Apr 2013 15:49:22 +0000 (15:49 +0000)]
Implement debug_printf() in the Emscripten front end, since that's the
easiest way to call js_debug with formatted parameters.

[originally from svn r9807]

11 years agoIE doesn't default to giving focus to the puzzle canvas on a mouse
Simon Tatham [Fri, 5 Apr 2013 15:49:21 +0000 (15:49 +0000)]
IE doesn't default to giving focus to the puzzle canvas on a mouse
click, so manually implement that behaviour. (Without it, it's quite
hard to focus the canvas at all in IE.)

[originally from svn r9806]

11 years agoI've just realised that the JS puzzles' permalinks were not updating
Simon Tatham [Fri, 5 Apr 2013 15:49:20 +0000 (15:49 +0000)]
I've just realised that the JS puzzles' permalinks were not updating
when the user pressed 'n' for a new game, because all the front end
knows is that it passed a keystroke to the puzzle, and it has no way
of hearing back that a particular keypress resulted in a game id
change.

To fix this, I've renamed midend_request_desc_changes to
midend_request_id_changes and expanded its remit to cover _any_ change
to the game ids. So now that callback in the Emscripten front end is
the only place from which update_permalinks is called (apart from
initialising them at setup time), and that should handle everything.

[originally from svn r9805]

11 years agoRemove trailing commas at the ends of initialiser lists. IE 8 and 9
Simon Tatham [Fri, 5 Apr 2013 15:49:19 +0000 (15:49 +0000)]
Remove trailing commas at the ends of initialiser lists. IE 8 and 9
didn't like them, which doesn't matter as such since they won't run
these JS puzzles anyway (no TypedArray support) but it hints that
other JS implementations might be picky about this too.

[originally from svn r9804]

11 years agoClarify header comments in the Emscripten frontend's source files to
Simon Tatham [Fri, 5 Apr 2013 15:49:18 +0000 (15:49 +0000)]
Clarify header comments in the Emscripten frontend's source files to
mention that the HTML pages generated by html/jspage.pl are also an
integral part of this front end. (The NestedVM frontend is more
self-contained, needing only an appropriate <applet> tag, but this one
expects quite a few components to exist on the page and have the right
ids.)

[originally from svn r9803]

11 years agoTry to give a more friendly message if anything goes wrong during
Simon Tatham [Wed, 3 Apr 2013 19:04:00 +0000 (19:04 +0000)]
Try to give a more friendly message if anything goes wrong during
puzzle startup. The puzzle web pages now enclose the whole puzzle
(buttons, canvas, permalinks) in a div set to display:none, and
instead display an apologetic message saying 'sorry, it didn't work';
then, if we get through the whole init function without crashing, we
show the puzzle and hide the apology.

[originally from svn r9802]

11 years agoFix a grammatical confusion on the Unruly web page.
Simon Tatham [Tue, 2 Apr 2013 10:58:52 +0000 (10:58 +0000)]
Fix a grammatical confusion on the Unruly web page.

[originally from svn r9801]

11 years agoRewrite trim_rect() for robustness.
Simon Tatham [Mon, 1 Apr 2013 16:23:03 +0000 (16:23 +0000)]
Rewrite trim_rect() for robustness.

The previous version dealt adequately with rectangles _partially_
overlapping the edge of the canvas, but doesn't correctly handle a
rectangle that's completely out of bounds in one direction. Replace
with a complete rewrite which is more easily seen to be correct. Also,
while I'm at it, add a missing condition to draw_update() so that we
don't even bother calling the Javascript half of it on any rectangle
that's been trimmed into nonexistence.

[originally from svn r9800]

11 years agoGreg Hewgill points out a code path on which the angle parameter to
Simon Tatham [Mon, 1 Apr 2013 09:38:04 +0000 (09:38 +0000)]
Greg Hewgill points out a code path on which the angle parameter to
the Penrose grid generation function can fail to be initialised.

[originally from svn r9798]

11 years agoFix the icon makefile in the wake of r9795.
Simon Tatham [Sun, 31 Mar 2013 22:06:07 +0000 (22:06 +0000)]
Fix the icon makefile in the wake of r9795.

[originally from svn r9797]
[r9795 == 3fc5a644a72e747b1f88125b38b2f178a9bc7ed3]

11 years agoA UI suggestion from Ben: label the Custom element in the dropdown
Simon Tatham [Sun, 31 Mar 2013 18:36:03 +0000 (18:36 +0000)]
A UI suggestion from Ben: label the Custom element in the dropdown
with a trailing "..." to hint that it opens a further dialog box.
However, the _invisible_ Custom option is merely indicating what you
_do_ have selected, so we leave that one as it is. (So now they're no
longer exact twins of each other, of course.)

[originally from svn r9796]

11 years agoUndead was not ever actually draw_update()ing to the edges of its
Simon Tatham [Sun, 31 Mar 2013 18:25:25 +0000 (18:25 +0000)]
Undead was not ever actually draw_update()ing to the edges of its
rectangle, which showed up on the Javascript front end since the JS
canvas doesn't start out defaulting to COL_BACKGROUND. Fixed it to
draw_update to the edge of its area, and while I'm at it, narrowed the
border (since this proves we didn't really need that much space
anyway).

[originally from svn r9795]

11 years agoMake sure the right element of the game-type dropdown starts off
Simon Tatham [Sun, 31 Mar 2013 11:50:46 +0000 (11:50 +0000)]
Make sure the right element of the game-type dropdown starts off
selected. Previously we were leaving the first element on the list
selected, which is _usually_ right, but not right for Slant.

In the process of doing this, I've also reorganised to fix a crash
which shows up with non-configurable games (admittedly currently only
Nullgame :-) when we still try to call js_select_preset in spite of
not having any preset options to select.

[originally from svn r9794]

11 years agoIntroduce a mechanism by which calls to midend_supersede_game_desc()
Simon Tatham [Sun, 31 Mar 2013 09:58:52 +0000 (09:58 +0000)]
Introduce a mechanism by which calls to midend_supersede_game_desc()
can trigger a call to a front end notification function. Use this to
update the game ID permalink when Mines supersedes its game ID.

[originally from svn r9793]

11 years agoReinstate a missing semicolon.
Simon Tatham [Sun, 31 Mar 2013 09:58:50 +0000 (09:58 +0000)]
Reinstate a missing semicolon.

[originally from svn r9792]

11 years agoOops. I consistently misspelled my desired lineCap and lineJoin values
Simon Tatham [Sun, 31 Mar 2013 09:58:48 +0000 (09:58 +0000)]
Oops. I consistently misspelled my desired lineCap and lineJoin values
as "1" rather than "round". Must have had my Postscript brain in,
and/or been confused by lineWidth = "1" just beforehand. This fixes a
display glitch in Towers, where there's a tiny spike at the top left
corner of each tower due to a very sharp mitred line join.

[originally from svn r9791]

11 years agoFix a crash when changing presets in Inertia. Turns out that my
Simon Tatham [Sun, 31 Mar 2013 09:58:47 +0000 (09:58 +0000)]
Fix a crash when changing presets in Inertia. Turns out that my
Javascript-side blitter creation function had forgotten to return the
new blitter's id, so the C code was still trying to use blitter #0
after it had been thrown away and replaced.

[originally from svn r9790]

11 years agoDon't forget to restore the correct selection in the dropdown list if
Simon Tatham [Sun, 31 Mar 2013 09:58:47 +0000 (09:58 +0000)]
Don't forget to restore the correct selection in the dropdown list if
the user cancels a configuration dialog.

[originally from svn r9789]

11 years agoApply a bodge to arrange that if the user selects Custom from the game
Simon Tatham [Sun, 31 Mar 2013 09:58:46 +0000 (09:58 +0000)]
Apply a bodge to arrange that if the user selects Custom from the game
type dropdown, we still get an 'onchange' event if they select it a
second time. Normally this wouldn't happen, because onchange means
what it says and we only get it if a _different_ element is selected.

My solution is to create two list items called Custom, set one of them
as display:none to stop it showing up when the list is dropped down,
and to select it after the configuration box closes.

[originally from svn r9788]

11 years agoStop using the dangerously unescaped 'innerHTML' for <option>
Simon Tatham [Sun, 31 Mar 2013 09:58:45 +0000 (09:58 +0000)]
Stop using the dangerously unescaped 'innerHTML' for <option>
contents; use document.createTextNode like I do everywhere else.

[originally from svn r9787]

11 years agoForgot to make the web-page-building scripts executable.
Simon Tatham [Sun, 31 Mar 2013 08:55:21 +0000 (08:55 +0000)]
Forgot to make the web-page-building scripts executable.

[originally from svn r9786]

11 years agoNew front end! To complement the webification of my puzzles via Java
Simon Tatham [Sat, 30 Mar 2013 20:16:21 +0000 (20:16 +0000)]
New front end! To complement the webification of my puzzles via Java
applets, here's an alternative webification in Javascript, using
Emscripten in asm.js mode (so that as browsers incorporate asm.js
optimisation, the game generation should run really fast).

[originally from svn r9781]

11 years agoIntroduce a mechanism in this source tree for building the container
Simon Tatham [Sat, 30 Mar 2013 20:04:10 +0000 (20:04 +0000)]
Introduce a mechanism in this source tree for building the container
web pages for the Java applets. Previously, those have all been
maintained by hand in my website's svn area, which is a bit silly. Now
we have a file per puzzle in the 'html' subdirectory which contains
the puzzle's name, one or two attributes, and the instructions snippet
to go below the puzzle applet; and then there's a Perl script that
builds all the real web pages out of that by adding in the parts
common across all files: the header, footer, and middle fragment with
the <applet> tag and resizing bits and pieces.

One piece _not_ checked in here is the footer text specific to my
hosting at chiark, which I think does still belong in the www area. So
Buildscr doesn't actually build the web pages; it just delivers the
bits and pieces by which my nightly snapshot script will be able to
run the program that _does_ build them, passing that footer as an
extra argument.

[originally from svn r9780]

11 years agoEdit the paragraph in the midend_deserialise() docs which I forgot to
Simon Tatham [Sat, 30 Mar 2013 18:03:15 +0000 (18:03 +0000)]
Edit the paragraph in the midend_deserialise() docs which I forgot to
fix in r9777 when I added documentation of the function it wistfully
imagined might one day exist.

[originally from svn r9779]
[r9777 == 1fdafb6abf2d3ea0d37e79b5dfd9daf8eed28f22]

11 years agoAdd a midend function to return the current random seed, parallel to
Simon Tatham [Sat, 30 Mar 2013 16:59:19 +0000 (16:59 +0000)]
Add a midend function to return the current random seed, parallel to
the existing one that returns the game id. No front end has so far
needed this, but one is about to.

[originally from svn r9778]

11 years agoAdd documentation for the identify_game() function which I introduced
Simon Tatham [Sat, 30 Mar 2013 16:59:18 +0000 (16:59 +0000)]
Add documentation for the identify_game() function which I introduced
in r9749 and forgot to write up.

[originally from svn r9777]
[r9749 == 6b6442b16c5de9f5f9479b736bf865a4236047cb]

11 years agoFound a bug in nullgame! Its vestigial game_redraw lacked a
Simon Tatham [Sat, 30 Mar 2013 16:59:17 +0000 (16:59 +0000)]
Found a bug in nullgame! Its vestigial game_redraw lacked a
draw_update, which isn't really setting a good example for people
cloning it :-) Add the missing draw_update call.

[originally from svn r9776]

11 years agoRemove a redundant and also erroneous memset.
Simon Tatham [Mon, 11 Mar 2013 19:58:28 +0000 (19:58 +0000)]
Remove a redundant and also erroneous memset.

(If you're going to memset a struct to 0 before filling in the fields
you care about, do use sizeof the struct rather than sizeof the
pointer; but also, if you're filling in _every_ field, there's no need
to bother anyway.)

[originally from svn r9773]

11 years agoClarify instructions for 'Range' -- I initially read the last point as
Jacob Nevins [Sun, 10 Mar 2013 13:56:12 +0000 (13:56 +0000)]
Clarify instructions for 'Range' -- I initially read the last point as
meaning the maximum white squares in any direction, rather than the total of
all directions.

[originally from svn r9771]

11 years agoMake Unruly's keyboard controls match the documentation and other puzzles in
Jacob Nevins [Sun, 10 Mar 2013 12:49:06 +0000 (12:49 +0000)]
Make Unruly's keyboard controls match the documentation and other puzzles in
the collection -- now Enter = black and Space = white.

[originally from svn r9770]

11 years agoFix entering pencil marks from the keyboard; the cursor is no longer removed
Jacob Nevins [Sun, 10 Mar 2013 12:28:13 +0000 (12:28 +0000)]
Fix entering pencil marks from the keyboard; the cursor is no longer removed
(this brings Undead into line with Solo, etc).

[originally from svn r9769]

11 years agoStop using CLUE2CHAR to translate clues into text; just do the obvious
Simon Tatham [Sun, 24 Feb 2013 12:52:17 +0000 (12:52 +0000)]
Stop using CLUE2CHAR to translate clues into text; just do the obvious
sprintf in both locations (screen and print) that need it. Fixes a bug
in which clues greater than 9 came out as hex digits in printed
puzzles.

[originally from svn r9765]

11 years agoStop the analysis pass in Loopy's redraw routine from being
Simon Tatham [Sat, 19 Jan 2013 18:56:07 +0000 (18:56 +0000)]
Stop the analysis pass in Loopy's redraw routine from being
conditionalised on !ds->started, so that we still do all the looping
over everything even if we know it's all going to be redrawn. This is
because deciding how much needs redrawing is not the only important
thing in those loops - they also set up arrays like ds->clue_error,
which tell the individual redraw functions _what_ to draw.

Fixes a bug in which, if you start a Loopy game and make moves causing
a clue to light up red for an error and then save your game, loading
the same save file at the start of a Loopy run would fail to highlight
the erroneous clue.

(This commit diff looks large, but actually it changes almost nothing
but whitespace.)

[originally from svn r9751]

11 years agoBring Pearl's game-completion handling in line with my usual practice:
Simon Tatham [Sat, 19 Jan 2013 18:56:06 +0000 (18:56 +0000)]
Bring Pearl's game-completion handling in line with my usual practice:
the 'completed' flag is not reset if you make a new move transforming
a solved game into an unsolved state, so the game won't flash again if
you manually erase and redraw a line segment (though it still will if
you undo and redo past the first solved state in the undo history).

[originally from svn r9750]

11 years agoRevamp of the Windows command-line parsing and puzzle-loading code.
Simon Tatham [Sat, 19 Jan 2013 18:56:05 +0000 (18:56 +0000)]
Revamp of the Windows command-line parsing and puzzle-loading code.

The Windows puzzles now accept similar command-line syntax to the GTK
ones, in that you can give them either a game ID (descriptive, random
or just plain params) or the name of a save file. Unlike the GTK ones,
however, the save file interpretation is tried first; this is because
some puzzles (e.g. Black Box) will interpret any old string as a valid
(if boring) game ID, and unlike the GTK puzzles it's not feasible to
require users to disambiguate via a command-line option, because on
Windows a thing that might easily happen is that a user passes a save
file to a puzzle binary via 'Open With' in the GUI shell, where they
don't get the chance to add extra options.

In order to make this work sensibly in the all-in-one Windows app, I
had to get round to another thing I've been planning to do for a
while, which is to write a function to examine a saved game file and
find out which puzzle it's for. So the combined Windows binary will
auto-switch to the right game if you pass a save file on its command
line, and also if you use Load while the program is running.

Another utility function I needed is one to split the WinMain single
command line string into argv. For this I've imported a copy of
split_into_argv() from Windows PuTTY (which doesn't affect this
package's list of copyright holders, since that function was all my
own code anyway).

[originally from svn r9749]

11 years agoPattern's display was broken for non-square puzzles, because
Simon Tatham [Wed, 9 Jan 2013 08:04:24 +0000 (08:04 +0000)]
Pattern's display was broken for non-square puzzles, because
draw_numbers() was considerably confused between the width of the clue
border at the left and the height of the clue border at the top.
Unconfuse it (I think).

[originally from svn r9737]

11 years agoActually do what the comment says at the top of main() regarding not
Simon Tatham [Fri, 28 Dec 2012 11:22:13 +0000 (11:22 +0000)]
Actually do what the comment says at the top of main() regarding not
bombing out due to an option that we don't recognise but GTK will.
Somehow my basically workable plan had been completely nullified by
putting the error check in the wrong place.

[originally from svn r9733]

11 years agoFix overnight build failure last night, by making the new call to
Simon Tatham [Wed, 21 Nov 2012 18:45:07 +0000 (18:45 +0000)]
Fix overnight build failure last night, by making the new call to
gtk_widget_get_allocation conditional on GTK being new enough to have
that function.

I'm assuming until someone proves otherwise that if it isn't that new,
then it also isn't one of the versions of GTK which exhibit the bug
which that call was working around (since gtk_widget_get_allocation
came in 2.18, and the problem seems to have arisen since 2.20).

[originally from svn r9712]

11 years agoWork around an annoying GTK behaviour I noticed the other day on my
Simon Tatham [Tue, 20 Nov 2012 20:05:27 +0000 (20:05 +0000)]
Work around an annoying GTK behaviour I noticed the other day on my
Ubuntu 12.04 machine. What seems to happen is that we set up a window
containing a menu bar, a drawing area and a status bar, and set the
size of the drawing area; then the window is displayed _without_ the
menu bar; then we reduce the drawing area's size request to (1,1) to
let the user resize the window smaller; and now GTK gets round to
constructing the menu bar, and the drawing area helpfully shrinks a
bit to make room for it.

My fix is to set a 'shrink pending' flag instead of shrinking the
drawing area's size request, and defer the actual shrink operation
until the menu bar and status bar are both present.

[originally from svn r9711]

11 years agoA user points out that I could usefully clarify the Undead clue
Simon Tatham [Sat, 3 Nov 2012 16:27:49 +0000 (16:27 +0000)]
A user points out that I could usefully clarify the Undead clue
semantics when a reflected sight-line crosses the same monster twice.

[originally from svn r9694]

11 years agoRemove an unused variable spotted by gcc 4.6.3.
Simon Tatham [Sun, 7 Oct 2012 15:41:44 +0000 (15:41 +0000)]
Remove an unused variable spotted by gcc 4.6.3.

[originally from svn r9682]

11 years agoNew puzzle! 'Unruly', contributed by Lennard Sprong, is an
Simon Tatham [Sun, 7 Oct 2012 10:18:33 +0000 (10:18 +0000)]
New puzzle! 'Unruly', contributed by Lennard Sprong, is an
implementation of a puzzle usually called 'Tohu wa Vohu'.

[originally from svn r9680]

11 years agoMake indentation consistent. (Somehow I forgot to do this before I
Simon Tatham [Mon, 10 Sep 2012 18:24:34 +0000 (18:24 +0000)]
Make indentation consistent. (Somehow I forgot to do this before I
originally committed the puzzle, as I usually do.)

[originally from svn r9660]

11 years agoForgot to add the new 'const' in the unfinished subdirectory. Oops.
Simon Tatham [Mon, 10 Sep 2012 18:05:54 +0000 (18:05 +0000)]
Forgot to add the new 'const' in the unfinished subdirectory. Oops.

[originally from svn r9659]

11 years agoOops, forgot to initialise changed_ascii on all paths in r9657.
Simon Tatham [Sun, 9 Sep 2012 21:55:14 +0000 (21:55 +0000)]
Oops, forgot to initialise changed_ascii on all paths in r9657.

[originally from svn r9658]
[r9657 == 3b250baa02a7332510685948bf17576c397b8ceb]

11 years agoNew rule: interpret_move() is passed a pointer to the game_drawstate
Simon Tatham [Sun, 9 Sep 2012 18:40:12 +0000 (18:40 +0000)]
New rule: interpret_move() is passed a pointer to the game_drawstate
basically just so that it can divide mouse coordinates by the tile
size, but is definitely not expected to _write_ to it, and it hadn't
previously occurred to me that anyone might try. Therefore,
interpret_move() now gets a pointer to a _const_ game_drawstate
instead of a writable one.

All existing puzzles cope fine with this API change (as long as the
new const qualifier is also added to a couple of subfunctions to which
interpret_move delegates work), except for the just-committed Undead,
which somehow had ds->ascii and ui->ascii the wrong way round but is
otherwise unproblematic.

[originally from svn r9657]

11 years agoMinor tweaks to Undead docs.
Jacob Nevins [Sun, 9 Sep 2012 11:50:05 +0000 (11:50 +0000)]
Minor tweaks to Undead docs.

[originally from svn r9656]