[Scummvm-cvs-logs] SF.net SVN: scummvm:[42731] scummvm/branches/gsoc2009-draci/engines/draci

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Sat Jul 25 05:28:05 CEST 2009


Revision: 42731
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42731&view=rev
Author:   dkasak13
Date:     2009-07-25 03:28:04 +0000 (Sat, 25 Jul 2009)

Log Message:
-----------
* Added DraciEngine::_initArchive and made Game use it. Fixes a memory bug because Game uses pointers from the init archive which should outlive it (but didn't previously).
* Added support for setting loop status to Game.
* Made some GPL commands check whether we are in the correct loop status before executing.

Modified Paths:
--------------
    scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/draci.h
    scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/game.h
    scummvm/branches/gsoc2009-draci/engines/draci/script.cpp

Modified: scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp	2009-07-25 02:23:00 UTC (rev 42730)
+++ scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp	2009-07-25 03:28:04 UTC (rev 42731)
@@ -53,6 +53,7 @@
 const Common::String animationsPath("ANIM.DFW");
 const Common::String iconsPath("HRA.DFW");
 const Common::String walkingMapsPath("MAPY.DFW");
+const Common::String initPath("INIT.DFW");
 
 DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc) 
  : Engine(syst) {
@@ -81,6 +82,7 @@
 	initGraphics(kScreenWidth, kScreenHeight, false);
 
 	// Open game's archives
+	_initArchive = new BArchive(initPath);
 	_objectsArchive = new BArchive(objectsPath);
 	_spritesArchive = new BArchive(spritesPath);
 	_paletteArchive = new BArchive(palettePath);
@@ -227,6 +229,7 @@
 	delete _script;
 	delete _anims;
 
+	delete _initArchive;
 	delete _paletteArchive;
 	delete _objectsArchive;
 	delete _spritesArchive;

Modified: scummvm/branches/gsoc2009-draci/engines/draci/draci.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.h	2009-07-25 02:23:00 UTC (rev 42730)
+++ scummvm/branches/gsoc2009-draci/engines/draci/draci.h	2009-07-25 03:28:04 UTC (rev 42731)
@@ -68,6 +68,7 @@
 	BArchive *_overlaysArchive;
 	BArchive *_animationsArchive;
 	BArchive *_walkingMapsArchive;
+	BArchive *_initArchive;
 
 	Common::RandomSource _rnd;
 };

Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.cpp	2009-07-25 02:23:00 UTC (rev 42730)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.cpp	2009-07-25 03:28:04 UTC (rev 42731)
@@ -39,14 +39,13 @@
 
 Game::Game(DraciEngine *vm) : _vm(vm) {
 	unsigned int i;
-	Common::String path("INIT.DFW");
 	
-	BArchive initArchive(path);
+	BArchive *initArchive = _vm->_initArchive;
 	BAFile *file;
 	
 	// Read in persons
 	
-	file = initArchive.getFile(5);
+	file = initArchive->getFile(5);
 	Common::MemoryReadStream personData(file->_data, file->_length);
 	
 	unsigned int numPersons = file->_length / personSize;
@@ -63,7 +62,7 @@
 	
 	// Read in dialog offsets
 	
-	file = initArchive.getFile(4);
+	file = initArchive->getFile(4);
 	Common::MemoryReadStream dialogData(file->_data, file->_length);
 	
 	unsigned int numDialogs = file->_length / sizeof(uint16);
@@ -80,7 +79,7 @@
 
 	// Read in game info
 	
-	file = initArchive.getFile(3);
+	file = initArchive->getFile(3);
 	Common::MemoryReadStream gameData(file->_data, file->_length);
 	
 	_info._startRoom = gameData.readByte() - 1;
@@ -105,7 +104,7 @@
 
 	// Read in variables
 	
-	file = initArchive.getFile(2);
+	file = initArchive->getFile(2);
 	unsigned int numVariables = file->_length / sizeof (int16);
 
 	_variables = new int[numVariables];
@@ -120,13 +119,13 @@
 
 	// Read in item icon status
 	
-	file = initArchive.getFile(1);
+	file = initArchive->getFile(1);
 	_iconStatus = file->_data;
 	uint numIcons = file->_length;
 	
 	// Read in object status
 	
-	file = initArchive.getFile(0);
+	file = initArchive->getFile(0);
 	unsigned int numObjects = file->_length;
 	
 	_objects = new GameObject[numObjects];
@@ -153,6 +152,8 @@
 }
 
 void Game::init() {
+	_loopStatus = kStatusOrdinary;
+
 	loadObject(kDragonObject);
 	
 	GameObject *dragon = getObject(kDragonObject);
@@ -521,6 +522,14 @@
 	loadOverlays();
 }
 
+void Game::setLoopStatus(LoopStatus status) {
+	_loopStatus = status;
+}
+
+LoopStatus Game::getLoopStatus() {
+	return _loopStatus;
+}
+
 int Game::getRoomNum() {
 	return _currentRoom._roomNum;
 }

Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.h	2009-07-25 02:23:00 UTC (rev 42730)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.h	2009-07-25 03:28:04 UTC (rev 42731)
@@ -132,6 +132,12 @@
 	GPL2Program _program;
 };
 
+enum LoopStatus { 
+	kStatusGate, kStatusOrdinary, kStatusInventory, 
+	kStatusDialogue, kStatusTalk, kStatusStrange, 
+	kStatusFade
+};
+
 class Game {
 
 public:
@@ -185,15 +191,22 @@
 	int getMarkedAnimationIndex();
 	void setMarkedAnimationIndex(int index);
 
+	void setLoopStatus(LoopStatus status);
+	LoopStatus getLoopStatus();
+
 private:
 	DraciEngine *_vm;
-	int *_variables;
+
 	GameInfo _info;
-	Person *_persons;
 	uint *_dialogOffsets;
+
+	int *_variables;
 	byte *_iconStatus;
+	Person *_persons;
 	GameObject *_objects;
+
 	Room _currentRoom;
+	LoopStatus _loopStatus;
 
 	int _markedAnimationIndex; //!< Used by the Mark GPL command
 };

Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-07-25 02:23:00 UTC (rev 42730)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-07-25 03:28:04 UTC (rev 42731)
@@ -265,6 +265,10 @@
 /* GPL commands */
 
 void Script::load(Common::Queue<int> &params) {
+	if (_vm->_game->getLoopStatus() == kStatusInventory) {
+		return;
+	}
+
 	int objID = params.pop() - 1;
 	int animID = params.pop() - 1;
 
@@ -275,6 +279,10 @@
 }
 
 void Script::start(Common::Queue<int> &params) {
+	if (_vm->_game->getLoopStatus() == kStatusInventory) {
+		return;
+	}
+
 	int objID = params.pop() - 1;
 	int animID = params.pop() - 1;
 


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