FULLPIPE: Removed PtrList usage in statics.cpp

This commit is contained in:
Eugene Sandulenko 2014-05-02 12:29:15 +03:00
parent 79cb4b994d
commit 2e7d5caa31
2 changed files with 47 additions and 48 deletions

View File

@ -164,22 +164,21 @@ StaticANIObject::StaticANIObject(StaticANIObject *src) : GameObject(src) {
_objtype = kObjTypeStaticANIObject;
for (uint i = 0; i < src->_staticsList.size(); i++)
_staticsList.push_back(new Statics((Statics *)src->_staticsList[i], 0));
_staticsList.push_back(new Statics(src->_staticsList[i], 0));
_movement = 0;
_statics = 0;
for (uint i = 0; i < src->_movements.size(); i++) {
Movement *newmov;
Movement *mov = (Movement *)src->_movements[i];
if (mov->_currMovement) {
if (src->_movements[i]->_currMovement) {
// WORKAROUND: Original uses weird construction here:
// new Movement(getMovementById(src->getMovementIdById(mov->_id)), this);
newmov = new Movement(src->getMovementById(src->getMovementIdById(mov->_id)), this);
newmov->_id = mov->_id;
newmov = new Movement(src->getMovementById(src->getMovementIdById(src->_movements[i]->_id)), this);
newmov->_id = src->_movements[i]->_id;
} else {
newmov = new Movement(mov, 0, -1, this);
newmov = new Movement(src->_movements[i], 0, -1, this);
}
_movements.push_back(newmov);
@ -224,7 +223,7 @@ bool StaticANIObject::load(MfcArchive &file) {
Common::Point pt;
if (count) { // We have movements
((Movement *)_movements[0])->getCurrDynamicPhaseXY(pt);
_movements[0]->getCurrDynamicPhaseXY(pt);
} else {
pt.x = pt.y = 100;
}
@ -392,34 +391,36 @@ bool StaticANIObject::isIdle() {
Statics *StaticANIObject::getStaticsById(int itemId) {
for (uint i = 0; i < _staticsList.size(); i++)
if (((Statics *)_staticsList[i])->_staticsId == itemId)
return (Statics *)_staticsList[i];
if (_staticsList[i]->_staticsId == itemId)
return _staticsList[i];
return 0;
}
Statics *StaticANIObject::getStaticsByName(char *name) {
for (uint i = 0; i < _staticsList.size(); i++)
if (!strcmp(((Statics *)_staticsList[i])->_staticsName, name))
return (Statics *)_staticsList[i];
if (!strcmp(_staticsList[i]->_staticsName, name))
return _staticsList[i];
return 0;
}
Movement *StaticANIObject::getMovementById(int itemId) {
for (uint i = 0; i < _movements.size(); i++)
if (((Movement *)_movements[i])->_id == itemId)
return (Movement *)_movements[i];
if (_movements[i]->_id == itemId)
return _movements[i];
return 0;
}
int StaticANIObject::getMovementIdById(int itemId) {
for (uint i = 0; i < _movements.size(); i++) {
Movement *mov = (Movement *)_movements[i];
Movement *mov = _movements[i];
if (mov->_currMovement) {
if (mov->_id == itemId)
return mov->_id;
if (mov->_currMovement->_id == itemId)
return mov->_id;
}
@ -430,8 +431,8 @@ int StaticANIObject::getMovementIdById(int itemId) {
Movement *StaticANIObject::getMovementByName(char *name) {
for (uint i = 0; i < _movements.size(); i++)
if (!strcmp(((Movement *)_movements[i])->_objectName, name))
return (Movement *)_movements[i];
if (!strcmp(_movements[i]->_objectName, name))
return _movements[i];
return 0;
}
@ -551,12 +552,12 @@ void Movement::draw(bool flipFlag, int angle) {
void StaticANIObject::loadMovementsPixelData() {
for (uint i = 0; i < _movements.size(); i++)
((Movement *)_movements[i])->loadPixelData();
_movements[i]->loadPixelData();
}
void StaticANIObject::freeMovementsPixelData() {
for (uint i = 0; i < _movements.size(); i++)
((Movement *)_movements[i])->freePixelData();
_movements[i]->freePixelData();
}
Statics *StaticANIObject::addReverseStatics(Statics *st) {
@ -665,11 +666,10 @@ MovTable *StaticANIObject::countMovements() {
movTable->movs = (int16 *)calloc(_movements.size(), sizeof(int16));
for (uint i = 0; i < _movements.size(); i++) {
GameObject *obj = (GameObject *)_movements[i];
movTable->movs[i] = 2;
for (GameVar *sub = preloadSubVar->_subVars; sub; sub = sub->_nextVarObj) {
if (scumm_stricmp(obj->getName(), sub->_varName) == 0) {
if (scumm_stricmp(_movements[i]->getName(), sub->_varName) == 0) {
movTable->movs[i] = 1;
break;
}
@ -702,21 +702,21 @@ void StaticANIObject::setSpeed(int speed) {
void StaticANIObject::setAlpha(int alpha) {
for (uint i = 0; i < _movements.size(); i++)
((Movement *)_movements[i])->setAlpha(alpha);
_movements[i]->setAlpha(alpha);
for (uint i = 0; i < _staticsList.size(); i++)
((Statics *)_staticsList[i])->setAlpha(alpha);
_staticsList[i]->setAlpha(alpha);
}
void StaticANIObject::initMovements() {
for (uint i = 0; i < _movements.size(); i++)
((Movement *)_movements[i])->removeFirstPhase();
_movements[i]->removeFirstPhase();
}
void StaticANIObject::preloadMovements(MovTable *mt) {
if ( mt ) {
if (mt) {
for (uint i = 0; i < _movements.size(); i++) {
Movement *mov = (Movement *)_movements[i];
Movement *mov = _movements[i];
if (mt->movs[i] == 1)
mov->loadPixelData();
@ -1177,8 +1177,8 @@ void StaticANIObject::startAnimSteps(int movementId, int messageQueueId, int x,
if (!(_flags & 0x80)) {
if (!_messageQueueId)
for (uint i = 0; i < _movements.size(); i++) {
if (((Movement *)_movements[i])->_id == movementId) {
mov = (Movement *)_movements[i];
if (_movements[i]->_id == movementId) {
mov = _movements[i];
break;
}
}
@ -1276,9 +1276,8 @@ bool StaticANIObject::startAnim(int movementId, int messageQueueId, int dynPhase
Movement *mov = 0;
for (uint i = 0; i < _movements.size(); i++) {
if (((Movement *)_movements[i])->_id == movementId) {
mov = (Movement *)_movements[i];
if (_movements[i]->_id == movementId) {
mov = _movements[i];
break;
}
}
@ -1501,7 +1500,7 @@ Movement::~Movement() {
_dynamicPhases.remove_at(0);
for (uint i = 0; i < _dynamicPhases.size(); i++)
delete (DynamicPhase *)_dynamicPhases[i];
delete _dynamicPhases[i];
_dynamicPhases.clear();
}
@ -1761,11 +1760,11 @@ Common::Point *Movement::calcSomeXY(Common::Point &p, int idx) {
void Movement::setAlpha(int alpha) {
if (_currMovement)
for (uint i = 0; i < _currMovement->_dynamicPhases.size(); i++) {
((DynamicPhase *)_currMovement->_dynamicPhases[i])->setAlpha(alpha);
_currMovement->_dynamicPhases[i]->setAlpha(alpha);
}
else
for (uint i = 0; i < _dynamicPhases.size(); i++) {
((DynamicPhase *)_dynamicPhases[i])->setAlpha(alpha);
_dynamicPhases[i]->setAlpha(alpha);
}
}
@ -1778,9 +1777,9 @@ Common::Point *Movement::getDimensionsOfPhase(Common::Point *p, int phaseIndex)
DynamicPhase *dyn;
if (_currMovement)
dyn = (DynamicPhase *)_currMovement->_dynamicPhases[idx];
dyn = _currMovement->_dynamicPhases[idx];
else
dyn = (DynamicPhase *)_dynamicPhases[idx];
dyn = _dynamicPhases[idx];
Common::Point point;
@ -1829,13 +1828,13 @@ void Movement::updateCurrDynamicPhase() {
return;
if (_currMovement->_dynamicPhases[_currDynamicPhaseIndex])
_currDynamicPhase = (DynamicPhase *)_currMovement->_dynamicPhases[_currDynamicPhaseIndex];
_currDynamicPhase = _currMovement->_dynamicPhases[_currDynamicPhaseIndex];
} else {
if (_dynamicPhases.size() == 0 || (uint)_currDynamicPhaseIndex >= _dynamicPhases.size())
return;
if (_dynamicPhases[_currDynamicPhaseIndex])
_currDynamicPhase = (DynamicPhase *)_dynamicPhases[_currDynamicPhaseIndex];
_currDynamicPhase = _dynamicPhases[_currDynamicPhaseIndex];
}
}
@ -1844,11 +1843,11 @@ int Movement::calcDuration() {
if (_currMovement)
for (uint i = 0; i < _currMovement->_dynamicPhases.size(); i++) {
res += ((DynamicPhase *)_currMovement->_dynamicPhases[i])->_initialCountdown;
res += _currMovement->_dynamicPhases[i]->_initialCountdown;
}
else
for (uint i = 0; i < _dynamicPhases.size(); i++) {
res += ((DynamicPhase *)_dynamicPhases[i])->_initialCountdown;
res += _dynamicPhases[i]->_initialCountdown;
}
return res;
@ -1889,12 +1888,12 @@ DynamicPhase *Movement::getDynamicPhaseByIndex(int idx) {
if (_currMovement->_dynamicPhases.size() == 0 || (uint)idx >= _currMovement->_dynamicPhases.size())
return 0;
return (DynamicPhase *)_currMovement->_dynamicPhases[idx];
return _currMovement->_dynamicPhases[idx];
} else {
if (_dynamicPhases.size() == 0 || (uint)idx >= _dynamicPhases.size())
return 0;
return (DynamicPhase *)_dynamicPhases[idx];
return _dynamicPhases[idx];
}
}
@ -1905,7 +1904,7 @@ void Movement::loadPixelData() {
for (uint i = 0; i < _dynamicPhases.size(); i++) {
if ((Statics *)_dynamicPhases[i] != mov->_staticsObj2 || !(mov->_staticsObj2->_staticsId & 0x4000))
((Statics *)_dynamicPhases[i])->getPixelData();
_dynamicPhases[i]->getPixelData();
}
if (!(mov->_staticsObj1->_staticsId & 0x4000))
@ -1915,7 +1914,7 @@ void Movement::loadPixelData() {
void Movement::freePixelData() {
if (!_currMovement)
for (uint i = 0; i < _dynamicPhases.size(); i++)
((DynamicPhase *)_dynamicPhases[i])->freePixelData();
_dynamicPhases[i]->freePixelData();
if (_staticsObj1)
_staticsObj1->freePixelData();
@ -1947,11 +1946,11 @@ bool Movement::gotoNextFrame(void (*callback1)(int, Common::Point *point, int, i
if (!callback2) {
if (_currMovement) {
if ((uint)_currDynamicPhaseIndex == _currMovement->_dynamicPhases.size() - 1
&& !(((DynamicPhase *)(_currMovement->_dynamicPhases.back()))->_countdown)) {
&& !(_currMovement->_dynamicPhases.back()->_countdown)) {
return false;
}
} else if ((uint)_currDynamicPhaseIndex == _dynamicPhases.size() - 1
&& !(((DynamicPhase *)(_dynamicPhases.back()))->_countdown)) {
&& !(_dynamicPhases.back()->_countdown)) {
return false;
}
}

View File

@ -121,7 +121,7 @@ class Movement : public GameObject {
int _field_50;
int _counterMax;
int _counter;
PtrList _dynamicPhases;
Common::Array<DynamicPhase *> _dynamicPhases;
int _field_78;
Common::Point **_framePosOffsets;
Movement *_currMovement;
@ -181,8 +181,8 @@ class StaticANIObject : public GameObject {
int _initialCounter;
void (*_callback1)(int, Common::Point *point, int, int);
void (*_callback2)(int *);
PtrList _movements;
PtrList _staticsList;
Common::Array<Movement *> _movements;
Common::Array<Statics *> _staticsList;
StepArray _stepArray;
int16 _field_96;
int _messageQueueId;