ASYLUM: Removed the actionarray class and rolled it into actionlist (which makes way more sense).

git-svn-id: http://asylumengine.googlecode.com/svn/trunk@394 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
Alex Bevilacqua 2009-11-27 12:22:37 +00:00 committed by Eugene Sandulenko
parent a33b9e677a
commit d9aaf26c18
No known key found for this signature in database
GPG key ID: 014D387312D34F08
8 changed files with 80 additions and 176 deletions

View file

@ -1,76 +0,0 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "asylum/actionarray.h"
namespace Asylum {
ActionArray::ActionArray(AsylumEngine *engine): _vm(engine) {
_actionFlag = false;
reset();
}
ActionArray::~ActionArray() {
}
void ActionArray::reset() {
memset(&_items, 0, sizeof(ActionStruct));
for (int i = 0; i < 10; i++)
_items.entries[i].actionListIndex = -1;
}
void ActionArray::initItem(ActionDefinitions *command, int actionIndex, int actorIndex) {
// TODO properly define what actionFlag is actually for.
// It appears to remain false 99% of the time, so I'm guessing
// it's a "skip processing" flag.
if (!_actionFlag) {
int i;
// iterate through the availble entry slots to determine
// the next available slot
for (i = 1; i < 10; i++) {
if (_items.entries[i].actionListIndex == -1)
break;
}
command->counter = 0;
_items.entries[i].field_10 = 0;
_items.entries[i].field_C = 0;
if (_items.count) {
_items.entries[_items.field_CC].field_C = i ;
_items.entries[0].field_10 = _items.field_CC;
} else {
_items.count = i;
}
_items.field_CC = i;
_items.entries[0].actionListIndex = actionIndex;
_items.entries[0].actionListItemIndex = 0;
_items.entries[0].actorIndex = actorIndex;
}
}
} // end of namespace Asylum

View file

@ -1,83 +0,0 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef ASYLUM_ACTIONARRAY_H_
#define ASYLUM_ACTIONARRAY_H_
#include "asylum/asylum.h"
#include "common/array.h"
namespace Asylum {
typedef struct ActionItem {
int actionListIndex;
int actionListItemIndex;
int actorIndex;
int field_C;
int field_10;
} ActionItem;
typedef struct ActionStruct {
ActionItem entries[10];
int count;
int field_CC;
} ActionStruct;
struct ActionDefinitions;
class ActionArray {
public:
ActionArray(AsylumEngine *engine);
virtual ~ActionArray();
/** .text:00401020
* Reset the _actionArray entries to their
* default values
*/
void reset();
/** .text:00401050
* Initialize the script element at actionIndex to
* the actor at actorIndex
*
* FIXME passing in a reference to the command at actionIndex
* to do a quick update.
*/
void initItem(ActionDefinitions *command, int actionIndex, int actorIndex);
void setActionFlag(bool value) { _actionFlag = value; }
private:
bool _actionFlag;
ActionStruct _items;
AsylumEngine *_vm;
}; // end of class ActionArray
} // end of namespace Asylum
#endif /* ASYLUM_ACTIONARRAY_H_ */

View file

