[Scummvm-cvs-logs] CVS: scummvm/scumm scumm.h,1.613,1.614 actor.cpp,1.349,1.350 scumm.cpp,1.477,1.478
Max Horn
fingolfin at users.sourceforge.net
Sat Apr 30 15:02:25 CEST 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27055
Modified Files:
scumm.h actor.cpp scumm.cpp
Log Message:
Only allocate the actor sorting array once
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.613
retrieving revision 1.614
diff -u -d -r1.613 -r1.614
--- scumm.h 30 Apr 2005 15:04:16 -0000 1.613
+++ scumm.h 30 Apr 2005 22:01:15 -0000 1.614
@@ -462,6 +462,7 @@
byte _numActors;
Actor *_actors; // Has _numActors elements
+ Actor **_sortedActors;
byte *_arraySlot;
uint16 *_inventory;
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.349
retrieving revision 1.350
diff -u -d -r1.349 -r1.350
--- actor.cpp 29 Apr 2005 01:36:28 -0000 1.349
+++ actor.cpp 30 Apr 2005 22:01:16 -0000 1.350
@@ -979,30 +979,25 @@
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 @@
a->animateCostume();
}
- delete [] actors;
-
if (_features & GF_NEW_COSTUMES)
akos_processQueue();
}
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.477
retrieving revision 1.478
diff -u -d -r1.477 -r1.478
--- scumm.cpp 30 Apr 2005 05:25:05 -0000 1.477
+++ scumm.cpp 30 Apr 2005 22:01:16 -0000 1.478
@@ -1175,6 +1175,7 @@
_mixer->stopAll();
delete [] _actors;
+ delete [] _sortedActors;
delete _2byteFontPtr;
delete _charset;
@@ -1546,6 +1547,7 @@
// Allocate and Initialize actors
Actor::initActorClass(this);
_actors = new Actor[_numActors];
+ _sortedActors = new Actor * [_numActors];
for (i = 0; i < _numActors; i++) {
_actors[i]._number = i;
_actors[i].initActor(1);
More information about the Scummvm-git-logs
mailing list