0

我正在开发一款 3D 游戏,目前我正在走路,但是当我走一步时,我会遇到运行时错误

'表达式:向量迭代器不兼容'

这里是第一次调用walking的地方:

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);
    }
}

我通过使用断点还发现底部 forloop 似乎是问题所在。

当我在以下添加断点时

tempPathWaypoints[i].x += firstStepX;

我收到运行时错误,但在此之前的任何地方都没有。

这是我其余的步行功能。(对于这个线程来说,把它放在 pastebin 太长了)

http://pastebin.com/ZGiuL2Wf

我很确定错误是基于 addToWalkingQueue 但我不确定

4

0 回答 0