aboutsummaryrefslogtreecommitdiff
path: root/galaxies.c (follow)
Commit message (Collapse)AuthorAge
* Galaxies: fix assertion failure when adding out-of-bounds association.Franklin Wei2020-12-07
| | | | | | | | | | Adding an association with an out-of-bounds square (i.e. by pressing Return with a dot selected, and then moving the cursor so the `opposite' arrow was off the screen) would cause space_opposite_dot() to return NULL, in turn causing ok_to_add_assoc_with_opposite_internal() to return false, failing the assertion. This assertion appears to have been introduced in 68363231.
* 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.
* Galaxies: prevent creation of empty undo-chain items.Simon Tatham2019-02-18
| | | | | | | | | | | | | | If you drag an arrow on to a square which is already filled in as part of a completed region, or whose counterpart is filled in, or whose counterpart is actually a dot, then the game can't actually place a double arrow. Previously, it didn't find that out until execute_move time, at which point it was too late to prevent a no-op action from being placed on the undo chain. Now we do those checks in interpret_move, before generating the move string that tries to place the double arrow in the first place. So execute_move can now enforce by assertion that arrow-placement moves it gets are valid.
* Add missing 'static' to game-internal declarations.Simon Tatham2018-11-13
| | | | | | | | | Another thing I spotted while trawling the whole source base was that a couple of games had omitted 'static' on a lot of their internal functions. Checking with nm, there turned out to be quite a few more than I'd spotted by eye, so this should fix them all. Also added one missing 'const', on the lookup table nbits[] in Tracks.
* 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.
* Enforce more than one dot in Galaxies puzzles.Chris Boyle2015-09-26
| | | | | | | | At minimum size (3x3) Galaxies can generate a pre-solved single dot game. You have to add and remove a line to get the victory flash which is a bit weird, so just prevent this.
* Handle replacing an existing arrowKevin Lyles2015-05-11
|
* Fix the extra arrow hanging around while moving the opposite existing arrowKevin Lyles2015-05-11
|
* Mark some arguments constantKevin Lyles2015-05-11
|
* Fix the issue with adding only one arrow when the other end was already whiteKevin Lyles2015-05-11
|
* Add/remove the opposite arrow when you let goKevin Lyles2015-05-11
|
* Draw the opposite arrow only while draggingKevin Lyles2015-05-11
|
* Moved all function declarations to the top of the fileKevin Lyles2015-05-11
|
* Use the game_state and space typedefsKevin Lyles2015-05-11
|
* Always use ret instead of state in execute_moveKevin Lyles2015-05-11
|
* Fixed a typo in a commentKevin Lyles2015-05-11
|
* 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]
* Swap a 'max' for a 'min', fixing an out-of-range colour componentSimon Tatham2012-04-08
| | | | | | being passed to the front end. [originally from svn r9451]
* 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]
* 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]
* Memory management and other fixes from James H.Simon Tatham2009-06-17
| | | | [originally from svn r8596]
* Keyboard cursor support in Galaxies, by James H.Simon Tatham2009-01-15
| | | | [originally from svn r8413]
* New infrastructure feature. Games are now permitted to beSimon Tatham2008-09-06
| | | | | | | | | | | | | | | | | | | | | | _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]
* Revise the printing colour framework so that we can explicitlySimon Tatham2008-04-07
| | | | | | | request either of hatching or halftoning, and also choose which to supply as a fallback when printing in colour. [originally from svn r7976]
* Kyle Brazell points out that the completion checker considers aSimon Tatham2007-03-23
| | | | | | | 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]
* My favourite kind of patch, from James H: one which decreases theSimon Tatham2007-03-03
| | | | | | | | | | | | 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]
* Fix problems with arrow UI with non-square grid.Jacob Nevins2007-03-02
| | | | [originally from svn r7355]
* Silliness! Here's a somewhat hacky patch which builds an additionalSimon Tatham2007-03-01
| | | | | | | | | | | | | | | | | 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]
* Cleanup patch from James H: disable the `s' key, which was only inSimon Tatham2007-03-01
| | | | | | there by accident. [originally from svn r7351]
* Bound edge thicknesses below so that they're always thicker than theSimon Tatham2007-03-01
| | | | | | grid lines. [originally from svn r7349]
* General cleanups patch from James H:Simon Tatham2007-02-28
| | | | | | | | | | | | - 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]
* Gary Wong points out a couple of minor errors in the setting ofSimon Tatham2007-02-28
| | | | | | `used_solve'. [originally from svn r7343]
* Dariusz Olszewski's changes to support compiling for PocketPC. ThisSimon Tatham2007-02-26
| | | | | | | | | | | | 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]
* Galaxies doesn't print in colour.Simon Tatham2007-02-25
| | | | [originally from svn r7334]
* Fix a UI glitch where dragging an existing arrow could change what itJacob Nevins2007-02-25
| | | | | | referred to. [originally from svn r7331]
* Somehow I let a couple of // comments get past me when I acceptedSimon Tatham2007-02-24
| | | | | | this file. Remove them. [originally from svn r7318]
* And fix the error _I_ made in r7311. I should stop coding now,Simon Tatham2007-02-22
| | | | | | | because I'm clearly too sleepy to get it right. [originally from svn r7312] [r7311 == 8c0890a331d93c9d12ef782601b9953463872fc6]
* Part of r7310 completely changed the careful semantics of mySimon Tatham2007-02-22
| | | | | | | | 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]
* Patch from James H to make the Palm compiler stop objecting to mySimon Tatham2007-02-22
| | | | | | | (as far as I could tell) perfectly legal use of floats, and also remove some VC warnings. [originally from svn r7310]
* We may reluctantly permit the returning of a too-easy puzzle if anSimon Tatham2007-02-22
| | | | | | | | | | | | | | | 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]