[Scummvm-cvs-logs] SF.net SVN: scummvm: [29608] scummvm/trunk/engines/agi
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Thu Nov 22 11:32:37 CET 2007
Revision: 29608
http://scummvm.svn.sourceforge.net/scummvm/?rev=29608&view=rev
Author: fingolfin
Date: 2007-11-22 02:32:36 -0800 (Thu, 22 Nov 2007)
Log Message:
-----------
Change the AGI image stack to use Common::Stack
Modified Paths:
--------------
scummvm/trunk/engines/agi/agi.cpp
scummvm/trunk/engines/agi/agi.h
scummvm/trunk/engines/agi/preagi.h
scummvm/trunk/engines/agi/saveload.cpp
Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp 2007-11-22 10:16:01 UTC (rev 29607)
+++ scummvm/trunk/engines/agi/agi.cpp 2007-11-22 10:32:36 UTC (rev 29608)
@@ -297,46 +297,27 @@
}
void AgiEngine::clearImageStack(void) {
- _imageStackPointer = 0;
+ _imageStack.clear();
}
void AgiEngine::releaseImageStack(void) {
- if (_imageStack)
- free(_imageStack);
- _imageStack = NULL;
- _stackSize = 0;
- _imageStackPointer = 0;
+ _imageStack.clear();
}
void AgiEngine::recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
int16 p4, int16 p5, int16 p6, int16 p7) {
- struct ImageStackElement *pnew;
+ ImageStackElement pnew;
- if (_imageStackPointer == _stackSize) {
- if (_stackSize == 0) { /* first call */
- _imageStack = (ImageStackElement *)malloc(INITIAL_IMAGE_STACK_SIZE * sizeof(ImageStackElement));
- _stackSize = INITIAL_IMAGE_STACK_SIZE;
- } else { /* has to grow */
- struct ImageStackElement *newStack;
- newStack = (ImageStackElement *)malloc(2 * _stackSize * sizeof(ImageStackElement));
- memcpy(newStack, _imageStack, _stackSize * sizeof(ImageStackElement));
- free(_imageStack);
- _imageStack = newStack;
- _stackSize *= 2;
- }
- }
+ pnew.type = type;
+ pnew.parm1 = p1;
+ pnew.parm2 = p2;
+ pnew.parm3 = p3;
+ pnew.parm4 = p4;
+ pnew.parm5 = p5;
+ pnew.parm6 = p6;
+ pnew.parm7 = p7;
- pnew = &_imageStack[_imageStackPointer];
- _imageStackPointer++;
-
- pnew->type = type;
- pnew->parm1 = p1;
- pnew->parm2 = p2;
- pnew->parm3 = p3;
- pnew->parm4 = p4;
- pnew->parm5 = p5;
- pnew->parm6 = p6;
- pnew->parm7 = p7;
+ _imageStack.push(pnew);
}
void AgiEngine::replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
@@ -660,10 +641,6 @@
_intobj = NULL;
- _stackSize = 0;
- _imageStack = NULL;
- _imageStackPointer = 0;
-
_menu = NULL;
_lastSentence[0] = 0;
Modified: scummvm/trunk/engines/agi/agi.h
===================================================================
--- scummvm/trunk/engines/agi/agi.h 2007-11-22 10:16:01 UTC (rev 29607)
+++ scummvm/trunk/engines/agi/agi.h 2007-11-22 10:32:36 UTC (rev 29608)
@@ -34,6 +34,7 @@
#include "common/savefile.h"
#include "common/system.h"
#include "common/hash-str.h"
+#include "common/stack.h"
#include "engines/engine.h"
@@ -658,12 +659,6 @@
AgiBase(OSystem *syst, const AGIGameDescription *gameDesc);
- #define INITIAL_IMAGE_STACK_SIZE 32
-
- int _stackSize;
- ImageStackElement *_imageStack;
- int _imageStackPointer;
-
virtual void clearImageStack() = 0;
virtual void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
int16 p4, int16 p5, int16 p6, int16 p7) = 0;
@@ -746,6 +741,8 @@
PictureMgr *_picture;
AgiLoader *_loader; /* loader */
+ Common::Stack<ImageStackElement> _imageStack;
+
void clearImageStack();
void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
int16 p4, int16 p5, int16 p6, int16 p7);
Modified: scummvm/trunk/engines/agi/preagi.h
===================================================================
--- scummvm/trunk/engines/agi/preagi.h 2007-11-22 10:16:01 UTC (rev 29607)
+++ scummvm/trunk/engines/agi/preagi.h 2007-11-22 10:32:36 UTC (rev 29608)
@@ -54,7 +54,7 @@
}
GfxMgr *_gfx;
- SoundMgr *_sound;
+ //SoundMgr *_sound;
PictureMgr *_picture;
PreAGI_Console *_console;
Modified: scummvm/trunk/engines/agi/saveload.cpp
===================================================================
--- scummvm/trunk/engines/agi/saveload.cpp 2007-11-22 10:16:01 UTC (rev 29607)
+++ scummvm/trunk/engines/agi/saveload.cpp 2007-11-22 10:32:36 UTC (rev 29608)
@@ -53,7 +53,6 @@
int AgiEngine::saveGame(const char *fileName, const char *description) {
char gameIDstring[8]="gameIDX";
int i;
- struct ImageStackElement *ptr = _imageStack;
Common::OutSaveFile *out;
int result = errOK;
@@ -190,16 +189,16 @@
/* Save image stack */
- for (i = 0; i < _imageStackPointer; i++) {
- ptr = &_imageStack[i];
- out->writeByte(ptr->type);
- out->writeSint16BE(ptr->parm1);
- out->writeSint16BE(ptr->parm2);
- out->writeSint16BE(ptr->parm3);
- out->writeSint16BE(ptr->parm4);
- out->writeSint16BE(ptr->parm5);
- out->writeSint16BE(ptr->parm6);
- out->writeSint16BE(ptr->parm7);
+ for (i = 0; i < _imageStack.size(); i++) {
+ ImageStackElement ise = _imageStack[i];
+ out->writeByte(ise.type);
+ out->writeSint16BE(ise.parm1);
+ out->writeSint16BE(ise.parm2);
+ out->writeSint16BE(ise.parm3);
+ out->writeSint16BE(ise.parm4);
+ out->writeSint16BE(ise.parm5);
+ out->writeSint16BE(ise.parm6);
+ out->writeSint16BE(ise.parm7);
}
out->writeByte(0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list