aboutsummaryrefslogtreecommitdiff
path: root/engines/fullpipe/gameloader.cpp
diff options
context:
space:
mode:
authorColin Snover2017-11-14 22:30:35 -0600
committerEugene Sandulenko2017-11-18 22:35:12 +0100
commite2367f3ed2060b273559200b3e40f75a98bb6a6f (patch)
treecfea744f09c075bedb9b3f4a3e9489bf5b14d829 /engines/fullpipe/gameloader.cpp
parent39ea2f66ac635613c3a817c16f80b11ac207d320 (diff)
downloadscummvm-rg350-e2367f3ed2060b273559200b3e40f75a98bb6a6f.tar.gz
scummvm-rg350-e2367f3ed2060b273559200b3e40f75a98bb6a6f.tar.bz2
scummvm-rg350-e2367f3ed2060b273559200b3e40f75a98bb6a6f.zip
FULLPIPE: Remove unnecessary and unsafe C-style casts
Diffstat (limited to 'engines/fullpipe/gameloader.cpp')
-rw-r--r--engines/fullpipe/gameloader.cpp36
1 files changed, 28 insertions, 8 deletions
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);