aboutsummaryrefslogtreecommitdiff
path: root/range.c (follow)
Commit message (Collapse)AuthorAge
* 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.
* Fix two bugs in Range's solver_reasoning_recursion().Stephen Clavering2018-04-12
| | | | | | | | | | | | | | | | | | | | | | | Firstly, it tries to use newstate after freeing it. I haven't come up with any way of actually triggering that bug. I suppose you'd need a grid that required recursion to solve, which the generator of course does not normally create. Secondly, it stores M_BLACK or M_WHITE in the grid before doing the recursion, whereas it should store BLACK or WHITE. I believe that since it tries M_BLACK first, which is zero, and since it's trying it on an undecided square (also zero), this leads to infinite recursion, and an eventual crash once you run out of stack space. You can (sometimes) trigger this by asking for a hint on a grid where you've already made a mistake. e.g. on the puzzle desc below there's a "9" at (13,7). If you place a black tile to its immediate left and right - (12,7) and (14,7) - then press 'h', you get a beachball and then crash (on macOS at least - I presume other OSes are similar). 15x15:i5g4d16a7a7c3b3b11f11_15d3p8b7_8b4h18c4d13b4i7a16k9a9i4b2d10c14h11b10_10b17p6d8_7f9b8b11c10a2a5d5g7i
* 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.
* Make cellsize a char.Phil Bordelon2017-06-05
| | | | | | | | Apparently new versions of GCC get grumpy if the possible range for a sprintf() call exceeds MAXINT, which would never happen in actuality here due to the size of the puzzles we're dealing with... but the compiler doesn't know that, of course, so thinks that something may have gone horribly awry. Changing it to a char solves the problem neatly.
* 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.
* Display improvements to Range.Jonas Kölker2015-10-03
| | | | | Make the grid look a lot less heavy; enhance highlighting of error clues; highlight enclosed small regions much more prettily.
* Range: add pencil marks to squares by Shift-cursor keys.Jonas Kölker2015-10-03
|
* Fix a memory leak in Range's find_errors.Jonas Kölker2015-10-03
| | | | | Only occurred in invalid instances, such as 3x1:1b when you put a black in the middle square.
* Fix segfault in Range's game_text_format.Jonas Kölker2015-10-03
| | | | Occurred on Nx1 puzzles, etc.
* Include an example of Range's text_format in the comments.Jonas Kölker2015-10-03
|
* Improve connectedness-error highlighting in Range.Simon Tatham2014-09-09
| | | | | | | | | | | 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]
* 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]
* Remove the 'cheated' flag in Range's game_ui, which was stickilySimon Tatham2011-09-18
| | | | | | | | | | | | | | | | | | | | remembering whether the player had ever used the hint or solve functions, even if they then pressed undo (and even if they saved and restored). As far as Solve+Undo is concerned, this just brings Range into line with common practice in the rest of my puzzles. On the other hand, Range is the first time there's been a 'hint' function to consider in this question, so here's a policy decision: the victory flash is not a congratulation for a puzzle solved unaided, it's a confirmation that you really have reached a correct solution and haven't made any mistakes. So the only reason to omit the victory flash is if you've used the Solve operation to go straight to a guaranteed-correct solution _in a single move_; if you're using the hint button, there's still scope for you to make mistakes in all your non-hint moves, so the victory flash is still a useful indicator that you didn't. [originally from svn r9306]
* 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]
* New puzzle from Jonas Koelker: 'Range', an implementation of theSimon Tatham2010-09-14
puzzle variously known (depending on which website you look at) as Kurodoko, Kuromasu or 'Where is Black Cells'. [originally from svn r8996]