diff options
| -rw-r--r-- | engines/agi/agi.cpp | 47 | ||||
| -rw-r--r-- | engines/agi/agi.h | 9 | ||||
| -rw-r--r-- | engines/agi/preagi.h | 2 | ||||
| -rw-r--r-- | engines/agi/saveload.cpp | 21 | 
4 files changed, 26 insertions, 53 deletions
| diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index e46b017ad8..dd03a9d589 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -297,46 +297,27 @@ void AgiEngine::agiTimerFunctionLow(void *refCon) {  }  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; - -	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; -		} -	} +	ImageStackElement pnew; -	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; -	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 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas  	_intobj = NULL; -	_stackSize = 0; -	_imageStack = NULL; -	_imageStackPointer = 0; -  	_menu = NULL;  	_lastSentence[0] = 0; diff --git a/engines/agi/agi.h b/engines/agi/agi.h index c1b649435c..b74c606692 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -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 @@ public:  	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 @@ public:  	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); diff --git a/engines/agi/preagi.h b/engines/agi/preagi.h index 0644a185c0..063ad329d8 100644 --- a/engines/agi/preagi.h +++ b/engines/agi/preagi.h @@ -54,7 +54,7 @@ public:  	}  	GfxMgr *_gfx; -	SoundMgr *_sound; +	//SoundMgr *_sound;  	PictureMgr *_picture;  	PreAGI_Console *_console; diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index 034e5c7d7b..2be908d29b 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -53,7 +53,6 @@ static const uint32 AGIflag=MKID_BE('AGI:');  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 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {  	/* 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); | 
