aboutsummaryrefslogtreecommitdiff
path: root/scumm/actor.cpp
diff options
context:
space:
mode:
authorMax Horn2005-04-30 22:01:16 +0000
committerMax Horn2005-04-30 22:01:16 +0000
commited4b43df73f8051a2c35c1278041dfbd89d83527 (patch)
treee167213444435d35f9485d3ae2de7496dda43727 /scumm/actor.cpp
parent280abe9e91c164548b8f2c6692de232c9e316315 (diff)
downloadscummvm-rg350-ed4b43df73f8051a2c35c1278041dfbd89d83527.tar.gz
scummvm-rg350-ed4b43df73f8051a2c35c1278041dfbd89d83527.tar.bz2
scummvm-rg350-ed4b43df73f8051a2c35c1278041dfbd89d83527.zip
Only allocate the actor sorting array once
svn-id: r17875
Diffstat (limited to 'scumm/actor.cpp')
-rw-r--r--scumm/actor.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index ea761c538d..09163b4481 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -979,30 +979,25 @@ static int compareDrawOrder(const void* a, const void* b)
void ScummEngine::processActors() {
int numactors = 0;
- // TODO : put this actors as a member array. It never has to grow or shrink
- // since _numActors is constant within a game.
- Actor** actors = new Actor * [_numActors];
-
// Make a list of all actors in this room
for (int i = 1; i < _numActors; i++) {
if (_version == 8 && _actors[i]._layer < 0)
continue;
if (_actors[i].isInCurrentRoom() && _actors[i]._costume)
- actors[numactors++] = &_actors[i];
+ _sortedActors[numactors++] = &_actors[i];
}
if (!numactors) {
- delete [] actors;
return;
}
// Sort actors by position before we draw them (to ensure that actors in
// front are drawn after those "behind" them).
- qsort(actors, numactors, sizeof (Actor*), compareDrawOrder);
+ qsort(_sortedActors, numactors, sizeof (Actor*), compareDrawOrder);
- Actor** end = actors + numactors;
+ Actor** end = _sortedActors + numactors;
// Finally draw the now sorted actors
- for (Actor** ac = actors; ac != end; ++ac) {
+ for (Actor** ac = _sortedActors; ac != end; ++ac) {
Actor* a = *ac;
CHECK_HEAP
a->drawActorCostume();
@@ -1010,8 +1005,6 @@ void ScummEngine::processActors() {
a->animateCostume();
}
- delete [] actors;
-
if (_features & GF_NEW_COSTUMES)
akos_processQueue();
}