src/game.c

changeset 49
02c509a44e98
parent 48
0cedda2544da
child 50
41017d0a72c5
--- a/src/game.c	Wed Jun 11 15:38:01 2014 +0200
+++ b/src/game.c	Wed Jun 11 16:54:20 2014 +0200
@@ -123,29 +123,9 @@
         }
 
         if (logelem) {
-            Move move = logelem->move;
-            if ((move.piece&PIECE_MASK) == KING &&
-                abs(move.tofile-move.fromfile) == 2) {
-                addstr(move.tofile==fileidx('c')?"O-O-O":"O-O");
-            } else {
-                char logstr[] = {
-                    getpiecechr(move.piece),
-                    filechr(move.fromfile), rowchr(move.fromrow),
-                    move.capture ? 'x':'\0',
-                    filechr(move.tofile), rowchr(move.torow),
-                    move.check ? '+' : (move.promotion ? '=' : '\0'),
-                    move.promotion ? getpiecechr(move.promotion) : '\0'
-                };
-                for (int stri = 0 ; stri < sizeof(logstr) ; stri++) {
-                    if (logstr[stri]) {
-                        addch(logstr[stri]);
-                    }
-                }
-            }
+            addstr(logelem->move.string);
             if (!logelem->next) {
-                if (gamestate->checkmate) {
-                    addstr("\b#");
-                } else if (gamestate->stalemate) {
+                if (gamestate->stalemate) {
                     addstr(" stalemate");
                 }
             }
@@ -311,7 +291,8 @@
                 int eval_result = eval_move(gamestate, movestr, &move);
                 switch (eval_result) {
                 case VALID_MOVE_SYNTAX:
-                    net_send_data(opponent, NETCODE_MOVE, &move, sizeof(Move));
+                    net_send_data(opponent, NETCODE_MOVE, &move,
+                        sizeof(Move)-8);
                     code = net_recieve_code(opponent);
                     move.check = code == NETCODE_CHECK ||
                         code == NETCODE_CHECKMATE;
@@ -407,7 +388,7 @@
                 }
                 break;
             case NETCODE_MOVE:
-                net_recieve_data(opponent, &move, sizeof(Move));
+                net_recieve_data(opponent, &move, sizeof(Move)-8);
                 code = validate_move(gamestate, &move);
                 if (code == VALID_MOVE_SEMANTICS) {
                     apply_move(gamestate, &move);

mercurial