ASYLUM: moved the checkFlags() and setNextFrame() methods that relate directly to barriers into the barrier class (off of the actionlist)

git-svn-id: http://asylumengine.googlecode.com/svn/trunk@350 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
Alex Bevilacqua 2009-09-19 13:59:29 +00:00 committed by Eugene Sandulenko
parent 4caee427b7
commit 4c01ffb9e3
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
4 changed files with 24 additions and 30 deletions

View File

@ -180,27 +180,6 @@ void ActionList::setScriptByIndex(uint32 index) {
}
}
int ActionList::checkBarrierFlags(int barrierId) {
int flags = _scene->worldstats()->getBarrierById(barrierId)->flags;
return flags & 1 && (flags & 8 || flags & 0x10000);
}
int ActionList::setBarrierNextFrame(int barrierId, int barrierFlags) {
int barrierIndex = _scene->worldstats()->getBarrierIndexById(barrierId);
Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIndex);
int newFlag = barrierFlags | 1 | barrier->flags;
barrier->flags |= barrierFlags | 1;
if (newFlag & 0x10000) {
barrier->frameIdx = barrier->frameCount - 1;
} else {
barrier->frameIdx = 0;
}
return barrierIndex;
}
void ActionList::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
int v4 = 0;
int result;
@ -433,19 +412,18 @@ int kShowCursor(ActionCommand *cmd, Scene *scn) {
}
int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
int barrierId = cmd->param1;
int barrierId = cmd->param1;
int barrierIndex = scn->worldstats()->getBarrierIndexById(barrierId);
Barrier *barrier = scn->worldstats()->getBarrierByIndex(barrierIndex);
if (cmd->param2 == 2) {
if (!scn->actions()->checkBarrierFlags(barrierId)) {
if (!barrier->checkFlags()) {
cmd->param2 = 1;
// FIXME Not sure why this break was here
// break;
}
scn->actions()->lineIncrement = 1;
} else {
int barrierIndex = scn->worldstats()->getBarrierIndexById(barrierId);
Barrier *barrier = scn->worldstats()->getBarrierByIndex(barrierIndex);
if (cmd->param4) { // RECHECK THIS
int newBarriedIndex = 213 * barrierIndex;
barrier->flags &= 0xFFFEF1C7;
@ -466,7 +444,7 @@ int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
}
}
scn->actions()->setBarrierNextFrame(barrierId, barrier->flags);
barrier->setNextFrame(barrier->flags);
if(barrier->field_688 == 1) {
// TODO: get barrier position

View File

@ -88,9 +88,6 @@ public:
ActionDefinitions* getScript() { return _currentScript; }
int process();
int checkBarrierFlags(int barrierId);
int setBarrierNextFrame(int barrierId, int barrierFlags);
void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
void enableActorSub(int actorIndex, int condition);

View File

@ -80,4 +80,18 @@ bool Barrier::onscreen() {
return visible() && (flags & 1) && screenRect.intersects(barrierRect);
}
int Barrier::checkFlags() {
return flags & 1 && (flags & 8 || flags & 0x10000);
}
void Barrier::setNextFrame(int targetFlags) {
int newFlag = targetFlags | 1 | flags;
flags |= targetFlags | 1;
if (newFlag & 0x10000)
frameIdx = frameCount - 1;
else
frameIdx = 0;
}
} // end of namespace Asylum

View File

@ -39,6 +39,11 @@ public:
uint32 getRandomId(); // TODO Give this a better name?
bool onscreen();
// TODO document this function
int checkFlags();
// TODO document this function
void setNextFrame(int flags);
uint32 id;
uint32 resId;
uint32 x;