Commit 23fbe29a authored by Frederik Schwarzer's avatar Frederik Schwarzer

Do not shadow variables.

parent 298b47b4
......@@ -317,11 +317,11 @@ bool Game::playMove(const Player &player, const Stone &stone, bool undoable)
m_currentMove++;
if (undoable) { // Do undo stuff if desired
Player *player;
Player *playerTemp;
UndoCommand::MoveType moveType;
QString undoStr;
if (tmp->isWhite()) {
player = &m_whitePlayer;
playerTemp = &m_whitePlayer;
if (stone.isValid()) {
moveType = UndoCommand::MoveType::Stone;
undoStr = i18nc("%1 stone coordinate", "White %1", stone.toString());
......@@ -330,7 +330,7 @@ bool Game::playMove(const Player &player, const Stone &stone, bool undoable)
undoStr = i18n("White passed");
}
} else {
player = &m_blackPlayer;
playerTemp = &m_blackPlayer;
if (stone.isValid()) {
moveType = UndoCommand::MoveType::Stone;
undoStr = i18nc("%1 stone coordinate", "Black %1", stone.toString());
......@@ -340,7 +340,7 @@ bool Game::playMove(const Player &player, const Stone &stone, bool undoable)
}
}
//qDebug() << "Push new undo command" << undoStr;
m_undoStack.push(new UndoCommand(player, moveType, undoStr));
m_undoStack.push(new UndoCommand(playerTemp, moveType, undoStr));
}
if (tmp->isWhite()) { // Determine the next current player
......@@ -378,14 +378,14 @@ bool Game::generateMove(const Player &player, bool undoable)
}
if (waitResponse(true)) {
bool boardChange = false;
Player *player;
Player *playerTemp;
UndoCommand::MoveType moveType;
QString undoStr;
if (tmp->isWhite()) {
player = &m_whitePlayer;
playerTemp = &m_whitePlayer;
} else {
player = &m_blackPlayer;
playerTemp = &m_blackPlayer;
}
if (m_response == QLatin1String("PASS")) {
m_currentMove++;
......@@ -425,7 +425,7 @@ bool Game::generateMove(const Player &player, bool undoable)
if (undoable) {
//qDebug() << "Push new undo command" << undoStr;
m_undoStack.push(new UndoCommand(player, moveType, undoStr));
m_undoStack.push(new UndoCommand(playerTemp, moveType, undoStr));
}
if (tmp->isWhite()) {
setCurrentPlayer(m_blackPlayer);
......
......@@ -138,33 +138,33 @@ void GameScene::showTerritory(bool show)
void GameScene::updateStoneItems()
{
QGraphicsPixmapItem *item;
QGraphicsPixmapItem *stoneItem;
const int halfStoneSize = m_stonePixmapSize.width() / 2;
const Stone lastStone = (m_game->moves().size() > 0) ? m_game->lastMove().stone() : Stone::Invalid;
foreach (item, m_stoneItems) { // Clear all stone items
removeItem(item);
foreach (stoneItem, m_stoneItems) { // Clear all stone items
removeItem(stoneItem);
}
m_stoneItems.clear();
foreach (const Stone &stone, m_game->stones(m_game->blackPlayer())) {
ThemeRenderer::Element element = (stone == lastStone) ? ThemeRenderer::Element::BlackStoneLast : ThemeRenderer::Element::BlackStone;
item = addPixmap(ThemeRenderer::self()->renderElement(element, m_stonePixmapSize));
item->setZValue(2);
stoneItem = addPixmap(ThemeRenderer::self()->renderElement(element, m_stonePixmapSize));
stoneItem->setZValue(2);
const int xOff = stone.x() >= 'I' ? stone.x() - 'A' - 1 : stone.x() - 'A';
item->setPos(QPointF(m_gridRect.x() + xOff * m_cellSize - halfStoneSize + 1,
stoneItem->setPos(QPointF(m_gridRect.x() + xOff * m_cellSize - halfStoneSize + 1,
m_gridRect.y() + (m_boardSize - stone.y()) * m_cellSize - halfStoneSize + 1));
m_stoneItems.append(item);
m_stoneItems.append(stoneItem);
}
foreach (const Stone &stone, m_game->stones(m_game->whitePlayer())) {
ThemeRenderer::Element element = (stone == lastStone) ? ThemeRenderer::Element::WhiteStoneLast : ThemeRenderer::Element::WhiteStone;
item = addPixmap(ThemeRenderer::self()->renderElement(element, m_stonePixmapSize));
item->setZValue(2);
stoneItem = addPixmap(ThemeRenderer::self()->renderElement(element, m_stonePixmapSize));
stoneItem->setZValue(2);
const int xOff = stone.x() >= 'I' ? stone.x() - 'A' - 1 : stone.x() - 'A';
item->setPos(QPointF(m_gridRect.x() + xOff * m_cellSize - halfStoneSize + 1,
stoneItem->setPos(QPointF(m_gridRect.x() + xOff * m_cellSize - halfStoneSize + 1,
m_gridRect.y() + (m_boardSize - stone.y()) * m_cellSize - halfStoneSize + 1));
m_stoneItems.append(item);
m_stoneItems.append(stoneItem);
}
if (m_showMoveNumbers) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment