diff options
author | Paul Gilbert | 2011-07-15 20:43:29 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-07-15 20:43:29 +1000 |
commit | 11fa6b941c520129c017c946474114afa71fe41f (patch) | |
tree | c489ef5bd495514a72c2b85ec01d6f7de0ff24b6 /engines/cge | |
parent | c3bed46ba06046c8ba76c12c42d016f63beb6331 (diff) | |
download | scummvm-rg350-11fa6b941c520129c017c946474114afa71fe41f.tar.gz scummvm-rg350-11fa6b941c520129c017c946474114afa71fe41f.tar.bz2 scummvm-rg350-11fa6b941c520129c017c946474114afa71fe41f.zip |
CGE: Fix some errors in the pathfinder setup
Diffstat (limited to 'engines/cge')
-rw-r--r-- | engines/cge/cge.cpp | 2 | ||||
-rw-r--r-- | engines/cge/walk.cpp | 69 | ||||
-rw-r--r-- | engines/cge/walk.h | 8 |
3 files changed, 24 insertions, 55 deletions
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 0861e3e7f2..e192774f45 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -68,6 +68,7 @@ void CGEEngine::setup() { VFile::init(); Bitmap::init(); Talk::init(); + Cluster::init(this); // Initialise engine objects _text = new Text(this, progName(), 128); @@ -132,6 +133,7 @@ CGEEngine::~CGEEngine() { Bitmap::deinit(); VFile::deinit(); Vga::deinit(); + Cluster::init(this); // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp index e33638b958..0e31e2e541 100644 --- a/engines/cge/walk.cpp +++ b/engines/cge/walk.cpp @@ -27,6 +27,7 @@ #include "common/scummsys.h" #include "cge/walk.h" +#include "cge/cge.h" #include "cge/sound.h" #include "cge/startup.h" #include "cge/config.h" @@ -47,14 +48,16 @@ namespace CGE { -WALK *_hero; +extern Bar _barriers[]; -struct TabDir { - int xd, yd; -}; +WALK *_hero; uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT]; +CGEEngine *Cluster::_vm; +void Cluster::init(CGEEngine *vm) { + _vm = vm; +} uint8 &Cluster::cell() { return _map[_b][_a]; @@ -64,49 +67,11 @@ bool Cluster::isValid() const { return (_a >= 0) && (_a < MAP_XCNT) && (_b >= 0) && (_b < MAP_ZCNT); } -bool Cluster::Protected() { -/* - if (A == Barriers[Now]._vert || B == Barriers[Now]._horz) - return true; - - _DX = (MAP_ZCNT << 8) + MAP_XCNT; - _BX = (uint16) this; - - asm mov ax,1 - asm mov cl,[bx].(COUPLE)A - asm mov ch,[bx].(COUPLE)B - asm test cx,0x8080 // (A < 0) || (B < 0) - asm jnz xit - - asm cmp cl,dl - asm jge xit - asm cmp ch,dh - asm jge xit - - // if (A < 0 || A >= MAP_XCNT || B < 0 || B >= MAP_ZCNT) return true; - - asm mov al,dl - asm mul ch - asm xor ch,ch - asm add ax,cx - asm mov bx,ax - _BX += (uint16) Map; - //asm add bx,offset CLUSTER::Map - asm mov al,[bx] - asm and ax,0xFF - asm jz xit - asm mov ax,1 - - // return Map[B][A] != 0; - - xit: return _AX; - */ - - warning("STUB: CLUSTER::Protected()"); - return true; +bool Cluster::chkBar() const { + assert(_vm->_now <= CAVE_MAX); + return (_a == _barriers[_vm->_now]._horz) && (_b == _barriers[_vm->_now]._vert); } - Cluster XZ(int x, int y) { if (y < MAP_TOP) y = MAP_TOP; @@ -125,7 +90,7 @@ Cluster XZ(Couple xy) { } WALK::WALK(CGEEngine *vm, BMP_PTR *shpl) - : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _vm(vm) { + : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _level(0), _vm(vm) { } @@ -221,15 +186,13 @@ void WALK::park() { void WALK::findWay(Cluster c) { if (c != _here) { - _level = 0; - for (_findLevel = 1; _findLevel <= MAX_FIND_LEVEL; _findLevel++) { signed char x, z; _here.split(x, z); - _target = (z << 8) | x; + _target = Couple(x, z); c.split(x, z); - if (find1Way(XZ(x, z))) + if (find1Way(Cluster(x, z))) break; } _tracePtr = (_findLevel > MAX_FIND_LEVEL) ? -1 : (_findLevel - 1); @@ -289,7 +252,7 @@ bool WALK::find1Way(Cluster c) { const Cluster tab[4] = { Cluster(-1, 0), Cluster(1, 0), Cluster(0, -1), Cluster(0, 1)}; const int tabLen = 4; - if (c == _here) + if (c == _target) // Found destination return true; @@ -298,7 +261,7 @@ bool WALK::find1Way(Cluster c) { return false; // Look for barriers - if (c.Protected()) + if (c.chkBar()) return false; if (c.cell()) @@ -329,7 +292,7 @@ bool WALK::find1Way(Cluster c) { _trace[_level] = start; return true; } - } while (c.Protected() && !c.cell()); + } while (c.chkBar() && !c.cell()); } return false; diff --git a/engines/cge/walk.h b/engines/cge/walk.h index 30eb727e2c..eb29d9b462 100644 --- a/engines/cge/walk.h +++ b/engines/cge/walk.h @@ -84,10 +84,14 @@ public: class Cluster : public Couple { public: static uint8 _map[MAP_ZCNT][MAP_XCNT]; + static CGEEngine *_vm; + + static void init(CGEEngine *vm); +public: uint8 &cell(); Cluster() : Couple() { } Cluster(int a, int b) : Couple(a, b) { } - bool Protected(); + bool chkBar() const; bool isValid() const; }; @@ -101,7 +105,7 @@ public: int _tracePtr; int _level; int _findLevel; - int _target; + Couple _target; Cluster _trace[MAX_FIND_LEVEL]; enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir; |