aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorAndrew Kurushin2004-12-18 20:33:02 +0000
committerAndrew Kurushin2004-12-18 20:33:02 +0000
commit62224e135b8e788564ef49676b790ca651b95fcd (patch)
tree9c1b2af74d79d82f947e36119abd6ec860450ed7 /saga
parentf33fc1d7ec21197bc74d5581ab669c0d4e2140b4 (diff)
downloadscummvm-rg350-62224e135b8e788564ef49676b790ca651b95fcd.tar.gz
scummvm-rg350-62224e135b8e788564ef49676b790ca651b95fcd.tar.bz2
scummvm-rg350-62224e135b8e788564ef49676b790ca651b95fcd.zip
- updating actors state so they can be clipped on drawing (intro now runs without artefact)
- order list now uses only in draw section - drawList rename to drawActors svn-id: r16122
Diffstat (limited to 'saga')
-rw-r--r--saga/actor.cpp134
-rw-r--r--saga/actor.h61
-rw-r--r--saga/actordata.cpp2
-rw-r--r--saga/actordata.h16
-rw-r--r--saga/render.cpp2
-rw-r--r--saga/scene.cpp3
-rw-r--r--saga/scene.h1
7 files changed, 108 insertions, 111 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 56319a483c..36337c3d01 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -70,13 +70,16 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
for (i = 0; i < ACTORCOUNT; i++) {
actor = &_actors[i];
- actor->_actorId = ACTOR_INDEX_TO_ID(i);
- actor->_index = i;
- debug(0, "init actorId=0x%X index=0x%X", actor->_actorId, actor->_index);
+ actor->actorId = ACTOR_INDEX_TO_ID(i);
+ actor->index = i;
+ debug(0, "init actorId=0x%X index=0x%X", actor->actorId, actor->index);
+ actor->nameIndex = ActorTable[i].nameIndex;
actor->spriteListResourceId = ActorTable[i].spriteListResourceId;
actor->frameListResourceId = ActorTable[i].frameListResourceId;
- actor->flags = ActorTable[i].flags;
actor->speechColor = ActorTable[i].speechColor;
+ actor->sceneNumber = ActorTable[i].sceneIndex;
+
+ actor->flags = ActorTable[i].flags;
actor->orient = ACTOR_DEFAULT_ORIENT;
actor->def_action = 0;
actor->def_action_flags = 0;
@@ -84,13 +87,11 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
actor->action_flags = 0;
actor->action_time = 0;
actor->action_frame = 0;
- actor->_disabled = !loadActorResources(actor);
- if (actor->_disabled) {
- warning("Disabling actorId=0x%X index=0x%X", actor->_actorId, actor->_index);
- } else {
- _orderList.push_back(actor);
- }
+ actor->disabled = !loadActorResources(actor);
+ if (actor->disabled) {
+ warning("Disabling actorId=0x%X index=0x%X", actor->actorId, actor->index);
+ }
}
}
@@ -110,7 +111,7 @@ Actor::~Actor() {
bool Actor::loadActorResources(ActorData * actor) {
byte *resourcePointer;
size_t resourceLength;
- int frameCount;
+ int framesCount;
ActorFrame *framesPointer;
int lastFrame;
int i, orient;
@@ -123,10 +124,10 @@ bool Actor::loadActorResources(ActorData * actor) {
return false;
}
- frameCount = resourceLength / 16;
- debug(0, "Frame resource contains %d frames", frameCount);
+ framesCount = resourceLength / 16;
+ debug(0, "Frame resource contains %d frames", framesCount);
- framesPointer = (ActorFrame *)malloc(sizeof(ActorFrame) * frameCount);
+ framesPointer = (ActorFrame *)malloc(sizeof(ActorFrame) * framesCount);
if (framesPointer == NULL) {
error("Couldn't allocate memory for sprite frames");
}
@@ -135,7 +136,7 @@ bool Actor::loadActorResources(ActorData * actor) {
lastFrame = 0;
- for (i = 0; i < frameCount; i++) {
+ for (i = 0; i < framesCount; i++) {
for (orient = 0; orient < ACTOR_ORIENTATION_COUNT; orient++) {
// Load all four orientations
framesPointer[i].dir[orient].frameIndex = readS.readUint16();
@@ -149,7 +150,7 @@ bool Actor::loadActorResources(ActorData * actor) {
RSC_FreeResource(resourcePointer);
actor->frames = framesPointer;
- actor->frameCount = frameCount;
+ actor->framesCount = framesCount;
debug(0, "Loading sprite resource id 0x%X", actor->spriteListResourceId);
@@ -179,39 +180,26 @@ ActorData *Actor::getActor(uint16 actorId) {
actor = &_actors[ACTOR_ID_TO_INDEX(actorId)];
- if (actor->_disabled)
+ if (actor->disabled)
error("Actor::getActor disabled actorId 0x%X", actorId);
return actor;
}
-ActorOrderList::iterator Actor::getActorOrderIterator(const ActorData *actor) {
- ActorOrderList::iterator actorOrderIterator;
+void Actor::updateActorsScene() {
+ int i;
+ ActorData *actor;
- for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator)
- if (actor == actorOrderIterator.operator*()) {
- return actorOrderIterator;
+ for (i = 0; i < ACTORCOUNT; i++) {
+ actor = &_actors[i];
+ if (actor->flags & (kProtagonist | kFollower)) {
+ actor->sceneNumber = _vm->_scene->currentSceneNumber();
}
-
- error("Actor::getActorOrderIterator actor");
-}
-
-void Actor::reorderActorUp(ActorData *actor) {
- ActorOrderList::iterator actorOrderIterator;
-
- actorOrderIterator = getActorOrderIterator(actor);
- actorOrderIterator = _orderList.reorderUp(actorOrderIterator, actorCompare);
-}
-
-void Actor::reorderActorDown(ActorData *actor) {
- ActorOrderList::iterator actorOrderIterator;
-
- actorOrderIterator = getActorOrderIterator(actor);
- actorOrderIterator = _orderList.reorderDown(actorOrderIterator, actorCompare);
+ }
}
int Actor::direct(int msec) {
- ActorOrderList::iterator actorOrderIterator;
+ int i;
ActorData *actor;
ActorIntentList::iterator actorIntentIterator;
@@ -221,8 +209,9 @@ int Actor::direct(int msec) {
int action_tdelta;
// Walk down the actor list and direct each actor
- for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator) {
- actor = actorOrderIterator.operator*();
+ for (i = 0; i < ACTORCOUNT; i++) {
+ actor = &_actors[i];
+ if (actor->disabled) continue;
// Process the actor intent list
actorIntentIterator = actor->a_intentlist.begin();
@@ -236,7 +225,6 @@ int Actor::direct(int msec) {
// Actor intends to go somewhere. Well good for him
{
handleWalkIntent(actor, &a_intent->walkIntent, &a_intent->a_idone, msec);
- actorOrderIterator = getActorOrderIterator(actor);
}
break;
case INTENT_SPEAK:
@@ -289,8 +277,22 @@ int Actor::direct(int msec) {
return SUCCESS;
}
-int Actor::drawList() {
- ActorOrderList::iterator actorOrderIterator;
+void Actor::createDrawOrderList() {
+ int i;
+ ActorData *actor;
+
+ _drawOrderList.clear();
+ for (i = 0;i < ACTORCOUNT;i++) {
+ actor = &_actors[i];
+ if (actor->disabled) continue;
+
+ if (actor->sceneNumber == _vm->_scene->currentSceneNumber())
+ _drawOrderList.pushBack(actor, actorCompare);
+ }
+}
+
+int Actor::drawActors() {
+ ActorOrderList::iterator actorDrawOrderIterator;
ActorData *actor;
ActorIntentList::iterator actorIntentIterator;
@@ -308,14 +310,16 @@ int Actor::drawList() {
back_buf = _vm->_gfx->getBackBuffer();
- for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator) {
- actor = actorOrderIterator.operator*();
- if(actor->frameCount == 0) continue;
+ createDrawOrderList();
+
+ for (actorDrawOrderIterator = _drawOrderList.begin(); actorDrawOrderIterator != _drawOrderList.end(); ++actorDrawOrderIterator) {
+ actor = actorDrawOrderIterator.operator*();
+ if (actor->framesCount == 0) continue;
o_idx = ActorOrientationLUT[actor->orient];
sprite_num = actor->frames[actor->action].dir[o_idx].frameIndex;
sprite_num += actor->action_frame;
- if(actor->spriteList->sprite_count <= sprite_num) continue;
+ if (actor->spriteList->sprite_count <= sprite_num) continue;
_vm->_sprite->drawOccluded(back_buf, actor->spriteList, sprite_num, actor->s_pt.x, actor->s_pt.y);
// If actor's current intent is to speak, oblige him by
@@ -345,7 +349,7 @@ int Actor::drawList() {
// dialogue entry if there is a current speak intent present.
int Actor::skipDialogue() {
- ActorOrderList::iterator actorOrderIterator;
+ int i;
ActorData *actor;
ActorIntentList::iterator actorIntentIterator;
@@ -354,8 +358,9 @@ int Actor::skipDialogue() {
ActorDialogList::iterator actorDialogIterator;
ACTORDIALOGUE *a_dialogue;
- for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator) {
- actor = actorOrderIterator.operator*();
+ for (i = 0; i < ACTORCOUNT; i++) {
+ actor = &_actors[i];
+ if (actor->disabled) continue;
// Check the actor's current intent for a speak intent
actorIntentIterator = actor->a_intentlist.begin();
if (actorIntentIterator != actor->a_intentlist.end()) {
@@ -526,7 +531,7 @@ void Actor::setAction(uint16 actorId, int action_n, uint16 action_flags) {
actor = getActor(actorId);
- if ((action_n < 0) || (action_n >= actor->frameCount)) {
+ if ((action_n < 0) || (action_n >= actor->framesCount)) {
error("Actor::setAction wrong action_n 0x%X", action_n);
}
@@ -542,7 +547,7 @@ void Actor::setDefaultAction(uint16 actorId, int action_n, uint16 action_flags)
actor = getActor(actorId);
- if ((action_n < 0) || (action_n >= actor->frameCount)) {
+ if ((action_n < 0) || (action_n >= actor->framesCount)) {
error("Actor::setDefaultAction wrong action_n 0x%X", action_n);
}
@@ -571,6 +576,8 @@ void Actor::walkTo(uint16 actorId, const Point *walk_pt, uint16 flags, SEMAPHORE
actor_intent.walkIntent.dst_pt = *walk_pt;
actor->a_intentlist.push_back(actor_intent);
+ int is = actor->a_intentlist.size();
+ debug(0, "actor->a_intentlist.size() %i", is);
if (sem != NULL) {
_vm->_script->SThreadHoldSem(sem);
@@ -620,7 +627,7 @@ int Actor::handleWalkIntent(ActorData *actor, WALKINTENT *a_walkint, int *comple
// Initialize walk intent
if (!a_walkint->wi_init) {
setPathNode(a_walkint, &actor->a_pt, &a_walkint->dst_pt, a_walkint->sem);
- setDefaultAction(actor->_actorId, ACTION_IDLE, ACTION_NONE);
+ setDefaultAction(actor->actorId, ACTION_IDLE, ACTION_NONE);
a_walkint->wi_init = 1;
}
@@ -741,12 +748,6 @@ int Actor::handleWalkIntent(ActorData *actor, WALKINTENT *a_walkint, int *comple
actor->s_pt.x = actor->a_pt.x >> 2;
actor->s_pt.y = actor->a_pt.y >> 2;
- if (path_slope < 0) {
- reorderActorUp(actor);
- } else {
- reorderActorDown(actor);
- }
-
return SUCCESS;
}
@@ -764,13 +765,6 @@ void Actor::move(uint16 actorId, const Point &movePoint) {
actor->a_pt = movePoint;
AtoS(actor->s_pt, actor->a_pt);
-
- if (moveUp) {
- reorderActorUp(actor);
- } else {
- reorderActorDown(actor);
- }
-
}
void Actor::moveRelative(uint16 actorId, const Point &movePoint) {
@@ -782,12 +776,6 @@ void Actor::moveRelative(uint16 actorId, const Point &movePoint) {
actor->a_pt.y += movePoint.y;
AtoS(actor->s_pt, actor->a_pt);
-
- if (actor->a_pt.y < 0) {
- reorderActorUp(actor);
- } else {
- reorderActorDown(actor);
- }
}
void Actor::AtoS(Point &screenPoint, const Point &actorPoint) {
diff --git a/saga/actor.h b/saga/actor.h
index 922fecdd17..3d48ff4b85 100644
--- a/saga/actor.h
+++ b/saga/actor.h
@@ -177,24 +177,29 @@ struct ACTORINTENT {
typedef Common::List<ACTORINTENT> ActorIntentList;
struct ActorData {
- bool _disabled;
- int _index; // Actor index
- uint16 _actorId; // Actor id
+ bool disabled; // Actor disabled in init section
+ int index; // Actor index
+ uint16 actorId; // Actor id
+ int nameIndex; // Actor's index in actor name string list
+ byte speechColor; // Actor dialogue color
+ uint16 flags; // Actor flags
+ int sceneNumber; // scene of actor
+
+ int currentAction;
+ int facingDirection;
+ int actionDirection;
+
+ SPRITELIST *spriteList; // Actor's sprite list data
+ int spriteListResourceId; // Actor's sprite list resource id
+
+ ActorFrame *frames; // Actor's frames
+ int framesCount; // Actor's frames count
+ int frameListResourceId; // Actor's frame list resource id
- int name_i; // Actor's index in actor name string list
- uint16 flags;
Point a_pt; // Actor's logical coordinates
Point s_pt; // Actor's screen coordinates
- SPRITELIST *spriteList; // Actor's sprite list data
- int spriteListResourceId; // Actor's sprite list resource id
-
- ActorFrame *frames; // Actor's frames
- int frameCount; // Actor's frames count
- int frameListResourceId; // Actor's frame list resource id
-
- byte speechColor; // Actor dialogue color
int idle_time;
int orient;
@@ -220,20 +225,24 @@ struct ActorData {
ActorData() {
- _disabled = false;
- _index = 0;
- _actorId = 0;
- name_i = 0;
- flags = 0;
+ disabled = false;
+ index = 0;
+ actorId = 0;
+ nameIndex = 0;
+ currentAction = 0;
+ facingDirection = 0;
+ actionDirection = 0;
+ speechColor = 0;
frames = NULL;
- frameCount = 0;
+ framesCount = 0;
frameListResourceId = 0;
spriteList = NULL;
spriteListResourceId = 0;
+ flags = 0;
+
idle_time = 0;
orient = 0;
speaking = 0;
- speechColor = 0;
def_action = 0;
def_action_flags = 0;
action = 0;
@@ -263,8 +272,9 @@ public:
void CF_actor_setact(int argc, const char **argv);
int direct(int msec);
+ int drawActors();
+ void updateActorsScene(); // calls from scene loading to update Actors info
- int drawList();
void AtoS(Point &screenPoint, const Point &actorPoint);
void StoA(Point &actorPoint, const Point &screenPoint);
@@ -282,7 +292,7 @@ public:
void setAction(uint16 actorId, int action_n, uint16 action_flags);
void setDefaultAction(uint16 actorId, int action_n, uint16 action_flags);
-
+
private:
int handleWalkIntent(ActorData *actor, WALKINTENT *a_walk_int, int *complete_p, int msec);
int handleSpeakIntent(ActorData *actor, SPEAKINTENT *a_speakint, int *complete_p, int msec);
@@ -292,14 +302,11 @@ private:
bool loadActorResources(ActorData * actor);
- ActorOrderList::iterator getActorOrderIterator(const ActorData *actor);
- void reorderActorUp(ActorData *actor);
- void reorderActorDown(ActorData *actor);
-
+ void createDrawOrderList();
SagaEngine *_vm;
RSCFILE_CONTEXT *_actorContext;
- ActorOrderList _orderList;
+ ActorOrderList _drawOrderList;
ActorData _actors[ACTORCOUNT];
};
diff --git a/saga/actordata.cpp b/saga/actordata.cpp
index f0de002947..896f126ff1 100644
--- a/saga/actordata.cpp
+++ b/saga/actordata.cpp
@@ -30,7 +30,7 @@ namespace Saga {
// Lookup table to convert 8 cardinal directions to 4
int ActorOrientationLUT[] = { 2, 0, 0, 0, 3, 1, 1, 1 };
-ACTORTABLE ActorTable[ACTORCOUNT] = {
+ActorTableData ActorTable[ACTORCOUNT] = {
// flags name scene x y z spr frm scp col
// -------------- --- ---- ---- ----- ---- ---- ---- --- ---- --- -- --
{ kProtagonist , 0, 1, 0, 0, 0, 37, 135, 0, 1, 0, 0, 0}, // map party
diff --git a/saga/actordata.h b/saga/actordata.h
index c6d1502c53..77cc64e7d6 100644
--- a/saga/actordata.h
+++ b/saga/actordata.h
@@ -29,18 +29,18 @@
namespace Saga {
enum {
- kProtagonist = 0x01, // Actor is protagonist
- kFollower = 0x02, // Actor is follower
- kCycle = 0x04, // Actor stand has a cycle
- kFaster = 0x08, // Actor is fast
- kFastest = 0x10, // Actor is faster
- kExtended = 0x20 // Actor uses extended sprites
+ kProtagonist = 0x01, // Actor is protagonist
+ kFollower = 0x02, // Actor is follower
+ kCycle = 0x04, // Actor stand has a cycle
+ kFaster = 0x08, // Actor is fast
+ kFastest = 0x10, // Actor is faster
+ kExtended = 0x20 // Actor uses extended sprites
};
// TODO: This doesn't quite correspond to the original Actor struct, so I'm not
// sure if I got it right.
-struct ACTORTABLE {
+struct ActorTableData {
byte flags;
byte nameIndex;
int32 sceneIndex;
@@ -59,7 +59,7 @@ struct ACTORTABLE {
#define ACTORCOUNT 181
extern int ActorOrientationLUT[];
-extern ACTORTABLE ActorTable[ACTORCOUNT];
+extern ActorTableData ActorTable[ACTORCOUNT];
} // End of namespace Saga
diff --git a/saga/render.cpp b/saga/render.cpp
index 80e7d3526c..38c9363bca 100644
--- a/saga/render.cpp
+++ b/saga/render.cpp
@@ -135,7 +135,7 @@ int Render::drawScene() {
}
// Draw queued actors
- _vm->_actor->drawList();
+ _vm->_actor->drawActors();
// Draw queued text strings
_vm->_scene->getInfo(&scene_info);
diff --git a/saga/scene.cpp b/saga/scene.cpp
index 53362bcc79..fd0c5c19c6 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -43,6 +43,7 @@
#include "saga/scene.h"
#include "saga/stream.h"
+#include "saga/actor.h"
namespace Saga {
@@ -552,6 +553,8 @@ int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SCENE_
getInfo(&scene_info);
_sceneProc(SCENE_BEGIN, &scene_info, this);
+
+ _vm->_actor->updateActorsScene();
return SUCCESS;
}
diff --git a/saga/scene.h b/saga/scene.h
index 3f821e460f..a7e4ac877e 100644
--- a/saga/scene.h
+++ b/saga/scene.h
@@ -137,7 +137,6 @@ struct SCENE_IMAGE {
struct SCENE_ANIMINFO {
int anim_res_number;
int anim_handle;
- //SCENE_ANIMINFO *next;
};
typedef SortedList<SCENE_ANIMINFO> SceneAnimInfoList;