- GLfloat shine[1];
- GLfloat spec[4];
- GLfloat mult;
- glTranslatef(cs->steps < 50 ? cs->from[1] : cs->to[1], 0.0,
- cs->steps < 50 ? cs->from[0] : cs->to[0]);
-
- mult = cs->steps < 10
- ? (1.0 - cs->steps / 10.0) : 100 - cs->steps < 10
- ? (1.0 - (100 - cs->steps) / 10.0) : 0.0;
-
- shine[0] = mult*shininess[0];
- spec[0] = mult*specular[0];
- spec[1] = mult*specular[1];
- spec[2] = mult*specular[2];
- spec[3] = 1.0;
- glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shine);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
+ /* If there is nothing in the path of a knight, move it by sliding,
+ just like the other pieces. But if there are any pieces on the
+ middle two squares in its path, the knight would intersect them,
+ so in that case, move it in an airborne arc. */
+ GLfloat y;
+ int i, j;
+ Bool blocked_p = False;
+ int fromx = MIN(cs->from[1], cs->to[1]);
+ int fromy = MIN(cs->from[0], cs->to[0]);
+ int tox = MAX(cs->from[1], cs->to[1]);
+ int toy = MAX(cs->from[0], cs->to[0]);
+ if (fromx == tox-2) fromx = tox = fromx+1;
+ if (fromy == toy-2) fromy = toy = fromy+1;
+ for (i = fromy; i <= toy; i++) {
+ for (j = fromx; j <= tox; j++) {
+ if (cs->game.board[i][j]) {
+ blocked_p = True;
+ break;
+ }
+ }
+ }