diff options
-rw-r--r-- | saga/actor.cpp | 104 | ||||
-rw-r--r-- | saga/actor.h | 10 | ||||
-rw-r--r-- | saga/ihnm_introproc.cpp | 10 | ||||
-rw-r--r-- | saga/ite_introproc.cpp | 18 | ||||
-rw-r--r-- | saga/rscfile.cpp | 3 | ||||
-rw-r--r-- | saga/scene.cpp | 4 | ||||
-rw-r--r-- | saga/scene.h | 4 |
7 files changed, 122 insertions, 31 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp index 32e371c774..d1da219a80 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -206,12 +206,13 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) { _pathRect.top = _vm->getDisplayInfo().pathStartY; _pathRect.bottom = _vm->getSceneHeight(); + // Get actor resource file context + _actorContext = _vm->_resource->getContext(GAME_RESOURCEFILE); + if (_actorContext == NULL) { + error("Actor::Actor() resource context not found"); + } + if (_vm->getGameType() == GType_ITE) { - // Get actor resource file context - _actorContext = _vm->_resource->getContext(GAME_RESOURCEFILE); - if (_actorContext == NULL) { - error("Actor::Actor() resource context not found"); - } _vm->_resource->loadResource(_actorContext, _vm->getResourceDescription()->actorsStringsResourceId, stringsPointer, stringsLength); @@ -281,7 +282,6 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) { Actor::~Actor() { int i; - ActorData *actor; ObjectData *obj; debug(9, "Actor::~Actor()"); @@ -296,11 +296,8 @@ Actor::~Actor() { free(_pathCell); _actorsStrings.freeMem(); //release resources - for (i = 0; i < _actorsCount; i++) { - actor = _actors[i]; - delete actor; - } - free(_actors); + freeList(); + for (i = 0; i < _objsCount; i++) { obj = _objs[i]; delete obj; @@ -372,8 +369,89 @@ bool Actor::loadActorResources(ActorData *actor) { return true; } -void Actor::loadList(int actorsEntrance, int actorCount, int actorsResourceID, - int protagStatesCount, int protagStatesResourceID) { +void Actor::freeList() { + int i; + ActorData *actor; + for (i = 0; i < _actorsCount; i++) { + actor = _actors[i]; + delete actor; + } + free(_actors); + _actors = NULL; + _actorsCount = 0; +} + +void Actor::loadList(int actorsEntrance, int actorCount, int actorsResourceID, int protagStatesCount, int protagStatesResourceID) { + int i; + ActorData *actor; + byte* actorListData; + size_t actorListLength; + freeList(); + + _vm->_resource->loadResource(_actorContext, actorsResourceID, actorListData, actorListLength); + + MemoryReadStream actorS(actorListData, actorListLength); + _actorsCount = actorListLength / ACTOR_INHM_SIZE; + + _actors = (ActorData **)malloc(_actorsCount * sizeof(*_actors)); + for (i = 0; i < _actorsCount; i++) { + actor = _actors[i] = new ActorData(); + actor->id = actorIndexToId(i); + actor->index = i; + debug(9, "init actor id=%d index=%d", actor->id, actor->index); + actorS.readUint32LE(); //next displayed + actorS.readByte(); //type + actor->flags = actorS.readByte(); + actor->nameIndex = actorS.readUint16LE(); + actor->sceneNumber = actorS.readUint32LE(); + actor->location.fromStream(actorS); + actor->screenPosition.x = actorS.readUint16LE(); + actor->screenPosition.y = actorS.readUint16LE(); + actor->screenScale = actorS.readUint16LE(); + actor->screenDepth = actorS.readUint16LE(); + actor->frameListResourceId = actorS.readUint32LE(); + actor->spriteListResourceId = actorS.readUint32LE(); + actor->scriptEntrypointNumber = actorS.readUint32LE(); + actorS.readByte(); + actorS.readByte(); + actorS.readByte(); + actorS.readByte(); + actorS.readUint16LE(); //LEFT + actorS.readUint16LE(); //RIGHT + actorS.readUint16LE(); //TOP + actorS.readUint16LE(); //BOTTOM + actor->speechColor = actorS.readByte(); + actor->currentAction = actorS.readByte(); + actor->facingDirection = actorS.readByte(); + actor->actionDirection = actorS.readByte(); + actor->actionCycle = actorS.readUint16LE(); + actor->frameNumber = actorS.readUint16LE(); + actor->finalTarget.fromStream(actorS); + actor->partialTarget.fromStream(actorS); + actorS.readUint16LE(); //movement speed + actorS.seek(128, SEEK_CUR); + actorS.readByte();//walkStepIndex + actorS.readByte();//walkStepCount + actorS.readUint32LE(); //sprites + actorS.readUint32LE(); //frames + actorS.readUint32LE(); //last zone + actor->targetObject = actorS.readUint16LE(); + actor->actorFlags = actorS.readUint16LE(); + actorS.readUint32LE(); //next in scene + actorS.seek(6, SEEK_CUR); //action vars + } + free(actorListData); + + for (i = 0; i < _actorsCount; i++) { + actor = _actors[i]; + if (actor->flags & kExtended) { + actor->disabled = !loadActorResources(actor); + if (actor->disabled) { + warning("Disabling actor Id=%d index=%d", actor->id, actor->index); + } + } + } +//TODO: protagonist stuff } void Actor::takeExit(uint16 actorId, const HitZone *hitZone) { diff --git a/saga/actor.h b/saga/actor.h index 3f44963680..3ff06709fd 100644 --- a/saga/actor.h +++ b/saga/actor.h @@ -72,6 +72,8 @@ class HitZone; #define PATH_NODE_EMPTY -1 +#define ACTOR_INHM_SIZE 228 + enum ActorActions { kActionWait = 0, kActionWalkToPoint = 1, @@ -227,6 +229,11 @@ struct Location { screenPoint.x = x / ACTOR_LMULT; screenPoint.y = y / ACTOR_LMULT - z; } + void fromStream(Common::MemoryReadStream &stream) { + x = stream.readUint16LE(); + y = stream.readUint16LE(); + z = stream.readUint16LE(); + } }; class CommonObjectData { @@ -247,7 +254,7 @@ public: Point screenPosition; // screen coordinates int32 screenDepth; // int32 screenScale; // - + void saveState(Common::OutSaveFile *out) { out->writeUint16LE(flags); out->writeSint32LE(nameIndex); @@ -572,6 +579,7 @@ public: void setProtagState(int state); int getProtagState() { return _protagState; } + void freeList(); void loadList(int actorsEntrance, int actorCount, int actorsResourceID, int protagStatesCount, int protagStatesResourceID); diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp index 19f892e4b0..7d162e09a1 100644 --- a/saga/ihnm_introproc.cpp +++ b/saga/ihnm_introproc.cpp @@ -80,10 +80,10 @@ SceneDescription IHNM_IntroMovie4Desc = { }; LoadSceneParams IHNM_IntroList[] = { - {0, kLoadByDescription, &IHNM_IntroMovie1Desc, Scene::SC_IHNMIntroMovieProc1, false, kTransitionNoFade, 0, -1}, - {0, kLoadByDescription, &IHNM_IntroMovie2Desc, Scene::SC_IHNMIntroMovieProc2, false, kTransitionNoFade, 0, -1}, - {0, kLoadByDescription, &IHNM_IntroMovie3Desc, Scene::SC_IHNMIntroMovieProc3, false, kTransitionNoFade, 0, -1}, - {0, kLoadByDescription, &IHNM_IntroMovie4Desc, Scene::SC_IHNMHateProc, false, kTransitionNoFade, 0, -1} + {0, kLoadByDescription, &IHNM_IntroMovie1Desc, Scene::SC_IHNMIntroMovieProc1, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {0, kLoadByDescription, &IHNM_IntroMovie2Desc, Scene::SC_IHNMIntroMovieProc2, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {0, kLoadByDescription, &IHNM_IntroMovie3Desc, Scene::SC_IHNMIntroMovieProc3, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {0, kLoadByDescription, &IHNM_IntroMovie4Desc, Scene::SC_IHNMHateProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE} }; int Scene::IHNMStartProc() { @@ -105,7 +105,7 @@ int Scene::IHNMStartProc() { firstScene.sceneProc = NULL; firstScene.transitionType = kTransitionFade; firstScene.actorsEntrance = 0; - firstScene.chapter = 0; + firstScene.chapter = -1; _vm->_scene->queueScene(&firstScene); diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index ba5a1fa594..d0ae95bc56 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -45,15 +45,15 @@ using Common::EN_USA; using Common::DE_DEU; LoadSceneParams ITE_IntroList[] = { - {RID_ITE_INTRO_ANIM_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroAnimProc, false, kTransitionNoFade, 0, -1}, - {RID_ITE_CAVE_SCENE_1, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave1Proc, false, kTransitionFade, 0, -1}, - {RID_ITE_CAVE_SCENE_2, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave2Proc, false, kTransitionNoFade, 0, -1}, - {RID_ITE_CAVE_SCENE_3, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave3Proc, false, kTransitionNoFade, 0, -1}, - {RID_ITE_CAVE_SCENE_4, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave4Proc, false, kTransitionNoFade, 0, -1}, - {RID_ITE_VALLEY_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroValleyProc, false, kTransitionFade, 0, -1}, - {RID_ITE_TREEHOUSE_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroTreeHouseProc, false, kTransitionNoFade, 0, -1}, - {RID_ITE_FAIREPATH_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFairePathProc, false, kTransitionNoFade, 0, -1}, - {RID_ITE_FAIRETENT_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFaireTentProc, false, kTransitionNoFade, 0, -1} + {RID_ITE_INTRO_ANIM_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroAnimProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {RID_ITE_CAVE_SCENE_1, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave1Proc, false, kTransitionFade, 0, NO_CHAPTER_CHANGE}, + {RID_ITE_CAVE_SCENE_2, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave2Proc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {RID_ITE_CAVE_SCENE_3, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave3Proc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {RID_ITE_CAVE_SCENE_4, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave4Proc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {RID_ITE_VALLEY_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroValleyProc, false, kTransitionFade, 0, NO_CHAPTER_CHANGE}, + {RID_ITE_TREEHOUSE_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroTreeHouseProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {RID_ITE_FAIREPATH_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFairePathProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {RID_ITE_FAIRETENT_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFaireTentProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE} }; int Scene::ITEStartProc() { diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp index 4b0b740669..5625f51b03 100644 --- a/saga/rscfile.cpp +++ b/saga/rscfile.cpp @@ -447,6 +447,9 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { _vm->_resource->loadResource(resourceContext, metaResourceTable[chapter], resourcePointer, resourceLength); + if (resourceLength == 0) { + error("Resource::loadGlobalResources wrong resource"); + } MemoryReadStream metaS(resourcePointer, resourceLength); _metaResource.sceneIndex = metaS.readSint16LE(); diff --git a/saga/scene.cpp b/saga/scene.cpp index 99ee820fe3..23570bb5f7 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -596,8 +596,8 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { EVENT event; EVENT *q_event; static PalEntry current_pal[PAL_ENTRIES]; - - if (loadSceneParams->chapter != -1) { + + if ((_vm->getGameType() == GType_IHNM) && (loadSceneParams->chapter != NO_CHAPTER_CHANGE)) { if (loadSceneParams->loadFlag != kLoadBySceneNumber) { error("loadScene wrong usage"); } diff --git a/saga/scene.h b/saga/scene.h index 5730fffac1..901d977683 100644 --- a/saga/scene.h +++ b/saga/scene.h @@ -34,6 +34,8 @@ namespace Saga { #define SCENE_DOORS_MAX 16 +#define NO_CHAPTER_CHANGE -2 + class ObjectMap; struct EVENT; @@ -248,7 +250,7 @@ class Scene { void clearSceneQueue(void) { _sceneQueue.clear(); } - void changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType, int chapter = -1); + void changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType, int chapter = NO_CHAPTER_CHANGE); void freeCutawayList(); bool isSceneLoaded() const { return _sceneLoaded; } |