diff --git a/engines/agi/checks.cpp b/engines/agi/checks.cpp
index c3b31f6..16be58b 100644
a
|
b
|
|
25 | 25 | namespace Agi { |
26 | 26 | |
27 | 27 | int 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); |
28 | 30 | debugC(4, kDebugLevelSprites, "check position @ %d, %d", v->xPos, v->yPos); |
29 | 31 | |
30 | 32 | if (v->xPos < 0 || |
… |
… |
int AgiEngine::checkPosition(VtEntry *v) {
|
34 | 36 | ((~v->flags & fIgnoreHorizon) && v->yPos <= _game.horizon)) { |
35 | 37 | debugC(4, kDebugLevelSprites, "check position failed: x=%d, y=%d, h=%d, w=%d", |
36 | 38 | v->xPos, v->yPos, v->xSize, v->ySize); |
| 39 | debug(1, "\treturn #1 0"); |
37 | 40 | return 0; |
38 | 41 | } |
39 | 42 | |
40 | 43 | // MH1 needs this, but it breaks LSL1 |
41 | 44 | if (getVersion() >= 0x3000) { |
42 | | if (v->yPos < v->ySize) |
| 45 | if (v->yPos < v->ySize) { |
| 46 | debug(1, "\treturn #2 0"); |
43 | 47 | return 0; |
| 48 | } |
44 | 49 | } |
45 | 50 | |
| 51 | debug(1, "\treturn #3 1"); |
46 | 52 | return 1; |
47 | 53 | } |
48 | 54 | |
… |
… |
int AgiEngine::checkPosition(VtEntry *v) {
|
50 | 56 | * Check if there's another object on the way |
51 | 57 | */ |
52 | 58 | int AgiEngine::checkCollision(VtEntry *v) { |
| 59 | debug(1, "AgiEngine::checkCollision(v)"); |
53 | 60 | VtEntry *u; |
54 | 61 | |
55 | | if (v->flags & fIgnoreObjects) |
| 62 | if (v->flags & fIgnoreObjects) { |
| 63 | debug(1, "\treturn #1 0"); |
56 | 64 | return 0; |
| 65 | } |
57 | 66 | |
58 | 67 | for (u = _game.viewTable; u < &_game.viewTable[MAX_VIEWTABLE]; u++) { |
59 | 68 | if ((u->flags & (fAnimated | fDrawn)) != (fAnimated | fDrawn)) |
… |
… |
int AgiEngine::checkCollision(VtEntry *v) {
|
73 | 82 | // Same y, return error! |
74 | 83 | if (v->yPos == u->yPos) { |
75 | 84 | debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry); |
| 85 | debug(1, "\treturn #2 1"); |
76 | 86 | return 1; |
77 | 87 | } |
78 | 88 | |
… |
… |
int AgiEngine::checkCollision(VtEntry *v) {
|
80 | 90 | if ((v->yPos > u->yPos && v->yPos2 < u->yPos2) || |
81 | 91 | (v->yPos < u->yPos && v->yPos2 > u->yPos2)) { |
82 | 92 | debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry); |
| 93 | debug(1, "\treturn #3 1"); |
83 | 94 | return 1; |
84 | 95 | } |
85 | 96 | } |
86 | 97 | |
| 98 | debug(1, "\treturn #4 0"); |
87 | 99 | return 0; |
88 | 100 | |
89 | 101 | } |
90 | 102 | |
91 | 103 | int AgiEngine::checkPriority(VtEntry *v) { |
| 104 | debug(1, "AgiEngine::checkPriority(v)"); |
92 | 105 | int i, trigger, water, pass, pri; |
93 | 106 | uint8 *p0; |
94 | 107 | |
… |
… |
int AgiEngine::checkPriority(VtEntry *v) {
|
108 | 121 | setflag(fEgoWater, water ? true : false); |
109 | 122 | } |
110 | 123 | |
| 124 | debug(1, "\treturn #1 pass: %d", pass); |
111 | 125 | return pass; |
112 | 126 | } |
113 | 127 | |
… |
… |
int AgiEngine::checkPriority(VtEntry *v) {
|
157 | 171 | setflag(fEgoWater, water ? true : false); |
158 | 172 | } |
159 | 173 | |
| 174 | debug(1, "\treturn #2 pass: %d", pass); |
160 | 175 | return pass; |
161 | 176 | } |
162 | 177 | |
… |
… |
void AgiEngine::updatePosition() {
|
271 | 286 | */ |
272 | 287 | void AgiEngine::fixPosition(int n) { |
273 | 288 | 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; |
275 | 291 | |
276 | 292 | debugC(4, kDebugLevelSprites, "adjusting view table entry #%d (%d,%d)", n, v->xPos, v->yPos); |
277 | 293 | |
… |
… |
void AgiEngine::fixPosition(int n) {
|
282 | 298 | dir = 0; |
283 | 299 | count = size = 1; |
284 | 300 | |
285 | | while (!checkPosition(v) || checkCollision(v) || !checkPriority(v)) { |
| 301 | while (shouldQuit() && (!checkPosition(v) || checkCollision(v) || !checkPriority(v))) { |
286 | 302 | switch (dir) { |
287 | 303 | case 0: // west |
288 | 304 | v->xPos--; |
289 | | if (--count) |
| 305 | if (count && --count) |
290 | 306 | continue; |
291 | 307 | dir = 1; |
292 | 308 | break; |
293 | 309 | case 1: // south |
294 | 310 | v->yPos++; |
295 | | if (--count) |
| 311 | if (count && --count) |
296 | 312 | continue; |
297 | 313 | dir = 2; |
298 | 314 | size++; |
299 | 315 | break; |
300 | 316 | case 2: // east |
301 | 317 | v->xPos++; |
302 | | if (--count) |
| 318 | if (count && --count) |
303 | 319 | continue; |
304 | 320 | dir = 3; |
305 | 321 | break; |
306 | 322 | case 3: // north |
307 | 323 | v->yPos--; |
308 | | if (--count) |
| 324 | if (count && --count) |
309 | 325 | continue; |
310 | 326 | dir = 0; |
311 | 327 | size++; |