@ -38,6 +38,8 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
delayedSceneIndex = -1;
delayedVideoIndex = -1;
allowInput = true;
_actionFlag = false;
reset();
}
ActionList::~ActionList() {
@ -185,6 +187,43 @@ void ActionList::setScriptByIndex(uint32 index) {
}
}
void ActionList::reset() {
memset(&_items, 0, sizeof(ActionStruct));
for (int i = 0; i < 10; i++)
_items.entries[i].actionListIndex = -1;
}
void ActionList::initItem(int actionIndex, int actorIndex) {
// TODO properly define what actionFlag is actually for.
// It appears to remain false 99% of the time, so I'm guessing
// it's a "skip processing" flag.
if (!_actionFlag) {
int i;
// iterate through the availble entry slots to determine
// the next available slot
for (i = 1; i < 10; i++) {
if (_items.entries[i].actionListIndex == -1)
break;
}
_scene->actions()->entries[actionIndex].counter = 0;
_items.entries[i].field_10 = 0;
_items.entries[i].field_C = 0;
if (_items.count) {
_items.entries[_items.field_CC].field_C = i ;
_items.entries[0].field_10 = _items.field_CC;
} else {
_items.count = i;
}
_items.field_CC = i;
_items.entries[0].actionListIndex = actionIndex;
_items.entries[0].actionListItemIndex = 0;
_items.entries[0].actorIndex = actorIndex;
}
}
void ActionList::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
//int v4 = 0;
int result;
@ -809,11 +848,11 @@ int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn) {
}
int kSetActionFlag(ActionCommand *cmd, Scene *scn) {
scn->vm()->actionarray()->setActionFlag(true);
scn->actions()->setActionFlag(true);
return 0;
}
int kClearActionFlag(ActionCommand *cmd, Scene *scn) {
scn->vm()->actionarray()->setActionFlag(false);
scn->actions()->setActionFlag(false);
return 0;
}
int kResetSceneRect(ActionCommand *cmd, Scene *scn) {

View file

@ -59,6 +59,22 @@ typedef struct ActionDefinitions {
uint32 counter;
} ActionDefinitions;
typedef struct ActionItem {
int actionListIndex;
int actionListItemIndex;
int actorIndex;
int field_C;
int field_10;
} ActionItem;
typedef struct ActionStruct {
ActionItem entries[10];
int count;
int field_CC;
} ActionStruct;
class ActionList {
public:
ActionList(Common::SeekableReadStream *stream, Scene *scene);
@ -83,15 +99,30 @@ public:
bool done;
bool waitCycle;
// TODO depreciate
void setScriptByIndex(uint32 index);
ActionDefinitions* getScript() {
return _currentScript;
}
// TODO depreciate
ActionDefinitions* getScript() { return _currentScript; }
/** .text:00402120
* Process the current script
*/
int process();
/** .text:00401020
* Reset the _actionArray entries to their
* default values
*/
void reset();
/** .text:00401050
* Initialize the script element at actionIndex to
* the actor at actorIndex
*/
void initItem(int actionIndex, int actorIndex);
/**
* Toggle the action queue processing flag
*/
void setActionFlag(bool value) { _actionFlag = value; }
void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
void enableActorSub(int actorIndex, int condition);
@ -99,9 +130,10 @@ public:
private:
Scene *_scene;
ActionDefinitions *_currentScript;
bool _actionFlag;
ActionStruct _items;
void load(Common::SeekableReadStream *stream);
};
// opcode functions

View file

@ -68,7 +68,6 @@ AsylumEngine::~AsylumEngine() {
delete _screen;
delete _encounter;
delete _text;
delete _actionArray;
}
Common::Error AsylumEngine::run() {
@ -95,7 +94,6 @@ Common::Error AsylumEngine::init() {
_introPlaying = false;
memset(_gameFlags, 0, 1512);
_actionArray = new ActionArray(this);
return Common::kNoError;
}

View file

@ -37,7 +37,6 @@
#include "asylum/video.h"
#include "asylum/blowuppuzzle.h"
#include "asylum/encounters.h"
#include "asylum/actionarray.h"
namespace Asylum {
@ -67,7 +66,6 @@ class Screen;
class Sound;
class Video;
class Encounter;
class ActionArray;
enum kDebugLevels {
kDebugLevelMain = 1 << 0,
@ -118,7 +116,6 @@ public:
Screen* screen() { return _screen; }
Scene* scene() { return _scene;}
Text* text() { return _text; }
ActionArray *actionarray() { return _actionArray; }
private:
void checkForEvent(bool doUpdate);
@ -141,8 +138,6 @@ private:
Text *_text;
Encounter *_encounter;
ActionArray *_actionArray;
int _gameFlags[1512];
friend class Console;

View file

@ -1,7 +1,6 @@
MODULE := engines/asylum
MODULE_OBJS := \
actionarray.o \
actionlist.o \
actor.o \
asylum.o \

View file

@ -170,7 +170,7 @@ void Scene::initialize() {
uint32 actionIdx = _ws->actionListIdx;
if (actionIdx)
_vm->actionarray()->initItem(&_actions->entries[actionIdx], actionIdx, 0);
_actions->initItem(actionIdx, 0);
// TODO initActionListArrayItem(idx, 0) .text:00401050
// XXX not sure why we need to do this again