Address some valgrind-detected problems, flag others for later.
[tagua/yd.git] / src / core / defaulttype.cpp
blob11fc235ed3bdb6da394edfc070071373204f949d
1 #include "defaultstate.h"
2 #include "defaulttype.h"
3 #include "move.h"
5 #include <KDebug>
7 bool DefaultType::canMove(const Piece& piece, const Piece&,
8 Move& move, const IState* state) const {
9 const DefaultState* dstate = dynamic_cast<const DefaultState*>(state);
10 if (dstate == NULL) {
11 kDebug() << "use of a non-DefaultState-derived state with DefaultType";
12 return false;
15 std::vector<const Point*> moves = dstate->theoreticalMoves(piece, move.src());
17 // theoreticalMoves() allocates Point objects for us, we must ensure
18 // all of them are freed, so we visit the whole moves vector.
19 bool ret = false;
20 for (std::vector<const Point*>::const_iterator it = moves.begin();
21 it != moves.end(); it++) {
22 if (move.dst() == **it)
23 ret = true;
24 delete *it;
27 return ret;