Skip to content

Commit d880a2a

Browse files
committed
in case parseJson fails, log error (IN DEBUG MODE only)
1 parent 9efb99c commit d880a2a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/WsClient.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ void WsClient::parseServerList(const cpr::Response &response)
170170
{
171171
this->deathNote = ex.what();
172172
this->isDead = true;
173+
#ifndef NDEBUG
174+
spdlog::error(ex.what());
175+
#endif // DEBUG
173176
}
174177
}
175178

src/managers/LocalGameManager.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ inline LocalGameManager::LocalGameManager(sf::RenderWindow *windowPtr)
3636
}
3737

3838
/**
39-
* Create all pieces for both players and add them to pieceList, using std C++ random num generator
39+
* Create all pieces for both players (using std C++ PRNG), then place them on the board.
4040
*/
4141
inline void LocalGameManager::createAllPieces()
4242
{
4343
std::random_device randomDevice;
44-
std::mt19937 randEngine(randomDevice());
44+
std::mt19937 randEngine{randomDevice()};
4545
std::uniform_int_distribution<short> dist(1, std::numeric_limits<short>::max());
4646

4747
// Reserve container for pieces on board

src/managers/OnlineGameManager.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ inline void chk::OnlineGameManager::createAllPieces()
8787
std::vector<chk::PiecePtr> pieceList;
8888
pieceList.reserve(chk::NUM_PIECES);
8989

90-
auto redItr = payload.pieces_red().begin();
91-
auto blackItr = payload.pieces_black().begin();
92-
// create pieces objects, and position them on Board
90+
auto redItr = payload.pieces_red().begin(); // red iterator
91+
auto blackItr = payload.pieces_black().begin(); // black iterator
92+
// place them on board
9393
for (uint16_t row = 0; row < chk::NUM_ROWS; row++)
9494
{
9595
for (uint16_t col = 0; col < chk::NUM_COLS; col++)
@@ -132,7 +132,7 @@ inline void chk::OnlineGameManager::createAllPieces()
132132
this->playerBlack->receivePiece(pp);
133133
}
134134
}
135-
pieceList.clear(); // SAFE! no longer used.
135+
pieceList.clear(); // SAFE! no longer needed.
136136
this->startMoveListener();
137137
this->startCaptureListener();
138138
});

0 commit comments

Comments
 (0)