Skip to content

Commit

Permalink
FULLPIPE: Proper use of copying consturctor for ExCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Jan 4, 2014
1 parent 0745e61 commit 8515164
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 27 deletions.
15 changes: 5 additions & 10 deletions engines/fullpipe/messages.cpp
Expand Up @@ -43,8 +43,8 @@ ExCommand::ExCommand(ExCommand *src) : Message(src) {
_parId = src->_parId;
}

ExCommand *ExCommand::createClone(ExCommand *src) {
return new ExCommand(src);
ExCommand *ExCommand::createClone() {
return new ExCommand(this);
}

ExCommand::ExCommand(int16 parentId, int messageKind, int messageNum, int x, int y, int a7, int a8, int sceneClickX, int sceneClickY, int a11) :
Expand Down Expand Up @@ -176,13 +176,8 @@ ExCommand2::~ExCommand2() {
free(_points);
}

ExCommand *ExCommand2::createClone(ExCommand *src) {
if (_objtype == kObjTypeExCommand)
return new ExCommand(src);
else if (_objtype == kObjTypeExCommand2)
return new ExCommand2((ExCommand2 *)src);

error("ExCommand2::createClone(): Wrong object type: %d", _objtype);
ExCommand2 *ExCommand2::createClone() {
return new ExCommand2(this);
}

Message::Message() {
Expand Down Expand Up @@ -284,7 +279,7 @@ MessageQueue::MessageQueue(MessageQueue *src, int parId, int field_38) {
_field_38 = (field_38 == 0);

for (Common::List<ExCommand *>::iterator it = src->_exCommands.begin(); it != src->_exCommands.end(); ++it) {
ExCommand *ex = new ExCommand(*it);
ExCommand *ex = (*it)->createClone();
ex->_excFlags |= 2;

_exCommands.push_back(ex);
Expand Down
4 changes: 2 additions & 2 deletions engines/fullpipe/messages.h
Expand Up @@ -69,7 +69,7 @@ class ExCommand : public Message {

virtual bool load(MfcArchive &file);

virtual ExCommand *createClone(ExCommand *src);
virtual ExCommand *createClone();

bool handleMessage();
void sendMessage();
Expand All @@ -89,7 +89,7 @@ class ExCommand2 : public ExCommand {
ExCommand2(ExCommand2 *src);
virtual ~ExCommand2();

virtual ExCommand *createClone(ExCommand *src);
virtual ExCommand2 *createClone();
};

class ObjstateCommand : public CObject {
Expand Down
2 changes: 1 addition & 1 deletion engines/fullpipe/motion.cpp
Expand Up @@ -210,7 +210,7 @@ MessageQueue *MctlCompound::doWalkTo(StaticANIObject *subj, int xpos, int ypos,

if (mq) {
for (uint i = 0; i < closestP->_messageQueueObj->getCount(); i++) {
ex = new ExCommand(closestP->_messageQueueObj->getExCommandByIndex(i));
ex = closestP->_messageQueueObj->getExCommandByIndex(i)->createClone()
ex->_excFlags |= 2;
mq->addExCommandToEnd(ex);
}
Expand Down
12 changes: 6 additions & 6 deletions engines/fullpipe/scenes/scene04.cpp
Expand Up @@ -298,7 +298,7 @@ void sceneHandler04_walkClimbLadder(ExCommand *ex) {
ExCommand *ex3;

if (ex) {
ex3 = new ExCommand(ex);
ex3 = ex->createClone();
} else {
ex3 = new ExCommand(0, 17, MSG_SC4_CLICKLADDER, 0, 0, 0, 1, 0, 0, 0);
ex3->_excFlags |= 3;
Expand Down Expand Up @@ -498,7 +498,7 @@ void sceneHandler04_gotoLadder(ExCommand *ex) {
mq->addExCommandToEnd(ex3);

if (ex) {
ExCommand *ex4 = new ExCommand(ex);
ExCommand *ex4 = ex->createClone();

mq->addExCommandToEnd(ex4);
}
Expand Down Expand Up @@ -630,7 +630,7 @@ MessageQueue *sceneHandler04_kozFly5(StaticANIObject *ani, double phase) {
MessageQueue *mq2 = mgm.genMovement(&mgminfo);

if (mq1 && mq2) {
mq1->addExCommandToEnd(new ExCommand(mq2->getExCommandByIndex(0)));
mq1->addExCommandToEnd(mq2->getExCommandByIndex(0)->createClone());

delete mq2;

Expand Down Expand Up @@ -890,7 +890,7 @@ void sceneHandler04_animOutOfBottle(ExCommand *ex) {
MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC4_MANFROMBOTTLE), 0, 0);

if (ex) {
ExCommand *newex = new ExCommand(ex);
ExCommand *newex = ex->createClone();

mq->addExCommandToEnd(newex);
}
Expand Down Expand Up @@ -1066,7 +1066,7 @@ void sceneHandler04_leaveLadder(ExCommand *ex) {
MessageQueue *mq = g_vars->scene04_ladder->controllerWalkTo(g_fp->_aniMan, 0);

if (mq) {
mq->addExCommandToEnd(new ExCommand(ex));
mq->addExCommandToEnd(ex->createClone());

if (mq->chain(g_fp->_aniMan) )
ex->_messageKind = 0;
Expand Down Expand Up @@ -1099,7 +1099,7 @@ void sceneHandler04_leaveLadder(ExCommand *ex) {
ex1->_excFlags |= 2;
mq->addExCommandToEnd(ex1);

ex1 = new ExCommand(ex);
ex1 = ex->createClone();
mq->addExCommandToEnd(ex1);

mq->setFlags(mq->getFlags() | 1);
Expand Down
2 changes: 1 addition & 1 deletion engines/fullpipe/scenes/scene08.cpp
Expand Up @@ -282,7 +282,7 @@ void sceneHandler08_finishArcade() {
void sceneHandler08_jumpOff(ExCommand *cmd) {
MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact());

mq->addExCommandToEnd(new ExCommand(cmd));
mq->addExCommandToEnd(cmd->createClone());
mq->setFlags(mq->getFlags() | 1);

g_fp->_globalMessageQueueList->addMessageQueue(mq);
Expand Down
6 changes: 3 additions & 3 deletions engines/fullpipe/scenes/scene22.cpp
Expand Up @@ -153,7 +153,7 @@ void sceneHandler22_fromStool(ExCommand *cmd) {
if (g_fp->_aniMan->isIdle() && !(g_fp->_aniMan->_flags & 0x100)) {
MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC22_FROMSTOOL), 0, 0);

mq->addExCommandToEnd(new ExCommand(cmd));
mq->addExCommandToEnd(cmd->createClone());
mq->setFlags(mq->getFlags() | 1);
mq->chain(0);
}
Expand Down Expand Up @@ -196,7 +196,7 @@ void sceneHandler22_stoolLogic(ExCommand *cmd) {
if (!mq)
return;

mq->addExCommandToEnd(new ExCommand(cmd));
mq->addExCommandToEnd(cmd->createClone));

postExCommand(g_fp->_aniMan->_id, 2, 841, 449, 0, -1);
return;
Expand Down Expand Up @@ -282,7 +282,7 @@ void sceneHandler22_stoolLogic(ExCommand *cmd) {
mq = getCurrSceneSc2MotionController()->method34(g_fp->_aniMan, 1010, 443, 1, ST_MAN_UP);

if (mq) {
mq->addExCommandToEnd(new ExCommand(cmd));
mq->addExCommandToEnd(cmd->createClone());

postExCommand(g_fp->_aniMan->_id, 2, 1010, 443, 0, -1);
return;
Expand Down
8 changes: 4 additions & 4 deletions engines/fullpipe/statics.cpp
Expand Up @@ -708,7 +708,7 @@ void StaticANIObject::update(int counterdiff) {

ex = dyn->getExCommand();
if (ex && ex->_messageKind != 35) {
newex = new ExCommand(ex);
newex = ex->createClone();
newex->_excFlags |= 2;
if (newex->_messageKind == 17) {
newex->_parentId = _id;
Expand Down Expand Up @@ -741,7 +741,7 @@ void StaticANIObject::update(int counterdiff) {
ex = dyn->getExCommand();
if (ex) {
if (ex->_messageKind == 35) {
newex = new ExCommand(ex);
newex = ex->createClone();
newex->_excFlags |= 2;
newex->sendMessage();
}
Expand Down Expand Up @@ -1048,7 +1048,7 @@ bool StaticANIObject::startAnim(int movementId, int messageQueueId, int dynPhase
ExCommand *ex = _movement->_currDynamicPhase->getExCommand();
if (ex) {
if (ex->_messageKind == 35) {
ExCommand *newex = new ExCommand(ex);
ExCommand *newex = ex->createClone();
newex->_excFlags |= 2;
newex->sendMessage();
}
Expand Down Expand Up @@ -1858,7 +1858,7 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) {
_field_7C = src->_field_7C;

if (src->getExCommand())
_exCommand = new ExCommand(src->getExCommand());
_exCommand = src->getExCommand()->createClone();
else
_exCommand = 0;

Expand Down

0 comments on commit 8515164

Please sign in to comment.