diff options
Diffstat (limited to 'engines/saga/actor.h')
-rw-r--r-- | engines/saga/actor.h | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/engines/saga/actor.h b/engines/saga/actor.h index ede2ee714b..2b6b5c2a3b 100644 --- a/engines/saga/actor.h +++ b/engines/saga/actor.h @@ -196,7 +196,7 @@ struct ActorFrameSequence { ActorFrameRange directions[ACTOR_DIRECTIONS_COUNT]; }; -//typedef Common::Array<ActorFrameSequence> ActorFrameSequences; +typedef Common::Array<ActorFrameSequence> ActorFrameSequences; uint pathLine(PointList &pointList, uint idx, const Point &point1, const Point &point2); @@ -325,6 +325,21 @@ public: _screenDepth = in->readSint32LE(); _screenScale = in->readSint32LE(); } + + CommonObjectData() { + _disabled = false; + _index = 0; + _id = 0; + _scriptEntrypointNumber = 0; + + _flags = 0; + _nameIndex = 0; + _sceneNumber = 0; + _spriteListResourceId = 0; + + _screenDepth = 0; + _screenScale = 0; + } }; typedef CommonObjectData *CommonObjectDataPointer; @@ -335,19 +350,21 @@ class ObjectData: public CommonObjectData { public: //constant uint16 _interactBits; + ObjectData() { - memset(this, 0, sizeof(*this)); + _interactBits = 0; } }; +typedef Common::Array<ObjectData> ObjectDataArray; + class ActorData: public CommonObjectData { public: //constant SpriteList _spriteList; // sprite list data - bool _shareFrames; - ActorFrameSequence *_frames; // Actor's frames - int _framesCount; // Actor's frames count + ActorFrameSequences *_frames; // Actor's frames + ActorFrameSequences _framesContainer; // Actor's frames int _frameListResourceId; // Actor's frame list resource id byte _speechColor; // Actor dialogue color @@ -391,18 +408,21 @@ public: public: ActorData(); - ~ActorData(); void saveState(Common::OutSaveFile *out); void loadState(uint32 version, Common::InSaveFile *in); void cycleWrap(int cycleLimit); void addWalkStepPoint(const Point &point); + bool shareFrames() { + return ((_frames != NULL) && (_frames != &_framesContainer)); + } }; +typedef Common::Array<ActorData> ActorDataArray; + struct ProtagStateData { - ActorFrameSequence *_frames; // Actor's frames - int _framesCount; // Actor's frames count + ActorFrameSequences _frames; // Actor's frames }; @@ -447,15 +467,17 @@ public: void cmdActorWalkTo(int argc, const char **argv); - bool validActorId(uint16 id) { return (id == ID_PROTAG) || ((id >= objectIndexToId(kGameObjectActor, 0)) && (id < objectIndexToId(kGameObjectActor, _actorsCount))); } + bool validActorId(uint16 id) { + return (id == ID_PROTAG) || ((id >= objectIndexToId(kGameObjectActor, 0)) && (id < objectIndexToId(kGameObjectActor, _actors.size()))); + } int actorIdToIndex(uint16 id) { return (id == ID_PROTAG) ? 0 : objectIdToIndex(id); } uint16 actorIndexToId(int index) { return (index == 0) ? ID_PROTAG : objectIndexToId(kGameObjectActor, index); } ActorData *getActor(uint16 actorId); - ActorData *getFirstActor() { return _actors[0]; } + ActorData *getFirstActor() { return &_actors.front(); } // clarification: Obj - means game object, such Hat, Spoon etc, Object - means Actor,Obj,HitZone,StepZone - bool validObjId(uint16 id) { return (id >= objectIndexToId(kGameObjectObject, 0)) && (id < objectIndexToId(kGameObjectObject, _objsCount)); } + bool validObjId(uint16 id) { return (id >= objectIndexToId(kGameObjectObject, 0)) && (id < objectIndexToId(kGameObjectObject, _objs.size())); } int objIdToIndex(uint16 id) { return objectIdToIndex(id); } uint16 objIndexToId(int index) { return objectIndexToId(kGameObjectObject, index); } ObjectData *getObj(uint16 objId); @@ -522,18 +544,14 @@ public: void setProtagState(int state); int getProtagState() { return _protagState; } - void freeProtagStates(); - - void freeActorList(); void loadActorList(int protagonistIdx, int actorCount, int actorsResourceID, int protagStatesCount, int protagStatesResourceID); - void freeObjList(); void loadObjList(int objectCount, int objectsResourceID); protected: friend class Script; bool loadActorResources(ActorData *actor); - void loadFrameList(int frameListResourceId, ActorFrameSequence *&framesPointer, int &framesCount); + void loadFrameList(int frameListResourceId, ActorFrameSequences &frames); private: void stepZoneAction(ActorData *actor, const HitZone *hitZone, bool exit, bool stopped); void loadActorSpriteList(ActorData *actor); @@ -581,11 +599,9 @@ private: protected: //constants - int _actorsCount; - ActorData **_actors; + ActorDataArray _actors; - int _objsCount; - ObjectData **_objs; + ObjectDataArray _objs; SagaEngine *_vm; ResourceContext *_actorContext; @@ -610,8 +626,7 @@ protected: bool _dragonHunt; private: - ProtagStateData *_protagStates; - int _protagStatesCount; + Common::Array<ProtagStateData> _protagStates; //path stuff struct PathNode { |