aboutsummaryrefslogtreecommitdiff
path: root/signpost.c (follow)
Commit message (Collapse)AuthorAge
* Signpost: fix star drawing on rockboxFranklin Wei2020-12-07
|
* Add method for frontends to query the backend's cursor location.Franklin Wei2020-12-07
| | | | | | | | | | | | | | | | The Rockbox frontend allows games to be displayed in a "zoomed-in" state targets with small displays. Currently we use a modal interface -- a "viewing" mode in which the cursor keys are used to pan around the rendered bitmap; and an "interaction" mode that actually sends keys to the game. This commit adds a midend_get_cursor_location() function to allow the frontend to retrieve the backend's cursor location or other "region of interest" -- such as the player location in Cube or Inertia. With this information, the Rockbox frontend can now intelligently follow the cursor around in the zoomed-in state, eliminating the need for a modal interface.
* Use C99 bool within source modules.Simon Tatham2018-11-13
| | | | | | | | | | This is the main bulk of this boolification work, but although it's making the largest actual change, it should also be the least disruptive to anyone interacting with this code base downstream of me, because it doesn't modify any interface between modules: all the inter-module APIs were updated one by one in the previous commits. This just cleans up the code within each individual source file to use bool in place of int where I think that makes things clearer.
* Replace TRUE/FALSE with C99 true/false throughout.Simon Tatham2018-11-13
| | | | | | This commit removes the old #defines of TRUE and FALSE from puzzles.h, and does a mechanical search-and-replace throughout the code to replace them with the C99 standard lowercase spellings.
* Adopt C99 bool in the game backend API.Simon Tatham2018-11-13
| | | | | | | | | | | encode_params, validate_params and new_desc now take a bool parameter; fetch_preset, can_format_as_text_now and timing_state all return bool; and the data fields is_timed, wants_statusbar and can_* are all bool. All of those were previously typed as int, but semantically boolean. This commit changes the API declarations in puzzles.h, updates all the games to match (including the unfinisheds), and updates the developer docs as well.
* Add a request_keys() function with a midend wrapper.Franklin Wei2018-04-22
| | | | | | | | This function gives the front end a way to find out what keys the back end requires; and as such it is mostly useful for ports without a keyboard. It is based on changes originally found in Chris Boyle's Android port, though some modifications were needed to make it more flexible.
* Make the code base clean under -Wwrite-strings.Simon Tatham2017-10-01
| | | | | I've also added that warning option and -Werror to the build script, so that I'll find out if I break this property in future.
* Return error messages as 'const char *', not 'char *'.Simon Tatham2017-10-01
| | | | | They're never dynamically allocated, and are almost always string literals, so const is more appropriate.
* Use a proper union in struct config_item.Simon Tatham2017-10-01
| | | | | | This allows me to use different types for the mutable, dynamically allocated string value in a C_STRING control and the fixed constant list of option names in a C_CHOICES.
* New name UI_UPDATE for interpret_move's return "".Simon Tatham2017-10-01
| | | | | | | | | | | | | Now midend.c directly tests the returned pointer for equality to this value, instead of checking whether it's the empty string. A minor effect of this is that games may now return a dynamically allocated empty string from interpret_move() and treat it as just another legal move description. But I don't expect anyone to be perverse enough to actually do that! The main purpose is that it avoids returning a string literal from a function whose return type is a pointer to _non-const_ char, i.e. we are now one step closer to being able to make this code base clean under -Wwrite-strings.
* Rework the preset menu system to permit submenus.Simon Tatham2017-04-26
| | | | | | | | | | | | | | | | | | | | To do this, I've completely replaced the API between mid-end and front end, so any downstream front end maintainers will have to do some rewriting of their own (sorry). I've done the necessary work in all five of the front ends I keep in-tree here - Windows, GTK, OS X, Javascript/Emscripten, and Java/NestedVM - and I've done it in various different styles (as each front end found most convenient), so that should provide a variety of sample code to show downstreams how, if they should need it. I've left in the old puzzle back-end API function to return a flat list of presets, so for the moment, all the puzzle backends are unchanged apart from an extra null pointer appearing in their top-level game structure. In a future commit I'll actually use the new feature in a puzzle; perhaps in the further future it might make sense to migrate all the puzzles to the new API and stop providing back ends with two alternative ways of doing things, but this seemed like enough upheaval for one day.
* Clarify conditions to avoid compiler errorsKhem Raj2016-12-06
| | | | | | | | | | Fix errors pointed out by clang error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses] | if (only_immutable && !copy->flags[i] & FLAG_IMMUTABLE) continue; | ^ Signed-off-by: Khem Raj <raj.khem@gmail.com>
* Fix an instance generation hang in Signpost.Jonas Kölker2015-10-03
| | | | Also expand the set of permissible parameters (add 1xN, Nx1 and 2x2).
* Special-case right-dragging of a numbered cell off the grid.Simon Tatham2015-05-09
| | | | | | | | | | | | | | | | Chris Boyle reports that if you right-drag a numbered cell off the grid, _all_ numbered cells (except the immutable initial clues) get reset to blank, because this is treated as an attempt to erase a whole chain of linked cells (of the form a,a+1,...,a_k) and the cells with definite numbers are all treated as 'chain 0'. In that situation, I now substitute the same behaviour you'd get by left-dragging the numbered cell off the board, i.e. erase _just_ that cell and not the whole of the rest of the puzzle. (The previous unintended behaviour was a UI action you surely never want - and Chris also reports that due to the Android front end's way of representing right-drags, it's especially easy to hit by mistake.)
* Sort out abs/fabs confusion.Simon Tatham2015-04-10
| | | | | | | | | | | | | | My Mac has just upgraded itself to include a version of clang which warns if you use abs() on a floating-point value, or fabs() on an integer. Fixed the two occurrences that came up in this build (and which were actual build failures, because of -Werror), one in each direction. I think both were benign. The potentially dangerous one was using abs in place of fabs in grid_find_incentre(), because that could actually lose precision, but I think that function had plenty of precision to spare (grid point separation being of the order of tens of pixels) so nothing should have gone seriously wrong with the old code.
* Fix a build failure on x32 (time_t printfs).Adam Borowski2015-03-09
| | | | | As that architecture has 64-bit time_t but only 32-bit longs, printf format causes a warning. Enter -Werror...
* Giant const patch of doom: add a 'const' to every parameter in everySimon Tatham2013-04-13
| | | | | | | | | | | | | | 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]
* Add 'const' to the game_params arguments in validate_desc andSimon Tatham2013-04-12
| | | | | | | | | | | | 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]
* New rule: interpret_move() is passed a pointer to the game_drawstateSimon Tatham2012-09-09
| | | | | | | | | | | | | | | | 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]
* Trivial and silly patch to allow users to configure the SignpostSimon Tatham2012-01-22
| | | | | | | | victory roll so that adjacent arrows rotate in opposite directions, giving the impression that they're an interlocking field of gears. Possibly even more brain-twisting than the original version :-) [originally from svn r9384]
* When we run out of background colours for chains and wrap back to theSimon Tatham2011-09-18
| | | | | | | | beginning, we should wrap back to COL_B0+1 rather than COL_B0 itself, so as not to reuse white. White should be special, and always indicate a properly numbered square. [originally from svn r9305]
* Patch from Chris Boyle to fix Signpost's labelling when you have moreSimon Tatham2011-09-18
| | | | | | | | than 26 separate linked chains of unnumbered squares: we now wrap from 'z' to an Excel-like 'aa', 'ab', ..., instead of falling off z into punctuation and control characters. [originally from svn r9304]
* Changed my mind about midend_is_solved: I've now reprototyped it asSimon Tatham2011-06-19
| | | | | | | | | | | | | | | | 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]
* Portability fixes, mostly from James for Palm purposes. MostlySimon Tatham2011-05-04
| | | | | | | | additions of missing 'static' and explicit 'void' in parameter lists, plus one or two other things like explicitly casting chars in variadic argument lists to int and using DBL_MAX if HUGE_VAL isn't available. [originally from svn r9166]
* Add a function to every game backend which indicates whether a gameSimon Tatham2011-04-02
| | | | | | | | | | | 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]
* A user points out that Signpost doesn't in fact use the numericSimon Tatham2010-05-09
| | | | | | keypad, so it shouldn't have the REQUIRE_NUMPAD flag. [originally from svn r8939]
* Fix incorrect uses of ctype.h (passing it uncast chars, or otherSimon Tatham2010-04-17
| | | | | | things potentially not in the range 0..255). [originally from svn r8922]
* Fix from James H for an assertion failure during SignpostSimon Tatham2010-04-17
| | | | | | generation. To reproduce, try 'signpost --generate 1 7x7#12345-162'. [originally from svn r8921]
* Dylan O'Donnell reports that Signpost hangs on trying to generate aSimon Tatham2010-04-02
| | | | | | 2x2 puzzle. Rule it out in validate_params(). [originally from svn r8913]
* Fixes from James H to the numbering of squares, in particular:Simon Tatham2010-02-22
| | | | | | | | | - sometimes two regions would get the same letter - immutable numbers could sometimes be modified - immutable numbers are now not flagged as errors when they clash (same as Solo's policy) [originally from svn r8882]
* Fix build failure on MacOS by initialising a variable which wasSimon Tatham2010-02-18
| | | | | | | | reported as potentially-unused. (In fact, as far as I can tell, it's only ever uninitialised in assertion-failing code paths, so not a real bug.) [originally from svn r8873]
* A proper fix from James H for the negative number issue: theSimon Tatham2010-02-17
| | | | | | | assertion I crudely commented out has now been replaced with code that clearly shows what you did wrong in the failing situation. [originally from svn r8872]
* 'Fix' an assertion failure during play: accidentally connecting aSimon Tatham2010-02-16
| | | | | | | | | | | | long chain to a square numbered so low that the start of the chain would have to go into negative numbers should not crash the game, particularly when it happens as a momentary in-passing illustration. I've fixed it for the moment just by removing the assertion. There's probably a better fix which causes something less strange to happen to the display as a result. [originally from svn r8867]
* Docs and comments fixes from James H.Simon Tatham2010-02-16
| | | | [originally from svn r8866]
* New puzzle! Setting what might be a record for how long we've sat onSimon Tatham2010-02-15
a puzzle before it was ready to commit, here is 'Signpost': a clone of janko.at's "Arrow Path", by James Harvey. [originally from svn r8861]