[Scummvm-cvs-logs] SF.net SVN: scummvm:[34931] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Fri Nov 7 16:35:18 CET 2008


Revision: 34931
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34931&view=rev
Author:   peres001
Date:     2008-11-07 15:35:18 +0000 (Fri, 07 Nov 2008)

Log Message:
-----------
* completed transition to Common::Archive for Nippon Safes.
* removed lots of old Archive swap magic

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/disk.h
    scummvm/trunk/engines/parallaction/disk_ns.cpp
    scummvm/trunk/engines/parallaction/gui_ns.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-11-07 13:50:56 UTC (rev 34930)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-11-07 15:35:18 UTC (rev 34931)
@@ -371,7 +371,6 @@
 	_gfx->freeLabels();
 	_gfx->updateScreen();
 
-	_disk->selectArchive("disk1");
 	parseLocation("common");
 
 	uint id[2];

Modified: scummvm/trunk/engines/parallaction/disk.h
===================================================================
--- scummvm/trunk/engines/parallaction/disk.h	2008-11-07 13:50:56 UTC (rev 34930)
+++ scummvm/trunk/engines/parallaction/disk.h	2008-11-07 15:35:18 UTC (rev 34931)
@@ -77,48 +77,23 @@
 	virtual void loadMask(const char *name, MaskBuffer &buffer) { }
 };
 
+class NSArchive;
 
-
-
-#define MAX_ARCHIVE_ENTRIES			384
-
-class NSArchive : public Common::Archive {
-
-	Common::SeekableReadStream	*_stream;
-
-	char			_archiveDir[MAX_ARCHIVE_ENTRIES][32];
-	uint32			_archiveLenghts[MAX_ARCHIVE_ENTRIES];
-	uint32			_archiveOffsets[MAX_ARCHIVE_ENTRIES];
-	uint32			_numFiles;
-
-	uint32 			lookup(const char *name);
-
-public:
-	NSArchive(Common::SeekableReadStream *stream, Common::Platform platform, uint32 features);
-	~NSArchive();
-
-	Common::SeekableReadStream *openFile(const Common::String &name);
-	bool hasFile(const Common::String &name);
-	int listMembers(Common::ArchiveMemberList &list);
-	Common::ArchiveMemberPtr getMember(const Common::String &name);
-};
-
 class Disk_ns : public Disk {
 
 protected:
 	Parallaction		*_vm;
 
-	NSArchive			*_resArchive;
-	NSArchive			*_locArchive;
+	Common::SearchSet	_sset;
 
 	Common::String		_resArchiveName;
 	Common::String		_language;
 	Common::SeekableReadStream *openFile(const char *filename);
-	Common::SeekableReadStream *tryOpenFile(const char *filename);
-	virtual Common::SeekableReadStream *tryOpenExternalFile(const char *filename);
-	virtual Common::SeekableReadStream *tryOpenArchivedFile(const char* name) { return 0; }
+	virtual Common::SeekableReadStream *tryOpenFile(const char *filename) { return 0; }
 	void errorFileNotFound(const char *filename);
 
+	void addArchive(const Common::String& name, int priority);
+
 public:
 	Disk_ns(Parallaction *vm);
 	virtual ~Disk_ns();
@@ -141,12 +116,14 @@
 
 protected:
 	Gfx	 *_gfx;
-	virtual Common::SeekableReadStream *tryOpenArchivedFile(const char* name);
+	virtual Common::SeekableReadStream *tryOpenFile(const char* name);
 
 public:
 	DosDisk_ns(Parallaction *vm);
 	virtual ~DosDisk_ns();
 
+	void init();
+
 	Script* loadLocation(const char *name);
 	Script* loadScript(const char* name);
 	GfxObj* loadTalk(const char *name);
@@ -170,7 +147,7 @@
 	void patchFrame(byte *dst, byte *dlta, uint16 bytesPerPlane, uint16 height);
 	void unpackFrame(byte *dst, byte *src, uint16 planeSize);
 	void unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 bytesPerPlane, uint16 height);
-	Common::SeekableReadStream *tryOpenArchivedFile(const char* name);
+	Common::SeekableReadStream *tryOpenFile(const char* name);
 	Font *createFont(const char *name, Common::SeekableReadStream &stream);
 	void loadMask(BackgroundInfo& info, const char *name);
 	void loadPath(BackgroundInfo& info, const char *name);
