ref: 45e2b4dfe9570aefe3e5f2a8b7af956b7365f522
parent: 8ac8b3e064f26a1e490accd16d1da30f9d6bb926
author: cinap_lenrek <[email protected]>
date: Sat May 7 11:19:41 EDT 2016
games/mahjongg: off by one in bmatch(), fix hint() redraw (thanks Kenji)
--- a/sys/src/games/mahjongg/graphics.c
+++ b/sys/src/games/mahjongg/graphics.c
@@ -135,7 +135,7 @@
hint(void)
{
int d = 0, x = 0, y = 0;
- Brick *b = nil;
+ Brick *a, *b = nil;
if(level.c.d != -1) {
if((b = bmatch(level.c)) != nil) {
@@ -154,24 +154,32 @@
Matched:
if (b == nil)
return;
- level.board[d][x][y].clicked = 1;
+
+ a = &level.board[d][x][y];
+ a->clicked = 1;
+ a->redraw = 1;
b->clicked = 1;
b->redraw = 1;
updatelevel();
- sleep(500);
- if(level.c.d == -1)
- level.board[d][x][y].clicked = 0;
+ sleep(100);
+ if(level.c.d == -1){
+ a->clicked = 0;
+ a->redraw = 1;
+ }
b->clicked = 0;
b->redraw = 1;
updatelevel();
- sleep(500);
- level.board[d][x][y].clicked = 1;
+ sleep(100);
+ a->clicked = 1;
+ a->redraw = 1;
b->clicked = 1;
b->redraw = 1;
updatelevel();
- sleep(500);
- if(level.c.d == -1)
- level.board[d][x][y].clicked = 0;
+ sleep(100);
+ if(level.c.d == -1){
+ a->clicked = 0;
+ a->redraw = 1;
+ }
b->clicked = 0;
b->redraw = 1;
updatelevel();
--- a/sys/src/games/mahjongg/logic.c
+++ b/sys/src/games/mahjongg/logic.c
@@ -77,7 +77,7 @@
{
Click lc;
- lc = cmatch(c, Depth);
+ lc = cmatch(c, Depth - 1);
if(lc.d == -1)
return nil;
else