Beispiel #1
0
bool Console::Cmd_Extract(int argc, const char **argv) {
	if (argc != 5) {
		DebugPrintf("Extract a file from the game's archives\n");
		DebugPrintf("Usage :\n");
		DebugPrintf("extract [room] [node id] [face number] [object type]\n");
		return true;
	}

	// Room names are uppercase
	Common::String room = Common::String(argv[1]);
	room.toUppercase();

	uint16 id = atoi(argv[2]);
	uint16 face = atoi(argv[3]);
	DirectorySubEntry::ResourceType type = (DirectorySubEntry::ResourceType) atoi(argv[4]);

	const DirectorySubEntry *desc = _vm->getFileDescription(room.c_str(), id, face, type);

	if (!desc) {
		DebugPrintf("File with room %s, id %d, face %d and type %d does not exist\n", room.c_str(), id, face, type);
		return true;
	}

	Common::MemoryReadStream *s = desc->getData();
	Common::String filename = Common::String::format("node%s_%d_face%d.%d", room.c_str(), id, face, type);
	Common::DumpFile f;
	f.open(filename);

	uint8 *buf = new uint8[s->size()];

	s->read(buf, s->size());
	f.write(buf, s->size());

	delete[] buf;

	f.close();

	delete s;

	DebugPrintf("File '%s' successfully written\n", filename.c_str());

	return true;
}
Beispiel #2
0
GTEST_TEST_F(LanguageManager, preParseColorCodes) {
	static const byte kColorString    [] = "<c""\xAB""\xCD""\xEF"">Foobar</c>";
	static const byte kPreparsedString[] = "<cABCDEFFF>Foobar</c>";

	Common::MemoryReadStream stream(kColorString);

	Common::MemoryReadStream *preparsed = LangMan.preParseColorCodes(stream);
	ASSERT_NE(preparsed, static_cast<Common::MemoryReadStream *>(0));
	ASSERT_EQ(preparsed->size(), sizeof(kPreparsedString));

	for (size_t i = 0; i < sizeof(kPreparsedString); i++)
		EXPECT_EQ(preparsed->readChar(), kPreparsedString[i]) << "At index " << i;

	delete preparsed;
}
Beispiel #3
0
GTEST_TEST(MemoryReadStream, readStream) {
	static const byte data[3] = { 0x12, 0x34, 0x56 };
	Common::MemoryReadStream stream(data);

	Common::MemoryReadStream *streamRead = stream.readStream(ARRAYSIZE(data));

	EXPECT_EQ(streamRead->size(), ARRAYSIZE(data));
	for (size_t i = 0; i < ARRAYSIZE(data); i++)
		EXPECT_EQ(streamRead->readByte(), data[i]) << "At index " << i;

	delete streamRead;

	stream.seek(0);

	EXPECT_THROW(stream.readStream(ARRAYSIZE(data) + 1), Common::Exception);
}
Beispiel #4
0
			warning("Failed to find audio entry %i", number);
			return NULL;
		}
	} else {
		audioRes = _resMan->findResource(ResourceId(kResourceTypeAudio36, volume, number), false);
		if (!audioRes) {
			warning("Failed to find audio entry (%i, %i, %i, %i, %i)", volume, (number >> 24) & 0xff,
					(number >> 16) & 0xff, (number >> 8) & 0xff, number & 0xff);
			return NULL;
		}
	}

	// Load the data into a MemoryReadStream. The AudioStream here cannot rely on
	// memory from the resource manager.
	Common::MemoryReadStream srcStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
	Common::ScopedPtr<Common::SeekableReadStream> stream(srcStream.readStream(srcStream.size()));

	byte audioFlags;
	uint32 audioCompressionType = audioRes->getAudioCompressionType();
	Audio::SeekableAudioStream *audioSeekStream = 0;

	if (audioCompressionType) {
#if (defined(USE_MAD) || defined(USE_VORBIS) || defined(USE_FLAC))
		switch (audioCompressionType) {
		case MKTAG('M','P','3',' '):
#ifdef USE_MAD
			audioSeekStream = Audio::makeMP3Stream(stream.release(), DisposeAfterUse::YES);
#endif
			break;
		case MKTAG('O','G','G',' '):
#ifdef USE_VORBIS