@@ -180,6 +157,8 @@
 	AmigaDisk_ns(Parallaction *vm);
 	virtual ~AmigaDisk_ns();
 
+	void init();
+
 	Script* loadLocation(const char *name);
 	Script* loadScript(const char* name);
 	GfxObj* loadTalk(const char *name);

Modified: scummvm/trunk/engines/parallaction/disk_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_ns.cpp	2008-11-07 13:50:56 UTC (rev 34930)
+++ scummvm/trunk/engines/parallaction/disk_ns.cpp	2008-11-07 15:35:18 UTC (rev 34931)
@@ -24,6 +24,7 @@
  */
 
 #include "graphics/iff.h"
+#include "common/config-manager.h"
 
 #include "parallaction/parallaction.h"
 
@@ -60,6 +61,30 @@
 #define NORMAL_ARCHIVE_DATA_OFS		0x4000
 #define SMALL_ARCHIVE_DATA_OFS		0x1966
 
+#define MAX_ARCHIVE_ENTRIES			384
+
+class NSArchive : public Common::Archive {
+
+	Common::SeekableReadStream	*_stream;
+
+	char			_archiveDir[MAX_ARCHIVE_ENTRIES][32];
+	uint32			_archiveLenghts[MAX_ARCHIVE_ENTRIES];
+	uint32			_archiveOffsets[MAX_ARCHIVE_ENTRIES];
+	uint32			_numFiles;
+
+	uint32 			lookup(const char *name);
+
+public:
+	NSArchive(Common::SeekableReadStream *stream, Common::Platform platform, uint32 features);
+	~NSArchive();
+
+	Common::SeekableReadStream *openFile(const Common::String &name);
+	bool hasFile(const Common::String &name);
+	int listMembers(Common::ArchiveMemberList &list);
+	Common::ArchiveMemberPtr getMember(const Common::String &name);
+};
+
+
 NSArchive::NSArchive(Common::SeekableReadStream *stream, Common::Platform platform, uint32 features) : _stream(stream) {
 	if (!_stream) {
 		error("NSArchive: invalid stream passed to constructor");
@@ -143,16 +168,18 @@
 }
 
 
+#define HIGHEST_PRIORITY			9
+#define NORMAL_ARCHIVE_PRIORITY		5
+#define LOW_ARCHIVE_PRIORITY		2
+#define LOWEST_ARCHIVE_PRIORITY		1
 
-
-Disk_ns::Disk_ns(Parallaction *vm) : _vm(vm), _language("ur") {
-	_locArchive = 0;
-	_resArchive = 0;
+Disk_ns::Disk_ns(Parallaction *vm) : _vm(vm) {
+	Common::FSDirectory *baseDir = new Common::FSDirectory(ConfMan.get("path"));
+	_sset.add("basedir", baseDir, HIGHEST_PRIORITY);
 }
 
 Disk_ns::~Disk_ns() {
-	delete _resArchive;
-	delete _locArchive;
+	_sset.clear();
 }
 
 void Disk_ns::errorFileNotFound(const char *s) {
@@ -166,33 +193,31 @@
 	return stream;
 }
 
-Common::SeekableReadStream *Disk_ns::tryOpenFile(const char *filename) {
-	Common::SeekableReadStream *stream = tryOpenExternalFile(filename);
-	if (stream)
-		return stream;
-	return tryOpenArchivedFile(filename);
-}
 
-Common::SeekableReadStream *Disk_ns::tryOpenExternalFile(const char *filename) {
-	assert(filename);
-	Common::File *stream = new Common::File;
-	if (!stream->open(filename)) {
-		delete stream;
-		stream = 0;
-	}
-	return stream;
+void Disk_ns::addArchive(const Common::String& name, int priority) {
+	Common::SeekableReadStream *stream = _sset.openFile(name);
+	if (!stream)
+		error("Disk_ns::addArchive() couldn't find archive '%s'", name.c_str());
+
+	debugC(1, kDebugDisk, "Disk_ns::addArchive(name = %s, priority = %i)", name.c_str(), priority);
+
+	NSArchive *arc = new NSArchive(stream, _vm->getPlatform(), _vm->getFeatures());
+	_sset.add(name, arc, priority);
 }
 
 Common::String Disk_ns::selectArchive(const Common::String& name) {
-	if (name.compareToIgnoreCase(_resArchiveName) == 0) {
-		return _resArchiveName;
+	Common::String oldName = _resArchiveName;
+
+	if (_sset.hasArchive(name)) {
+		return oldName;
 	}
 
-	debugC(1, kDebugDisk, "Disk_ns::selectArchive(%s)", name.c_str());
+	if (!_resArchiveName.empty()) {
+		_sset.remove(_resArchiveName);
+	}
+	_resArchiveName = name;
+	addArchive(name, LOW_ARCHIVE_PRIORITY);
 
-	Common::String oldName = _resArchiveName;
-	delete _resArchive;
-	_resArchive = new NSArchive(tryOpenExternalFile(name.c_str()), _vm->getPlatform(), _vm->getFeatures());
 	return oldName;
 }
 
@@ -200,21 +225,23 @@
 	debugC(1, kDebugDisk, "setLanguage(%i)", language);
 	assert(language < 4);
 
+	if (!_language.empty()) {
+		_sset.remove(_language);
+	}
+
 	static const char *languages[] = { "it", "fr", "en", "ge" };
+	_language = languages[language];
 
-	if (_language.compareToIgnoreCase(languages[language]) == 0) {
+	if (_sset.hasArchive(_language)) {
 		return;
 	}
 
-	_language = languages[language];
-	delete _locArchive;
-	_locArchive = new NSArchive(tryOpenExternalFile(_language.c_str()), _vm->getPlatform(), _vm->getFeatures());
+	addArchive(_language, LOWEST_ARCHIVE_PRIORITY);
 }
 
 #pragma mark -
 
 
-
 DosDisk_ns::DosDisk_ns(Parallaction* vm) : Disk_ns(vm) {
 
 }
@@ -222,27 +249,21 @@
 DosDisk_ns::~DosDisk_ns() {
 }
 
+void DosDisk_ns::init() {
+	// setup permament archives
+	addArchive("disk1", NORMAL_ARCHIVE_PRIORITY);
+}
 
-Common::SeekableReadStream *DosDisk_ns::tryOpenArchivedFile(const char* name) {
-	debugC(3, kDebugDisk, "DosDisk_ns::openArchivedFile(%s)", name);
+Common::SeekableReadStream *DosDisk_ns::tryOpenFile(const char* name) {
+	debugC(3, kDebugDisk, "DosDisk_ns::tryOpenFile(%s)", name);
 
-	NSArchive *arc = 0;
-
-	Common::String filename(name);
-	if (filename.hasSuffix(".loc")) {
-		arc = _locArchive;
-	} else {
-		arc = _resArchive;
-	}
-
-	Common::SeekableReadStream *stream = arc->openFile(name);
-	if (stream) {
+	Common::SeekableReadStream *stream = _sset.openFile(name);
+	if (stream)
 		return stream;
-	}
 
 	char path[PATH_LEN];
 	sprintf(path, "%s.pp", name);
-	return arc->openFile(path);
+	return _sset.openFile(path);
 }
 
 
@@ -685,6 +706,16 @@
 
 }
 
+void AmigaDisk_ns::init() {
+	// setup permament archives
+	if (_vm->getFeatures() & GF_DEMO) {
+		addArchive("disk0", NORMAL_ARCHIVE_PRIORITY);
+	} else {
+		addArchive("disk0", NORMAL_ARCHIVE_PRIORITY);
+		addArchive("disk1", NORMAL_ARCHIVE_PRIORITY);
+	}
+}
+
 #define NUM_PLANES		5
 
 /*
@@ -854,30 +885,21 @@
 	return new GfxObj(0, makeCnv(s, true), name);
 }
 
-Common::SeekableReadStream *AmigaDisk_ns::tryOpenArchivedFile(const char* name) {
-	debugC(3, kDebugDisk, "AmigaDisk_ns::openArchivedFile(%s)", name);
+Common::SeekableReadStream *AmigaDisk_ns::tryOpenFile(const char* name) {
+	debugC(3, kDebugDisk, "AmigaDisk_ns::tryOpenFile(%s)", name);
 
-	NSArchive *arc = 0;
-
-	Common::String filename(name);
-	if (filename.hasSuffix(".loc")) {
-		arc = _locArchive;
-	} else {
-		arc = _resArchive;
-	}
-
-	Common::SeekableReadStream *stream = arc->openFile(name);
+	Common::SeekableReadStream *stream = _sset.openFile(name);
 	if (stream)
 		return stream;
 
 	char path[PATH_LEN];
 	sprintf(path, "%s.pp", name);
-	stream = arc->openFile(path);
+	stream = _sset.openFile(path);
 	if (stream)
 		return new PowerPackerStream(*stream);
 
 	sprintf(path, "%s.dd", name);
-	stream = arc->openFile(path);
+	stream = _sset.openFile(path);
 	if (stream)
 		return new PowerPackerStream(*stream);
 

Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-11-07 13:50:56 UTC (rev 34930)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-11-07 15:35:18 UTC (rev 34931)
@@ -319,7 +319,6 @@
 	}
 
 	virtual void enter() {
-		_vm->_disk->selectArchive("disk1");
 		_vm->setBackground("test", NULL, NULL);
 		_vm->_input->setMouseState(MOUSE_ENABLED_HIDE);
 
@@ -544,7 +543,6 @@
 
 	virtual void enter() {
 		_vm->_soundMan->stopMusic();
-		_vm->_disk->selectArchive((_vm->getFeatures() & GF_DEMO) ? "disk0" : "disk1");
 		_vm->showSlide("password");
 
 		_emptySlots.create(BLOCK_WIDTH * 8, BLOCK_HEIGHT, 1);
@@ -798,8 +796,6 @@
 const char *EndPartInputState_NS::endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"};
 
 void Parallaction_ns::startGui() {
-	_disk->selectArchive((getFeatures() & GF_DEMO) ? "disk0" : "disk1");
-
 	_menuHelper = new MenuInputHelper;
 	assert(_menuHelper);
 

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-11-07 13:50:56 UTC (rev 34930)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-11-07 15:35:18 UTC (rev 34931)
@@ -66,8 +66,6 @@
 	// FIXME
 	_vm = this;
 
-	Common::File::addDefaultDirectory(_gameDataDir);
-
 	Common::addSpecialDebugLevel(kDebugDialogue, "dialogue", "Dialogues debug level");
 	Common::addSpecialDebugLevel(kDebugParser, "parser", "Parser debug level");
 	Common::addSpecialDebugLevel(kDebugDisk, "disk", "Disk debug level");

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-11-07 13:50:56 UTC (rev 34930)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-11-07 15:35:18 UTC (rev 34931)
@@ -155,9 +155,10 @@
 			strcpy(_location._name, "fognedemo");
 		}
 		_disk = new AmigaDisk_ns(this);
-		_disk->selectArchive((getFeatures() & GF_DEMO) ? "disk0" : "disk1");
 	}
 
+	_disk->init();
+
 	if (getPlatform() == Common::kPlatformPC) {
 		int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
 		MidiDriver *driver = MidiDriver::createMidi(midiDriver);
@@ -394,16 +395,11 @@
 	// character for sanity before memory is freed
 	freeCharacter();
 
-	Common::String oldArchive = _disk->selectArchive((getFeatures() & GF_DEMO) ? "disk0" : "disk1");
 	_char._ani->gfxobj = _gfx->loadAnim(_char.getFullName());
 	_char._ani->gfxobj->setFlags(kGfxObjCharacter);
 	_char._ani->gfxobj->clearFlags(kGfxObjNormal);
 
 	if (!_char.dummy()) {
-		if (getPlatform() == Common::kPlatformAmiga) {
-			_disk->selectArchive("disk0");
-		}
-
 		_char._head = _disk->loadHead(_char.getBaseName());
 		_char._talk = _disk->loadTalk(_char.getBaseName());
 		_char._objs = _disk->loadObjects(_char.getBaseName());
@@ -420,9 +416,6 @@
 			parseLocation("common");
 	}
 
-	if (!oldArchive.empty())
-		_disk->selectArchive(oldArchive);
-
 	strcpy(_characterName1, _char.getFullName());
 
 	debugC(3, kDebugExec, "changeCharacter: switch completed");


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