Add debug trace to understand why corr move 1 isn't recorded
[vchess.git] / server / models / Game.js
index cfaddfe..2e33031 100644 (file)
@@ -242,6 +242,11 @@ const GameModel =
         query += modifs + " WHERE id = " + id;
         db.run(query);
       }
+
+
+return cb({errmsg: JSON.stringify(obj.move)});
+
+
       // NOTE: move, chat and delchat are mutually exclusive
       if (obj.move)
       {
@@ -253,13 +258,13 @@ const GameModel =
         db.get(query, (err,ret) => {
           const m = obj.move;
 
+return cb({errmsg: ret.maxIdx + " " + m.idx + " " + (!ret.maxIdx || ret.maxIdx + 1 == m.idx) + " " + query});
 
 
           if (!ret.maxIdx || ret.maxIdx + 1 == m.idx) {
             query =
               "INSERT INTO Moves (gid, squares, played, idx) VALUES " +
               "(" + id + ",?," + m.played + "," + m.idx + ")";
-return cb({errmsg: (!ret.maxIdx || ret.maxIdx + 1 == m.idx) + " " + query});
             db.run(query, JSON.stringify(m.squares));
             cb(null);
           }