35 Commits

Author SHA1 Message Date
bef1b2c59b Mark some arguments constant 2015-05-11 10:46:12 +01:00
3768ed65f2 Fix the issue with adding only one arrow when the other end was already white 2015-05-11 10:46:12 +01:00
83318d4218 Add/remove the opposite arrow when you let go 2015-05-11 10:46:12 +01:00
4fa5df1cba Draw the opposite arrow only while dragging 2015-05-11 10:15:02 +01:00
774395d373 Moved all function declarations to the top of the file 2015-05-11 10:14:57 +01:00
155607b768 Use the game_state and space typedefs 2015-05-11 10:14:53 +01:00
6684bec60c Always use ret instead of state in execute_move 2015-05-11 10:14:48 +01:00
7cf1e1f83e Fixed a typo in a comment 2015-05-11 10:14:44 +01:00
251b21c418 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]
2013-04-13 10:37:32 +00:00
0b93de904a 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]
2013-04-12 17:11:49 +00:00
3b250baa02 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]
2012-09-09 18:40:12 +00:00
b4f3b57aa1 Swap a 'max' for a 'min', fixing an out-of-range colour component
being passed to the front end.

[originally from svn r9451]
2012-04-08 13:06:46 +00:00
73daff3937 Changed my mind about midend_is_solved: I've now reprototyped it as
midend_status(), and given it three return codes for win, (permanent)
loss and game-still-in-play. Depending on what the front end wants to
use it for, it may find any or all of these three states worth
distinguishing from each other.

