X-Git-Url: https://git.auder.net/images/pieces/Cwda/bd.svg?a=blobdiff_plain;ds=sidebyside;f=server%2Fmodels%2FGame.js;h=92c013016034416daf8f27772acac4ae5553ecb0;hb=3b64b66722edfed26978c2894e5357d066f33943;hp=3fde91f8cb03b9b6fdcec573995777a35c53ce15;hpb=db1f1f9adb920605c7a16b060a7737e54636ee08;p=vchess.git diff --git a/server/models/Game.js b/server/models/Game.js index 3fde91f8..92c01301 100644 --- a/server/models/Game.js +++ b/server/models/Game.js @@ -242,6 +242,7 @@ const GameModel = query += modifs + " WHERE id = " + id; db.run(query); } + // NOTE: move, chat and delchat are mutually exclusive if (obj.move) { // Security: only update moves if index is right @@ -251,6 +252,10 @@ const GameModel = "WHERE gid = " + id; 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 " + @@ -275,7 +280,7 @@ const GameModel = "DELETE " + "FROM Chats " + "WHERE gid = " + id; - db.run(query, cb); + db.run(query); } }); },