I'm working on a 3D game and i'm on walking at the moment but when I walk one step I then get a runtime error
'Expression: vector iterators incompatible'
Here is where walking is first called:
void Packets::handleMoving(Player* p, Stream* s)
{
printf("handling movement for player: %s\n", p->getUsername());
int newWalkCmdSteps = (p->packetSize - 5) / 2;
if(newWalkCmdSteps > WALKING_QUEUE_SIZE)
{
printWarning("Warning: walkTo(%d) command contains too many steps (%d).\n", p->packetType, newWalkCmdSteps);
return;
}
PlayerHandler::resetWalkingQueue(p);
Pos temp;
vector<Pos> tempPathWaypoints;
int firstStepX = s->readSignedWordBigEndianA();
for(int i = 0; i < newWalkCmdSteps; i++) {
temp.x = s->readSignedByte();
temp.y = s->readSignedByte();
tempPathWaypoints.push_back(temp);
}
int firstStepY = s->readSignedWordBigEndian(); //absPos
int isRunning = s->readSignedByteC() == 1; //seems always be 0 so useless..
PlayerHandler::addToWalkingQueue(p, firstStepX, firstStepY);
for(int i = 0; i < newWalkCmdSteps; i++) {
tempPathWaypoints[i].x += firstStepX;
tempPathWaypoints[i].y += firstStepY;
PlayerHandler::addToWalkingQueue(p, tempPathWaypoints[i].x, tempPathWaypoints[i].y);
}
}
What I have also found by using breakpoints is that the bottom forloop seems to be where the issue is.
When I add a break point on the following
tempPathWaypoints[i].x += firstStepX;
I get the runtime error but anywhere before that I do not.
Here are the rest of my walking functions. (Put it in pastebin too long for this thread)
I am pretty sure that the error is based in the addToWalkingQueue but I am not sure