Skip to content

Commit

Permalink
LASTEXPRESS: Reduce nesting in Entities::processEntity()
Browse files Browse the repository at this point in the history
  • Loading branch information
Templier committed Jul 27, 2012
1 parent 552e8d4 commit 7974b62
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions engines/lastexpress/game/entities.cpp
Expand Up @@ -751,43 +751,41 @@ void Entities::processEntity(EntityIndex entityIndex) {

if (data->frame->getInfo()->field_30 > (data->field_49B + 1) || (data->direction == kDirectionLeft && data->sequence->count() == 1)) {
++data->field_49B;
} else {
if (data->frame->getInfo()->field_30 > data->field_49B && !data->frame->getInfo()->keepPreviousFrame) {
++data->field_49B;
} else {
if (data->frame->getInfo()->keepPreviousFrame == 1)
keepPreviousFrame = true;
} else if (data->frame->getInfo()->field_30 <= data->field_49B || data->frame->getInfo()->keepPreviousFrame) {
if (data->frame->getInfo()->keepPreviousFrame == 1)
keepPreviousFrame = true;

// Increment current frame
++data->currentFrame;
// Increment current frame
++data->currentFrame;

if (data->currentFrame > (int16)(data->sequence->count() - 1) || (data->field_4A9 && checkSequenceFromPosition(entityIndex))) {

if (data->direction == kDirectionLeft) {
data->currentFrame = 0;
} else {
keepPreviousFrame = true;
drawNextSequence(entityIndex);
if (data->currentFrame > (int16)(data->sequence->count() - 1) || (data->field_4A9 && checkSequenceFromPosition(entityIndex))) {

if (getFlags()->flag_entities_0 || data->doProcessEntity)
return;
if (data->direction == kDirectionLeft) {
data->currentFrame = 0;
} else {
keepPreviousFrame = true;
drawNextSequence(entityIndex);

if (!data->sequence2) {
updateEntityPosition(entityIndex);
data->doProcessEntity = false;
return;
}
if (getFlags()->flag_entities_0 || data->doProcessEntity)
return;

copySequenceData(entityIndex);
if (!data->sequence2) {
updateEntityPosition(entityIndex);
data->doProcessEntity = false;
return;
}

copySequenceData(entityIndex);
}

processFrame(entityIndex, keepPreviousFrame, false);

if (getFlags()->flag_entities_0 || data->doProcessEntity)
return;
}

processFrame(entityIndex, keepPreviousFrame, false);

if (getFlags()->flag_entities_0 || data->doProcessEntity)
return;
} else {
++data->field_49B;
}

incrementDirectionCounter(data);
Expand Down

0 comments on commit 7974b62

Please sign in to comment.