Commit 7bf1d43f authored by Loic Guegan's avatar Loic Guegan
Browse files

Debug, cleaning

parent a408577b
Pipeline #219708073 passed with stage
in 9 minutes and 39 seconds
......@@ -23,17 +23,21 @@ namespace ochess
editorMove.data=this;
FEN=FEN_INITIAL;
}
void Move::dump()
void Move::Dump()
{
cout << "isCheck:" << isCheck << " isPromotion:" << isPromotion << " isCheckMate:" << isCheckMate << " isPawn:" << isPawn << " isCapture:" << isCapture << " isLongCastle:" << isLongCastle << " isShortCastle:" << isShortCastle << " dst:" << dst << " promoteTo:" << promoteTo << " col:" << col << " clk:" << clk[0] << ":" << clk[1] << ":" << clk[2];
LOG(info) << "isCheck:" << isCheck << " isPromotion:" << isPromotion << " isCheckMate:" << isCheckMate << " isPawn:" << isPawn << " isCapture:" << isCapture << " isLongCastle:" << isLongCastle << " isShortCastle:" << isShortCastle << " dst:" << dst << " promoteTo:" << promoteTo << " col:" << col << " clk:" << clk[0] << ":" << clk[1] << ":" << clk[2];
}
Move::~Move()
{
if(this->parent !=nullptr){
this->parent->main=nullptr;
this->parent->editorMove.next=nullptr;
}
if (this->main != nullptr)
freeMove(this->main);
delete this->main;
for (auto v : this->variations)
freeMove(v);
delete v;
}
Move Move::FromLA(string move)
......@@ -66,7 +70,7 @@ namespace ochess
m->parent=this;
m->isWhite=!(this->isWhite);
}
void Move::addVariation(Move *m){
void Move::AddVariation(Move *m){
this->variations.push_back(m);
this->editorMove.variations.push_back(&m->editorMove);
}
......
......@@ -53,7 +53,7 @@ namespace ochess
*/
Move();
~Move();
void dump();
void Dump();
/// @brief Free a game AST
static void freeMove(Move *m);
......@@ -67,7 +67,7 @@ namespace ochess
bool IsLeaf();
void expand(Move*m);
bool operator== (const Move &m);
void addVariation(Move *m);
void AddVariation(Move *m);
};
......
......@@ -256,7 +256,7 @@ namespace ochess
read(); // Skip parenthesis for the parseLine function
Move *var=parseLine(l);
var->isWhite=!l->isWhite;
l->addVariation(var);
l->AddVariation(var);
skipSpaces();
}
......@@ -290,9 +290,10 @@ namespace ochess
}
if (root != l)
{ // Last created move is not usefull anymore
l->parent->main = nullptr;
l->parent->editorMove.next=nullptr;
free(l);
//l->parent->main = nullptr;
//l->parent->editorMove.next=nullptr;
//free(l);
delete l;
}
skipSpaces();
if (NEXTCHAR() == ')') // Read the last parenthesis of a variation
......
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