aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game_tab/Game.hpp2
-rw-r--r--src/game_tab/HalfMove.cpp22
-rw-r--r--src/game_tab/HalfMove.hpp7
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.cpp10
4 files changed, 24 insertions, 17 deletions
diff --git a/src/game_tab/Game.hpp b/src/game_tab/Game.hpp
index e0337ce..bc00c5a 100644
--- a/src/game_tab/Game.hpp
+++ b/src/game_tab/Game.hpp
@@ -5,8 +5,6 @@
#include "ochess.hpp"
#include <unordered_map>
-#define UNPACK_ABSOLUTE_MOVE(MOVE,SRC,DST) {(SRC)=(MOVE).substr(0,2);(DST)=(MOVE).substr(2,2);}
-
class Game {
std::string board;
std::string initial_fen;
diff --git a/src/game_tab/HalfMove.cpp b/src/game_tab/HalfMove.cpp
index 01621e2..ae63527 100644
--- a/src/game_tab/HalfMove.cpp
+++ b/src/game_tab/HalfMove.cpp
@@ -1,13 +1,13 @@
#include "HalfMove.hpp"
HalfMove::HalfMove(std::string move_absolute,std::string move_san) : capture(' ') {
- this->move_absolute=move_absolute;
+ SetAbsoluteMove(move_absolute);
this->move = move_san;
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
}
HalfMove::HalfMove(std::string move_absolute, std::string move_san, std::string fen) : fen(fen), capture(' ') {
- this->move_absolute=move_absolute;
+ SetAbsoluteMove(move_absolute);
this->move = move_san;
}
@@ -21,7 +21,8 @@ HalfMove::~HalfMove() {
}
HalfMove::HalfMove(HalfMove *m){
- move_absolute=m->move_absolute;
+ src=m->src;
+ dst=m->dst;
move=m->move;
fen=m->fen;
capture=m->capture;
@@ -137,6 +138,11 @@ void HalfMove::SetAsMainline() {
HalfMove *HalfMove::GetMainline() { return (mainline); }
+void HalfMove::SetAbsoluteMove(const std::string &move_absolute){
+ this->src=move_absolute.substr(0,2);
+ this->dst=move_absolute.substr(2,2);
+}
+
HalfMove::HalfMove(pgnp::HalfMove *m) : capture(' ') {
this->move = m->move;
this->nag = m->NAG;
@@ -151,6 +157,11 @@ HalfMove::HalfMove(pgnp::HalfMove *m) : capture(' ') {
}
}
+void HalfMove::GetAbsoluteMove(std::string &src,std::string &dst){
+ src=this->src;
+ dst=this->dst;
+}
+
void HalfMove::SetFen(std::string fen) { this->fen = fen; }
void HalfMove::Promote() {
@@ -213,8 +224,9 @@ bool HalfMove::IsABlackMove() { return (IsBlack); }
void HalfMove::BuildAndVerify(HalfMove *m, std::string fen) {
arbiter.Setup(fen);
- m->move_absolute=arbiter.ParseSAN(m->move);
- bool work = arbiter.Play(m->move_absolute,arbiter.ParseSANPromotion(m->move));
+ std::string move_absolute=arbiter.ParseSAN(m->move);
+ m->SetAbsoluteMove(move_absolute);
+ bool work = arbiter.Play(move_absolute,arbiter.ParseSANPromotion(m->move));
if (!work) {
wxLogDebug("Bug! %s", m->move);
}
diff --git a/src/game_tab/HalfMove.hpp b/src/game_tab/HalfMove.hpp
index 08a190b..9775c3e 100644
--- a/src/game_tab/HalfMove.hpp
+++ b/src/game_tab/HalfMove.hpp
@@ -21,11 +21,9 @@ class HalfMove : public cgeditor::CGEHalfMove {
std::string fen;
char capture;
void BuildAndVerify(HalfMove *m, std::string fen);
- std::string move_absolute;
+ std::string src,dst;
public:
-
-
HalfMove(HalfMove *m);
HalfMove(std::string move_absolute,std::string move_san);
HalfMove(std::string move_absolute,std::string move_san, std::string fen);
@@ -62,7 +60,8 @@ public:
void SetFen(std::string fen);
void SetCapture(char c);
bool IsABlackMove();
- std::string GetAbsoluteMove(){return move_absolute;};
+ void GetAbsoluteMove(std::string &src,std::string &dst);
+ void SetAbsoluteMove(const std::string &move_absolute);
/**
* @brief Build current move
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.cpp b/src/game_tab/left_panel/GameTabLeftPanel.cpp
index fa97f6f..4aaddb4 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.cpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.cpp
@@ -72,34 +72,32 @@ void GameTabLeftPanel::OnPlay(wxCommandEvent &event) {
}
void GameTabLeftPanel::Notify(bool skip_animation) {
- wxLogDebug("Called!");
// Update fen and captures
std::string fen = game->GetFen();
std::map<char, std::uint8_t> captures;
bool animate=false;
HalfMove *m = game->GetCurrentMove();
std::string src,dst;
-
// Update capture and check if we should to animations during moves change:
if (m){
captures = m->GetLineCaptures();
if(m->HasParent(last_move)){
- UNPACK_ABSOLUTE_MOVE(m->GetAbsoluteMove(),src,dst);
+ m->GetAbsoluteMove(src,dst);
animate=true;
}else if(m->HasChild(last_move)){
// Accessing last_move here is safe since it is still
// in the tree of moves (since HasChild found it so not deleted)
- UNPACK_ABSOLUTE_MOVE(last_move->GetAbsoluteMove(),dst,src);
+ last_move->GetAbsoluteMove(dst,src);
animate=true;
}
} else if(game->GetNextMove()){ // First move animation
HalfMove *next=game->GetNextMove();
if(next==last_move){
- UNPACK_ABSOLUTE_MOVE(game->GetNextMove()->GetAbsoluteMove(),dst,src);
+ game->GetNextMove()->GetAbsoluteMove(dst,src);
animate=true;
}
}
-
+
// Update board canvas:
if(skip_animation || !animate){
board_canvas->SetupBoard(chessarbiter::FENParser::Parse(fen).board,