aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kurushin2005-05-08 14:04:06 +0000
committerAndrew Kurushin2005-05-08 14:04:06 +0000
commita81b093e65f90ea70c5b07676a1fcc46d3e95a5e (patch)
treee0fced8f17e32e28fe24a1c948d2a74e6a039699
parent781472641e32d1999660caa54c27b218c5b4298d (diff)
downloadscummvm-rg350-a81b093e65f90ea70c5b07676a1fcc46d3e95a5e.tar.gz
scummvm-rg350-a81b093e65f90ea70c5b07676a1fcc46d3e95a5e.tar.bz2
scummvm-rg350-a81b093e65f90ea70c5b07676a1fcc46d3e95a5e.zip
fixed sfSceneEq bug
fixed load actors entrance removed some orphans svn-id: r17964
-rw-r--r--saga/actor.cpp28
-rw-r--r--saga/actor.h4
-rw-r--r--saga/events.cpp4
-rw-r--r--saga/ihnm_introproc.cpp49
-rw-r--r--saga/ite_introproc.cpp119
-rw-r--r--saga/render.cpp5
-rw-r--r--saga/saga.h10
-rw-r--r--saga/saveload.cpp47
-rw-r--r--saga/scene.cpp321
-rw-r--r--saga/scene.h136
-rw-r--r--saga/sdebug.cpp7
-rw-r--r--saga/sfuncs.cpp12
12 files changed, 324 insertions, 418 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 1990e1ef5f..73ee425361 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -374,7 +374,7 @@ void Actor::takeExit(uint16 actorId, const HitZone *hitZone) {
actor = getActor(actorId);
actor->lastZone = NULL;
- _vm->_scene->changeScene(hitZone->getSceneNumber(), hitZone->getActorsEntrance());
+ _vm->_scene->changeScene(hitZone->getSceneNumber(), hitZone->getActorsEntrance(), kTransitionNoFade);
_vm->_script->setNoPendingVerb();
}
@@ -562,6 +562,10 @@ void Actor::updateActorsScene(int actorsEntrance) {
return;
}
+ if (_vm->_scene->currentSceneNumber() == 0) {
+ error("Actor::updateActorsScene _vm->_scene->currentSceneNumber() == 0");
+ }
+
_activeSpeech.stringsCount = 0;
_protagonist = NULL;
@@ -597,8 +601,6 @@ void Actor::updateActorsScene(int actorsEntrance) {
_protagonist->location.z = sceneEntry->location.z * ACTOR_LMULT;
}
_protagonist->facingDirection = _protagonist->actionDirection = sceneEntry->facing;
- } else {
- warning("actorsEntrance < 0");
}
_protagonist->currentAction = kActionWait;
@@ -1261,7 +1263,11 @@ bool Actor::getSpriteParams(CommonObjectData *commonObjectData, int &frameNumber
return true;
}
-int Actor::drawActors() {
+void Actor::drawActors() {
+ if (_vm->_scene->currentSceneNumber() <= 0) {
+ return;
+ }
+
CommonObjectOrderList::iterator drawOrderIterator;
CommonObjectDataPointer drawObject;
int frameNumber;
@@ -1321,8 +1327,6 @@ int Actor::drawActors() {
}
}
-
- return SUCCESS;
}
bool Actor::followProtagonist(ActorData *actor) {
@@ -2295,8 +2299,6 @@ void Actor::drawPathTest() {
void Actor::saveState(File& out) {
uint16 i;
- out.writeSint32LE(_centerActor == NULL ? -1 : _centerActor->index);
- out.writeSint32LE(_protagonist == NULL ? -1 : _protagonist->index);
out.writeSint16LE(getProtagState());
for (i = 0; i < _actorsCount; i++) {
@@ -2304,8 +2306,6 @@ void Actor::saveState(File& out) {
a->saveState(out);
}
- //TODO: save _activeSpeech
-
for (i = 0; i < _objsCount; i++) {
ObjectData *o = _objs[i];
o->saveState(out);
@@ -2315,16 +2315,8 @@ void Actor::saveState(File& out) {
void Actor::loadState(File& in) {
int32 i;
- i = in.readSint32LE();
- _centerActor = (i < 0) ? NULL : _actors[i];
-
- i = in.readSint32LE();
- _protagonist = (i < 0) ? NULL : _actors[i];
-
setProtagState(in.readSint16LE());
- //TODO: load _activeSpeech
-
for (i = 0; i < _actorsCount; i++) {
ActorData *a = _actors[i];
a->loadState(in);
diff --git a/saga/actor.h b/saga/actor.h
index 93a36d7ad3..2afc7ec806 100644
--- a/saga/actor.h
+++ b/saga/actor.h
@@ -60,6 +60,8 @@ class HitZone;
#define ACTOR_SPEECH_STRING_MAX 16 // speech const
#define ACTOR_SPEECH_ACTORS_MAX 8
+#define ACTOR_NO_ENTRANCE -1
+
#define PATH_NODE_EMPTY -1
enum ActorActions {
@@ -464,7 +466,7 @@ public:
}
int direct(int msec);
- int drawActors();
+ void drawActors();
void updateActorsScene(int actorsEntrance); // calls from scene loading to update Actors info
void drawPathTest();
diff --git a/saga/events.cpp b/saga/events.cpp
index 759ac679b1..61f70ef612 100644
--- a/saga/events.cpp
+++ b/saga/events.cpp
@@ -277,9 +277,7 @@ int Events::handleOneShot(EVENT *event) {
break;
case EVENT_REMOVE:
{
- SCENE_INFO scene_info;
- _vm->_scene->getInfo(&scene_info);
- _vm->textDeleteEntry(scene_info.text_list, (TEXTLIST_ENTRY *)event->data);
+ _vm->textDeleteEntry(_vm->_scene->_textList, (TEXTLIST_ENTRY *)event->data);
}
break;
default:
diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp
index 2d98788694..09428d3ceb 100644
--- a/saga/ihnm_introproc.cpp
+++ b/saga/ihnm_introproc.cpp
@@ -80,18 +80,18 @@ SceneDescription IHNM_IntroMovie4Desc = {
ARRAYSIZE(IHNM_IntroMovie4RL)
};
-SCENE_QUEUE IHNM_IntroList[] = {
- {0, &IHNM_IntroMovie1Desc, BY_DESC, Scene::SC_IHNMIntroMovieProc1, 0, SCENE_NOFADE},
- {0, &IHNM_IntroMovie2Desc, BY_DESC, Scene::SC_IHNMIntroMovieProc2, 0, SCENE_NOFADE},
- {0, &IHNM_IntroMovie3Desc, BY_DESC, Scene::SC_IHNMIntroMovieProc3, 0, SCENE_NOFADE},
- {0, &IHNM_IntroMovie4Desc, BY_DESC, Scene::SC_IHNMHateProc, 0, SCENE_NOFADE}
+LoadSceneParams IHNM_IntroList[] = {
+ {0, kLoadByDescription, &IHNM_IntroMovie1Desc, Scene::SC_IHNMIntroMovieProc1, false, kTransitionNoFade, 0},
+ {0, kLoadByDescription, &IHNM_IntroMovie2Desc, Scene::SC_IHNMIntroMovieProc2, false, kTransitionNoFade, 0},
+ {0, kLoadByDescription, &IHNM_IntroMovie3Desc, Scene::SC_IHNMIntroMovieProc3, false, kTransitionNoFade, 0},
+ {0, kLoadByDescription, &IHNM_IntroMovie4Desc, Scene::SC_IHNMHateProc, false, kTransitionNoFade, 0}
};
int Scene::IHNMStartProc() {
size_t n_introscenes;
size_t i;
- SCENE_QUEUE first_scene;
+ LoadSceneParams firstScene;
n_introscenes = ARRAYSIZE(IHNM_IntroList);
@@ -106,22 +106,23 @@ int Scene::IHNMStartProc() {
// IHNM yet. Also, the end titles music to plays over the scene, which
// is wrong. (But hey, it's a nice piece of music!)
- first_scene.load_flag = BY_SCENE;
- first_scene.scene_n = _vm->getStartSceneNumber();
- first_scene.scene_skiptarget = 1;
- first_scene.scene_proc = NULL;
- first_scene.fadeType = SCENE_FADE;
+ firstScene.loadFlag = kLoadBySceneNumber;
+ firstScene.sceneDescriptor = _vm->getStartSceneNumber();
+ firstScene.sceneSkipTarget = true;
+ firstScene.sceneProc = NULL;
+ firstScene.transitionType = kTransitionFade;
+ firstScene.actorsEntrance = 0;
- _vm->_scene->queueScene(&first_scene);
+ _vm->_scene->queueScene(&firstScene);
return SUCCESS;
}
-int Scene::SC_IHNMIntroMovieProc1(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->IHNMIntroMovieProc1(param, scene_info);
+int Scene::SC_IHNMIntroMovieProc1(int param, void *refCon) {
+ return ((Scene *)refCon)->IHNMIntroMovieProc1(param);
}
-int Scene::IHNMIntroMovieProc1(int param, SCENE_INFO *scene_info) {
+int Scene::IHNMIntroMovieProc1(int param) {
EVENT event;
EVENT *q_event;
@@ -155,11 +156,11 @@ int Scene::IHNMIntroMovieProc1(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_IHNMIntroMovieProc2(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->IHNMIntroMovieProc2(param, scene_info);
+int Scene::SC_IHNMIntroMovieProc2(int param, void *refCon) {
+ return ((Scene *)refCon)->IHNMIntroMovieProc2(param);
}
-int Scene::IHNMIntroMovieProc2(int param, SCENE_INFO *scene_info) {
+int Scene::IHNMIntroMovieProc2(int param) {
EVENT event;
EVENT *q_event;
PALENTRY *pal;
@@ -241,11 +242,11 @@ int Scene::IHNMIntroMovieProc2(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_IHNMIntroMovieProc3(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->IHNMIntroMovieProc3(param, scene_info);
+int Scene::SC_IHNMIntroMovieProc3(int param, void *refCon) {
+ return ((Scene *)refCon)->IHNMIntroMovieProc3(param);
}
-int Scene::IHNMIntroMovieProc3(int param, SCENE_INFO *scene_info) {
+int Scene::IHNMIntroMovieProc3(int param) {
EVENT event;
EVENT *q_event;
PALENTRY *pal;
@@ -327,11 +328,11 @@ int Scene::IHNMIntroMovieProc3(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_IHNMHateProc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->IHNMHateProc(param, scene_info);
+int Scene::SC_IHNMHateProc(int param, void *refCon) {
+ return ((Scene *)refCon)->IHNMHateProc(param);
}
-int Scene::IHNMHateProc(int param, SCENE_INFO *scene_info) {
+int Scene::IHNMHateProc(int param) {
EVENT event;
EVENT *q_event;
diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp
index 9f4b33b3c8..fd22d091db 100644
--- a/saga/ite_introproc.cpp
+++ b/saga/ite_introproc.cpp
@@ -40,46 +40,47 @@
namespace Saga {
-SCENE_QUEUE ITE_IntroList[] = {
- {RID_ITE_INTRO_ANIM_SCENE, NULL, BY_RESOURCE, Scene::SC_ITEIntroAnimProc, 0, SCENE_NOFADE},
- {RID_ITE_CAVE_SCENE_1, NULL, BY_RESOURCE, Scene::SC_ITEIntroCave1Proc, 0, SCENE_FADE_NO_INTERFACE},
- {RID_ITE_CAVE_SCENE_2, NULL, BY_RESOURCE, Scene::SC_ITEIntroCave2Proc, 0, SCENE_NOFADE},
- {RID_ITE_CAVE_SCENE_3, NULL, BY_RESOURCE, Scene::SC_ITEIntroCave3Proc, 0, SCENE_NOFADE},
- {RID_ITE_CAVE_SCENE_4, NULL, BY_RESOURCE, Scene::SC_ITEIntroCave4Proc, 0, SCENE_NOFADE},
- {RID_ITE_VALLEY_SCENE, NULL, BY_RESOURCE, Scene::SC_ITEIntroValleyProc, 0, SCENE_FADE_NO_INTERFACE},
- {RID_ITE_TREEHOUSE_SCENE, NULL, BY_RESOURCE, Scene::SC_ITEIntroTreeHouseProc, 0, SCENE_NOFADE},
- {RID_ITE_FAIREPATH_SCENE, NULL, BY_RESOURCE, Scene::SC_ITEIntroFairePathProc, 0, SCENE_NOFADE},
- {RID_ITE_FAIRETENT_SCENE, NULL, BY_RESOURCE, Scene::SC_ITEIntroFaireTentProc, 0, SCENE_NOFADE}
+LoadSceneParams ITE_IntroList[] = {
+ {RID_ITE_INTRO_ANIM_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroAnimProc, false, kTransitionNoFade, 0},
+ {RID_ITE_CAVE_SCENE_1, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave1Proc, false, kTransitionFadeNoInterface, 0},
+ {RID_ITE_CAVE_SCENE_2, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave2Proc, false, kTransitionNoFade, 0},
+ {RID_ITE_CAVE_SCENE_3, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave3Proc, false, kTransitionNoFade, 0},
+ {RID_ITE_CAVE_SCENE_4, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave4Proc, false, kTransitionNoFade, 0},
+ {RID_ITE_VALLEY_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroValleyProc, false, kTransitionFadeNoInterface, 0},
+ {RID_ITE_TREEHOUSE_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroTreeHouseProc, false, kTransitionNoFade, 0},
+ {RID_ITE_FAIREPATH_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFairePathProc, false, kTransitionNoFade, 0},
+ {RID_ITE_FAIRETENT_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFaireTentProc, false, kTransitionNoFade, 0}
};
int Scene::ITEStartProc() {
size_t n_introscenes;
size_t i;
- SCENE_QUEUE first_scene;
- SCENE_QUEUE tempScene;
+ LoadSceneParams firstScene;
+ LoadSceneParams tempScene;
n_introscenes = ARRAYSIZE(ITE_IntroList);
for (i = 0; i < n_introscenes; i++) {
tempScene = ITE_IntroList[i];
- tempScene.scene_n = RSC_ConvertID(tempScene.scene_n);
+ tempScene.sceneDescriptor = RSC_ConvertID(tempScene.sceneDescriptor);
_vm->_scene->queueScene(&tempScene);
}
- first_scene.load_flag = BY_SCENE;
- first_scene.scene_n = _vm->getStartSceneNumber();
- first_scene.scene_skiptarget = 1;
- first_scene.scene_proc = NULL;
- first_scene.fadeType = SCENE_FADE;
+ firstScene.loadFlag = kLoadBySceneNumber;
+ firstScene.sceneDescriptor = _vm->getStartSceneNumber();
+ firstScene.sceneSkipTarget = true;
+ firstScene.sceneProc = NULL;
+ firstScene.transitionType = kTransitionFade;
+ firstScene.actorsEntrance = 0;
- _vm->_scene->queueScene(&first_scene);
+ _vm->_scene->queueScene(&firstScene);
return SUCCESS;
}
-EVENT *Scene::ITEQueueDialogue(EVENT *q_event, SCENE_INFO *scene_info, int n_dialogues, const INTRO_DIALOGUE dialogue[]) {
+EVENT *Scene::ITEQueueDialogue(EVENT *q_event, int n_dialogues, const INTRO_DIALOGUE dialogue[]) {
TEXTLIST_ENTRY text_entry;
TEXTLIST_ENTRY *entry_p;
EVENT event;
@@ -96,7 +97,7 @@ EVENT *Scene::ITEQueueDialogue(EVENT *q_event, SCENE_INFO *scene_info, int n_dia
for (i = 0; i < n_dialogues; i++) {
text_entry.string = dialogue[i].i_str;
- entry_p = _vm->textAddEntry(scene_info->text_list, &text_entry);
+ entry_p = _vm->textAddEntry(_textList, &text_entry);
// Display text
event.type = ONESHOT_EVENT;
@@ -154,7 +155,7 @@ enum {
// Queue a page of credits text. The original interpreter did word-wrapping
// automatically. We currently don't.
-EVENT *Scene::ITEQueueCredits(SCENE_INFO *scene_info, int delta_time, int duration, int n_credits, const INTRO_CREDIT credits[]) {
+EVENT *Scene::ITEQueueCredits(int delta_time, int duration, int n_credits, const INTRO_CREDIT credits[]) {
int game;
// The assumption here is that all WyrmKeep versions have the same
@@ -240,7 +241,7 @@ EVENT *Scene::ITEQueueCredits(SCENE_INFO *scene_info, int delta_time, int durati
text_entry.font_id = font;
text_entry.text_y = y;
- entry_p = _vm->textAddEntry(scene_info->text_list, &text_entry);
+ entry_p = _vm->textAddEntry(_textList, &text_entry);
// Display text
event.type = ONESHOT_EVENT;
@@ -266,12 +267,12 @@ EVENT *Scene::ITEQueueCredits(SCENE_INFO *scene_info, int delta_time, int durati
return q_event;
}
-int Scene::SC_ITEIntroAnimProc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->ITEIntroAnimProc(param, scene_info);
+int Scene::SC_ITEIntroAnimProc(int param, void *refCon) {
+ return ((Scene *)refCon)->ITEIntroAnimProc(param);
}
// Handles the introductory Dreamer's Guild / NWC logo animation scene.
-int Scene::ITEIntroAnimProc(int param, SCENE_INFO *scene_info) {
+int Scene::ITEIntroAnimProc(int param) {
EVENT event;
EVENT *q_event;
@@ -347,12 +348,12 @@ int Scene::ITEIntroAnimProc(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_ITEIntroCave1Proc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->ITEIntroCave1Proc(param, scene_info);
+int Scene::SC_ITEIntroCave1Proc(int param, void *refCon) {
+ return ((Scene *)refCon)->ITEIntroCave1Proc(param);
}
// Handles first introductory cave painting scene
-int Scene::ITEIntroCave1Proc(int param, SCENE_INFO *scene_info) {
+int Scene::ITEIntroCave1Proc(int param) {
EVENT event;
EVENT *q_event;
int lang = _vm->getFeatures() & GF_LANG_DE ? 1 : 0;
@@ -414,7 +415,7 @@ int Scene::ITEIntroCave1Proc(int param, SCENE_INFO *scene_info) {
q_event = _vm->_events->queue(&event);
// Queue narrator dialogue list
- q_event = ITEQueueDialogue(q_event, scene_info, n_dialogues, dialogue[lang]);
+ q_event = ITEQueueDialogue(q_event, n_dialogues, dialogue[lang]);
// End scene after last dialogue over
event.type = ONESHOT_EVENT;
@@ -435,12 +436,12 @@ int Scene::ITEIntroCave1Proc(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_ITEIntroCave2Proc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->ITEIntroCave2Proc(param, scene_info);
+int Scene::SC_ITEIntroCave2Proc(int param, void *refCon) {
+ return ((Scene *)refCon)->ITEIntroCave2Proc(param);
}
// Handles second introductory cave painting scene
-int Scene::ITEIntroCave2Proc(int param, SCENE_INFO *scene_info) {
+int Scene::ITEIntroCave2Proc(int param) {
EVENT event;
EVENT *q_event;
int lang = _vm->getFeatures() & GF_LANG_DE ? 1 : 0;
@@ -499,7 +500,7 @@ int Scene::ITEIntroCave2Proc(int param, SCENE_INFO *scene_info) {
q_event = _vm->_events->chain(q_event, &event);
// Queue narrator dialogue list
- q_event = ITEQueueDialogue(q_event, scene_info, n_dialogues, dialogue[lang]);
+ q_event = ITEQueueDialogue(q_event, n_dialogues, dialogue[lang]);
// End scene after last dialogue over
event.type = ONESHOT_EVENT;
@@ -519,12 +520,12 @@ int Scene::ITEIntroCave2Proc(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_ITEIntroCave3Proc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->ITEIntroCave3Proc(param, scene_info);
+int Scene::SC_ITEIntroCave3Proc(int param, void *refCon) {
+ return ((Scene *)refCon)->ITEIntroCave3Proc(param);
}
// Handles third introductory cave painting scene
-int Scene::ITEIntroCave3Proc(int param, SCENE_INFO *scene_info) {
+int Scene::ITEIntroCave3Proc(int param) {
EVENT event;
EVENT *q_event;
int lang = _vm->getFeatures() & GF_LANG_DE ? 1 : 0;
@@ -583,7 +584,7 @@ int Scene::ITEIntroCave3Proc(int param, SCENE_INFO *scene_info) {
q_event = _vm->_events->chain(q_event, &event);
// Queue narrator dialogue list
- q_event = ITEQueueDialogue(q_event, scene_info, n_dialogues, dialogue[lang]);
+ q_event = ITEQueueDialogue(q_event, n_dialogues, dialogue[lang]);
// End scene after last dialogue over
event.type = ONESHOT_EVENT;
@@ -603,12 +604,12 @@ int Scene::ITEIntroCave3Proc(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_ITEIntroCave4Proc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->ITEIntroCave4Proc(param, scene_info);
+int Scene::SC_ITEIntroCave4Proc(int param, void *refCon) {
+ return ((Scene *)refCon)->ITEIntroCave4Proc(param);
}
// Handles fourth introductory cave painting scene
-int Scene::ITEIntroCave4Proc(int param, SCENE_INFO *scene_info) {
+int Scene::ITEIntroCave4Proc(int param) {
EVENT event;
EVENT *q_event;
int lang = _vm->getFeatures() & GF_LANG_DE ? 1 : 0;
@@ -676,7 +677,7 @@ int Scene::ITEIntroCave4Proc(int param, SCENE_INFO *scene_info) {
q_event = _vm->_events->chain(q_event, &event);
// Queue narrator dialogue list
- q_event = ITEQueueDialogue(q_event, scene_info, n_dialogues, dialogue[lang]);
+ q_event = ITEQueueDialogue(q_event, n_dialogues, dialogue[lang]);
// End scene after last dialogue over
event.type = ONESHOT_EVENT;
@@ -696,12 +697,12 @@ int Scene::ITEIntroCave4Proc(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_ITEIntroValleyProc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->ITEIntroValleyProc(param, scene_info);
+int Scene::SC_ITEIntroValleyProc(int param, void *refCon) {
+ return ((Scene *)refCon)->ITEIntroValleyProc(param);
}
// Handles intro title scene (valley overlook)
-int Scene::ITEIntroValleyProc(int param, SCENE_INFO *scene_info) {
+int Scene::ITEIntroValleyProc(int param) {
EVENT event;
EVENT *q_event;
@@ -782,7 +783,7 @@ int Scene::ITEIntroValleyProc(int param, SCENE_INFO *scene_info) {
q_event = _vm->_events->chain(q_event, &event);
// Queue game credits list
- q_event = ITEQueueCredits(scene_info, 9000, CREDIT_DURATION1, n_credits, credits);
+ q_event = ITEQueueCredits(9000, CREDIT_DURATION1, n_credits, credits);
// End scene after credit display
event.type = ONESHOT_EVENT;
@@ -802,12 +803,12 @@ int Scene::ITEIntroValleyProc(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->ITEIntroTreeHouseProc(param, scene_info);
+int Scene::SC_ITEIntroTreeHouseProc(int param, void *refCon) {
+ return ((Scene *)refCon)->ITEIntroTreeHouseProc(param);
}
// Handles second intro credit screen (treehouse view)
-int Scene::ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info) {
+int Scene::ITEIntroTreeHouseProc(int param) {
EVENT event;
EVENT *q_event;
@@ -866,8 +867,8 @@ int Scene::ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info) {
q_event = _vm->_events->chain(q_event, &event);
// Queue game credits list
- q_event = ITEQueueCredits(scene_info, DISSOLVE_DURATION + 2000, CREDIT_DURATION1, n_credits1, credits1);
- q_event = ITEQueueCredits(scene_info, DISSOLVE_DURATION + 7000, CREDIT_DURATION1, n_credits2, credits2);
+ q_event = ITEQueueCredits(DISSOLVE_DURATION + 2000, CREDIT_DURATION1, n_credits1, credits1);
+ q_event = ITEQueueCredits(DISSOLVE_DURATION + 7000, CREDIT_DURATION1, n_credits2, credits2);
// End scene after credit display
event.type = ONESHOT_EVENT;
@@ -887,12 +888,12 @@ int Scene::ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_ITEIntroFairePathProc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->ITEIntroFairePathProc(param, scene_info);
+int Scene::SC_ITEIntroFairePathProc(int param, void *refCon) {
+ return ((Scene *)refCon)->ITEIntroFairePathProc(param);
}
// Handles third intro credit screen (path to puzzle tent)
-int Scene::ITEIntroFairePathProc(int param, SCENE_INFO *scene_info) {
+int Scene::ITEIntroFairePathProc(int param) {
EVENT event;
EVENT *q_event;
@@ -944,8 +945,8 @@ int Scene::ITEIntroFairePathProc(int param, SCENE_INFO *scene_info) {
q_event = _vm->_events->chain(q_event, &event);
// Queue game credits list
- q_event = ITEQueueCredits(scene_info, DISSOLVE_DURATION + 2000, CREDIT_DURATION1, n_credits1, credits1);
- q_event = ITEQueueCredits(scene_info, DISSOLVE_DURATION + 7000, CREDIT_DURATION1, n_credits2, credits2);
+ q_event = ITEQueueCredits(DISSOLVE_DURATION + 2000, CREDIT_DURATION1, n_credits1, credits1);
+ q_event = ITEQueueCredits(DISSOLVE_DURATION + 7000, CREDIT_DURATION1, n_credits2, credits2);
// End scene after credit display
event.type = ONESHOT_EVENT;
@@ -965,12 +966,12 @@ int Scene::ITEIntroFairePathProc(int param, SCENE_INFO *scene_info) {
return 0;
}
-int Scene::SC_ITEIntroFaireTentProc(int param, SCENE_INFO *scene_info, void *refCon) {
- return ((Scene *)refCon)->ITEIntroFaireTentProc(param, scene_info);
+int Scene::SC_ITEIntroFaireTentProc(int param, void *refCon) {
+ return ((Scene *)refCon)->ITEIntroFaireTentProc(param);
}
// Handles fourth intro credit screen (treehouse view)
-int Scene::ITEIntroFaireTentProc(int param, SCENE_INFO *scene_info) {
+int Scene::ITEIntroFaireTentProc(int param) {
EVENT event;
EVENT *q_event;
EVENT *q_event_start;
diff --git a/saga/render.cpp b/saga/render.cpp
index 93b4068eed..eab1884729 100644
--- a/saga/render.cpp
+++ b/saga/render.cpp
@@ -96,7 +96,6 @@ bool Render::initialized() {
int Render::drawScene() {
SURFACE *backbuf_surface;
- SCENE_INFO scene_info;
SCENE_BGINFO bg_info;
Point bg_pt;
char txt_buf[20];
@@ -140,9 +139,7 @@ int Render::drawScene() {
}
// Draw queued text strings
- _vm->_scene->getInfo(&scene_info);
-
- _vm->textDrawList(scene_info.text_list, backbuf_surface);
+ _vm->textDrawList(_vm->_scene->_textList, backbuf_surface);
// Handle user input
_vm->processInput();
diff --git a/saga/saga.h b/saga/saga.h
index 081d820275..11027dd25a 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -433,8 +433,14 @@ public:
virtual ~SagaEngine();
void shutDown() { _quit = true; }
- void save();
- void load();
+ void save() { //TODO: remove
+ save("iteSCUMMVM.sav");
+ }
+ void load() { //TODO: remove
+ load("iteSCUMMVM.sav");
+ }
+ void save(const char *fileName);
+ void load(const char *fileName);
int _soundEnabled;
int _musicEnabled;
diff --git a/saga/saveload.cpp b/saga/saveload.cpp
index 37d1933991..36c397054f 100644
--- a/saga/saveload.cpp
+++ b/saga/saveload.cpp
@@ -39,26 +39,24 @@
namespace Saga {
-void SagaEngine::save() {
+void SagaEngine::save(const char *fileName) {
File out;
- out.open("iteSCUMMVM.sav", File::kFileWriteMode);
+ out.open(fileName, File::kFileWriteMode);
//TODO: version number
- out.writeSint16LE(_script->_commonBufferSize);
-
// Surrounding scene
out.writeSint32LE(_scene->getOutsetSceneNumber());
- out.writeSint32LE(0);
// Inset scene
out.writeSint32LE(_scene->currentSceneNumber());
- out.writeSint32LE(0);
uint16 i;
_actor->saveState(out);
+ out.writeSint16LE(_script->_commonBufferSize);
+
for (i = 0; i < _script->_commonBufferSize; i++)
out.writeByte(_script->_commonBuffer[i]);
@@ -68,36 +66,33 @@ void SagaEngine::save() {
out.close();
}
-void SagaEngine::load() {
+void SagaEngine::load(const char *fileName) {
File in;
int commonBufferSize;
- int scenenum, inset;
+ int sceneNumber, insetSceneNumber;
int mapx, mapy;
+ uint16 i;
- in.open("iteSCUMMVM.sav");
+ in.open(fileName);
if (!in.isOpen())
return;
- commonBufferSize = in.readSint16LE();
// Surrounding scene
- scenenum = in.readSint32LE();
- in.readSint32LE();
+ sceneNumber = in.readSint32LE();
// Inset scene
- inset = in.readSint32LE();
- in.readSint32LE();
-
- debug(0, "scene: %d out: %d", scenenum, inset);
+ insetSceneNumber = in.readSint32LE();
- uint16 i;
+ debug(0, "scene: #%d inset scene: #%d", sceneNumber, insetSceneNumber);
- _interface->clearInventory(); //TODO: interface load-save-state
+ _interface->clearInventory();
_actor->loadState(in);
+ commonBufferSize = in.readSint16LE();
for (i = 0; i < commonBufferSize; i++)
_script->_commonBuffer[i] = in.readByte();
@@ -108,20 +103,18 @@ void SagaEngine::load() {
_isoMap->setMapPosition(mapx, mapy);
- // FIXME: When save/load screen will be implemented we should
- // call these after that screen left by user
- _interface->draw();
-
- // FIXME: hmmm... now we always require actorsEntrance to be defined
- // so no way to restore at arbitrary position
_scene->clearSceneQueue();
- _scene->changeScene(scenenum, 0);
+ _scene->changeScene(sceneNumber, ACTOR_NO_ENTRANCE, kTransitionNoFade);
- if (inset != scenenum) {
+ if (insetSceneNumber != sceneNumber) {
_render->drawScene();
_scene->clearSceneQueue();
- _scene->changeScene(inset, 0);
+ _scene->changeScene(insetSceneNumber, ACTOR_NO_ENTRANCE, kTransitionNoFade);
}
+
+ // FIXME: When save/load screen will be implemented we should
+ // call these after that screen left by user
+ _interface->draw();
}
} // End of namespace Saga
diff --git a/saga/scene.cpp b/saga/scene.cpp
index a9c2e33f86..4c33ee59ce 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -86,6 +86,7 @@ Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) {
for (i = 0; i < _sceneMax; i++) {
_sceneLUT[i] = readS.readUint16();
+ debug(8, "sceneNumber %i has resourceId %i", i, _sceneLUT[i]);
}
free(scene_lut_p);
@@ -108,8 +109,8 @@ Scene::Scene(SagaEngine *vm) : _vm(vm), _initialized(false) {
_sceneNumber = 0;
_sceneResourceId = 0;
_inGame = false;
- _loadDesc = false;
- memset(&_desc, 0, sizeof(_desc));
+ _loadDescription = false;
+ memset(&_sceneDescription, 0, sizeof(_sceneDescription));
_resListEntries = 0;
_resList = NULL;
_animEntries = 0;
@@ -130,37 +131,17 @@ Scene::~Scene() {
}
}
-int Scene::queueScene(SCENE_QUEUE *scene_queue) {
- assert(_initialized);
- assert(scene_queue != NULL);
-
- _sceneQueue.push_back(*scene_queue);
- return SUCCESS;
-}
-
-int Scene::clearSceneQueue() {
- assert(_initialized);
-
- _sceneQueue.clear();
-
- return SUCCESS;
-}
-
-int Scene::startScene() {
+void Scene::startScene() {
SceneQueueList::iterator queueIterator;
- SCENE_QUEUE *scene_qdat;
+ LoadSceneParams *sceneQueue;
EVENT event;
- assert(_initialized);
-
if (_sceneLoaded) {
- warning("Scene::start(): Error: Can't start game...scene already loaded");
- return FAILURE;
+ error("Scene::start(): Error: Can't start game...scene already loaded");
}
if (_inGame) {
- warning("Scene::start(): Error: Can't start game...game already started");
- return FAILURE;
+ error("Scene::start(): Error: Can't start game...game already started");
}
// Hide cursor during intro
@@ -177,38 +158,31 @@ int Scene::startScene() {
IHNMStartProc();
break;
default:
- warning("Scene::start(): Error: Can't start game... gametype not supported");
+ error("Scene::start(): Error: Can't start game... gametype not supported");
break;
}
// Load the head in scene queue
queueIterator = _sceneQueue.begin();
if (queueIterator == _sceneQueue.end()) {
- return SUCCESS;
+ return;
}
- scene_qdat = queueIterator.operator->();
- assert(scene_qdat != NULL);
+ sceneQueue = queueIterator.operator->();
- loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->sceneDescription, scene_qdat->fadeType, 0);
-
- return SUCCESS;
+ loadScene(sceneQueue);
}
-int Scene::nextScene() {
+void Scene::nextScene() {
SceneQueueList::iterator queueIterator;
- SCENE_QUEUE *scene_qdat;
-
- assert(_initialized);
+ LoadSceneParams *sceneQueue;
if (!_sceneLoaded) {
- warning("Scene::next(): Error: Can't advance scene...no scene loaded");
- return FAILURE;
+ error("Scene::next(): Error: Can't advance scene...no scene loaded");
}
if (_inGame) {
- warning("Scene::next(): Error: Can't advance scene...game already started");
- return FAILURE;
+ error("Scene::next(): Error: Can't advance scene...game already started");
}
endScene();
@@ -216,100 +190,82 @@ int Scene::nextScene() {
// Delete the current head in scene queue
queueIterator = _sceneQueue.begin();
if (queueIterator == _sceneQueue.end()) {
- return SUCCESS;
+ return;
}
queueIterator = _sceneQueue.erase(queueIterator);
if (queueIterator == _sceneQueue.end()) {
- return SUCCESS;
+ return;
}
// Load the head in scene queue
- scene_qdat = queueIterator.operator->();
- assert(scene_qdat != NULL);
+ sceneQueue = queueIterator.operator->();
- loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->sceneDescription, scene_qdat->fadeType, 0);
-
- return SUCCESS;
+ loadScene(sceneQueue);
}
-int Scene::skipScene() {
+void Scene::skipScene() {
SceneQueueList::iterator queueIterator;
- SCENE_QUEUE *scene_qdat = NULL;
- SCENE_QUEUE *skip_qdat = NULL;
+ LoadSceneParams *sceneQueue = NULL;
+ LoadSceneParams *skipQueue = NULL;
assert(_initialized);
if (!_sceneLoaded) {
- warning("Scene::skip(): Error: Can't skip scene...no scene loaded");
- return FAILURE;
+ error("Scene::skip(): Error: Can't skip scene...no scene loaded");
}
if (_inGame) {
- warning("Scene::skip(): Error: Can't skip scene...game already started");
- return FAILURE;
+ error("Scene::skip(): Error: Can't skip scene...game already started");
}
// Walk down scene queue and try to find a skip target
queueIterator = _sceneQueue.begin();
if (queueIterator == _sceneQueue.end()) {
- warning("Scene::skip(): Error: Can't skip scene...no scenes in queue");
- return FAILURE;
+ error("Scene::skip(): Error: Can't skip scene...no scenes in queue");
}
++queueIterator;
while (queueIterator != _sceneQueue.end()) {
- scene_qdat = queueIterator.operator->();
- assert(scene_qdat != NULL);
+ sceneQueue = queueIterator.operator->();
+ assert(sceneQueue != NULL);
- if (scene_qdat->scene_skiptarget) {
- skip_qdat = scene_qdat;
+ if (sceneQueue->sceneSkipTarget) {
+ skipQueue = sceneQueue;
break;
}
++queueIterator;
}
// If skip target found, remove preceding scenes and load
- if (skip_qdat != NULL) {
+ if (skipQueue != NULL) {
_sceneQueue.erase(_sceneQueue.begin(), queueIterator);
endScene();
- loadScene(skip_qdat->scene_n, skip_qdat->load_flag, skip_qdat->scene_proc, skip_qdat->sceneDescription, skip_qdat->fadeType, 0);
+ loadScene(skipQueue);
}
- // Search for a scene to skip to
-
- return SUCCESS;
}
-int Scene::changeScene(int sceneNumber, int actorsEntrance, int fadeIn) {
- assert(_initialized);
+void Scene::changeScene(uint16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType) {
+ LoadSceneParams sceneParams;
- if (!_sceneLoaded) {
- warning("Scene::changeScene(): Error: Can't change scene. No scene currently loaded. Game in invalid state");
- return FAILURE;
- }
-
- if ((sceneNumber < 0) || (sceneNumber > _sceneMax)) {
- warning("Scene::changeScene(): Error: Can't change scene. Invalid scene number");
- return FAILURE;
- }
-
- if (_sceneLUT[sceneNumber] == 0) {
- warning("Scene::changeScene(): Error: Can't change scene; invalid scene descriptor resource number (0)");
- return FAILURE;
- }
+ sceneParams.actorsEntrance = actorsEntrance;
+ sceneParams.loadFlag = kLoadBySceneNumber;
+ sceneParams.sceneDescriptor = sceneNumber;
+ sceneParams.transitionType = transitionType;
+ sceneParams.sceneProc = NULL;
+ sceneParams.sceneSkipTarget = false;
endScene();
- loadScene(sceneNumber, BY_SCENE, NULL, NULL, fadeIn, actorsEntrance);
+ loadScene(&sceneParams);
- return SUCCESS;
}
void Scene::getSlopes(int &beginSlope, int &endSlope) {
- beginSlope = _vm->getSceneHeight() - _desc.beginSlope;
- endSlope = _vm->getSceneHeight() - _desc.endSlope;
+ beginSlope = _vm->getSceneHeight() - _sceneDescription.beginSlope;
+ endSlope = _vm->getSceneHeight() - _sceneDescription.endSlope;
}
int Scene::getBGInfo(SCENE_BGINFO *bginfo) {
@@ -434,78 +390,50 @@ void Scene::initDoorsState() {
memcpy(_sceneDoors, initSceneDoors, sizeof (_sceneDoors) );
}
-int Scene::getInfo(SCENE_INFO *si) {
- assert(_initialized);
- assert(si != NULL);
-
- si->text_list = _textList;
-
- return SUCCESS;
-}
-
-int Scene::getSceneLUT(int scene_num) {
- assert((scene_num > 0) && (scene_num < _sceneMax));
-
- return _sceneLUT[scene_num];
-}
-
-int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SceneDescription *scene_desc_param, int fadeType, int actorsEntrance) {
- SCENE_INFO scene_info;
- uint32 resourceId = 0;
+void Scene::loadScene(LoadSceneParams *loadSceneParams) {
int result;
int i;
EVENT event;
EVENT *q_event;
static PALENTRY current_pal[PAL_ENTRIES];
- assert(_initialized);
-
if (_sceneLoaded) {
- warning("Scene::loadScene(): Error, a scene is already loaded");
- return FAILURE;
+ error("Scene::loadScene(): Error, a scene is already loaded");
}
- _loadDesc = true;
- _sceneNumber = -1;
+ _loadDescription = true;
- switch (load_flag) {
- case BY_RESOURCE:
- resourceId = scene_num;
+ switch (loadSceneParams->loadFlag) {
+ case kLoadByResourceId:
+ _sceneNumber = 0; // original assign zero for loaded by resource id
+ _sceneResourceId = loadSceneParams->sceneDescriptor;
break;
- case BY_SCENE:
- assert((scene_num > 0) && (scene_num < _sceneMax));
- resourceId = _sceneLUT[scene_num];
- _sceneNumber = scene_num;
+ case kLoadBySceneNumber:
+ _sceneNumber = loadSceneParams->sceneDescriptor;
+ _sceneResourceId = getSceneResourceId(_sceneNumber);
break;
- case BY_DESC:
- assert(scene_desc_param != NULL);
- assert(scene_desc_param->resList != NULL);
- _loadDesc = false;
- _desc = *scene_desc_param;
- _resList = scene_desc_param->resList;
- _resListEntries = scene_desc_param->resListCnt;
- break;
- default:
- warning("Scene::loadScene(): Error: Invalid scene load flag");
- return FAILURE;
+ case kLoadByDescription:
+ _sceneNumber = -1;
+ _sceneResourceId = -1;
+ assert(loadSceneParams->sceneDescription != NULL);
+ assert(loadSceneParams->sceneDescription->resList != NULL);
+ _loadDescription = false;
+ _sceneDescription = *loadSceneParams->sceneDescription;
+ _resList = loadSceneParams->sceneDescription->resList;
+ _resListEntries = loadSceneParams->sceneDescription->resListCnt;
break;
}
// Load scene descriptor and resource list resources
- if (_loadDesc) {
-
- _sceneResourceId = resourceId;
- assert(_sceneResourceId != 0);
- debug(0, "Loading scene resource %u:", resourceId);
+ if (_loadDescription) {
+ debug(0, "Loading scene resource %u:", _sceneResourceId);
- if (loadSceneDescriptor(resourceId) != SUCCESS) {
- warning("Scene::loadScene(): Error reading scene descriptor");
- return FAILURE;
+ if (loadSceneDescriptor(_sceneResourceId) != SUCCESS) {
+ error("Scene::loadScene(): Error reading scene descriptor");
}
- if (loadSceneResourceList(_desc.resListRN) != SUCCESS) {
- warning("Scene::loadScene(): Error reading scene resource list");
- return FAILURE;
+ if (loadSceneResourceList(_sceneDescription.resListRN) != SUCCESS) {
+ error("Scene::loadScene(): Error reading scene resource list");
}
} else {
debug(0, "Loading memory scene resource.");
@@ -516,18 +444,16 @@ int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SceneD
result = RSC_LoadResource(_sceneContext, _resList[i].res_number,
&_resList[i].res_data, &_resList[i].res_data_len);
if (result != SUCCESS) {
- warning("Scene::loadScene(): Error: Allocation failure loading scene resource list");
- return FAILURE;
+ error("Scene::loadScene(): Error: Allocation failure loading scene resource list");
}
}
// Process resources from scene resource list
if (processSceneResources() != SUCCESS) {
- warning("Scene::loadScene(): Error loading scene resources");
- return FAILURE;
+ error("Scene::loadScene(): Error loading scene resources");
}
- if (_desc.flags & kSceneFlagISO) {
+ if (_sceneDescription.flags & kSceneFlagISO) {
_outsetSceneNumber = _sceneNumber;
} else {
if (!(_bg.w < _vm->getDisplayWidth() || _bg.h < _vm->getSceneHeight()))
@@ -537,7 +463,8 @@ int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SceneD
_sceneLoaded = true;
q_event = NULL;
- if (fadeType == SCENE_FADE || fadeType == SCENE_FADE_NO_INTERFACE) {
+ if (loadSceneParams->transitionType == kTransitionFade ||
+ loadSceneParams->transitionType == kTransitionFadeNoInterface) {
_vm->_interface->rememberMode();
_vm->_interface->setMode(kPanelFade, true);
@@ -552,7 +479,7 @@ int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SceneD
event.data = current_pal;
q_event = _vm->_events->queue(&event);
- if (fadeType != SCENE_FADE_NO_INTERFACE) {
+ if (loadSceneParams->transitionType != kTransitionFadeNoInterface) {
// Activate user interface
event.type = IMMEDIATE_EVENT;
event.code = INTERFACE_EVENT;
@@ -581,22 +508,23 @@ int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SceneD
}
// Start the scene pre script, but stay with black palette
- if (_desc.startScriptEntrypointNumber > 0) {
+ if (_sceneDescription.startScriptEntrypointNumber > 0) {
event.type = ONESHOT_EVENT;
event.code = SCRIPT_EVENT;
event.op = EVENT_EXEC_BLOCKING;
event.time = 0;
- event.param = _desc.scriptModuleNumber;
- event.param2 = _desc.startScriptEntrypointNumber;
+ event.param = _sceneDescription.scriptModuleNumber;
+ event.param2 = _sceneDescription.startScriptEntrypointNumber;
event.param3 = 0; // Action
event.param4 = _sceneNumber; // Object
- event.param5 = actorsEntrance; // With Object
+ event.param5 = loadSceneParams->actorsEntrance; // With Object
event.param6 = 0; // Actor
q_event = _vm->_events->chain(q_event, &event);
}
- if (fadeType == SCENE_FADE || fadeType == SCENE_FADE_NO_INTERFACE) {
+ if (loadSceneParams->transitionType == kTransitionFade ||
+ loadSceneParams->transitionType == kTransitionFadeNoInterface) {
// Fade in from black to the scene background palette
event.type = IMMEDIATE_EVENT;
event.code = PAL_EVENT;
@@ -608,9 +536,8 @@ int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SceneD
q_event = _vm->_events->chain(q_event, &event);
}
- getInfo(&scene_info);
- if (scene_proc == NULL) {
+ if (loadSceneParams->sceneProc == NULL) {
if (!_inGame) {
_inGame = true;
_vm->_interface->setMode(kPanelInventory);
@@ -619,10 +546,10 @@ int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SceneD
_vm->_sound->stopVoice();
_vm->_sound->stopSound();
- if (_desc.musicRN >= 0) {
+ if (_sceneDescription.musicRN >= 0) {
event.type = ONESHOT_EVENT;
event.code = MUSIC_EVENT;
- event.param = _desc.musicRN;
+ event.param = _sceneDescription.musicRN;
event.param2 = MUSIC_DEFAULT;
event.op = EVENT_PLAY;
event.time = 0;
@@ -669,16 +596,16 @@ int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SceneD
_vm->_events->chain(q_event, &event);
// Start the scene main script
- if (_desc.sceneScriptEntrypointNumber > 0) {
+ if (_sceneDescription.sceneScriptEntrypointNumber > 0) {
event.type = ONESHOT_EVENT;
event.code = SCRIPT_EVENT;
event.op = EVENT_EXEC_NONBLOCKING;
event.time = 0;
- event.param = _desc.scriptModuleNumber;
- event.param2 = _desc.sceneScriptEntrypointNumber;
+ event.param = _sceneDescription.scriptModuleNumber;
+ event.param2 = _sceneDescription.sceneScriptEntrypointNumber;
event.param3 = kVerbEnter; // Action
event.param4 = _sceneNumber; // Object
- event.param5 = actorsEntrance; // With Object
+ event.param5 = loadSceneParams->actorsEntrance; // With Object
event.param6 = 0; // Actor
_vm->_events->queue(&event);
@@ -687,20 +614,19 @@ int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SceneD
debug(0, "Scene started");
} else {
- scene_proc(SCENE_BEGIN, &scene_info, this);
+ loadSceneParams->sceneProc(SCENE_BEGIN, this);
}
- // We probably don't want "followers" to go into scene -1. At the very
+ // We probably don't want "followers" to go into scene -1 , 0. At the very
// least we don't want garbage to be drawn that early in the ITE intro.
- if (_sceneNumber != -1)
- _vm->_actor->updateActorsScene(actorsEntrance);
+ if (_sceneNumber > 0)
+ _vm->_actor->updateActorsScene(loadSceneParams->actorsEntrance);
- if (_desc.flags & kSceneFlagShowCursor)
+ if (_sceneDescription.flags & kSceneFlagShowCursor)
_vm->_interface->activate();
- return SUCCESS;
}
int Scene::loadSceneDescriptor(uint32 res_number) {
@@ -716,14 +642,14 @@ int Scene::loadSceneDescriptor(uint32 res_number) {
MemoryReadStreamEndian readS(scene_desc_data, scene_desc_len, IS_BIG_ENDIAN);
- _desc.flags = readS.readSint16();
- _desc.resListRN = readS.readSint16();
- _desc.endSlope = readS.readSint16();
- _desc.beginSlope = readS.readSint16();
- _desc.scriptModuleNumber = readS.readUint16();
- _desc.sceneScriptEntrypointNumber = readS.readUint16();
- _desc.startScriptEntrypointNumber = readS.readUint16();
- _desc.musicRN = readS.readSint16();
+ _sceneDescription.flags = readS.readSint16();
+ _sceneDescription.resListRN = readS.readSint16();
+ _sceneDescription.endSlope = readS.readSint16();
+ _sceneDescription.beginSlope = readS.readSint16();
+ _sceneDescription.scriptModuleNumber = readS.readUint16();
+ _sceneDescription.sceneScriptEntrypointNumber = readS.readUint16();
+ _sceneDescription.startScriptEntrypointNumber = readS.readUint16();
+ _sceneDescription.musicRN = readS.readSint16();
RSC_FreeResource(scene_desc_data);
@@ -828,7 +754,7 @@ int Scene::processSceneResources() {
_actionMap->load(res_data, res_data_len);
break;
case SAGA_ISO_IMAGES:
- if (!(_desc.flags & kSceneFlagISO)) {
+ if (!(_sceneDescription.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -837,7 +763,7 @@ int Scene::processSceneResources() {
_vm->_isoMap->loadImages(res_data, res_data_len);
break;
case SAGA_ISO_MAP:
- if (!(_desc.flags & kSceneFlagISO)) {
+ if (!(_sceneDescription.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -846,7 +772,7 @@ int Scene::processSceneResources() {
_vm->_isoMap->loadMap(res_data, res_data_len);
break;
case SAGA_ISO_PLATFORMS:
- if (!(_desc.flags & kSceneFlagISO)) {
+ if (!(_sceneDescription.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -855,7 +781,7 @@ int Scene::processSceneResources() {
_vm->_isoMap->loadPlatforms(res_data, res_data_len);
break;
case SAGA_ISO_METATILES:
- if (!(_desc.flags & kSceneFlagISO)) {
+ if (!(_sceneDescription.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -891,7 +817,7 @@ int Scene::processSceneResources() {
}
break;
case SAGA_ISO_MULTI:
- if (!(_desc.flags & kSceneFlagISO)) {
+ if (!(_sceneDescription.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -926,7 +852,7 @@ int Scene::draw(SURFACE *dst_s) {
_vm->_render->getBufferInfo(&buf_info);
- if (_desc.flags & kSceneFlagISO) {
+ if (_sceneDescription.flags & kSceneFlagISO) {
_vm->_isoMap->adjustScroll(false);
_vm->_isoMap->draw(dst_s);
} else {
@@ -937,22 +863,16 @@ int Scene::draw(SURFACE *dst_s) {
return SUCCESS;
}
-int Scene::endScene() {
- SCENE_INFO scene_info;
-
- assert(_initialized);
+void Scene::endScene() {
if (!_sceneLoaded) {
- warning("Scene::endScene(): No scene to end");
- return -1;
+ error("Scene::endScene(): No scene to end");
}
debug(0, "Ending scene...");
if (_sceneProc != NULL) {
- getInfo(&scene_info);
-
- _sceneProc(SCENE_END, &scene_info, this);
+ _sceneProc(SCENE_END, this);
}
//
@@ -978,7 +898,7 @@ int Scene::endScene() {
}
// Free scene resource list
- if (_loadDesc) {
+ if (_loadDescription) {
free(_resList);
}
@@ -1003,7 +923,6 @@ int Scene::endScene() {
_sceneLoaded = false;
- return SUCCESS;
}
void Scene::cmdSceneChange(int argc, const char **argv) {
@@ -1018,11 +937,7 @@ void Scene::cmdSceneChange(int argc, const char **argv) {
clearSceneQueue();
- if (changeScene(scene_num, 0) == SUCCESS) {
- _vm->_console->DebugPrintf("Scene changed.\n");
- } else {
- _vm->_console->DebugPrintf("Couldn't change scene!\n");
- }
+ changeScene(scene_num, 0, kTransitionNoFade);
}
void Scene::cmdSceneInfo() {
@@ -1031,14 +946,14 @@ void Scene::cmdSceneInfo() {
_vm->_console->DebugPrintf(fmt, "Scene number:", _sceneNumber);
_vm->_console->DebugPrintf(fmt, "Descriptor ResourceId:", _sceneResourceId);
_vm->_console->DebugPrintf("-------------------------\n");
- _vm->_console->DebugPrintf(fmt, "Flags:", _desc.flags);
- _vm->_console->DebugPrintf(fmt, "Resource list R#:", _desc.resListRN);
- _vm->_console->DebugPrintf(fmt, "End slope:", _desc.endSlope);
- _vm->_console->DebugPrintf(fmt, "Begin slope:", _desc.beginSlope);
- _vm->_console->DebugPrintf(fmt, "scriptModuleNumber:", _desc.scriptModuleNumber);
- _vm->_console->DebugPrintf(fmt, "sceneScriptEntrypointNumber:", _desc.sceneScriptEntrypointNumber);
- _vm->_console->DebugPrintf(fmt, "startScriptEntrypointNumber:", _desc.startScriptEntrypointNumber);
- _vm->_console->DebugPrintf(fmt, "Music R#", _desc.musicRN);
+ _vm->_console->DebugPrintf(fmt, "Flags:", _sceneDescription.flags);
+ _vm->_console->DebugPrintf(fmt, "Resource list R#:", _sceneDescription.resListRN);
+ _vm->_console->DebugPrintf(fmt, "End slope:", _sceneDescription.endSlope);
+ _vm->_console->DebugPrintf(fmt, "Begin slope:", _sceneDescription.beginSlope);
+ _vm->_console->DebugPrintf(fmt, "scriptModuleNumber:", _sceneDescription.scriptModuleNumber);
+ _vm->_console->DebugPrintf(fmt, "sceneScriptEntrypointNumber:", _sceneDescription.sceneScriptEntrypointNumber);
+ _vm->_console->DebugPrintf(fmt, "startScriptEntrypointNumber:", _sceneDescription.startScriptEntrypointNumber);
+ _vm->_console->DebugPrintf(fmt, "Music R#", _sceneDescription.musicRN);
}
diff --git a/saga/scene.h b/saga/scene.h
index 7405bcea77..6281497fb5 100644
--- a/saga/scene.h
+++ b/saga/scene.h
@@ -53,18 +53,8 @@ struct SCENE_BGINFO {
size_t bg_buflen;
};
-struct SCENE_INFO {
- SCENE_BGINFO bg_info;
- TEXTLIST *text_list;
-};
-
-typedef int (SCENE_PROC) (int, SCENE_INFO *, void *);
+typedef int (SceneProc) (int, void *);
-enum SCENE_LOAD_FLAGS {
- BY_RESOURCE = 0,
- BY_SCENE,
- BY_DESC
-};
enum SCENE_PROC_PARAMS {
SCENE_BEGIN = 0,
@@ -166,21 +156,28 @@ struct SCENE_ANIMINFO {
typedef SortedList<SCENE_ANIMINFO> SceneAnimInfoList;
enum SceneTransitionType {
- SCENE_NOFADE = 0,
- SCENE_FADE = 1,
- SCENE_FADE_NO_INTERFACE = 2
+ kTransitionNoFade,
+ kTransitionFade,
+ kTransitionFadeNoInterface
};
-struct SCENE_QUEUE {
- uint32 scene_n;
+enum SceneLoadFlags {
+ kLoadByResourceId,
+ kLoadBySceneNumber,
+ kLoadByDescription
+};
+
+struct LoadSceneParams {
+ uint32 sceneDescriptor;
+ SceneLoadFlags loadFlag;
SceneDescription* sceneDescription;
- int load_flag;
- SCENE_PROC *scene_proc;
- int scene_skiptarget;
- int fadeType;
+ SceneProc *sceneProc;
+ bool sceneSkipTarget;
+ SceneTransitionType transitionType;
+ int actorsEntrance;
};
-typedef Common::List<SCENE_QUEUE> SceneQueueList;
+typedef Common::List<LoadSceneParams> SceneQueueList;
///// IHNM-specific stuff
#define IHNM_PALFADE_TIME 1000
@@ -227,14 +224,17 @@ class Scene {
void cmdSceneChange(int argc, const char **argv);
- int startScene();
- int nextScene();
- int skipScene();
- int endScene();
- int queueScene(SCENE_QUEUE *scene_queue);
+ void startScene();
+ void nextScene();
+ void skipScene();
+ void endScene();
+ void queueScene(LoadSceneParams *sceneQueue) {
+ _sceneQueue.push_back(*sceneQueue);
+ }
+
int draw(SURFACE *);
- int getFlags() const { return _desc.flags; }
- int getScriptModuleNumber() const { return _desc.scriptModuleNumber; }
+ int getFlags() const { return _sceneDescription.flags; }
+ int getScriptModuleNumber() const { return _sceneDescription.scriptModuleNumber; }
bool isInDemo() { return !_inGame; }
void getBGMaskInfo(int &width, int &height, byte *&buffer, size_t &bufferLength);
@@ -250,22 +250,28 @@ class Scene {
int getBGInfo(SCENE_BGINFO *bginfo);
int getBGPal(PALENTRY **pal);
- int getInfo(SCENE_INFO *si);
void getSlopes(int &beginSlope, int &endSlope);
- int clearSceneQueue(void);
- int changeScene(int sceneNumber, int actorsEntrance, int fadeIn = SCENE_NOFADE);
+ void clearSceneQueue(void) {
+ _sceneQueue.clear();
+ }
+ void changeScene(uint16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType);
bool initialized() { return _initialized; }
- int getSceneLUT(int num);
+ int getSceneResourceId(int sceneNumber) {
+ if ((sceneNumber < 0) || (sceneNumber >= _sceneMax)) {
+ error("getSceneResourceId: wrong sceneNumber");
+ }
+ return _sceneLUT[sceneNumber];
+ }
int currentSceneNumber() const { return _sceneNumber; }
int getOutsetSceneNumber() const { return _outsetSceneNumber; }
int currentSceneResourceId() const { return _sceneResourceId; }
private:
- int loadScene(int scene, int load_flag, SCENE_PROC scene_proc, SceneDescription *, int fadeIn, int actorsEntrance);
+ void loadScene(LoadSceneParams *loadSceneParams);
int loadSceneDescriptor(uint32 res_number);
int loadSceneResourceList(uint32 res_number);
void loadSceneEntryList(const byte* resourcePointer, size_t resourceLength);
@@ -286,14 +292,13 @@ class Scene {
int _outsetSceneNumber;
int _sceneResourceId;
bool _inGame;
- bool _loadDesc;
- SceneDescription _desc;
+ bool _loadDescription;
+ SceneDescription _sceneDescription;
int _resListEntries;
SCENE_RESLIST *_resList;
int _animEntries;
SceneAnimInfoList _animList;
- SCENE_PROC *_sceneProc;
- TEXTLIST *_textList;
+ SceneProc *_sceneProc;
SCENE_IMAGE _bg;
SCENE_IMAGE _bgMask;
@@ -305,46 +310,47 @@ class Scene {
ObjectMap *_objectMap;
SceneEntryList _entryList;
StringsTable _sceneStrings;
+ TEXTLIST *_textList;
private:
int IHNMStartProc();
int ITEStartProc();
public:
- static int SC_IHNMIntroMovieProc1(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_IHNMIntroMovieProc2(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_IHNMIntroMovieProc3(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_IHNMHateProc(int param, SCENE_INFO *scene_info, void *refCon);
+ static int SC_IHNMIntroMovieProc1(int param, void *refCon);
+ static int SC_IHNMIntroMovieProc2(int param, void *refCon);
+ static int SC_IHNMIntroMovieProc3(int param, void *refCon);
+ static int SC_IHNMHateProc(int param, void *refCon);
private:
- int IHNMIntroMovieProc1(int param, SCENE_INFO *scene_info);
- int IHNMIntroMovieProc2(int param, SCENE_INFO *scene_info);
- int IHNMIntroMovieProc3(int param, SCENE_INFO *scene_info);
- int IHNMHateProc(int param, SCENE_INFO *scene_info);
+ int IHNMIntroMovieProc1(int param);
+ int IHNMIntroMovieProc2(int param);
+ int IHNMIntroMovieProc3(int param);
+ int IHNMHateProc(int param);
public:
- static int SC_ITEIntroAnimProc(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_ITEIntroCave1Proc(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_ITEIntroCave2Proc(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_ITEIntroCave3Proc(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_ITEIntroCave4Proc(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_ITEIntroValleyProc(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_ITEIntroFairePathProc(int param, SCENE_INFO *scene_info, void *refCon);
- static int SC_ITEIntroFaireTentProc(int param, SCENE_INFO *scene_info, void *refCon);
+ static int SC_ITEIntroAnimProc(int param, void *refCon);
+ static int SC_ITEIntroCave1Proc(int param, void *refCon);
+ static int SC_ITEIntroCave2Proc(int param, void *refCon);
+ static int SC_ITEIntroCave3Proc(int param, void *refCon);
+ static int SC_ITEIntroCave4Proc(int param, void *refCon);
+ static int SC_ITEIntroValleyProc(int param, void *refCon);
+ static int SC_ITEIntroTreeHouseProc(int param, void *refCon);
+ static int SC_ITEIntroFairePathProc(int param, void *refCon);
+ static int SC_ITEIntroFaireTentProc(int param, void *refCon);
private:
- EVENT *ITEQueueDialogue(EVENT *q_event, SCENE_INFO *scene_info, int n_dialogues, const INTRO_DIALOGUE dialogue[]);
- EVENT *ITEQueueCredits(SCENE_INFO *scene_info, int delta_time, int duration, int n_credits, const INTRO_CREDIT credits[]);
- int ITEIntroAnimProc(int param, SCENE_INFO *scene_info);
- int ITEIntroCave1Proc(int param, SCENE_INFO *scene_info);
- int ITEIntroCave2Proc(int param, SCENE_INFO *scene_info);
- int ITEIntroCave3Proc(int param, SCENE_INFO *scene_info);
- int ITEIntroCave4Proc(int param, SCENE_INFO *scene_info);
- int ITEIntroValleyProc(int param, SCENE_INFO *scene_info);
- int ITEIntroTreeHouseProc(int param, SCENE_INFO *scene_info);
- int ITEIntroFairePathProc(int param, SCENE_INFO *scene_info);
- int ITEIntroFaireTentProc(int param, SCENE_INFO *scene_info);
+ EVENT *ITEQueueDialogue(EVENT *q_event, int n_dialogues, const INTRO_DIALOGUE dialogue[]);
+ EVENT *ITEQueueCredits(int delta_time, int duration, int n_credits, const INTRO_CREDIT credits[]);
+ int ITEIntroAnimProc(int param);
+ int ITEIntroCave1Proc(int param);
+ int ITEIntroCave2Proc(int param);
+ int ITEIntroCave3Proc(int param);
+ int ITEIntroCave4Proc(int param);
+ int ITEIntroValleyProc(int param);
+ int ITEIntroTreeHouseProc(int param);
+ int ITEIntroFairePathProc(int param);
+ int ITEIntroFaireTentProc(int param);
};
diff --git a/saga/sdebug.cpp b/saga/sdebug.cpp
index ebc378ea7c..7235023c67 100644
--- a/saga/sdebug.cpp
+++ b/saga/sdebug.cpp
@@ -45,14 +45,11 @@ int Script::SDebugPrintInstr(ScriptThread *thread) {
// int op_offset;
int n_switch;
int i;
- SCENE_INFO si;
-
- _vm->_scene->getInfo(&si);
disp_buf[0] = 0;
if (_dbg_txtentry != NULL) {
- _vm->textDeleteEntry(si.text_list, _dbg_txtentry);
+ _vm->textDeleteEntry(_vm->_scene->_textList, _dbg_txtentry);
_dbg_txtentry = NULL;
}
@@ -469,7 +466,7 @@ int Script::SDebugPrintInstr(ScriptThread *thread) {
break;
}
- _dbg_txtentry = _vm->textAddEntry(si.text_list, &tl_e);
+ _dbg_txtentry = _vm->textAddEntry(_vm->_scene->_textList, &tl_e);
_vm->textSetDisplay(_dbg_txtentry, 1);
return SUCCESS;
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index 434873069c..02881efef5 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -512,7 +512,7 @@ void Script::sfScriptGotoScene(SCRIPTFUNC_PARAMS) {
}
}
- _vm->_scene->changeScene(sceneNumber, entrance, (sceneNumber == RID_ITE_ENDCREDIT_SCENE_1) ? SCENE_FADE : SCENE_NOFADE);
+ _vm->_scene->changeScene(sceneNumber, entrance, (sceneNumber == RID_ITE_ENDCREDIT_SCENE_1) ? kTransitionFade : kTransitionNoFade);
//TODO: placard stuff
_pendingVerb = kVerbNone;
@@ -718,10 +718,11 @@ void Script::sfScriptMoveTo(SCRIPTFUNC_PARAMS) {
}
// Script function #31 (0x21)
+// Param1: sceneNumber
void Script::sfSceneEq(SCRIPTFUNC_PARAMS) {
- int16 param = thread->pop();
+ int16 sceneNumber = thread->pop();
- if (_vm->_scene->getSceneLUT(param) == _vm->_scene->currentSceneNumber())
+ if (_vm->_scene->getSceneResourceId(sceneNumber) == _vm->_scene->currentSceneResourceId())
thread->_returnValue = 1;
else
thread->_returnValue = 0;
@@ -1199,9 +1200,6 @@ void Script::sfPlacard(SCRIPTFUNC_PARAMS) {
// but it's close enough for now at least.
TEXTLIST_ENTRY text_entry;
- SCENE_INFO scene_info;
-
- _vm->_scene->getInfo(&scene_info);
text_entry.color = kITEColorBrightWhite;
text_entry.effect_color = kITEColorBlack;
@@ -1211,7 +1209,7 @@ void Script::sfPlacard(SCRIPTFUNC_PARAMS) {
text_entry.flags = FONT_OUTLINE | FONT_CENTERED;
text_entry.string = thread->_strings->getString(stringId);
- placardTextEntry = _vm->textAddEntry(scene_info.text_list, &text_entry);
+ placardTextEntry = _vm->textAddEntry(_vm->_scene->_textList, &text_entry);
event.type = ONESHOT_EVENT;
event.code = TEXT_EVENT;