src/chess/rules.c

changeset 177
18dbb0dc9cd6
parent 173
e541b6002933
equal deleted inserted replaced
176:ef8c39362342 177:18dbb0dc9cd6
395 395
396 /* copy the move data into the game's move array */ 396 /* copy the move data into the game's move array */
397 Move *melem = &gamestate->moves[gamestate->movecount]; 397 Move *melem = &gamestate->moves[gamestate->movecount];
398 *melem = *move; 398 *melem = *move;
399 399
400 /* calculate the FEN and store it in the FEN array */
401 char fen[FEN_MAX_LENGTH];
402 fen_compute(fen, gamestate);
403 gamestate->fen[gamestate->movecount] = strdup(fen);
404
405 /* only if move has no time info, compute it */ 400 /* only if move has no time info, compute it */
406 if (melem->movetime.tv_sec == 0 && melem->movetime.tv_usec == 0) { 401 if (melem->movetime.tv_sec == 0 && melem->movetime.tv_usec == 0) {
407 calc_movetime(gamestate, melem); 402 calc_movetime(gamestate, melem);
408 } 403 }
409 404
410 /* important: only "add" the move after calculating the time! */ 405 /* important: only "add" the move after calculating the time! */
411 gamestate->movecount++; 406 gamestate->movecount++;
407
408 /* calculate the FEN of the new position and store it in the FEN array */
409 char fen[FEN_MAX_LENGTH];
410 fen_compute(fen, gamestate);
411 gamestate->fen[gamestate->movecount - 1] = strdup(fen);
412 } 412 }
413 413
414 void apply_move(GameState *gamestate, Move *move) { 414 void apply_move(GameState *gamestate, Move *move) {
415 apply_move_internal(gamestate, move); 415 apply_move_internal(gamestate, move);
416 416

mercurial