diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agos/contain.cpp | 16 | ||||
-rw-r--r-- | engines/agos/debugger.cpp | 2 | ||||
-rw-r--r-- | engines/agos/intern.h | 15 | ||||
-rw-r--r-- | engines/agos/items.cpp | 28 | ||||
-rw-r--r-- | engines/agos/res.cpp | 54 | ||||
-rw-r--r-- | engines/agos/rooms.cpp | 22 | ||||
-rw-r--r-- | engines/agos/saveload.cpp | 28 | ||||
-rw-r--r-- | engines/agos/script.cpp | 12 | ||||
-rw-r--r-- | engines/agos/script_e1.cpp | 24 | ||||
-rw-r--r-- | engines/agos/script_e2.cpp | 10 | ||||
-rw-r--r-- | engines/agos/script_ff.cpp | 2 | ||||
-rw-r--r-- | engines/agos/script_s1.cpp | 2 | ||||
-rw-r--r-- | engines/agos/script_ww.cpp | 2 | ||||
-rw-r--r-- | engines/agos/string.cpp | 2 |
14 files changed, 117 insertions, 102 deletions
diff --git a/engines/agos/contain.cpp b/engines/agos/contain.cpp index b5ca344905..891ac36d30 100644 --- a/engines/agos/contain.cpp +++ b/engines/agos/contain.cpp @@ -34,8 +34,8 @@ int AGOSEngine::canPlace(Item *x, Item *y) { Item *z = derefItem(x->parent); if (getGameType() == GType_ELVIRA1) { - SubPlayer *p = (SubPlayer *)findChildOfType(y, 3); - SubContainer *c = (SubContainer *)findChildOfType(y, 7); + SubPlayer *p = (SubPlayer *)findChildOfType(y, kPlayerType); + SubContainer *c = (SubContainer *)findChildOfType(y, kContainerType); int cap = 0; int wt; @@ -59,7 +59,7 @@ int AGOSEngine::canPlace(Item *x, Item *y) { return -2; /* Too heavy */ } } else { - SubObject *o = (SubObject *)findChildOfType(y, 2); + SubObject *o = (SubObject *)findChildOfType(y, kObjectType); int ct; int cap = 0; @@ -120,11 +120,11 @@ int AGOSEngine::sizeRec(Item *x, int d) { } int AGOSEngine::sizeOfRec(Item *i, int d) { - SubObject *o = (SubObject *)findChildOfType(i, 2); + SubObject *o = (SubObject *)findChildOfType(i, kObjectType); if (getGameType() == GType_ELVIRA1) { - SubPlayer *p = (SubPlayer *)findChildOfType(i, 3); - SubContainer *c = (SubContainer *)findChildOfType(i, 7); + SubPlayer *p = (SubPlayer *)findChildOfType(i, kPlayerType); + SubContainer *c = (SubContainer *)findChildOfType(i, kContainerType); if ((c) && (c->flags & 1)) { if (o) @@ -174,10 +174,10 @@ int AGOSEngine::weightRec(Item *x, int d) { } int AGOSEngine::weightOf(Item *x) { - SubObject *o = (SubObject *)findChildOfType(x, 2); + SubObject *o = (SubObject *)findChildOfType(x, kObjectType); if (getGameType() == GType_ELVIRA1) { - SubPlayer *p = (SubPlayer *)findChildOfType(x, 3); + SubPlayer *p = (SubPlayer *)findChildOfType(x, kPlayerType); if (o) return o->objectWeight; if (p) diff --git a/engines/agos/debugger.cpp b/engines/agos/debugger.cpp index ce50460621..3fc5a1f967 100644 --- a/engines/agos/debugger.cpp +++ b/engines/agos/debugger.cpp @@ -174,7 +174,7 @@ bool Debugger::Cmd_SetObjectFlag(int argc, const char **argv) { prop = atoi(argv[2]); if (obj >= 1 && obj < _vm->_itemArraySize) { - SubObject *o = (SubObject *)_vm->findChildOfType(_vm->derefItem(obj), 2); + SubObject *o = (SubObject *)_vm->findChildOfType(_vm->derefItem(obj), kObjectType); if (o != NULL) { if (o->objectFlags & (1 << prop) && prop < 16) { uint offs = _vm->getOffsetOfChild2Param(o, 1 << prop); diff --git a/engines/agos/intern.h b/engines/agos/intern.h index a863dc7c0f..cac5813ca4 100644 --- a/engines/agos/intern.h +++ b/engines/agos/intern.h @@ -28,6 +28,21 @@ namespace AGOS { +enum ChildType { + kRoomType = 1, + kObjectType = 2, + kPlayerType = 3, + kSuperRoomType = 4, + + kGenExitType = 4, // FIXME: Clash with kSuperRoomType ?!? + + kContainerType = 7, + kChainType = 8, + kUserFlagType = 9, + + kInheritType = 255 +}; + struct Child { Child *next; uint16 type; diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp index a911bee5a5..9a46b6e8ac 100644 --- a/engines/agos/items.cpp +++ b/engines/agos/items.cpp @@ -66,7 +66,7 @@ bool AGOSEngine::hasIcon(Item *item) { if (getGameType() == GType_ELVIRA1) { return (getUserFlag(item, 7) != 0); } else { - SubObject *child = (SubObject *)findChildOfType(item, 2); + SubObject *child = (SubObject *)findChildOfType(item, kObjectType); return (child && (child->objectFlags & kOFIcon) != 0); } } @@ -75,7 +75,7 @@ uint AGOSEngine::itemGetIconNumber(Item *item) { if (getGameType() == GType_ELVIRA1) { return getUserFlag(item, 7); } else { - SubObject *child = (SubObject *)findChildOfType(item, 2); + SubObject *child = (SubObject *)findChildOfType(item, kObjectType); uint offs; if (child == NULL || !(child->objectFlags & kOFIcon)) @@ -97,7 +97,7 @@ void AGOSEngine::createPlayer() { _currentPlayer->adjective = -1; _currentPlayer->noun = 10000; - p = (SubPlayer *)allocateChildBlock(_currentPlayer, 3, sizeof(SubPlayer)); + p = (SubPlayer *)allocateChildBlock(_currentPlayer, kPlayerType, sizeof(SubPlayer)); if (p == NULL) error("createPlayer: player create failure"); @@ -135,14 +135,14 @@ Child *AGOSEngine::findChildOfType(Item *i, uint type) { int AGOSEngine::getUserFlag(Item *item, int a) { SubUserFlag *subUserFlag; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) return 0; if (a < 0 || a > 7) return 0; - return subUserFlag->userFlags[a]; + return subUserFlag->userFlags[a]; } int AGOSEngine::getUserFlag1(Item *item, int a) { @@ -151,7 +151,7 @@ int AGOSEngine::getUserFlag1(Item *item, int a) { if (item == NULL || item == _dummyItem2 || item == _dummyItem3) return -1; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) return 0; @@ -164,9 +164,9 @@ int AGOSEngine::getUserFlag1(Item *item, int a) { void AGOSEngine::setUserFlag(Item *item, int a, int b) { SubUserFlag *subUserFlag; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) { - subUserFlag = (SubUserFlag *) allocateChildBlock(item, 9, sizeof(SubUserFlag)); + subUserFlag = (SubUserFlag *)allocateChildBlock(item, kUserFlagType, sizeof(SubUserFlag)); } if (a < 0 || a > 7) @@ -178,7 +178,7 @@ void AGOSEngine::setUserFlag(Item *item, int a, int b) { int AGOSEngine::getUserItem(Item *item, int n) { SubUserFlag *subUserFlag; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) return 0; @@ -191,9 +191,9 @@ int AGOSEngine::getUserItem(Item *item, int n) { void AGOSEngine::setUserItem(Item *item, int n, int m) { SubUserFlag *subUserFlag; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) { - subUserFlag = (SubUserFlag *) allocateChildBlock(item, 9, sizeof(SubUserFlag)); + subUserFlag = (SubUserFlag *)allocateChildBlock(item, kUserFlagType, sizeof(SubUserFlag)); } if (n == 0) @@ -201,15 +201,15 @@ void AGOSEngine::setUserItem(Item *item, int n, int m) { } bool AGOSEngine::isRoom(Item *item) { - return findChildOfType(item, 1) != NULL; + return findChildOfType(item, kRoomType) != NULL; } bool AGOSEngine::isObject(Item *item) { - return findChildOfType(item, 2) != NULL; + return findChildOfType(item, kObjectType) != NULL; } bool AGOSEngine::isPlayer(Item *item) { - return findChildOfType(item, 3) != NULL; + return findChildOfType(item, kPlayerType) != NULL; } uint AGOSEngine::getOffsetOfChild2Param(SubObject *child, uint prop) { diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index 394c4956ae..4898cc9a45 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -350,13 +350,13 @@ void AGOSEngine::readItemFromGamePc(Common::SeekableReadStream *in, Item *item) } void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) { - if (type == 1) { - SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, 1, sizeof(SubRoom)); + if (type == kRoomType) { + SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, kRoomType, sizeof(SubRoom)); subRoom->roomShort = in->readUint32BE(); subRoom->roomLong = in->readUint32BE(); subRoom->flags = in->readUint16BE(); - } else if (type == 2) { - SubObject *subObject = (SubObject *)allocateChildBlock(item, 2, sizeof(SubObject)); + } else if (type == kObjectType) { + SubObject *subObject = (SubObject *)allocateChildBlock(item, kObjectType, sizeof(SubObject)); in->readUint32BE(); in->readUint32BE(); in->readUint32BE(); @@ -364,8 +364,8 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui subObject->objectSize = in->readUint16BE(); subObject->objectWeight = in->readUint16BE(); subObject->objectFlags = in->readUint16BE(); - } else if (type == 4) { - SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, 4, sizeof(SubGenExit)); + } else if (type == kGenExitType) { + SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, kGenExitType, sizeof(SubGenExit)); genExit->dest[0] = (uint16)fileReadItemID(in); genExit->dest[1] = (uint16)fileReadItemID(in); genExit->dest[2] = (uint16)fileReadItemID(in); @@ -378,14 +378,14 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); - } else if (type == 7) { - SubContainer *container = (SubContainer *)allocateChildBlock(item, 7, sizeof(SubContainer)); + } else if (type == kContainerType) { + SubContainer *container = (SubContainer *)allocateChildBlock(item, kContainerType, sizeof(SubContainer)); container->volume = in->readUint16BE(); container->flags = in->readUint16BE(); - } else if (type == 8) { - SubChain *chain = (SubChain *)allocateChildBlock(item, 8, sizeof(SubChain)); + } else if (type == kChainType) { + SubChain *chain = (SubChain *)allocateChildBlock(item, kChainType, sizeof(SubChain)); chain->chChained = (uint16)fileReadItemID(in); - } else if (type == 9) { + } else if (type == kUserFlagType) { setUserFlag(item, 0, in->readUint16BE()); setUserFlag(item, 1, in->readUint16BE()); setUserFlag(item, 2, in->readUint16BE()); @@ -394,13 +394,13 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui setUserFlag(item, 5, in->readUint16BE()); setUserFlag(item, 6, in->readUint16BE()); setUserFlag(item, 7, in->readUint16BE()); - SubUserFlag *subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + SubUserFlag *subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); subUserFlag->userItems[0] = (uint16)fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); - } else if (type == 255) { - SubInherit *inherit = (SubInherit *)allocateChildBlock(item, 255, sizeof(SubInherit)); + } else if (type == kInheritType) { + SubInherit *inherit = (SubInherit *)allocateChildBlock(item, kInheritType, sizeof(SubInherit)); inherit->inMaster = (uint16)fileReadItemID(in); } else { error("readItemChildren: invalid type %d", type); @@ -408,7 +408,7 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui } void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) { - if (type == 1) { + if (type == kRoomType) { uint fr1 = in->readUint16BE(); uint fr2 = in->readUint16BE(); uint i, size; @@ -420,14 +420,14 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * if (j & 3) size += sizeof(subRoom->roomExit[0]); - subRoom = (SubRoom *)allocateChildBlock(item, 1, size); + subRoom = (SubRoom *)allocateChildBlock(item, kRoomType, size); subRoom->subroutine_id = fr1; subRoom->roomExitStates = fr2; for (i = k = 0, j = fr2; i != 6; i++, j >>= 2) if (j & 3) subRoom->roomExit[k++] = (uint16)fileReadItemID(in); - } else if (type == 2) { + } else if (type == kObjectType) { uint32 fr = in->readUint32BE(); uint i, k, size; SubObject *subObject; @@ -437,7 +437,7 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * if (fr & (1 << i)) size += sizeof(subObject->objectFlagValue[0]); - subObject = (SubObject *)allocateChildBlock(item, 2, size); + subObject = (SubObject *)allocateChildBlock(item, kObjectType, size); subObject->objectFlags = fr; k = 0; @@ -450,7 +450,7 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * if (getGameType() != GType_ELVIRA2) subObject->objectName = (uint16)in->readUint32BE(); - } else if (type == 4) { + } else if (type == kSuperRoomType) { assert(getGameType() == GType_ELVIRA2); uint i, j, k, size; @@ -467,7 +467,7 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * for (i = 0; i != j; i++) size += sizeof(subSuperRoom->roomExitStates[0]); - subSuperRoom = (SubSuperRoom *)allocateChildBlock(item, 4, size); + subSuperRoom = (SubSuperRoom *)allocateChildBlock(item, kSuperRoomType, size); subSuperRoom->subroutine_id = id; subSuperRoom->roomX = x; subSuperRoom->roomY = y; @@ -475,20 +475,20 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * for (i = k = 0; i != j; i++) subSuperRoom->roomExitStates[k++] = in->readUint16BE(); - } else if (type == 7) { - SubContainer *container = (SubContainer *)allocateChildBlock(item, 7, sizeof(SubContainer)); + } else if (type == kContainerType) { + SubContainer *container = (SubContainer *)allocateChildBlock(item, kContainerType, sizeof(SubContainer)); container->volume = in->readUint16BE(); container->flags = in->readUint16BE(); - } else if (type == 8) { - SubChain *chain = (SubChain *)allocateChildBlock(item, 8, sizeof(SubChain)); + } else if (type == kChainType) { + SubChain *chain = (SubChain *)allocateChildBlock(item, kChainType, sizeof(SubChain)); chain->chChained = (uint16)fileReadItemID(in); - } else if (type == 9) { + } else if (type == kUserFlagType) { setUserFlag(item, 0, in->readUint16BE()); setUserFlag(item, 1, in->readUint16BE()); setUserFlag(item, 2, in->readUint16BE()); setUserFlag(item, 3, in->readUint16BE()); - } else if (type == 255) { - SubInherit *inherit = (SubInherit *)allocateChildBlock(item, 255, sizeof(SubInherit)); + } else if (type == kInheritType) { + SubInherit *inherit = (SubInherit *)allocateChildBlock(item, kInheritType, sizeof(SubInherit)); inherit->inMaster = (uint16)fileReadItemID(in); } else { error("readItemChildren: invalid type %d", type); diff --git a/engines/agos/rooms.cpp b/engines/agos/rooms.cpp index af1bd0fe93..5e612080df 100644 --- a/engines/agos/rooms.cpp +++ b/engines/agos/rooms.cpp @@ -49,7 +49,7 @@ uint16 AGOSEngine::getDoorState(Item *item, uint16 d) { uint16 mask = 3; uint16 n; - SubRoom *subRoom = (SubRoom *)findChildOfType(item, 1); + SubRoom *subRoom = (SubRoom *)findChildOfType(item, kRoomType); if (subRoom == NULL) return 0; @@ -66,7 +66,7 @@ uint16 AGOSEngine::getExitOf(Item *item, uint16 d) { uint16 x; uint16 y = 0; - subRoom = (SubRoom *)findChildOfType(item, 1); + subRoom = (SubRoom *)findChildOfType(item, kRoomType); if (subRoom == NULL) return 0; x = d; @@ -93,7 +93,7 @@ void AGOSEngine::setDoorState(Item *i, uint16 d, uint16 n) { uint16 d1; uint16 y = 0; - r = (SubRoom *)findChildOfType(i, 1); + r = (SubRoom *)findChildOfType(i, kRoomType); if (r == NULL) return; d1 = d; @@ -107,7 +107,7 @@ void AGOSEngine::setDoorState(Item *i, uint16 d, uint16 n) { j = derefItem(r->roomExit[d1]); if (j == NULL) return; - r1 = (SubRoom *)findChildOfType(j, 1); + r1 = (SubRoom *)findChildOfType(j, kRoomType); if (r1 == NULL) return; d = getBackExit(d); @@ -130,7 +130,7 @@ Item *AGOSEngine::getDoorOf(Item *i, uint16 d) { SubGenExit *g; Item *x; - g = (SubGenExit *)findChildOfType(i, 4); + g = (SubGenExit *)findChildOfType(i, kGenExitType); if (g == NULL) return 0; @@ -146,7 +146,7 @@ Item *AGOSEngine::getExitOf_e1(Item *item, uint16 d) { SubGenExit *g; Item *x; - g = (SubGenExit *)findChildOfType(item, 4); + g = (SubGenExit *)findChildOfType(item, kGenExitType); if (g == NULL) return 0; @@ -192,10 +192,10 @@ void AGOSEngine_Elvira2::moveDirn(Item *i, uint x) { return; p = derefItem(i->parent); - if (findChildOfType(p, 4)) { + if (findChildOfType(p, kSuperRoomType)) { n = getExitState(p, _superRoomNumber,x); if (n == 1) { - sr = (SubSuperRoom *)findChildOfType(p, 4); + sr = (SubSuperRoom *)findChildOfType(p, kSuperRoomType); switch (x) { case 0: a = -(sr->roomX); break; case 1: a = 1; break; @@ -319,7 +319,7 @@ uint16 AGOSEngine_Elvira2::getExitState(Item *i, uint16 x, uint16 d) { uint16 mask = 3; uint16 n; - sr = (SubSuperRoom *)findChildOfType(i, 4); + sr = (SubSuperRoom *)findChildOfType(i, kSuperRoomType); if (sr == NULL) return 0; @@ -331,7 +331,7 @@ uint16 AGOSEngine_Elvira2::getExitState(Item *i, uint16 x, uint16 d) { } void AGOSEngine_Elvira2::setExitState(Item *i, uint16 n, uint16 d, uint16 s) { - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, kSuperRoomType); if (sr) changeExitStates(sr, n, d, s); } @@ -339,7 +339,7 @@ void AGOSEngine_Elvira2::setExitState(Item *i, uint16 n, uint16 d, uint16 s) { void AGOSEngine_Elvira2::setSRExit(Item *i, int n, int d, uint16 s) { uint16 mask = 3; - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, kSuperRoomType); if (sr) { n--; d <<= 1; diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index eb2266550a..56e314c3e7 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -999,13 +999,13 @@ bool AGOSEngine::loadGame(const char *filename, bool restartMode) { item->state = f->readUint16BE(); item->classFlags = f->readUint16BE(); - SubObject *o = (SubObject *)findChildOfType(item, 2); + SubObject *o = (SubObject *)findChildOfType(item, kObjectType); if (o) { o->objectSize = f->readUint16BE(); o->objectWeight = f->readUint16BE(); } - SubPlayer *p = (SubPlayer *)findChildOfType(item, 3); + SubPlayer *p = (SubPlayer *)findChildOfType(item, kPlayerType); if (p) { p->score = f->readUint32BE(); p->level = f->readUint16BE(); @@ -1014,7 +1014,7 @@ bool AGOSEngine::loadGame(const char *filename, bool restartMode) { p->strength = f->readUint16BE(); } - SubUserFlag *u = (SubUserFlag *) findChildOfType(item, 9); + SubUserFlag *u = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (u) { for (i = 0; i != 8; i++) { u->userFlags[i] = f->readUint16BE(); @@ -1083,13 +1083,13 @@ bool AGOSEngine::saveGame(uint slot, const char *caption) { f->writeUint16BE(item->state); f->writeUint16BE(item->classFlags); - SubObject *o = (SubObject *)findChildOfType(item, 2); + SubObject *o = (SubObject *)findChildOfType(item, kObjectType); if (o) { f->writeUint16BE(o->objectSize); f->writeUint16BE(o->objectWeight); } - SubPlayer *p = (SubPlayer *)findChildOfType(item, 3); + SubPlayer *p = (SubPlayer *)findChildOfType(item, kPlayerType); if (p) { f->writeUint32BE(p->score); f->writeUint16BE(p->level); @@ -1098,7 +1098,7 @@ bool AGOSEngine::saveGame(uint slot, const char *caption) { f->writeUint16BE(p->strength); } - SubUserFlag *u = (SubUserFlag *) findChildOfType(item, 9); + SubUserFlag *u = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (u) { for (i = 0; i != 8; i++) { f->writeUint16BE(u->userFlags[i]); @@ -1204,19 +1204,19 @@ bool AGOSEngine_Elvira2::loadGame(const char *filename, bool restartMode) { item->state = f->readUint16BE(); item->classFlags = f->readUint16BE(); - SubRoom *r = (SubRoom *)findChildOfType(item, 1); + SubRoom *r = (SubRoom *)findChildOfType(item, kRoomType); if (r) { r->roomExitStates = f->readUint16BE(); } - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, kSuperRoomType); if (sr) { uint16 n = sr->roomX * sr->roomY * sr->roomZ; for (i = j = 0; i != n; i++) sr->roomExitStates[j++] = f->readUint16BE(); } - SubObject *o = (SubObject *)findChildOfType(item, 2); + SubObject *o = (SubObject *)findChildOfType(item, kObjectType); if (o) { o->objectFlags = f->readUint32BE(); i = o->objectFlags & 1; @@ -1228,7 +1228,7 @@ bool AGOSEngine_Elvira2::loadGame(const char *filename, bool restartMode) { } } - SubUserFlag *u = (SubUserFlag *) findChildOfType(item, 9); + SubUserFlag *u = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (u) { for (i = 0; i != 4; i++) { u->userFlags[i] = f->readUint16BE(); @@ -1345,19 +1345,19 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) { f->writeUint16BE(item->state); f->writeUint16BE(item->classFlags); - SubRoom *r = (SubRoom *)findChildOfType(item, 1); + SubRoom *r = (SubRoom *)findChildOfType(item, kRoomType); if (r) { f->writeUint16BE(r->roomExitStates); } - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, kSuperRoomType); if (sr) { uint16 n = sr->roomX * sr->roomY * sr->roomZ; for (i = j = 0; i != n; i++) f->writeUint16BE(sr->roomExitStates[j++]); } - SubObject *o = (SubObject *)findChildOfType(item, 2); + SubObject *o = (SubObject *)findChildOfType(item, kObjectType); if (o) { f->writeUint32BE(o->objectFlags); i = o->objectFlags & 1; @@ -1369,7 +1369,7 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) { } } - SubUserFlag *u = (SubUserFlag *)findChildOfType(item, 9); + SubUserFlag *u = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (u) { for (i = 0; i != 4; i++) { f->writeUint16BE(u->userFlags[i]); diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index c5cf6c5872..bb7faa91d3 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -206,7 +206,7 @@ void AGOSEngine::o_state() { void AGOSEngine::o_oflag() { // 28: item has prop - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); uint num = getVarOrByte(); setScriptCondition(subObject != NULL && (subObject->objectFlags & (1 << num)) != 0); } @@ -326,7 +326,7 @@ void AGOSEngine::o_goto() { void AGOSEngine::o_oset() { // 56: set child2 fr bit - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); int value = getVarOrByte(); if (subObject != NULL && value >= 16) subObject->objectFlags |= (1 << value); @@ -334,7 +334,7 @@ void AGOSEngine::o_oset() { void AGOSEngine::o_oclear() { // 57: clear child2 fr bit - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); int value = getVarOrByte(); if (subObject != NULL && value >= 16) subObject->objectFlags &= ~(1 << value); @@ -426,7 +426,7 @@ void AGOSEngine::o_if2() { void AGOSEngine::o_isCalled() { // 79: childstruct fr2 is - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); uint stringId = getNextStringID(); setScriptCondition((subObject != NULL) && subObject->objectName == stringId); } @@ -985,10 +985,10 @@ Child *nextSub(Child *sub, int16 key) { } void AGOSEngine::synchChain(Item *i) { - SubChain *c = (SubChain *)findChildOfType(i, 8); + SubChain *c = (SubChain *)findChildOfType(i, kChainType); while (c) { setItemState(derefItem(c->chChained), i->state); - c = (SubChain *)nextSub((Child *)c, 8); + c = (SubChain *)nextSub((Child *)c, kChainType); } } diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp index b003a7262f..5a1d7d104b 100644 --- a/engines/agos/script_e1.cpp +++ b/engines/agos/script_e1.cpp @@ -419,7 +419,7 @@ void AGOSEngine_Elvira1::oe1_notPresent() { void AGOSEngine_Elvira1::oe1_worn() { // 4: worn Item *item = getNextItemPtr(); - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); if (item->parent != getItem1ID() || subObject == NULL) setScriptCondition(false); @@ -430,7 +430,7 @@ void AGOSEngine_Elvira1::oe1_worn() { void AGOSEngine_Elvira1::oe1_notWorn() { // 5: not worn Item *item = getNextItemPtr(); - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); if (item->parent != getItem1ID() || subObject == NULL) setScriptCondition(false); @@ -532,7 +532,7 @@ void AGOSEngine_Elvira1::oe1_moveDirn() { void AGOSEngine_Elvira1::oe1_score() { // 90: score - SubPlayer *p = (SubPlayer *) findChildOfType(me(), 3); + SubPlayer *p = (SubPlayer *)findChildOfType(me(), kPlayerType); showMessageFormat("Your score is %ld.\n", p->score); } @@ -542,9 +542,9 @@ void AGOSEngine_Elvira1::oe1_look() { if (i == NULL) return; - SubRoom *r = (SubRoom *)findChildOfType(i, 1); - SubObject *o = (SubObject *)findChildOfType(i, 2); - SubPlayer *p = (SubPlayer *)findChildOfType(i, 3); + SubRoom *r = (SubRoom *)findChildOfType(i, kRoomType); + SubObject *o = (SubObject *)findChildOfType(i, kObjectType); + SubPlayer *p = (SubPlayer *)findChildOfType(i, kPlayerType); if (p == NULL) return; @@ -594,7 +594,7 @@ void AGOSEngine_Elvira1::oe1_doClass() { void AGOSEngine_Elvira1::oe1_pObj() { // 112: print object - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); getVarOrWord(); if (subObject != NULL) @@ -624,7 +624,7 @@ void AGOSEngine_Elvira1::oe1_isCalled() { void AGOSEngine_Elvira1::oe1_cFlag() { // 162: check container flag - SubContainer *c = (SubContainer *)findChildOfType(getNextItemPtr(), 7); + SubContainer *c = (SubContainer *)findChildOfType(getNextItemPtr(), kContainerType); uint bit = getVarOrWord(); if (c == NULL) @@ -678,7 +678,7 @@ void AGOSEngine_Elvira1::oe1_doorExit() { int16 f = getVarOrWord(); int16 ct = 0; - c = (SubChain *)findChildOfType(d, 8); + c = (SubChain *)findChildOfType(d, kChainType); if (c) a = derefItem(c->chChained); while (ct < 6) { @@ -986,7 +986,7 @@ void AGOSEngine_Elvira1::oe1_printMonsterHit() { } int16 AGOSEngine::levelOf(Item *item) { - SubPlayer *p = (SubPlayer *) findChildOfType(item, 3); + SubPlayer *p = (SubPlayer *)findChildOfType(item, kPlayerType); if (p == NULL) return 0; @@ -998,7 +998,7 @@ int16 AGOSEngine::moreText(Item *i) { i = derefItem(i->next); while (i) { - o = (SubObject *)findChildOfType(i, 2); + o = (SubObject *)findChildOfType(i, kObjectType); if ((o) && (o->objectFlags & 1)) goto l1; if (i != me()) @@ -1014,7 +1014,7 @@ void AGOSEngine::lobjFunc(Item *i, const char *f) { SubObject *o; while (i) { - o = (SubObject *)findChildOfType(i, 2); + o = (SubObject *)findChildOfType(i, kObjectType); if ((o) && (o->objectFlags & 1)) goto l1; if (i == me()) diff --git a/engines/agos/script_e2.cpp b/engines/agos/script_e2.cpp index cef50f11f2..61655e63f9 100644 --- a/engines/agos/script_e2.cpp +++ b/engines/agos/script_e2.cpp @@ -309,7 +309,7 @@ void AGOSEngine_Elvira2::oe2_doClass() { void AGOSEngine_Elvira2::oe2_pObj() { // 73: print object - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (subObject != NULL && subObject->objectFlags & kOFText) showMessageFormat("%s\n", (const char *)getStringPtrByID(subObject->objectFlagValue[0])); // Difference @@ -348,7 +348,7 @@ void AGOSEngine_Elvira2::oe2_doTable() { // 143: start item sub Item *i = getNextItemPtr(); - SubRoom *r = (SubRoom *)findChildOfType(i, 1); + SubRoom *r = (SubRoom *)findChildOfType(i, kRoomType); if (r != NULL) { Subroutine *sub = getSubroutineByID(r->subroutine_id); if (sub) { @@ -358,7 +358,7 @@ void AGOSEngine_Elvira2::oe2_doTable() { } if (getGameType() == GType_ELVIRA2) { - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, kSuperRoomType); if (sr != NULL) { Subroutine *sub = getSubroutineByID(sr->subroutine_id); if (sub) { @@ -485,7 +485,7 @@ void AGOSEngine_Elvira2::oe2_bNotZero() { void AGOSEngine_Elvira2::oe2_getOValue() { // 157: get item int prop Item *item = getNextItemPtr(); - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); uint prop = getVarOrByte(); if (subObject != NULL && subObject->objectFlags & (1 << prop) && prop < 16) { @@ -499,7 +499,7 @@ void AGOSEngine_Elvira2::oe2_getOValue() { void AGOSEngine_Elvira2::oe2_setOValue() { // 158: set item prop Item *item = getNextItemPtr(); - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); uint prop = getVarOrByte(); int value = getVarOrWord(); diff --git a/engines/agos/script_ff.cpp b/engines/agos/script_ff.cpp index c3e6dc5192..8b7af31a66 100644 --- a/engines/agos/script_ff.cpp +++ b/engines/agos/script_ff.cpp @@ -528,7 +528,7 @@ void AGOSEngine_Feeble::off_screenTextPObj() { TextLocation *tl = NULL; char buf[256]; - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (subObject != NULL && subObject->objectFlags & kOFText) { string_ptr = (const char *)getStringPtrByID(subObject->objectFlagValue[0]); tl = getTextLocation(vgaSpriteId); diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp index 93b907e688..4dc7324f64 100644 --- a/engines/agos/script_s1.cpp +++ b/engines/agos/script_s1.cpp @@ -419,7 +419,7 @@ void AGOSEngine_Simon1::os1_screenTextPObj() { uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (getFeatures() & GF_TALKIE) { if (subObject != NULL && subObject->objectFlags & kOFVoice) { uint offs = getOffsetOfChild2Param(subObject, kOFVoice); diff --git a/engines/agos/script_ww.cpp b/engines/agos/script_ww.cpp index 377b49ae3f..3fa9e92687 100644 --- a/engines/agos/script_ww.cpp +++ b/engines/agos/script_ww.cpp @@ -419,7 +419,7 @@ void AGOSEngine_Waxworks::oww_printBox() { void AGOSEngine_Waxworks::oww_boxPObj() { // 188: print object name to box - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (subObject != NULL && subObject->objectFlags & kOFText) boxTextMsg((const char *)getStringPtrByID(subObject->objectFlagValue[0])); diff --git a/engines/agos/string.cpp b/engines/agos/string.cpp index 483f101889..90620517c8 100644 --- a/engines/agos/string.cpp +++ b/engines/agos/string.cpp @@ -274,7 +274,7 @@ bool AGOSEngine::printNameOf(Item *item, uint x, uint y) { if (item == 0 || item == _dummyItem2 || item == _dummyItem3) return false; - subObject = (SubObject *)findChildOfType(item, 2); + subObject = (SubObject *)findChildOfType(item, kObjectType); if (subObject == NULL) return false; |