Skip to content

Commit

Permalink
ChessGame: remove improper references
Browse files Browse the repository at this point in the history
See #317.

In these cases, `$board` is an array that is not modified, and `$p`
is a ChessPiece instance.
  • Loading branch information
hemberger committed May 26, 2020
1 parent a2b7430 commit 65a3b83
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Default/ChessGame.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function getMoves() {

public function getFENString() {
$fen = '';
$board =& $this->getBoard();
$board = $this->getBoard();
$blanks = 0;
for($y=0; $y < 8; $y++) {
if($y > 0) {
Expand Down Expand Up @@ -457,7 +457,7 @@ public static function movePiece(array &$board, array &$hasMoved, $x, $y, $toX,
}
$pieceTaken = $board[$toY][$toX];
$board[$toY][$toX] = $board[$y][$x];
$p =& $board[$toY][$toX];
$p = $board[$toY][$toX];
$board[$y][$x] = null;
if($p == null) {
throw new Exception('Trying to move non-existent piece: ' . var_export($board, true));
Expand Down Expand Up @@ -541,7 +541,7 @@ public static function undoMovePiece(array &$board, array &$hasMoved, $x, $y, $t
throw new Exception('Undoing move onto another piece? x=' . $x . ', y=' . $y);
}
$board[$y][$x] = $board[$toY][$toX];
$p =& $board[$y][$x];
$p = $board[$y][$x];
if($p == null) {
throw new Exception('Trying to undo move of a non-existent piece: ' . var_export($board, true));
}
Expand Down Expand Up @@ -620,7 +620,7 @@ public function tryMove($x, $y, $toX, $toY, $forAccountID, $pawnPromotionPiece)
$moveInfo = ChessGame::movePiece($this->board, $this->getHasMoved(), $x, $y, $toX, $toY, $pawnPromotionPiece);

//We have taken the move, we should refresh $p
$p =& $this->board[$toY][$toX];
$p = $this->board[$toY][$toX];

$pieceTakenID = null;
if($moveInfo['PieceTaken'] != null) {
Expand Down

0 comments on commit 65a3b83

Please sign in to comment.