X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Fmodels%2FGame.js;h=4d06e48d38665eafc0a3f6db793bc97329da67f9;hb=89ffc919a31cc1cd24beadc63050d9097e7505f7;hp=cfaddfefbe306d0adecb617d06a4a22bcbe1feb5;hpb=e4b6e2850770c0511ddd17d29adf6a903b4792b1;p=vchess.git diff --git a/server/models/Game.js b/server/models/Game.js index cfaddfef..4d06e48d 100644 --- a/server/models/Game.js +++ b/server/models/Game.js @@ -242,8 +242,13 @@ 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) + if (!!obj.move) { // Security: only update moves if index is right query = @@ -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); }