girst [Thu, 14 Feb 2019 20:30:30 +0000 (21:30 +0100)]
WIP: freecell implementation (unfinished)
what's missing:
- t2t() and corresponding undo_pop()
- get_cmd() "select from which {cell,foundation}?" dialog
- some mouse details (term2pile, wait_mouse_up, set_mouse)
- join() for freecell
no of the additions affect klondike or spider, so its safe to commit.
girst [Sun, 3 Feb 2019 16:54:57 +0000 (17:54 +0100)]
fix segfault when mouse-moving multiple cards to empty tableu
the "up to?" dialog calls getch(NULL), which caused a segfault.
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000004030fb in getch (buf=0x0) at spider.c:940
> 940 if (buf[3]) {
> (gdb) bt
> #0 0x00000000004030fb in getch (buf=0x0) at spider.c:940
> #1 0x0000000000402c97 in get_cmd (from=0x7ffeba433bfc, to=0x7ffeba433bf8,
> opt=0x7ffeba433bf4) at spider.c:808
> #2 0x0000000000400ebf in sol () at spider.c:108
> #3 0x0000000000400e2f in main (argc=2, argv=0x7ffeba433d28) at spider.c:88
girst [Mon, 21 Jan 2019 18:29:49 +0000 (19:29 +0100)]
use getch() everywhere
except for inside getch(), of course. where no mouse is needed, one can
pass NULL instead of a buffer; KEY_INVAL will then be returned if a
mouse click was received.
girst [Sun, 20 Jan 2019 23:44:15 +0000 (00:44 +0100)]
implement restart same game, increase portability, update TODOs
* use rand() instead of random() to get in line with mines and viiper
* reorder playfield struct for better alignment
* remove ignore warnings pragma (not needed any more)
* remove _POSIX_C_SOURCE feture test (not needed and breaks freebsd)
girst [Sun, 20 Jan 2019 20:32:24 +0000 (21:32 +0100)]
first version of join() -- to be replaced
this version is very suboptimal. we shouldn't take from longest piles,
as that will rip apart already constructed piles. instead, take from
piles where the card we want to move has the least amount of movable
cards _above_ it. even better if the card above is closed. even better
yet if there is no card above (resulting in an empty pile)
girst [Sun, 20 Jan 2019 18:50:19 +0000 (19:50 +0100)]
automagic conserve space
only when the window size would be too small to display a pile
completely. still has the problem that sometimes the terminal is too
small for even the extreme overlap.
girst [Sun, 20 Jan 2019 17:05:52 +0000 (18:05 +0100)]
fix BULCARD() padding
using ESC produces tofu on some terminal emulators. switching to SI
(Switch To Standard Charset) for padding seems to work better. (SI
should have no effect on Unicode terminal emulators). this also made
detecting the padded lines easier, as \017 (SI) is only appearing in
those.
girst [Sat, 19 Jan 2019 16:37:02 +0000 (17:37 +0100)]
fix foundation rendering (SPIDER)
by using a static int to store the foundation index, it couldn't be
reset when a new game was started. this caused the first pile to be e.g.
to end up on the second foundation if the game before had 1 completed.
girst [Thu, 10 Jan 2019 14:16:31 +0000 (15:16 +0100)]
fix broken halfcard rendering
due to the faint hack, black cards were 1 byte shorter than red cards.
this meant, that the offset for halfcard was off for red colors (as it
has been adjusted for black cards), which caused printing errors in
spider's foundation for overlapping red cards. can't pad with zero bytes
(as that would end the string), but using an extra escape seems to be OK
for xterm and vte-based terminals.
girst [Mon, 7 Jan 2019 17:12:55 +0000 (18:12 +0100)]
awful hack that un-breaks faint+bold printing
bold and faint can bet set individually, but only reset both at once.
this causes the bold attribute (useful for determining with cards are
movable) to be reset when faint was. we are splitting the string at a
known-whitespace position only if we are at the faint printed lines
(str[n]==033).