(I suppose a further enhancement might be to add _non_-permanent loss
as a fourth distinct status, to describe situations in which you can't
play further without pressing Undo but doing so is not completely
pointless. That might reasonably include dead-end situations in Same
Game and Pegs, and blown-self-up situations in Mines and Inertia.
However, I haven't done this at present.)

[originally from svn r9179]
2011-06-19 13:43:35 +00:00
980880be1f Add a function to every game backend which indicates whether a game
state is in a solved position, and a midend function wrapping it.

(Or, at least, a situation in which further play is pointless. The
point is, given that game state, would it be a good idea for a front
end that does that sort of thing to proactively provide the option to
start a fresh game?)

[originally from svn r9140]
2011-04-02 16:19:12 +00:00
0687980f0c Memory management and other fixes from James H.
[originally from svn r8596]
2009-06-17 20:01:45 +00:00
4850845205 Keyboard cursor support in Galaxies, by James H.
[originally from svn r8413]
2009-01-15 18:18:21 +00:00
a7431c0b7c New infrastructure feature. Games are now permitted to be
_conditionally_ able to format the current puzzle as text to be sent
to the clipboard. For instance, if a game were to support playing on
a square grid and on other kinds of grid such as hexagonal, then it
might reasonably feel that only the former could be sensibly
rendered in ASCII art; so it can now arrange for the "Copy" menu
item to be greyed out depending on the game_params.

To do this I've introduced a new backend function
(can_format_as_text_now()), and renamed the existing static backend
field "can_format_as_text" to "can_format_as_text_ever". The latter
will cause compile errors for anyone maintaining a third-party front
end; if any such person is reading this, I apologise to them for the
inconvenience, but I did do it deliberately so that they'd know to
update their front end.

As yet, no checked-in game actually uses this feature; all current
games can still either copy always or copy never.

[originally from svn r8161]
2008-09-06 09:27:56 +00:00
0564211167 Revise the printing colour framework so that we can explicitly
request either of hatching or halftoning, and also choose which to
supply as a fallback when printing in colour.

[originally from svn r7976]
2008-04-07 17:13:29 +00:00
5fb108db00 Kyle Brazell points out that the completion checker considers a
region valid if it has _a_ dot at its centre of symmetry, even if
that dot isn't actually within the region in question.

[originally from svn r7407]
2007-03-23 18:08:21 +00:00
587d105799 My favourite kind of patch, from James H: one which decreases the
amount of code. James has ripped out the solver's version of
check_complete(), in favour of using the one I wrote for the
game-playing UI. My one checks connectedness, which means that the
solver will now not believe non-solutions to puzzles where
connectedness becomes a difficult issue. Examples of game IDs which
are now solved correctly but were previously not are 5x3:ubb and
7x7:ajfzmfqgtdzgt.

[originally from svn r7362]
2007-03-03 17:15:25 +00:00
6713d21cd1 Fix problems with arrow UI with non-square grid.
[originally from svn r7355]
2007-03-02 20:14:15 +00:00
3584fc5a1b Silliness! Here's a somewhat hacky patch which builds an additional
binary from the Galaxies source file. The function of the new
`galaxiespicture' is to take a .xbm bitmap on standard input and
convert it into a Galaxies game ID using both black and white dots,
such that when solved the puzzle displays the input bitmap.

In the process of this I've implemented a post-processing pass after
the main game generation, to prevent clusters of adjacent
singletons. James H already solved that problem for unconstrained
game generation, but for some reason it came back when I did this.
However, the post-processing pass is still turned off for normal
usage, on the basis that (a) if it ain't broke don't fix it, and (b)
it's rather slow and best avoided if not necessary.

[originally from svn r7354]
2007-03-01 18:57:36 +00:00
db743e54e8 Cleanup patch from James H: disable the `s' key, which was only in
there by accident.

[originally from svn r7351]
2007-03-01 07:41:11 +00:00
cf0b0b747b Bound edge thicknesses below so that they're always thicker than the
grid lines.

[originally from svn r7349]
2007-03-01 07:32:35 +00:00
9287d95d08 General cleanups patch from James H:
- missing static in filling.c
 - better robustness in execute_move() in filling.c
 - remove side effects in assert statements
 - remove rogue diagnostic in galaxies.c
 - remove // comment in map.c
 - add more stylus-friendly UI to Pattern
 - bias Unequal towards generating inequality clues rather than numeric

[originally from svn r7344]
2007-02-28 21:19:15 +00:00
de5ccc9352 Gary Wong points out a couple of minor errors in the setting of
`used_solve'.

[originally from svn r7343]
2007-02-28 21:02:31 +00:00
15f70f527a Dariusz Olszewski's changes to support compiling for PocketPC. This
is mostly done with ifdefs in windows.c; so mkfiles.pl generates a
new makefile (Makefile.wce) and Recipe enables it, but it's hardly
any different from Makefile.vc apart from a few definitions at the
top of the files.

Currently the PocketPC build is not enabled in the build script, but
with any luck I'll be able to do so reasonably soon.

[originally from svn r7337]
2007-02-26 20:35:47 +00:00
bc64fc8481 Galaxies doesn't print in colour.
[originally from svn r7334]
2007-02-25 15:50:24 +00:00
b9fd636928 Fix a UI glitch where dragging an existing arrow could change what it
referred to.

[originally from svn r7331]
2007-02-25 12:54:46 +00:00
63e5783d7e Somehow I let a couple of // comments get past me when I accepted
this file. Remove them.

[originally from svn r7318]
2007-02-24 17:34:21 +00:00
9f9a1368a9 And fix the error _I_ made in r7311. I should stop coding now,
because I'm clearly too sleepy to get it right.

[originally from svn r7312]
[r7311 == 8c0890a331d93c9d12ef782601b9953463872fc6]
2007-02-22 19:05:10 +00:00
8c0890a331 Part of r7310 completely changed the careful semantics of my
coordinate-rounding, causing picking up arrows from a dot anywhere
other than at the centre of a square to break.

[originally from svn r7311]
[r7310 == a428c5899de86897fe4e92fa6585b3c3908ce2ad]
2007-02-22 18:59:15 +00:00
a428c5899d Patch from James H to make the Palm compiler stop objecting to my
(as far as I could tell) perfectly legal use of floats, and also
remove some VC warnings.

[originally from svn r7310]
2007-02-22 18:13:12 +00:00
9d9e02f1d5 We may reluctantly permit the returning of a too-easy puzzle if an
adequately hard one couldn't be found, but we must never return a
puzzle harder than the user asked for, and we _certainly_ mustn't
return one that we aren't even sure has a unique solution.

However, when I attempted to implement this rule, it turned out that
an attempt to generate a 15x15 Easy puzzle didn't terminate before I
got bored and killed it. I'm therefore retiring the Easy difficulty
level on the grounds that it's not a wide enough band to be useful.
I've renamed Hard to Normal, and (while I was there) renamed
Recursive to Unreasonable in line with my normal practice.

[originally from svn r7309]
2007-02-22 18:09:51 +00:00
e137ad8b1a Add James Harvey's excellent new puzzle, `Galaxies'.
[originally from svn r7304]
2007-02-22 09:31:43 +00:00