summaryrefslogtreecommitdiffstats
path: root/mbbsd/gomo1.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
commit1603deaec5d0a94c9a8201b0ba286e8e492a3602 (patch)
treee6405cfd39f8ac166ab7d00752ed6cfa3ac0a928 /mbbsd/gomo1.c
parent10bda3e57cad194ac33ccdcd01aee2d935f1544a (diff)
downloadpttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.gz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.bz2
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.lz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.xz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.zst
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.zip
indent
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@415 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/gomo1.c')
-rw-r--r--mbbsd/gomo1.c108
1 files changed, 59 insertions, 49 deletions
diff --git a/mbbsd/gomo1.c b/mbbsd/gomo1.c
index c741f538..462ceb47 100644
--- a/mbbsd/gomo1.c
+++ b/mbbsd/gomo1.c
@@ -1,87 +1,95 @@
-/* $Id: gomo1.c,v 1.2 2002/06/04 13:08:33 in2 Exp $ */
+/* $Id: gomo1.c,v 1.3 2002/07/05 17:10:27 in2 Exp $ */
#include "bbs.h"
#define QCAST int (*)(const void *, const void *)
/* pattern and advance map */
-static int intrevcmp(const void *a, const void *b) {
+static int
+intrevcmp(const void *a, const void *b)
+{
return (*(int *)b - *(int *)a);
}
/* x,y: 0..BRDSIZ-1 ; color: CBLACK,CWHITE ; dx,dy: -1,0,+1 */
-static int gomo_getindex(int x, int y, int color, int dx, int dy) {
- int i, k, n;
- for(n = -1, i = 0, k = 1; i < 5; i++, k <<= 1) {
+static int
+gomo_getindex(int x, int y, int color, int dx, int dy)
+{
+ int i, k, n;
+ for (n = -1, i = 0, k = 1; i < 5; i++, k <<= 1) {
x += dx;
y += dy;
-
- if((x < 0) || (x >= BRDSIZ) || ( y < 0) || ( y >= BRDSIZ)) {
+
+ if ((x < 0) || (x >= BRDSIZ) || (y < 0) || (y >= BRDSIZ)) {
n += k;
break;
- } else if(ku[x][y] != BBLANK) {
+ } else if (ku[x][y] != BBLANK) {
n += k;
- if(ku[x][y] != color)
+ if (ku[x][y] != color)
break;
}
}
-
- if(i >= 5)
+
+ if (i >= 5)
n += k;
return n;
}
-int chkwin(int style, int limit) {
- if(style == 0x0c)
- return 1 /* style */;
- else if(limit == 0) {
- if(style == 0x0b)
- return 1 /* style */;
+int
+chkwin(int style, int limit)
+{
+ if (style == 0x0c)
+ return 1 /* style */ ;
+ else if (limit == 0) {
+ if (style == 0x0b)
+ return 1 /* style */ ;
return 0;
}
- if((style < 0x0c) && (style > 0x07))
- return -1 /* -style */;
+ if ((style < 0x0c) && (style > 0x07))
+ return -1 /* -style */ ;
return 0;
}
/* x,y: 0..BRDSIZ-1 ; color: CBLACK,CWHITE ; limit:1,0 ; dx,dy: 0,1 */
-static int dirchk(int x, int y, int color, int limit, int dx, int dy) {
- int le, ri, loc, style = 0;
+static int
+dirchk(int x, int y, int color, int limit, int dx, int dy)
+{
+ int le, ri, loc, style = 0;
le = gomo_getindex(x, y, color, -dx, -dy);
- ri = gomo_getindex(x, y, color, dx, dy);
+ ri = gomo_getindex(x, y, color, dx, dy);
loc = (le > ri) ? (((le * (le + 1)) >> 1) + ri) :
(((ri * (ri + 1)) >> 1) + le);
-
+
style = pat[loc];
-
- if(limit == 0)
+
+ if (limit == 0)
return (style & 0x0f);
style >>= 4;
-
- if((style == 3) || (style == 2)) {
- int i, n = 0, tmp, nx, ny;
-
+
+ if ((style == 3) || (style == 2)) {
+ int i, n = 0, tmp, nx, ny;
+
n = adv[loc >> 1];
-
+
((loc & 1) == 0) ? (n >>= 4) : (n &= 0x0f);
-
+
ku[x][y] = color;
-
- for(i = 0; i < 2; i++) {
- if((tmp = (i == 0) ? (-(n >> 2)):(n & 3)) != 0) {
+
+ for (i = 0; i < 2; i++) {
+ if ((tmp = (i == 0) ? (-(n >> 2)) : (n & 3)) != 0) {
nx = x + (le > ri ? 1 : -1) * tmp * dx;
ny = y + (le > ri ? 1 : -1) * tmp * dy;
-
- if((dirchk(nx, ny, color, 0, dx, dy) == 0x06) &&
- (chkwin(getstyle(nx, ny, color, limit), limit) >= 0))
+
+ if ((dirchk(nx, ny, color, 0, dx, dy) == 0x06) &&
+ (chkwin(getstyle(nx, ny, color, limit), limit) >= 0))
break;
}
}
- if(i >= 2)
+ if (i >= 2)
style = 0;
ku[x][y] = BBLANK;
}
@@ -92,26 +100,28 @@ static int dirchk(int x, int y, int color, int limit, int dx, int dy) {
/* 四三=7 活四=6 斷四=5 死四=4 活三=3 斷三=2 保留=1 無效=0 */
/* x,y: 0..BRDSIZ-1 ; color: CBLACK,CWHITE ; limit: 1,0 */
-int getstyle(int x, int y, int color, int limit) {
- int i, j, dir[4], style;
+int
+getstyle(int x, int y, int color, int limit)
+{
+ int i, j, dir[4], style;
- if((x < 0) || (x >= BRDSIZ) || ( y < 0) || (y >= BRDSIZ))
+ if ((x < 0) || (x >= BRDSIZ) || (y < 0) || (y >= BRDSIZ))
return 0x0f;
- if(ku[x][y] != BBLANK)
+ if (ku[x][y] != BBLANK)
return 0x0d;
- for(i = 0; i < 4; i++)
- dir[i] = dirchk(x, y, color, limit, i ? (i>>1) : -1, i ? (i&1) : 1);
+ for (i = 0; i < 4; i++)
+ dir[i] = dirchk(x, y, color, limit, i ? (i >> 1) : -1, i ? (i & 1) : 1);
qsort(dir, 4, sizeof(int), (QCAST)intrevcmp);
- if((style = dir[0]) >= 2) {
- for(i = 1, j = 6 + (limit ? 1 : 0); i < 4; i++) {
- if((style > j) || (dir[i] < 2))
+ if ((style = dir[0]) >= 2) {
+ for (i = 1, j = 6 + (limit ? 1 : 0); i < 4; i++) {
+ if ((style > j) || (dir[i] < 2))
break;
- if(dir[i] > 3)
+ if (dir[i] > 3)
style = 9;
- else if((style < 7) && (style > 3))
+ else if ((style < 7) && (style > 3))
style = 7;
else
style = 8;