Skip to content

Commit

Permalink
CGE: Move two globals functions to CGEEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Sep 16, 2011
1 parent a607247 commit 15bf805
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 2 additions & 0 deletions engines/cge/cge.h
Expand Up @@ -230,6 +230,8 @@ class CGEEngine : public Engine {
int takeEnum(const char **tab, const char *text);
int newRandom(int range);
void sndSetVolume();
Sprite *locate(int ref);
Sprite *spriteAt(int x, int y);

void snBackPt(Sprite *spr, int stp);
void snHBarrier(const int scene, const int barX);
Expand Down
18 changes: 18 additions & 0 deletions engines/cge/cge_main.cpp
Expand Up @@ -1221,6 +1221,24 @@ void CGEEngine::loadScript(const char *fname) {
error("Bad INI line %d [%s]", lcnt, fname);
}

Sprite *CGEEngine::locate(int ref) {
Sprite *spr = _vga->_showQ->locate(ref);
return (spr) ? spr : _vga->_spareQ->locate(ref);
}

Sprite *CGEEngine::spriteAt(int x, int y) {
Sprite *spr = NULL, * tail = _vga->_showQ->last();
if (tail) {
for (spr = tail->_prev; spr; spr = spr->_prev) {
if (! spr->_flags._hide && ! spr->_flags._tran) {
if (spr->shp()->solidAt(x - spr->_x, y - spr->_y))
break;
}
}
}
return spr;
}

void CGEEngine::mainLoop() {
_vga->show();
_snail_->runCom();
Expand Down
2 changes: 1 addition & 1 deletion engines/cge/events.cpp
Expand Up @@ -242,7 +242,7 @@ void Mouse::newMouse(Common::Event &event) {
CGEEvent &evt = _eventManager->getNextEvent();
evt._x = event.mouse.x;
evt._y = event.mouse.y;
evt._spritePtr = spriteAt(evt._x, evt._y);
evt._spritePtr = _vm->spriteAt(evt._x, evt._y);

switch (event.type) {
case Common::EVENT_MOUSEMOVE:
Expand Down
4 changes: 2 additions & 2 deletions engines/cge/snail.cpp
Expand Up @@ -964,7 +964,7 @@ void Snail::runCom() {
break;
}

Sprite *spr = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr));
Sprite *spr = ((snc->_ref >= 0) ? _vm->locate(snc->_ref) : ((Sprite *) snc->_ptr));
switch (snc->_com) {
case kSnLabel:
break;
Expand Down Expand Up @@ -1033,7 +1033,7 @@ void Snail::runCom() {
_vm->snCover(spr, snc->_val);
break;
case kSnUncover:
_vm->snUncover(spr, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr));
_vm->snUncover(spr, (snc->_val >= 0) ? _vm->locate(snc->_val) : ((Sprite *) snc->_ptr));
break;
case kSnKeep:
_vm->snKeep(spr, snc->_val);
Expand Down
1 change: 1 addition & 0 deletions engines/cge/snail.h
Expand Up @@ -70,6 +70,7 @@ class Snail {
bool _talkEnable;
Snail(CGEEngine *vm, bool turbo);
~Snail();

void runCom();
void addCom(SnCom com, int ref, int val, void *ptr);
void addCom2(SnCom com, int ref, int val, CallbackType cbType);
Expand Down
18 changes: 0 additions & 18 deletions engines/cge/vga13h.cpp
Expand Up @@ -64,11 +64,6 @@ Dac mkDac(uint8 r, uint8 g, uint8 b) {
return x;
}

Sprite *locate(int ref) {
Sprite *spr = _vga->_showQ->locate(ref);
return (spr) ? spr : _vga->_spareQ->locate(ref);
}

Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP)
: _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0),
_next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0),
Expand Down Expand Up @@ -556,19 +551,6 @@ void Sprite::sync(Common::Serializer &s) {
s.syncAsUint16LE(unused); // _next
}

Sprite *spriteAt(int x, int y) {
Sprite *spr = NULL, * tail = _vga->_showQ->last();
if (tail) {
for (spr = tail->_prev; spr; spr = spr->_prev) {
if (! spr->_flags._hide && ! spr->_flags._tran) {
if (spr->shp()->solidAt(x - spr->_x, y - spr->_y))
break;
}
}
}
return spr;
}

Queue::Queue(bool show) : _head(NULL), _tail(NULL), _show(show) {
}

Expand Down
3 changes: 0 additions & 3 deletions engines/cge/vga13h.h
Expand Up @@ -266,9 +266,6 @@ uint8 closest(CBLK *pal, CBLK x) {
#undef f
}

Sprite *spriteAt(int x, int y);
Sprite *locate(int ref);

} // End of namespace CGE

#endif

0 comments on commit 15bf805

Please sign in to comment.