Ticket #5916: agi-fix-debug.patch

File agi-fix-debug.patch, 3.8 KB (added by digitall, 12 years ago)

Fix, but with a bunch of debug as well...

  • engines/agi/checks.cpp

    diff --git a/engines/agi/checks.cpp b/engines/agi/checks.cpp
    index c3b31f6..16be58b 100644
    a b  
    2525namespace Agi {
    2626
    2727int AgiEngine::checkPosition(VtEntry *v) {
     28        debug(1, "AgiEngine::checkPosition(v) v->xPos:%d v->yPos:%d v->xSize:%d v->ySize:%d", v->xPos, v->yPos, v->xSize, v->ySize);
     29        debug(1, "\t _WIDTH:%d _HEIGHT:%d (~v->flags & fIgnoreHorizon):%d _game.horizon:%d", _WIDTH, _HEIGHT, (~v->flags & fIgnoreHorizon), _game.horizon);
    2830        debugC(4, kDebugLevelSprites, "check position @ %d, %d", v->xPos, v->yPos);
    2931
    3032        if (v->xPos < 0 ||
    int AgiEngine::checkPosition(VtEntry *v) {  
    3436                        ((~v->flags & fIgnoreHorizon) && v->yPos <= _game.horizon)) {
    3537                debugC(4, kDebugLevelSprites, "check position failed: x=%d, y=%d, h=%d, w=%d",
    3638                                v->xPos, v->yPos, v->xSize, v->ySize);
     39                debug(1, "\treturn #1 0");
    3740                return 0;
    3841        }
    3942
    4043        // MH1 needs this, but it breaks LSL1
    4144        if (getVersion() >= 0x3000) {
    42                 if (v->yPos < v->ySize)
     45                if (v->yPos < v->ySize) {
     46                        debug(1, "\treturn #2 0");
    4347                        return 0;
     48                }
    4449        }
    4550
     51        debug(1, "\treturn #3 1");
    4652        return 1;
    4753}
    4854
    int AgiEngine::checkPosition(VtEntry *v) {  
    5056 * Check if there's another object on the way
    5157 */
    5258int AgiEngine::checkCollision(VtEntry *v) {
     59        debug(1, "AgiEngine::checkCollision(v)");
    5360        VtEntry *u;
    5461
    55         if (v->flags & fIgnoreObjects)
     62        if (v->flags & fIgnoreObjects) {
     63                debug(1, "\treturn #1 0");
    5664                return 0;
     65        }
    5766
    5867        for (u = _game.viewTable; u < &_game.viewTable[MAX_VIEWTABLE]; u++) {
    5968                if ((u->flags & (fAnimated | fDrawn)) != (fAnimated | fDrawn))
    int AgiEngine::checkCollision(VtEntry *v) {  
    7382                // Same y, return error!
    7483                if (v->yPos == u->yPos) {
    7584                        debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
     85                        debug(1, "\treturn #2 1");
    7686                        return 1;
    7787                }
    7888
    int AgiEngine::checkCollision(VtEntry *v) {  
    8090                if ((v->yPos > u->yPos && v->yPos2 < u->yPos2) ||
    8191                                (v->yPos < u->yPos && v->yPos2 > u->yPos2)) {
    8292                        debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
     93                        debug(1, "\treturn #3 1");
    8394                        return 1;
    8495                }
    8596        }
    8697
     98        debug(1, "\treturn #4 0");
    8799        return 0;
    88100
    89101}
    90102
    91103int AgiEngine::checkPriority(VtEntry *v) {
     104        debug(1, "AgiEngine::checkPriority(v)");
    92105        int i, trigger, water, pass, pri;
    93106        uint8 *p0;
    94107
    int AgiEngine::checkPriority(VtEntry *v) {  
    108121                        setflag(fEgoWater, water ? true : false);
    109122                }
    110123
     124                debug(1, "\treturn #1 pass: %d", pass);
    111125                return pass;
    112126        }
    113127
    int AgiEngine::checkPriority(VtEntry *v) {  
    157171                setflag(fEgoWater, water ? true : false);
    158172        }
    159173
     174        debug(1, "\treturn #2 pass: %d", pass);
    160175        return pass;
    161176}
    162177
    void AgiEngine::updatePosition() {  
    271286 */
    272287void AgiEngine::fixPosition(int n) {
    273288        VtEntry *v = &_game.viewTable[n];
    274         int count, dir, size;
     289        debug(1, "AgiEngine::fixPosition(n: %d) adjusting view table entry #%d (%d,%d)", n, n, v->xPos, v->yPos);
     290        int dir, count, size;
    275291
    276292        debugC(4, kDebugLevelSprites, "adjusting view table entry #%d (%d,%d)", n, v->xPos, v->yPos);
    277293
    void AgiEngine::fixPosition(int n) {  
    282298        dir = 0;
    283299        count = size = 1;
    284300
    285         while (!checkPosition(v) || checkCollision(v) || !checkPriority(v)) {
     301        while (shouldQuit() && (!checkPosition(v) || checkCollision(v) || !checkPriority(v))) {
    286302                switch (dir) {
    287303                case 0: // west
    288304                        v->xPos--;
    289                         if (--count)
     305                        if (count && --count)
    290306                                continue;
    291307                        dir = 1;
    292308                        break;
    293309                case 1: // south
    294310                        v->yPos++;
    295                         if (--count)
     311                        if (count && --count)
    296312                                continue;
    297313                        dir = 2;
    298314                        size++;
    299315                        break;
    300316                case 2: // east
    301317                        v->xPos++;
    302                         if (--count)
     318                        if (count && --count)
    303319                                continue;
    304320                        dir = 3;
    305321                        break;
    306322                case 3: // north
    307323                        v->yPos--;
    308                         if (--count)
     324                        if (count && --count)
    309325                                continue;
    310326                        dir = 0;
    311327                        size++;