Esempio n. 1
0
InspectionMatch Tool::inspectInput(const Common::Filename &filename) {
	for (ToolInputs::iterator iter = _inputPaths.begin(); iter != _inputPaths.end(); ++iter) {
		std::string p = iter->format;
		if (p == "/") {
			// TODO
			// Directory, we don't handle this yet, don't display at all
			return IMATCH_AWFUL;
		}

		Common::Filename cmp_filename = p;

		if (cmp_filename.getName() == "*") {
			if (cmp_filename.getExtension() == "*")
				// Match anything!
				return IMATCH_POSSIBLE;
			else if (scumm_stricmp(cmp_filename.getExtension().c_str(), filename.getExtension().c_str()) == 0)
				// Extensions are the same
				return IMATCH_PERFECT;
		} else {
			// Match on filename
			if (cmp_filename.getName() == filename.getName()) {
				if (cmp_filename.getExtension() == "*")
					return IMATCH_PERFECT;
				else if (scumm_stricmp(cmp_filename.getExtension().c_str(), filename.getExtension().c_str()) == 0)
					// Filenames are identical
					return IMATCH_PERFECT;
			}
		}
	}

	// Didn't match any of our inputs
	return IMATCH_AWFUL;
}
Esempio n. 2
0
InspectionMatch Tool::inspectInput(const Common::Filename &filename, const std::string& format) {
	// Case were we expect a directory
	if (format == "/") {
		if (filename.directory())
			return IMATCH_POSSIBLE;
		return IMATCH_AWFUL;
	}

	// We expect a file.
	// First check this is not a directory.
	if (filename.directory())
		return IMATCH_AWFUL;
	
	Common::Filename cmp_filename = format;
	if (cmp_filename.getName() == "*") {
		if (cmp_filename.getExtension() == "*")
			// Match anything!
			return IMATCH_POSSIBLE;
		else if (scumm_stricmp(cmp_filename.getExtension().c_str(), filename.getExtension().c_str()) == 0)
			// Extensions are the same
			return IMATCH_PERFECT;
	} else {
		// Match on filename
		if (cmp_filename.getName() == filename.getName()) {
			if (cmp_filename.getExtension() == "*")
				return IMATCH_PERFECT;
			else if (scumm_stricmp(cmp_filename.getExtension().c_str(), filename.getExtension().c_str()) == 0)
				// Filenames are identical
				return IMATCH_PERFECT;
		}
	}
	return IMATCH_AWFUL;
}
InspectionMatch ExtractScummMac::inspectInput(const Common::Filename &filename) {
	std::string name = filename.getFullName();
	std::transform(name.begin(), name.end(), name.begin(), tolower);
	std::string::size_type pos = name.find(" data");
	if (pos == name.length() - 5) // True if the file name ends with " Data"
		return IMATCH_PERFECT;
	return IMATCH_AWFUL;
}
Esempio n. 4
0
void PackPrince::execute() {
	Common::Filename mainDir = _inputPaths[0].path;
	// We always need to setup default output path, since there is no obligation to specify it
	if (_outputPath.empty()) {
		_outputPath.setFullPath("./");
	}

	_outputPath.setFullName("prince_translation.dat");
	_fFiles.open(_outputPath, "wb");
	if (!_fFiles.isOpen()) {
		error("Unable to create prince_translation.dat");
	}

	// Export names of files
	_fFiles.print("variatxt_translate.dat\n");
	_fFiles.print("invtxt_translate.dat\n");
	_fFiles.print("talktxt_translate.dat\n");
	_fFiles.print("mob_translate.dat\n");
	_fFiles.print("credits_translate.dat\n");


	// Export files infomation
	int posOfFilesInformation = _fFiles.pos();
	FileEntry filesInfo[5];
	int fileNr = 0;
	for (int i = 0; i < 5; i++) {
		_fFiles.writeUint32LE(0); // place for files offsets
		_fFiles.writeUint32LE(0); // and size of files
	}

	printf("Packing The Prince and the Coward text data...\n");

	filesInfo[fileNr]._offset = _fFiles.pos();
	mainDir.setFullName("variatxt.txt");
	_databank.open(mainDir, "rb");
	if (!_databank.isOpen()) {
		error("Unable to open variatxt.txt");
	}
	packVariaTxt();
	filesInfo[fileNr]._size = _fFiles.pos() - filesInfo[fileNr]._offset;
	fileNr++;
	_databank.close();
	printf("variatxt_translate.dat - done\n");

	filesInfo[fileNr]._offset = _fFiles.pos();
	mainDir.setFullName("invtxt.txt");
	_databank.open(mainDir, "rb");
	if (!_databank.isOpen()) {
		error("Unable to open invtxt.txt");
	}
	packInvTxt();
	filesInfo[fileNr]._size = _fFiles.pos() - filesInfo[fileNr]._offset;
	fileNr++;
	_databank.close();
	printf("invtxt_translate.dat - done\n");

	filesInfo[fileNr]._offset = _fFiles.pos();
	mainDir.setFullName("talktxt.txt");
	_databank.open(mainDir, "rb");
	if (!_databank.isOpen()) {
		error("Unable to open talktxt.txt");
	}
	packTalkTxt();
	filesInfo[fileNr]._size = _fFiles.pos() - filesInfo[fileNr]._offset;
	fileNr++;
	_databank.close();
	printf("talktxt_translate.dat - done\n");

	filesInfo[fileNr]._offset = _fFiles.pos();
	mainDir.setFullName("mob.txt");
	_databank.open(mainDir, "rb");
	if (!_databank.isOpen()) {
		error("Unable to open mob.txt");
	}
	packMobs();
	filesInfo[fileNr]._size = _fFiles.pos() - filesInfo[fileNr]._offset;
	fileNr++;
	_databank.close();
	printf("mob_translate.dat - done\n");

	filesInfo[fileNr]._offset = _fFiles.pos();
	mainDir.setFullName("credits.txt");
	_databank.open(mainDir, "rb");
	if (!_databank.isOpen()) {
		error("Unable to open credits.txt");
	}
	packCredits();
	filesInfo[fileNr]._size = _fFiles.pos() - filesInfo[fileNr]._offset;
	fileNr++;
	_databank.close();
	printf("credits_translate.dat - done\n");

	// Files offset and size setting
	_fFiles.seek(posOfFilesInformation, SEEK_SET);
	for (int i = 0; i < fileNr; i++) {
		_fFiles.writeUint32LE(filesInfo[i]._offset);
		_fFiles.writeUint32LE(filesInfo[i]._size);
	}
	_fFiles.close();
	printf("All done!\n");
	printf("File is created in %s\n", _outputPath.getFullPath().c_str());
}
Esempio n. 5
0
void PackPrince::packTalkTxt() {
	// IDs array for first 2000 offsets calculation
	const int kSetStringValues = 2000;
	int setStringIdArray[kSetStringValues];
	Common::Filename mainDir = _inputPaths[0].path;
	Common::File idsFile;
	mainDir.setFullName("talktxt_ids.txt");
	idsFile.open(mainDir, "rb");
	if (!idsFile.isOpen()) {
		error("Unable to open talktxt_ids.txt");
	}

	// Header test
	byte c;
	std::string line;
	while ((c = idsFile.readByte()) != '\r') {
		line += c;
	}
	if (line.compare("talktxt_ids")) {
		error("Wrong header in talktxt_ids.txt");
	}
	idsFile.readByte(); // skip '\n'

	// IDs loading
	for (int i = 0; i < kSetStringValues; i++) {
		int value = 0;
		while ((c = idsFile.readByte()) != '\r') {
			value *= 10;
			value += c - 48;
		}
		idsFile.readByte(); // skip '\n'
		setStringIdArray[i] = value;
	}
	idsFile.close();

	// Main file
	// File size
	uint fileSize = _databank.size();

	// Header test
	line.clear();
	while ((c = _databank.readByte()) != '\r') {
		line += c;
	}
	if (line.compare("talktxt.dat")) {
		error("Wrong header in talktxt.txt");
	}
	_databank.readByte(); // skip '\n'

	// Start pos of talkTxt file for later offset setting
	int startTalkTxtPos = _fFiles.pos();

	// Making space for main offsets
	for (int i = 0; i < kSetStringValues; i++) {
		_fFiles.writeUint32LE(0);
	}

	int id = 1;
	int setStringOffsetsArray[kSetStringValues];
	for (int i = 0; i < kSetStringValues; i++) {
		setStringOffsetsArray[i] = 0;
	}

	while (1) {
		line.clear();
		while ((c = _databank.readByte()) != '\r') {
			line += c;
		}
		_databank.readByte(); // skip '\n'

		for (int i = 0; i < kSetStringValues; i++) {
			if (id == setStringIdArray[i]) {
				setStringOffsetsArray[i] = _fFiles.pos() - startTalkTxtPos;
			}
		}

		if (!line.compare("@DIALOGBOX_LINES:")) {
			talkTxtWithDialog();
		} else if (!line.compare("@NORMAL_LINES:")) {
			talkTxtNoDialog();
		}

		id++;

		if ((uint)_databank.pos() == fileSize) {
			break;
		}
	}
	// End of talkTxt file
	int endTalkTxtPos = _fFiles.pos();

	// Back to start of talkTxt file for offsets setting
	_fFiles.seek(startTalkTxtPos, SEEK_SET);
	for (int i = 0; i < kSetStringValues; i++) {
		_fFiles.writeUint32LE(setStringOffsetsArray[i]);
	}

	// Back to the end of talkTxt file
	_fFiles.seek(endTalkTxtPos, SEEK_SET);
}