Every time I compile the code for a RTS Project I am working on, I get this error:
error C2664: 'std::_Vector_iterator<_Ty,_Alloc> std::vector<_Ty>::erase(std::_Vector_const_iterator<_Ty,_Alloc>)' : cannot convert parameter 1 from 'MAPTILE *' to 'std::_Vector_const_iterator<_Ty,_Alloc>'
The code area that I have for this method is this:
MAPTILE *startTile = GetTile(start);
MAPTILE *goalTile = GetTile(goal);
...
std::vector<MAPTILE*> open; //Create Our Open list
startTile->g = 0; //Init our starting point (SP)
startTile->f = H(start, goal);
startTile->open = true;
open.push_back(startTile); //Add SP to the Open list
bool found = false; // Search as long as a path hasnt been found,
while(!found && !open.empty()) // or there is no more tiles to search
{
MAPTILE * best = open[0]; // Find the best tile (i.e. the lowest F value)
int bestPlace = 0;
for(int i=1;i<open.size();i++)
if(open[i]->f < best->f)
{
best = open[i];
bestPlace = i;
}
if(best == NULL)break; //No path found
open[bestPlace]->open = false;
open.erase(&open[bestPlace]); // Take the best node out of the Open list
I have searched on this website and a few others, but I could not find the correct area.
I am reading "Programming a RTS Game With Direct3D" By Carl Granberg.
All of my code is right because I matched it with the source code, and I got the same error.
I am using Visual C++ 2008 Express Edition.
I have never gotten this error before.