X-Git-Url: http://git.shiar.net/netris.git/blobdiff_plain/0e934ad47c5e35e9a652dbe56961a707a32e7a54..3b453bab5c990f862a4915ae4e5e4a0e90b167f2:/board.c diff --git a/board.c b/board.c index c6c4837..9044f78 100644 --- a/board.c +++ b/board.c @@ -94,10 +94,10 @@ int ShapeIterate(char s, int scr, int y, int x, ShapeDrawFunc func) int i, j, result; char type, rotation; - type = s/4; - rotation = s&3; - for (i = 0; i<4; i++) - for (j = 0; j<4; j++) + type = s / 4; + rotation = s & 3; + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) if (shapes[type][rotation][i][j]) if (result = func(scr, y-i, x+j, shapes[type][rotation][i][j])) return result; @@ -112,9 +112,10 @@ char ChooseOption(float options[7]) int i; float total = 0, val; - for (i = 0; i<7; i++) total += options[i]; - val = Random(0, 32767)/32768.0*total; - for (i = 0; i<7; i++) if ((val -= options[i])<0) return i<<2; + for (i = 0; i < 7; i++) total += options[i]; + val = Random(0, 32767) / 32768.0 * total; + for (i = 0; i < 7; i++) if ((val -= options[i]) < 0) + return i << 2; return 0; } @@ -319,7 +320,7 @@ int CheckFall(int scr) unsigned char z; if (!Game.gravity) return 0; - for (y = Players[scr].boardHeight-1; y > 0; y--) + for (y = Players[scr].boardHeight - 1; y > 0; y--) for (x = 0; x < Players[scr].boardWidth; x++) { if (((z = GetBlock(scr, y, x)) > BT_none) && ((z & 160) == 0)) { //doesn't stick left/up => topleft block @@ -362,7 +363,7 @@ int ClearFullLines(int scr) from++; //skip for (x = 0; x1) + if (from > 1) SetBlock(scr, from-2, x, GetBlock(scr, from-2, x)&223); } //don't stick blocks to line which we'll remove } //full lines