From a72f35ecf79c1c86014c6beb80936f504fec0b60 Mon Sep 17 00:00:00 2001 From: Idonotus <102253332+Idonotus@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:35:32 +0000 Subject: [PATCH] fixed queue set state crashing game --- src/client/scripts/esm/chess/logic/movepiece.js | 8 ++++---- src/client/scripts/esm/chess/logic/specialmove.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client/scripts/esm/chess/logic/movepiece.js b/src/client/scripts/esm/chess/logic/movepiece.js index fda23683..d60d1ba6 100644 --- a/src/client/scripts/esm/chess/logic/movepiece.js +++ b/src/client/scripts/esm/chess/logic/movepiece.js @@ -106,11 +106,11 @@ function makeMove(gamefile, move) { * @param {Move} move */ function deleteEnpassantAndSpecialRightsProperties(gamefile, move) { - state.queueSetState(move.changes, "enpassant", gamefile.enpassant, undefined); + state.queueSetState(gamefile, move.changes, "enpassant", undefined); let key = coordutil.getKeyFromCoords(move.startCoords); - state.queueSetState(move.changes, `specialRights.${key}`, gamefile.specialRights[key], undefined); + state.queueSetState(gamefile, move.changes, `specialRights.${key}`, undefined); key = coordutil.getKeyFromCoords(move.endCoords); - state.queueSetState(move.changes, `specialRights.${key}`, gamefile.specialRights[key], undefined); // We also delete the captured pieces specialRights for ANY move. + state.queueSetState(gamefile, move.changes, `specialRights.${key}`, undefined); // We also delete the captured pieces specialRights for ANY move. } /** @@ -145,7 +145,7 @@ function incrementMoveRule(gamefile, move, wasACapture) { // Reset if it was a capture or pawn movement const newMoveRule = (wasACapture || move.type.startsWith('pawns')) ? 0 : gamefile.moveRuleState + 1; - state.queueSetState(move.changes, 'moveRuleState', gamefile.moveRuleState, newMoveRule, {global: true}); + state.queueSetState(gamefile, move.changes, 'moveRuleState', newMoveRule, {global: true}); } /** diff --git a/src/client/scripts/esm/chess/logic/specialmove.js b/src/client/scripts/esm/chess/logic/specialmove.js index b7105c50..f6f4bde2 100644 --- a/src/client/scripts/esm/chess/logic/specialmove.js +++ b/src/client/scripts/esm/chess/logic/specialmove.js @@ -52,7 +52,7 @@ function kings(gamefile, piece, move) { const landSquare = [move.endCoords[0] - specialTag.dir, move.endCoords[1]]; // Delete the rook's special move rights const key = coordutil.getKeyFromCoords(pieceToCastleWith.coords); - state.queueSetState(moveChanges, `specialRights.${key}`, gamefile.specialRights[key], undefined); + state.queueSetState(gamefile, moveChanges, `specialRights.${key}`, undefined); boardchanges.queueMovePiece(moveChanges, pieceToCastleWith, landSquare); // Make normal move @@ -66,7 +66,7 @@ function pawns(gamefile, piece, move, { updateProperties = true } = {}) { // If it was a double push, then add the enpassant flag to the gamefile, and remove its special right! if (updateProperties && isPawnMoveADoublePush(piece.coords, move.endCoords)) { - state.queueSetState(moveChanges, "enpassant", gamefile.undefined, getEnPassantSquare(piece.coords, move.endCoords)); + state.queueSetState(gamefile, moveChanges, "enpassant", getEnPassantSquare(piece.coords, move.endCoords)); } const enpassantTag = move.enpassant; // -1/1