aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/fullpipe/behavior.cpp2
-rw-r--r--engines/fullpipe/gameloader.cpp36
-rw-r--r--engines/fullpipe/gameloader.h2
-rw-r--r--engines/fullpipe/gfx.cpp14
-rw-r--r--engines/fullpipe/input.cpp4
-rw-r--r--engines/fullpipe/interaction.cpp34
-rw-r--r--engines/fullpipe/interaction.h11
-rw-r--r--engines/fullpipe/inventory.cpp2
-rw-r--r--engines/fullpipe/lift.cpp6
-rw-r--r--engines/fullpipe/messagehandlers.cpp22
-rw-r--r--engines/fullpipe/messages.cpp5
-rw-r--r--engines/fullpipe/modal.cpp2
-rw-r--r--engines/fullpipe/motion.cpp94
-rw-r--r--engines/fullpipe/motion.h6
-rw-r--r--engines/fullpipe/scene.cpp28
-rw-r--r--engines/fullpipe/scenes/scene03.cpp2
-rw-r--r--engines/fullpipe/scenes/scene04.cpp4
-rw-r--r--engines/fullpipe/scenes/scene06.cpp4
-rw-r--r--engines/fullpipe/scenes/scene11.cpp7
-rw-r--r--engines/fullpipe/scenes/scene33.cpp2
-rw-r--r--engines/fullpipe/scenes/sceneDbg.cpp2
-rw-r--r--engines/fullpipe/stateloader.cpp14
-rw-r--r--engines/fullpipe/statics.cpp6
-rw-r--r--engines/fullpipe/utils.cpp20
-rw-r--r--engines/fullpipe/utils.h32
25 files changed, 198 insertions, 163 deletions
diff --git a/engines/fullpipe/behavior.cpp b/engines/fullpipe/behavior.cpp
index a1e01b2373..2c0cba8f84 100644
--- a/engines/fullpipe/behavior.cpp
+++ b/engines/fullpipe/behavior.cpp
@@ -63,7 +63,7 @@ void BehaviorManager::initBehavior(Scene *sc, GameVar *var) {
StaticANIObject *ani = sc->getStaticANIObject1ByName(subvar->_varName, -1);
if (ani) {
for (uint i = 0; i < sc->_staticANIObjectList1.size(); i++) {
- if (((StaticANIObject *)sc->_staticANIObjectList1[i])->_id == ani->_id) {
+ if (sc->_staticANIObjectList1[i]->_id == ani->_id) {
_behaviors.push_back(BehaviorInfo());
BehaviorInfo &behinfo = _behaviors.back();
behinfo.initObjectBehavior(subvar, sc, ani);
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp
index 70cb937da4..ce98d7c1be 100644
--- a/engines/fullpipe/gameloader.cpp
+++ b/engines/fullpipe/gameloader.cpp
@@ -38,12 +38,32 @@ Inventory2 *getGameLoaderInventory() {
return &g_fp->_gameLoader->_inventory;
}
-MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId) {
- for (uint i = 0; i < g_fp->_gameLoader->_sc2array.size(); i++)
- if (g_fp->_gameLoader->_sc2array[i]._sceneId == sceneId)
- return (MctlCompound *)g_fp->_gameLoader->_sc2array[i]._motionController;
+static MotionController *getMotionControllerBySceneId(int16 sceneId) {
+ for (uint i = 0; i < g_fp->_gameLoader->_sc2array.size(); i++) {
+ if (g_fp->_gameLoader->_sc2array[i]._sceneId == sceneId) {
+ return g_fp->_gameLoader->_sc2array[i]._motionController;
+ }
+ }
+
+ return nullptr;
+}
- return 0;
+MovGraph *getSc2MovGraphBySceneId(int16 sceneId) {
+ MotionController *mc = getMotionControllerBySceneId(sceneId);
+ if (mc) {
+ assert(mc->_objtype == kObjTypeMovGraph);
+ return static_cast<MovGraph *>(mc);
+ }
+ return nullptr;
+}
+
+MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId) {
+ MotionController *mc = getMotionControllerBySceneId(sceneId);
+ if (mc) {
+ assert(mc->_objtype == kObjTypeMctlCompound);
+ return static_cast<MctlCompound *>(mc);
+ }
+ return nullptr;
}
InteractionController *getGameLoaderInteractionController() {
@@ -136,7 +156,7 @@ bool GameLoader::load(MfcArchive &file) {
debugC(1, kDebugLoading, "sc: %s", tmp);
- _sc2array[i].loadFile((const char *)tmp);
+ _sc2array[i].loadFile(tmp);
}
_preloadItems.load(file);
@@ -146,7 +166,7 @@ bool GameLoader::load(MfcArchive &file) {
debugC(1, kDebugLoading, "_field_FA: %d\n_field_F8: %d", _field_FA, _field_F8);
- _gameVar = (GameVar *)file.readClass();
+ _gameVar = file.readClass<GameVar>();
return true;
}
@@ -615,7 +635,7 @@ bool Sc2::load(MfcArchive &file) {
_sceneId = file.readUint16LE();
- _motionController = (MotionController *)file.readClass();
+ _motionController = file.readClass<MotionController>();
_count1 = file.readUint32LE();
debugC(4, kDebugLoading, "count1: %d", _count1);
diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h
index 39ccb7784c..10c0912416 100644
--- a/engines/fullpipe/gameloader.h
+++ b/engines/fullpipe/gameloader.h
@@ -39,6 +39,7 @@ class MctlCompound;
class InputController;
class InteractionController;
class MotionController;
+class MovGraph;
class Sc2 : public CObject {
public:
@@ -148,6 +149,7 @@ void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDesc
Inventory2 *getGameLoaderInventory();
InteractionController *getGameLoaderInteractionController();
MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId);
+MovGraph *getSc2MovGraphBySceneId(int16 sceneId);
MctlCompound *getCurrSceneSc2MotionController();
} // End of namespace Fullpipe
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index da626c7f1f..b12edcb621 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -300,8 +300,8 @@ void GameObject::renumPictures(Common::Array<StaticANIObject *> *lst) {
int *buf = (int *)calloc(lst->size() + 2, sizeof(int));
for (uint i = 0; i < lst->size(); i++) {
- if (_id == ((GameObject *)((*lst)[i]))->_id)
- buf[((GameObject *)((*lst)[i]))->_odelay] = 1;
+ if (_id == (*lst)[i]->_id)
+ buf[(*lst)[i]->_odelay] = 1;
}
if (buf[_odelay]) {
@@ -318,8 +318,8 @@ void GameObject::renumPictures(Common::Array<PictureObject *> *lst) {
int *buf = (int *)calloc(lst->size() + 2, sizeof(int));
for (uint i = 0; i < lst->size(); i++) {
- if (_id == ((GameObject *)((*lst)[i]))->_id)
- buf[((GameObject *)((*lst)[i]))->_odelay] = 1;
+ if (_id == (*lst)[i]->_id)
+ buf[(*lst)[i]->_odelay] = 1;
}
if (buf[_odelay]) {
@@ -348,7 +348,7 @@ bool GameObject::getPicAniInfo(PicAniInfo *info) {
}
if (_objtype == kObjTypeStaticANIObject) {
- StaticANIObject *ani = (StaticANIObject *)this;
+ StaticANIObject *ani = static_cast<StaticANIObject *>(this);
info->type = (ani->_messageQueueId << 16) | 1;
info->objectId = ani->_id;
@@ -398,8 +398,8 @@ bool GameObject::setPicAniInfo(PicAniInfo *picAniInfo) {
return true;
}
- if (picAniInfo->type & 1) {
- StaticANIObject *ani = (StaticANIObject *)this;
+ if (picAniInfo->type & 1 && _objtype == kObjTypeStaticANIObject) {
+ StaticANIObject *ani = static_cast<StaticANIObject *>(this);
ani->_messageQueueId = (picAniInfo->type >> 16) & 0xffff;
ani->_odelay = picAniInfo->field_8;
diff --git a/engines/fullpipe/input.cpp b/engines/fullpipe/input.cpp
index 499b985d22..6bd992a4d2 100644
--- a/engines/fullpipe/input.cpp
+++ b/engines/fullpipe/input.cpp
@@ -215,7 +215,7 @@ void FullpipeEngine::winArcade() {
void FullpipeEngine::updateCursorCommon() {
GameObject *ani = _currentScene->getStaticANIObjectAtPos(_mouseVirtX, _mouseVirtY);
- GameObject *pic = _currentScene->getPictureObjectAtPos(_mouseVirtX, _mouseVirtY);
+ PictureObject *pic = _currentScene->getPictureObjectAtPos(_mouseVirtX, _mouseVirtY);
if (!ani || (pic && pic->_priority < ani->_priority))
ani = pic;
@@ -241,7 +241,7 @@ void FullpipeEngine::updateCursorCommon() {
_cursorId = PIC_CSR_DEFAULT_INV;
return;
}
- if (_objectIdAtCursor == ANI_LIFTBUTTON && lift_getButtonIdP(((StaticANIObject *)ani)->_statics->_staticsId)) {
+ if (_objectIdAtCursor == ANI_LIFTBUTTON && ani->_objtype == kObjTypeStaticANIObject && lift_getButtonIdP(static_cast<StaticANIObject *>(ani)->_statics->_staticsId)) {
_cursorId = PIC_CSR_LIFT;
return;
}
diff --git a/engines/fullpipe/interaction.cpp b/engines/fullpipe/interaction.cpp
index 1d04aa019d..b15ae80150 100644
--- a/engines/fullpipe/interaction.cpp
+++ b/engines/fullpipe/interaction.cpp
@@ -40,8 +40,8 @@ bool canInteractAny(GameObject *obj1, GameObject *obj2, int invId) {
sceneId = g_fp->_currentScene->_sceneId;
InteractionController *intC = getGameLoaderInteractionController();
- for (ObList::iterator i = intC->_interactions.begin(); i != intC->_interactions.end(); ++i) {
- Interaction *intr = (Interaction *)*i;
+ for (InteractionController::InteractionList::iterator i = intC->_interactions.begin(); i != intC->_interactions.end(); ++i) {
+ Interaction *intr = *i;
if (intr->_sceneId > 0 && intr->_sceneId != sceneId)
break;
@@ -69,10 +69,7 @@ bool InteractionController::load(MfcArchive &file) {
int static_compSceneId = 0;
-bool InteractionController::compareInteractions(const void *p1, const void *p2) {
- const Interaction *i1 = (const Interaction *)p1;
- const Interaction *i2 = (const Interaction *)p2;
-
+bool InteractionController::compareInteractions(const Interaction *i1, const Interaction *i2) {
if (i2->_sceneId < i1->_sceneId) {
if (i1->_sceneId != static_compSceneId)
return false;
@@ -118,8 +115,8 @@ bool InteractionController::handleInteraction(StaticANIObject *subj, GameObject
MessageQueue *mq;
ExCommand *ex;
- for (ObList::iterator i = _interactions.begin(); i != _interactions.end(); ++i) {
- Interaction *cinter = (Interaction *)*i;
+ for (InteractionList::iterator i = _interactions.begin(); i != _interactions.end(); ++i) {
+ Interaction *cinter = *i;
if (!cinter->canInteract(subj, obj, invId))
continue;
@@ -134,8 +131,8 @@ bool InteractionController::handleInteraction(StaticANIObject *subj, GameObject
obj->getPicAniInfo(&aniInfo);
- if (cinter->_staticsId1) {
- StaticANIObject *ani = (StaticANIObject *)obj;
+ if (cinter->_staticsId1 && obj->_objtype == kObjTypeStaticANIObject) {
+ StaticANIObject *ani = static_cast<StaticANIObject *>(obj);
ani->_messageQueueId = 0;
ani->changeStatics2(cinter->_staticsId1);
}
@@ -241,7 +238,7 @@ LABEL_38:
if (inter->isOverlapping(subj, obj)) {
if (obj->_objtype == kObjTypeStaticANIObject) {
- StaticANIObject *ani = (StaticANIObject *)obj;
+ StaticANIObject *ani = static_cast<StaticANIObject *>(obj);
ani->queueMessageQueue(0);
@@ -304,7 +301,7 @@ LABEL_38:
obj->getPicAniInfo(&aniInfo);
if (obj->_objtype == kObjTypeStaticANIObject && inter->_staticsId1) {
- StaticANIObject *ani = (StaticANIObject *)obj;
+ StaticANIObject *ani = static_cast<StaticANIObject *>(obj);
ani->_messageQueueId = 0;
ani->changeStatics2(inter->_staticsId1);
@@ -346,7 +343,10 @@ LABEL_38:
if (!inter->_staticsId1 || !(inter->_flags & 1))
return true;
- StaticANIObject *ani = (StaticANIObject *)obj;
+ if (obj->_objtype != kObjTypeStaticANIObject)
+ return false;
+
+ StaticANIObject *ani = static_cast<StaticANIObject *>(obj);
if (!ani->isIdle())
return false;
@@ -407,8 +407,8 @@ LABEL_38:
}
Interaction *InteractionController::getInteractionByObjectIds(int obId, int obId2, int obId3) {
- for (ObList::iterator i = _interactions.begin(); i != _interactions.end(); ++i) {
- Interaction *intr = (Interaction *)*i;
+ for (InteractionList::iterator i = _interactions.begin(); i != _interactions.end(); ++i) {
+ Interaction *intr = *i;
if (intr->_objectId1 == obId && intr->_objectId2 == obId2 && intr->_objectId3 == obId3)
return intr;
@@ -458,7 +458,7 @@ bool Interaction::load(MfcArchive &file) {
_flags = file.readUint32LE();
_actionName = file.readPascalString();
- _messageQueue = (MessageQueue *)file.readClass();
+ _messageQueue = file.readClass<MessageQueue>();
return true;
}
@@ -480,7 +480,7 @@ bool Interaction::canInteract(GameObject *obj1, GameObject *obj2, int invId) {
if (obj2->_objtype != kObjTypeStaticANIObject)
return false;
- StaticANIObject *st = (StaticANIObject *)obj2;
+ StaticANIObject *st = static_cast<StaticANIObject *>(obj2);
if (!st->_statics)
return false;
diff --git a/engines/fullpipe/interaction.h b/engines/fullpipe/interaction.h
index 97fb19beb9..9ffcdccc91 100644
--- a/engines/fullpipe/interaction.h
+++ b/engines/fullpipe/interaction.h
@@ -62,13 +62,16 @@ class Interaction : public CObject {
};
class InteractionController : public CObject {
- public:
- ObList _interactions;
- int16 _field_20;
+ friend bool canInteractAny(GameObject *obj1, GameObject *obj2, int invId);
+
+public:
+ typedef ObList<Interaction> InteractionList;
bool _flag24;
private:
- static bool compareInteractions(const void *p1, const void *p2);
+ InteractionList _interactions;
+ int16 _field_20;
+ static bool compareInteractions(const Interaction *i1, const Interaction *i2);
public:
InteractionController() : _field_20(0), _flag24(true) {}
diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp
index 5ddf26d06a..cb9eec75c3 100644
--- a/engines/fullpipe/inventory.cpp
+++ b/engines/fullpipe/inventory.cpp
@@ -238,7 +238,7 @@ void Inventory2::rebuildItemRects() {
int itemY = 0;
for (uint i = 0; i < _scene->_picObjList.size(); i++) {
- PictureObject *pic = (PictureObject *)_scene->_picObjList[i];
+ PictureObject *pic = _scene->_picObjList[i];
for (uint j = 0; j < _itemsPool.size(); j++) {
if (_itemsPool[j]->pictureObjectNormal == pic->_id) {
diff --git a/engines/fullpipe/lift.cpp b/engines/fullpipe/lift.cpp
index 113ddf719e..1bbe5a726b 100644
--- a/engines/fullpipe/lift.cpp
+++ b/engines/fullpipe/lift.cpp
@@ -195,7 +195,7 @@ void FullpipeEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
_lift = sc->getStaticANIObject1ById(ANI_LIFT, -1);
for (uint i = 0; i < sc->_staticANIObjectList1.size(); i++) {
- StaticANIObject *ani = (StaticANIObject *)sc->_staticANIObjectList1[i];
+ StaticANIObject *ani = sc->_staticANIObjectList1[i];
if (ani->_id == ANI_LIFTBUTTON)
ani->_statics = ani->getStaticsById(lift_getButtonIdP(ani->_statics->_staticsId));
@@ -205,7 +205,7 @@ void FullpipeEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
if (var) {
for (var = var->_subVars; var; var = var->_nextVarObj) {
for (uint i = 0; i < sc->_staticANIObjectList1.size(); i++) {
- StaticANIObject *ani = (StaticANIObject *)sc->_staticANIObjectList1[i];
+ StaticANIObject *ani = sc->_staticANIObjectList1[i];
if (ani->_id == ANI_LIFTBUTTON) {
int id = lift_getButtonIdN(ani->_statics->_staticsId);
@@ -506,7 +506,7 @@ bool FullpipeEngine::lift_checkButton(const char *varName) {
void FullpipeEngine::lift_setButtonStatics(Scene *sc, int buttonId) {
for (uint i = 0; i < sc->_staticANIObjectList1.size(); i++) {
- StaticANIObject *ani = (StaticANIObject *)sc->_staticANIObjectList1[i];
+ StaticANIObject *ani = sc->_staticANIObjectList1[i];
if (ani->_id == ANI_LIFTBUTTON) {
int id = lift_getButtonIdN(ani->_statics->_staticsId);
diff --git a/engines/fullpipe/messagehandlers.cpp b/engines/fullpipe/messagehandlers.cpp
index 61b3429c50..d5f0e0d700 100644
--- a/engines/fullpipe/messagehandlers.cpp
+++ b/engines/fullpipe/messagehandlers.cpp
@@ -517,7 +517,7 @@ int global_messageHandler3(ExCommand *cmd) {
return doSomeAnimation2(cmd->_parentId, cmd->_param);
case 63:
if (cmd->_objtype == kObjTypeObjstateCommand) {
- ObjstateCommand *c = (ObjstateCommand *)cmd;
+ ObjstateCommand *c = static_cast<ObjstateCommand *>(cmd);
result = 1;
g_fp->setObjectState(c->_objCommandName.c_str(), c->_value);
}
@@ -595,12 +595,14 @@ int global_messageHandler4(ExCommand *cmd) {
if (flags <= 0)
flags = -1;
- ExCommand2 *cmd2 = (ExCommand2 *)cmd;
+ if (cmd->_objtype == kObjTypeExCommand2) {
+ ExCommand2 *cmd2 = static_cast<ExCommand2 *>(cmd);
- if (cmd->_excFlags & 1) {
- ani->startAnimSteps(cmd->_messageNum, 0, cmd->_x, cmd->_y, cmd2->_points, cmd2->_pointsSize, flags);
- } else {
- ani->startAnimSteps(cmd->_messageNum, cmd->_parId, cmd->_x, cmd->_y, cmd2->_points, cmd2->_pointsSize, flags);
+ if (cmd->_excFlags & 1) {
+ ani->startAnimSteps(cmd->_messageNum, 0, cmd->_x, cmd->_y, cmd2->_points, cmd2->_pointsSize, flags);
+ } else {
+ ani->startAnimSteps(cmd->_messageNum, cmd->_parId, cmd->_x, cmd->_y, cmd2->_points, cmd2->_pointsSize, flags);
+ }
}
break;
}
@@ -769,20 +771,20 @@ int MovGraph::messageHandler(ExCommand *cmd) {
if (getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->_objtype != kObjTypeMovGraph || !ani)
return 0;
- MovGraph *gr = (MovGraph *)getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId);
+ MovGraph *gr = getSc2MovGraphBySceneId(g_fp->_currentScene->_sceneId);
MovGraphLink *link = 0;
double mindistance = 1.0e10;
Common::Point point;
- for (ObList::iterator i = gr->_links.begin(); i != gr->_links.end(); ++i) {
+ for (LinkList::iterator i = gr->_links.begin(); i != gr->_links.end(); ++i) {
point.x = ani->_ox;
point.y = ani->_oy;
- double dst = gr->putToLink(&point, (MovGraphLink *)(*i), 0);
+ double dst = gr->putToLink(&point, *i, 0);
if (dst >= 0.0 && dst < mindistance) {
mindistance = dst;
- link = (MovGraphLink *)(*i);
+ link = *i;
}
}
diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp
index 22a1fe7108..e332728f5b 100644
--- a/engines/fullpipe/messages.cpp
+++ b/engines/fullpipe/messages.cpp
@@ -317,7 +317,7 @@ MessageQueue::MessageQueue(MessageQueue *src, int parId, int field_38) {
MessageQueue::~MessageQueue() {
for (Common::List<ExCommand *>::iterator it = _exCommands.begin(); it != _exCommands.end(); ++it) {
- ExCommand *ex = (ExCommand *)*it;
+ ExCommand *ex = *it;
if (ex && ex->_excFlags & 2)
delete ex;
@@ -347,8 +347,7 @@ bool MessageQueue::load(MfcArchive &file) {
_queueName = file.readPascalString();
for (int i = 0; i < count; i++) {
- ExCommand *tmp = (ExCommand *)file.readClass();
-
+ ExCommand *tmp = file.readClass<ExCommand>();
_exCommands.push_back(tmp);
}
diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp
index 1c98f5e2df..ef3546788a 100644
--- a/engines/fullpipe/modal.cpp
+++ b/engines/fullpipe/modal.cpp
@@ -2340,7 +2340,7 @@ bool ModalDemo::launch() {
_scene = sc;
for (uint i = 1; i < sc->_picObjList.size(); i++) {
- if (((PictureObject *)sc->_picObjList[i])->_id == 399)
+ if (sc->_picObjList[i]->_id == 399)
sc->_picObjList[i]->_flags |= 4;
else
sc->_picObjList[i]->_flags &= 0xFFFB;
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index cfe9ecb5cb..5a106ed527 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -49,10 +49,10 @@ void MotionController::enableLinks(const char *linkName, bool enable) {
if (con->_objtype == kObjTypeMovGraph) {
MovGraph *gr = static_cast<MovGraph *>(con);
- for (ObList::iterator l = gr->_links.begin(); l != gr->_links.end(); ++l) {
- assert(((CObject *)*l)->_objtype == kObjTypeMovGraphLink);
+ for (MovGraph::LinkList::iterator l = gr->_links.begin(); l != gr->_links.end(); ++l) {
+ assert((*l)->_objtype == kObjTypeMovGraphLink);
- MovGraphLink *lnk = (MovGraphLink *)*l;
+ MovGraphLink *lnk = static_cast<MovGraphLink *>(*l);
if (lnk->_name == linkName) {
if (enable)
@@ -69,18 +69,18 @@ MovGraphLink *MotionController::getLinkByName(const char *name) {
debugC(4, kDebugPathfinding, "MotionController::getLinkByName(%s)", name);
if (_objtype == kObjTypeMctlCompound) {
- MctlCompound *obj = (MctlCompound *)this;
+ MctlCompound *obj = static_cast<MctlCompound *>(this);
for (uint i = 0; i < obj->getMotionControllerCount(); i++) {
MotionController *con = obj->getMotionController(i);
if (con->_objtype == kObjTypeMovGraph) {
- MovGraph *gr = (MovGraph *)con;
+ MovGraph *gr = static_cast<MovGraph *>(con);
- for (ObList::iterator l = gr->_links.begin(); l != gr->_links.end(); ++l) {
- assert(((CObject *)*l)->_objtype == kObjTypeMovGraphLink);
+ for (MovGraph::LinkList::iterator l = gr->_links.begin(); l != gr->_links.end(); ++l) {
+ assert((*l)->_objtype == kObjTypeMovGraphLink);
- MovGraphLink *lnk = (MovGraphLink *)*l;
+ MovGraphLink *lnk = static_cast<MovGraphLink *>(*l);
if (lnk->_name == name)
return lnk;
@@ -90,12 +90,12 @@ MovGraphLink *MotionController::getLinkByName(const char *name) {
}
if (_objtype == kObjTypeMovGraph) {
- MovGraph *gr = (MovGraph *)this;
+ MovGraph *gr = static_cast<MovGraph *>(this);
- for (ObList::iterator l = gr->_links.begin(); l != gr->_links.end(); ++l) {
- assert(((CObject *)*l)->_objtype == kObjTypeMovGraphLink);
+ for (MovGraph::LinkList::iterator l = gr->_links.begin(); l != gr->_links.end(); ++l) {
+ assert((*l)->_objtype == kObjTypeMovGraphLink);
- MovGraphLink *lnk = (MovGraphLink *)*l;
+ MovGraphLink *lnk = static_cast<MovGraphLink *>(*l);
if (lnk->_name == name)
return lnk;
@@ -116,14 +116,14 @@ bool MctlCompound::load(MfcArchive &file) {
debugC(6, kDebugLoading, "CompoundArray[%d]", i);
MctlItem *obj = new MctlItem();
- obj->_motionControllerObj = (MotionController *)file.readClass();
+ obj->_motionControllerObj = file.readClass<MotionController>();
int count1 = file.readUint32LE();
debugC(6, kDebugLoading, "ConnectionPoint::count: %d", count1);
for (int j = 0; j < count1; j++) {
debugC(6, kDebugLoading, "ConnectionPoint[%d]", j);
- MctlConnectionPoint *obj1 = (MctlConnectionPoint *)file.readClass();
+ MctlConnectionPoint *obj1 = file.readClass<MctlConnectionPoint>();
obj->_connectionPoints.push_back(obj1);
}
@@ -132,7 +132,7 @@ bool MctlCompound::load(MfcArchive &file) {
obj->_field_24 = file.readUint32LE();
debugC(6, kDebugLoading, "graphReact");
- obj->_movGraphReactObj = (MovGraphReact *)file.readClass();
+ obj->_movGraphReactObj = file.readClass<MovGraphReact>();
_motionControllers.push_back(obj);
}
@@ -166,7 +166,7 @@ void MctlCompound::initMctlGraph() {
if (_motionControllers[i]->_motionControllerObj->_objtype != kObjTypeMovGraph)
continue;
- MovGraph *gr = (MovGraph *)_motionControllers[i]->_motionControllerObj;
+ MovGraph *gr = static_cast<MovGraph *>(_motionControllers[i]->_motionControllerObj);
MctlGraph *newgr = new MctlGraph();
@@ -701,10 +701,10 @@ MctlConnectionPoint *MctlCompound::findClosestConnectionPoint(int ox, int oy, in
void MctlCompound::replaceNodeX(int from, int to) {
for (uint i = 0; i < _motionControllers.size(); i++) {
if (_motionControllers[i]->_motionControllerObj->_objtype == kObjTypeMovGraph) {
- MovGraph *gr = (MovGraph *)_motionControllers[i]->_motionControllerObj;
+ MovGraph *gr = static_cast<MovGraph *>(_motionControllers[i]->_motionControllerObj);
- for (ObList::iterator n = gr->_nodes.begin(); n != gr->_nodes.end(); ++n) {
- MovGraphNode *node = (MovGraphNode *)*n;
+ for (MovGraph::NodeList::iterator n = gr->_nodes.begin(); n != gr->_nodes.end(); ++n) {
+ MovGraphNode *node = static_cast<MovGraphNode *>(*n);
if (node->_x == from)
node->_x = to;
@@ -816,10 +816,10 @@ MovGraph::MovGraph() {
}
MovGraph::~MovGraph() {
- for (ObList::iterator i = _links.begin(); i != _links.end(); ++i)
+ for (LinkList::iterator i = _links.begin(); i != _links.end(); ++i)
delete *i;
- for (ObList::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
+ for (NodeList::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
delete *i;
detachAllObjects();
@@ -1395,10 +1395,10 @@ double MovGraph::putToLink(Common::Point *point, MovGraphLink *link, int fuzzyMa
void MovGraph::recalcLinkParams() {
debugC(4, kDebugPathfinding, "MovGraph::recalcLinkParams()");
- for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
- assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
+ for (LinkList::iterator i = _links.begin(); i != _links.end(); ++i) {
+ assert((*i)->_objtype == kObjTypeMovGraphLink);
- MovGraphLink *lnk = (MovGraphLink *)*i;
+ MovGraphLink *lnk = static_cast<MovGraphLink *>(*i);
lnk->_flags &= 0x7FFFFFFF;
@@ -1413,8 +1413,8 @@ bool MovGraph::getNearestPoint(int unusedArg, Common::Point *p, MovArr *movarr)
double mindist = 1.0e20;
int resx = 0, resy = 0;
- for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
- MovGraphLink *lnk = (MovGraphLink *)*i;
+ for (LinkList::iterator i = _links.begin(); i != _links.end(); ++i) {
+ MovGraphLink *lnk = static_cast<MovGraphLink *>(*i);
if ((lnk->_flags & 0x10000000) && !(lnk->_flags & 0x20000000) ) {
double dx1 = lnk->_graphSrc->_x - p->x;
@@ -1483,8 +1483,8 @@ Common::Array<MovArr *> *MovGraph::getHitPoints(int x, int y, int *arrSize, int
Common::Array<MovArr *> *arr = new Common::Array<MovArr *>;
MovArr *movarr;
- for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
- MovGraphLink *lnk = (MovGraphLink *)*i;
+ for (LinkList::iterator i = _links.begin(); i != _links.end(); ++i) {
+ MovGraphLink *lnk = static_cast<MovGraphLink *>(*i);
if (flag1) {
Common::Point point(x, y);
@@ -1556,8 +1556,8 @@ void MovGraph::findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array
tempObList1.push_back(lnk);
- for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
- MovGraphLink *l = (MovGraphLink *)*i;
+ for (LinkList::iterator i = _links.begin(); i != _links.end(); ++i) {
+ MovGraphLink *l = static_cast<MovGraphLink *>(*i);
if (l->_graphSrc != lnk->_graphSrc) {
if (l->_graphDst != lnk->_graphSrc) {
@@ -2430,10 +2430,10 @@ MessageQueue *MctlGraph::makeQueue(StaticANIObject *obj, int xpos, int ypos, int
}
MovGraphNode *MctlGraph::getHitNode(int x, int y, int strictMatch) {
- for (ObList::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
- assert(((CObject *)*i)->_objtype == kObjTypeMovGraphNode);
+ for (NodeList::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
+ assert((*i)->_objtype == kObjTypeMovGraphNode);
- MovGraphNode *node = (MovGraphNode *)*i;
+ MovGraphNode *node = *i;
if (!strictMatch) {
if (abs(node->_x - x) < 15 && abs(node->_y - y) < 15)
@@ -2719,10 +2719,10 @@ MovGraphLink *MctlGraph::getHitLink(int x, int y, int idx, int fuzzyMatch) {
Common::Point point;
MovGraphLink *res = 0;
- for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
- assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
+ for (LinkList::iterator i = _links.begin(); i != _links.end(); ++i) {
+ assert((*i)->_objtype == kObjTypeMovGraphLink);
- MovGraphLink *lnk = (MovGraphLink *)*i;
+ MovGraphLink *lnk = static_cast<MovGraphLink *>(*i);
if (fuzzyMatch) {
point.x = x;
@@ -2755,10 +2755,10 @@ MovGraphLink *MctlGraph::getNearestLink(int x, int y) {
double mindist = 1.0e20;
MovGraphLink *res = 0;
- for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
- assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
+ for (LinkList::iterator i = _links.begin(); i != _links.end(); ++i) {
+ assert((*i)->_objtype == kObjTypeMovGraphLink);
- MovGraphLink *lnk = (MovGraphLink *)*i;
+ MovGraphLink *lnk = static_cast<MovGraphLink *>(*i);
if (!(lnk->_flags & 0x20000000)) {
double n1x = lnk->_graphSrc->_x;
@@ -2802,8 +2802,8 @@ double MctlGraph::iterate(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, Comm
double minDistance = -1.0;
if (linkInfoSource->node) {
- for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
- MovGraphLink *lnk = (MovGraphLink *)*i;
+ for (LinkList::iterator i = _links.begin(); i != _links.end(); ++i) {
+ MovGraphLink *lnk = static_cast<MovGraphLink *>(*i);
if ((lnk->_graphSrc == linkInfoSource->node || lnk->_graphDst == linkInfoSource->node) && !(lnk->_flags & 0xA0000000)) {
linkInfoWorkSource.node = 0;
@@ -2872,10 +2872,10 @@ MovGraphNode *MovGraph::calcOffset(int ox, int oy) {
MovGraphNode *res = 0;
double mindist = 1.0e10;
- for (ObList::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
- assert(((CObject *)*i)->_objtype == kObjTypeMovGraphNode);
+ for (NodeList::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
+ assert((*i)->_objtype == kObjTypeMovGraphNode);
- MovGraphNode *node = (MovGraphNode *)*i;
+ MovGraphNode *node = static_cast<MovGraphNode *>(*i);
double dist = sqrt((double)((node->_x - oy) * (node->_x - oy) + (node->_x - ox) * (node->_x - ox)));
if (dist < mindist) {
@@ -2917,16 +2917,16 @@ bool MovGraphLink::load(MfcArchive &file) {
_flags = file.readUint32LE();
debugC(8, kDebugLoading, "GraphNode1");
- _graphSrc = (MovGraphNode *)file.readClass();
+ _graphSrc = file.readClass<MovGraphNode>();
debugC(8, kDebugLoading, "GraphNode2");
- _graphDst = (MovGraphNode *)file.readClass();
+ _graphDst = file.readClass<MovGraphNode>();
_length = file.readDouble();
_angle = file.readDouble();
debugC(8, kDebugLoading, "length: %g, angle: %g", _length, _angle);
- _movGraphReact = (MovGraphReact *)file.readClass();
+ _movGraphReact = file.readClass<MovGraphReact>();
_name = file.readPascalString();
return true;
diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h
index c08d56fd8c..c86c161b09 100644
--- a/engines/fullpipe/motion.h
+++ b/engines/fullpipe/motion.h
@@ -280,8 +280,10 @@ friend class MctlCompound;
friend class MctlGraph;
friend class MotionController;
private:
- ObList _nodes;
- ObList _links;
+ typedef ObList<MovGraphNode> NodeList;
+ typedef ObList<MovGraphLink> LinkList;
+ NodeList _nodes;
+ LinkList _links;
int _field_44;
Common::Array<MovGraphItem> _items;
MovArr *(*_callback1)(StaticANIObject *ani, Common::Array<MovItem *> *items, signed int counter);
diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp
index 76384c3785..69ab170e4d 100644
--- a/engines/fullpipe/scene.cpp
+++ b/engines/fullpipe/scene.cpp
@@ -251,7 +251,7 @@ void Scene::init() {
g_fp->_sceneRect.moveTo(0, 0);
for (uint i = 0; i < _picObjList.size(); i++)
- ((PictureObject *)_picObjList[i])->clearFlags();
+ _picObjList[i]->clearFlags();
for (uint i = 0; i < _staticANIObjectList1.size(); i++)
_staticANIObjectList1[i]->clearFlags();
@@ -324,7 +324,7 @@ void Scene::addStaticANIObject(StaticANIObject *obj, bool addList2) {
void Scene::setPictureObjectsFlag4() {
for (uint i = 0; i < _picObjList.size(); i++) {
- ((PictureObject *)_picObjList[i])->_flags |= 4;
+ _picObjList[i]->_flags |= 4;
}
}
@@ -335,8 +335,8 @@ void Scene::stopAllSounds() {
PictureObject *Scene::getPictureObjectById(int objId, int flags) {
for (uint i = 1; i < _picObjList.size(); i++) {
- if (((PictureObject *)_picObjList[i])->_id == objId && ((PictureObject *)_picObjList[i])->_odelay == flags)
- return (PictureObject *)_picObjList[i];
+ if (_picObjList[i]->_id == objId && _picObjList[i]->_odelay == flags)
+ return _picObjList[i];
}
return 0;
@@ -344,8 +344,8 @@ PictureObject *Scene::getPictureObjectById(int objId, int flags) {
PictureObject *Scene::getPictureObjectByName(const Common::String &objName, int flags) {
for (uint i = 0; i < _picObjList.size(); i++) {
- if ((((PictureObject *)_picObjList[i])->_objectName == objName) && (((PictureObject *)_picObjList[i])->_odelay == flags || flags == -1))
- return (PictureObject *)_picObjList[i];
+ if ((_picObjList[i]->_objectName == objName) && (_picObjList[i]->_odelay == flags || flags == -1))
+ return _picObjList[i];
}
return 0;
@@ -353,7 +353,7 @@ PictureObject *Scene::getPictureObjectByName(const Common::String &objName, int
void Scene::deletePictureObject(PictureObject *obj) {
for (uint i = 0; i < _picObjList.size(); i++) {
- if (((PictureObject *)_picObjList[i]) == obj) {
+ if (_picObjList[i] == obj) {
_picObjList.remove_at(i);
delete obj;
@@ -547,7 +547,7 @@ void Scene::updateScrolling() {
int offsetY = 0;
if (_x < 0) {
- if (!g_fp->_sceneRect.left && !(((PictureObject *)_picObjList[0])->_flags & 2))
+ if (!g_fp->_sceneRect.left && !(_picObjList[0]->_flags & 2))
_x = 0;
if (_x <= -g_fp->_scrollSpeed) {
@@ -620,7 +620,7 @@ PictureObject *Scene::getPictureObjectAtPos(int x, int y) {
PictureObject *res = 0;
for (uint i = 0; i < _picObjList.size(); i++) {
- PictureObject *p = (PictureObject *)_picObjList[i];
+ PictureObject *p = _picObjList[i];
if ((p->_field_8 & 0x100) && (p->_flags & 4) &&
p->isPixelHitAtPos(x, y) &&
(!res || res->_priority >= p->_priority))
@@ -635,7 +635,7 @@ int Scene::getPictureObjectIdAtPos(int x, int y) {
int res = 0;
for (uint i = 0; i < _picObjList.size(); i++) {
- PictureObject *p = (PictureObject *)_picObjList[i];
+ PictureObject *p = _picObjList[i];
if ((p->_field_8 & 0x100) && (p->_flags & 4) &&
p->isPixelHitAtPos(x, y) &&
(!res || resp->_priority >= p->_priority)) {
@@ -673,7 +673,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
#endif
if (minPri == -1 && _picObjList.size())
- minPri = ((PictureObject *)_picObjList.back())->_priority - 1;
+ minPri = _picObjList.back()->_priority - 1;
if (maxPri == -1)
maxPri = 60000;
@@ -725,7 +725,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
v25++;
if (v25 >= _bigPictureArray2Count) {
- if (!(((PictureObject *)_picObjList[0])->_flags & 0x20))
+ if (!(_picObjList[0]->_flags & 0x20))
break;
v25 = 0;
}
@@ -736,7 +736,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
bgNumX++;
if (bgNumX >= _bigPictureArray1Count) {
- if (!(((PictureObject *)_picObjList[0])->_flags & 0x2))
+ if (!(_picObjList[0]->_flags & 0x2))
break;
bgNumX = 0;
}
@@ -748,7 +748,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
for (uint i = 1; i < _picObjList.size(); i++) {
- PictureObject *obj = (PictureObject *)_picObjList[i];
+ PictureObject *obj = _picObjList[i];
if (obj->_priority < minPri || obj->_priority >= maxPri)
continue;
diff --git a/engines/fullpipe/scenes/scene03.cpp b/engines/fullpipe/scenes/scene03.cpp
index 25b48dea3c..1882ecf459 100644
--- a/engines/fullpipe/scenes/scene03.cpp
+++ b/engines/fullpipe/scenes/scene03.cpp
@@ -210,7 +210,7 @@ void sceneHandler03_takeEgg(ExCommand *ex) {
&& ex1) {
if (ex1->_objtype == kObjTypeObjstateCommand) {
- ObjstateCommand *com = (ObjstateCommand *)ex1;
+ ObjstateCommand *com = static_cast<ObjstateCommand *>(ex1);
com->_value = g_fp->getObjectEnumState(sO_EggGulper, sO_WantsNothing);
}
diff --git a/engines/fullpipe/scenes/scene04.cpp b/engines/fullpipe/scenes/scene04.cpp
index ae8e5674f7..c899e46ab9 100644
--- a/engines/fullpipe/scenes/scene04.cpp
+++ b/engines/fullpipe/scenes/scene04.cpp
@@ -958,7 +958,7 @@ void sceneHandler04_walkKozyawka() {
void sceneHandler04_bottleUpdateObjects(int off) {
for (Common::List<GameObject *>::iterator it = g_vars->scene04_bottleObjList.begin(); it != g_vars->scene04_bottleObjList.end(); ++it) {
if ((*it)->_objtype == kObjTypeStaticANIObject) {
- StaticANIObject *st = (StaticANIObject *)*it;
+ StaticANIObject *st = static_cast<StaticANIObject *>(*it);
st->setOXY(st->_ox, off + st->_oy);
} else {
@@ -1138,7 +1138,7 @@ void sceneHandler04_leaveLadder(ExCommand *ex) {
if (!(g_fp->_aniMan->_flags & 0x100)) {
if (getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->_objtype == kObjTypeMctlCompound) {
- MctlCompound *mc = (MctlCompound *)getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId);
+ MctlCompound *mc = static_cast<MctlCompound *>(getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId));
if (mc->_motionControllers[0]->_movGraphReactObj->pointInRegion(g_fp->_sceneRect.left + ex->_x, g_fp->_sceneRect.top + ex->_y)) {
if (g_vars->scene04_ladder->collisionDetection(g_fp->_aniMan)) {
diff --git a/engines/fullpipe/scenes/scene06.cpp b/engines/fullpipe/scenes/scene06.cpp
index f434848c05..54b3fb7ed5 100644
--- a/engines/fullpipe/scenes/scene06.cpp
+++ b/engines/fullpipe/scenes/scene06.cpp
@@ -53,13 +53,13 @@ int scene06_updateCursor() {
return PIC_CSR_ARCADE2_D;
}
- if (g_fp->_aniMan == (StaticANIObject *)g_fp->_objectAtCursor) {
+ if (g_fp->_aniMan == g_fp->_objectAtCursor) {
if (g_fp->_aniMan->_statics->_staticsId == ST_MAN6_BALL && g_fp->_cursorId == PIC_CSR_DEFAULT) {
g_fp->_cursorId = PIC_CSR_ITN;
return PIC_CSR_ITN;
}
- } else if (g_fp->_objectAtCursor && (StaticANIObject *)g_fp->_objectAtCursor == g_vars->scene06_currentBall
+ } else if (g_fp->_objectAtCursor && g_fp->_objectAtCursor == g_vars->scene06_currentBall
&& g_fp->_cursorId == PIC_CSR_DEFAULT) {
g_fp->_cursorId = PIC_CSR_ITN;
}
diff --git a/engines/fullpipe/scenes/scene11.cpp b/engines/fullpipe/scenes/scene11.cpp
index 72af59aacf..6a08677571 100644
--- a/engines/fullpipe/scenes/scene11.cpp
+++ b/engines/fullpipe/scenes/scene11.cpp
@@ -134,9 +134,7 @@ void scene11_initScene(Scene *sc) {
getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 1);
getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 1);
getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 0);
-
- ((MctlCompound *)getCurrSceneSc2MotionController())->replaceNodeX(805, 905);
-
+ getCurrSceneSc2MotionController()->replaceNodeX(805, 905);
getSc2MctlCompoundBySceneId(sc->_sceneId)->replaceNodeX(303, 353);
} else if (swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsStandingInBoots)
|| swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsStandingInCorner)) {
@@ -148,8 +146,7 @@ void scene11_initScene(Scene *sc) {
getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 0);
getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 1);
getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 0);
-
- ((MctlCompound *)getCurrSceneSc2MotionController())->replaceNodeX(905, 805);
+ getCurrSceneSc2MotionController()->replaceNodeX(905, 805);
} else {
g_vars->scene11_swingIsSwinging = false;
g_vars->scene11_swingieStands = false;
diff --git a/engines/fullpipe/scenes/scene33.cpp b/engines/fullpipe/scenes/scene33.cpp
index 717e9f6572..6719673c7b 100644
--- a/engines/fullpipe/scenes/scene33.cpp
+++ b/engines/fullpipe/scenes/scene33.cpp
@@ -211,7 +211,7 @@ void sceneHandler33_clickZones(ExCommand *cmd) {
double mindist = 1e10;
for (uint i = 0; i < g_fp->_currentScene->_staticANIObjectList1.size(); i++) {
- StaticANIObject *ani = (StaticANIObject *)g_fp->_currentScene->_staticANIObjectList1[i];
+ StaticANIObject *ani = g_fp->_currentScene->_staticANIObjectList1[i];
if (ani->_id == ANI_VENT_33) {
int dx = ani->_ox - cmd->_sceneClickX;
diff --git a/engines/fullpipe/scenes/sceneDbg.cpp b/engines/fullpipe/scenes/sceneDbg.cpp
index 4d061e603c..759480d1f0 100644
--- a/engines/fullpipe/scenes/sceneDbg.cpp
+++ b/engines/fullpipe/scenes/sceneDbg.cpp
@@ -45,7 +45,7 @@ GameObject *sceneHandlerDbgMenu_getObjectAtXY(int x, int y) {
return 0;
for (uint i = 1; i < g_fp->_currentScene->_picObjList.size(); i++) {
- PictureObject *pic = (PictureObject *)g_fp->_currentScene->_picObjList[i];
+ PictureObject *pic = g_fp->_currentScene->_picObjList[i];
if (x >= pic->_ox && y >= pic->_oy) {
const Dims dims = pic->getDimensions();
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp
index 0ff8c60d42..cc5c904897 100644
--- a/engines/fullpipe/stateloader.cpp
+++ b/engines/fullpipe/stateloader.cpp
@@ -85,7 +85,7 @@ bool GameLoader::readSavegame(const char *fname) {
Common::MemoryReadStream *archiveStream = new Common::MemoryReadStream(data, header.encSize);
MfcArchive *archive = new MfcArchive(archiveStream);
- GameVar *var = (GameVar *)archive->readClass();
+ GameVar *var = archive->readClass<GameVar>();
GameVar *v = _gameVar->getSubVarByName("OBJSTATES");
@@ -301,7 +301,7 @@ bool FullpipeEngine::loadGam(const char *fname, int scene) {
_inventory->rebuildItemRects();
for (uint i = 0; i < _inventory->getScene()->_picObjList.size(); i++)
- ((MemoryObject *)_inventory->getScene()->_picObjList[i]->_picture)->load();
+ _inventory->getScene()->_picObjList[i]->_picture->MemoryObject::load();
// _sceneSwitcher = sceneSwitcher; // substituted with direct call
_gameLoader->_preloadCallback = preloadCallback;
@@ -474,11 +474,11 @@ bool GameVar::load(MfcArchive &file) {
}
file.incLevel();
- _parentVarObj = (GameVar *)file.readClass();
- _prevVarObj = (GameVar *)file.readClass();
- _nextVarObj = (GameVar *)file.readClass();
- _field_14 = (GameVar *)file.readClass();
- _subVars = (GameVar *)file.readClass();
+ _parentVarObj = file.readClass<GameVar>();
+ _prevVarObj = file.readClass<GameVar>();
+ _nextVarObj = file.readClass<GameVar>();
+ _field_14 = file.readClass<GameVar>();
+ _subVars = file.readClass<GameVar>();
file.decLevel();
return true;
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index 8c0a045aa9..994feee866 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -1592,8 +1592,8 @@ Movement::Movement(Movement *src, int *oldIdxs, int newSize, StaticANIObject *an
_framePosOffsets[i]->y = src->_framePosOffsets[oldIdxs[i]]->y;
}
}
- _staticsObj1 = (Statics *)_dynamicPhases.front();
- _staticsObj2 = (Statics *)_dynamicPhases.back();
+ _staticsObj1 = dynamic_cast<Statics *>(_dynamicPhases.front());
+ _staticsObj2 = dynamic_cast<Statics *>(_dynamicPhases.back());
} else {
for (int i = 0; i < newSize; i++) {
src->setDynamicPhaseIndex(i);
@@ -2231,7 +2231,7 @@ bool StaticPhase::load(MfcArchive &file) {
_field_6A = file.readUint16LE();
if (g_fp->_gameProjectVersion >= 12) {
- _exCommand = (ExCommand *)file.readClass();
+ _exCommand = file.readClass<ExCommand>();
return true;
}
diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp
index 72a3377f74..f3f07b0514 100644
--- a/engines/fullpipe/utils.cpp
+++ b/engines/fullpipe/utils.cpp
@@ -45,22 +45,6 @@ bool CObject::loadFile(const Common::String &fname) {
return load(archive);
}
-bool ObList::load(MfcArchive &file) {
- debugC(5, kDebugLoading, "ObList::load()");
- int count = file.readCount();
-
- debugC(9, kDebugLoading, "ObList::count: %d:", count);
-
- for (int i = 0; i < count; i++) {
- debugC(9, kDebugLoading, "ObList::[%d]", i);
- CObject *t = file.readClass();
-
- push_back(t);
- }
-
- return true;
-}
-
bool ObArray::load(MfcArchive &file) {
debugC(5, kDebugLoading, "ObArray::load()");
int count = file.readCount();
@@ -68,7 +52,7 @@ bool ObArray::load(MfcArchive &file) {
resize(count);
for (int i = 0; i < count; i++) {
- CObject *t = file.readClass();
+ CObject *t = file.readClass<CObject>();
push_back(*t);
}
@@ -379,7 +363,7 @@ void MfcArchive::init() {
_objectIdMap.push_back(kNullObject);
}
-CObject *MfcArchive::readClass() {
+CObject *MfcArchive::readBaseClass() {
bool isCopyReturned;
CObject *res = parseClass(&isCopyReturned);
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h
index 2b97ab6480..8966ceb8ba 100644
--- a/engines/fullpipe/utils.h
+++ b/engines/fullpipe/utils.h
@@ -58,7 +58,17 @@ public:
int readCount();
double readDouble();
CObject *parseClass(bool *isCopyReturned);
- CObject *readClass();
+
+ template <typename T>
+ T *readClass() {
+ CObject *obj = readBaseClass();
+ if (!obj)
+ return nullptr;
+
+ T *res = dynamic_cast<T *>(obj);
+ assert(res);
+ return res;
+ }
void writeObject(CObject *obj);
@@ -76,6 +86,7 @@ public:
private:
void init();
+ CObject *readBaseClass();
};
enum ObjType {
@@ -106,9 +117,24 @@ public:
bool loadFile(const Common::String &fname);
};
-class ObList : public Common::List<CObject *>, public CObject {
+template <class T>
+class ObList : public Common::List<T *>, public CObject {
public:
- virtual bool load(MfcArchive &file);
+ virtual bool load(MfcArchive &file) {
+ debugC(5, kDebugLoading, "ObList::load()");
+ int count = file.readCount();
+
+ debugC(9, kDebugLoading, "ObList::count: %d:", count);
+
+ for (int i = 0; i < count; i++) {
+ debugC(9, kDebugLoading, "ObList::[%d]", i);
+ T *t = file.readClass<T>();
+
+ this->push_back(t);
+ }
+
+ return true;
+ }
};
class MemoryObject : CObject {