当前位置: 首页>>代码示例>>C++>>正文


C++ SeekableReadStream::seek方法代码示例

本文整理汇总了C++中common::SeekableReadStream::seek方法的典型用法代码示例。如果您正苦于以下问题:C++ SeekableReadStream::seek方法的具体用法?C++ SeekableReadStream::seek怎么用?C++ SeekableReadStream::seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common::SeekableReadStream的用法示例。


在下文中一共展示了SeekableReadStream::seek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadPalette

void ImageFile::loadPalette(Common::SeekableReadStream &stream) {
	// Check for palette
	uint16 width        = stream.readUint16LE() + 1;
	uint16 height       = stream.readUint16LE() + 1;
	byte   paletteBase  = stream.readByte();
	byte   rleEncoded   = stream.readByte();
	byte   offsetX      = stream.readByte();
	byte   offsetY      = stream.readByte();
	uint32 palSignature = 0;

	if ((width == 390) && (height == 2) && (!paletteBase) && (!rleEncoded) && (!offsetX) && (!offsetY)) {
		// We check for these specific values
		// We can't do "width * height", because at least the first German+Spanish menu bar is 60 x 13
		// which is 780, which is the size of the palette. We obviously don't want to detect it as palette.

		// As another security measure, we also check for the signature text
		palSignature = stream.readUint32BE();
		if (palSignature != MKTAG('V', 'G', 'A', ' ')) {
			// signature mismatch, rewind
			stream.seek(-12, SEEK_CUR);
			return;
		}
		// Found palette, so read it in
		stream.seek(8, SEEK_CUR); // Skip over the rest of the signature text "VGA palette"
		for (int idx = 0; idx < PALETTE_SIZE; ++idx)
			_palette[idx] = VGA_COLOR_TRANS(stream.readByte());
	} else {
		// Not a palette, so rewind to start of frame data for normal frame processing
		stream.seek(-8, SEEK_CUR);
	}
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:31,代码来源:image_file.cpp

示例2: loadEXE

void DirectorEngine::loadEXE() {
    Common::SeekableReadStream *exeStream = SearchMan.createReadStreamForMember(getEXEName());
    if (!exeStream)
        error("Failed to open EXE '%s'", getEXEName().c_str());

    _lingo->processEvent(kEventStart, 0);

    exeStream->seek(-4, SEEK_END);
    exeStream->seek(exeStream->readUint32LE());

    switch (getVersion()) {
    case 3:
        loadEXEv3(exeStream);
        break;
    case 4:
        loadEXEv4(exeStream);
        break;
    case 5:
        loadEXEv5(exeStream);
        break;
    case 7:
        loadEXEv7(exeStream);
        break;
    default:
        error("Unhandled Windows EXE version %d", getVersion());
    }
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:27,代码来源:resource.cpp

示例3: readBIFList

void KEYFile::readBIFList(Common::SeekableReadStream &key, uint32 offset) {
	key.seek(offset);

	for (BIFList::iterator bif = _bifs.begin(); bif != _bifs.end(); ++bif) {
		key.skip(4); // File size of the bif

		uint32 nameOffset = key.readUint32LE();
		uint32 nameSize   = 0;

		// nameSize is expanded to 4 bytes in 1.1 and the location is dropped
		if (_version == kVersion11) {
			nameSize = key.readUint32LE();
		} else {
			nameSize = key.readUint16LE();
			key.skip(2); // Location of the bif (HD, CD, ...)
		}

		uint32 curPos = key.seek(nameOffset);

		*bif = Common::readStringFixed(key, Common::kEncodingASCII, nameSize);

		key.seek(curPos);

		bif->replaceAll('\\', '/');
		if (bif->beginsWith("/"))
			bif->erase(bif->begin());
	}
}
开发者ID:idkwim,项目名称:xoreos-tools,代码行数:28,代码来源:keyfile.cpp

示例4: _decryptHeader

void Archive::_decryptHeader(Common::SeekableReadStream &inStream, Common::WriteStream &outStream) {
	static const uint32 addKey = 0x3C6EF35F;
	static const uint32 multKey = 0x0019660D;

	inStream.seek(0);
	uint32 size = inStream.readUint32LE();

	bool encrypted = size > 1000000;
	
	inStream.seek(0);

	if (encrypted) {
		uint32 decryptedSize = size ^ addKey;

		uint32 currentKey = 0;
		for (uint i = 0; i < decryptedSize; i++) {
			currentKey += addKey;
			outStream.writeUint32LE(inStream.readUint32LE() ^ currentKey);
			currentKey *= multKey;
		}
	} else {
		for (uint i = 0; i < size; i++) {
			outStream.writeUint32LE(inStream.readUint32LE());
		}
	}
}
开发者ID:ComputeLinux,项目名称:residualvm,代码行数:26,代码来源:archive.cpp

示例5: getInfo

bool SaveReader::getInfo(Common::SeekableReadStream &stream, SavePartInfo &info) {
	// Remeber the stream's starting position to seek back to
	uint32 startPos = stream.pos();

	// Get parts' basic information
	Common::Array<SaveContainer::PartInfo> *partsInfo = getPartsInfo(stream);

	// No parts => fail
	if (!partsInfo) {
		stream.seek(startPos);
		return false;
	}

	bool result = false;
	// Iterate over all parts
	for (Common::Array<SaveContainer::PartInfo>::iterator it = partsInfo->begin();
	     it != partsInfo->end(); ++it) {

		// Check for the info part
		if (it->id == SavePartInfo::kID) {
			if (!stream.seek(it->offset))
				break;

			// Read it
			result = info.read(stream);
			break;
		}
	}

	stream.seek(startPos);

	delete partsInfo;
	return result;
}
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:34,代码来源:savefile.cpp

示例6:

Common::Archive *Resource::loadArchive(const Common::String &name, Common::ArchiveMemberPtr member) {
	ArchiveMap::iterator cachedArchive = _archiveCache.find(name);
	if (cachedArchive != _archiveCache.end())
		return cachedArchive->_value;

	Common::SeekableReadStream *stream = member->createReadStream();

	if (!stream)
		return 0;

	Common::Archive *archive = 0;
	for (LoaderList::const_iterator i = _loaders.begin(); i != _loaders.end(); ++i) {
		if ((*i)->checkFilename(name)) {
			if ((*i)->isLoadable(name, *stream)) {
				stream->seek(0, SEEK_SET);
				archive = (*i)->load(member, *stream);
				break;
			} else {
				stream->seek(0, SEEK_SET);
			}
		}
	}

	delete stream;

	if (!archive)
		return 0;

	_archiveCache[name] = archive;
	return archive;
}
开发者ID:chrisws,项目名称:scummvm,代码行数:31,代码来源:resource.cpp

示例7: getMessage

Common::String Resource::getMessage(uint16 id, uint16 message) {
	Common::SeekableReadStream *lookup = _text->createReadStreamForIndex(id + 6);
	Common::SeekableReadStream *strings = _text->createReadStreamForIndex(id + 7);

	char buff[1024];
	int j = 0;

	int size = lookup->size()/2;
	for (int i = 0; i < size; ++i) {
		uint16 val = lookup->readUint16LE();
		if (val == message) {
			strings->seek(i*2);
			uint16 offset = strings->readUint16LE();
			char c = 0;
			strings->seek(offset);
			do {
				c = strings->readByte();
				buff[j++] = c;
			} while (c != 0);

			return buff;
		}
	}
	return "";
}
开发者ID:klusark,项目名称:twin,代码行数:25,代码来源:resource.cpp

示例8: loadActions

void GameModule::loadActions(Common::SeekableReadStream &s) {
	debug(0, "GameModule::loadActions()");

	s.seek(0x180);
	_actionsCount = s.readUint32LE();
	uint32 offs = s.readUint32LE();
	_actions = new Action[_actionsCount];
	for (int i = 0; i < _actionsCount; ++i) {
		s.seek(offs + i * 72);
		debug(0, "Action(%d) offs: %08X", i, offs + i * 72);
		_actions[i].conditions = readConditions(s);
		for (int j = 0; j < 8; ++j) {
			_actions[i].results.actionResults[j].kind = s.readByte();
			_actions[i].results.actionResults[j].value1 = s.readByte();
			_actions[i].results.actionResults[j].value2 = s.readUint16LE();
		}
		const int actionListCount = s.readUint32LE();
		const uint32 actionListOffs = s.readUint32LE();
		s.seek(actionListOffs);
		for (int j = 0; j < actionListCount; ++j) {
			ActionCommand actionCommand;
			actionCommand.cmd = s.readUint16LE();
			actionCommand.sceneObjectIndex = s.readUint16LE();
			actionCommand.timeStamp = s.readUint32LE();
			actionCommand.walkDest = readPoint(s);
			actionCommand.param = s.readUint32LE();
			_actions[i].actionCommands.push_back(actionCommand);
		}
	}
}
开发者ID:86400,项目名称:scummvm,代码行数:30,代码来源:gamemodule.cpp

示例9: playFile

void DrasculaEngine::playFile(const char *fname) {
	Common::SeekableReadStream *stream = _archives.open(fname);
	if (stream) {
		int soundSize = stream->size();
		byte *soundData = (byte *)malloc(soundSize);

		if (!(!strcmp(fname, "3.als") && soundSize == 145166 && _lang != kSpanish)) {
			stream->seek(32);
		} else {
			// WORKAROUND: File 3.als with English speech files has a big silence at
			// its beginning and end. We seek past the silence at the beginning,
			// and ignore the silence at the end
			// Fixes bug #2111815 - "DRASCULA: Voice delayed"
			stream->seek(73959, SEEK_SET);
			soundSize = 117158 - 73959;
		}

		stream->read(soundData, soundSize);
		delete stream;

		_subtitlesDisabled = !ConfMan.getBool("subtitles");
		if (ConfMan.getBool("speech_mute"))
			memset(soundData, 0x80, soundSize); // Mute speech but keep the pause

		Audio::AudioStream *sound = Audio::makeRawStream(soundData, soundSize - 64,
						11025, Audio::FLAG_UNSIGNED);
		_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_soundHandle, sound);
	} else
		warning("playFile: Could not open %s", fname);
}
开发者ID:Termimad,项目名称:scummvm,代码行数:30,代码来源:sound.cpp

示例10: loadResourcesFromSave

/**
 * Load animDataTable from save
 * @param fHandle Savefile open for reading
 * @param saveGameFormat The used savegame format
 * @todo Add Operation Stealth savefile support
 *
 * Unlike the old code, this one actually rebuilds the table one frame
 * at a time.
 */
void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGameFormat saveGameFormat) {
    int16 foundFileIdx;
    char *animName, part[256], name[10];

    strcpy(part, currentPartName);

    // We only support these variations of the savegame format at the moment.
    assert(saveGameFormat == ANIMSIZE_23 || saveGameFormat == ANIMSIZE_30_PTRS_INTACT);

    const int entrySize = ((saveGameFormat == ANIMSIZE_23) ? 23 : 30);
    const int fileStartPos = fHandle.pos();

    for(int resourceIndex=0; resourceIndex<NUM_MAX_ANIMDATA; resourceIndex++) {
        // Seek to the start of the current animation's entry
        fHandle.seek(fileStartPos + resourceIndex * entrySize);
        // Read in the current animation entry
        fHandle.readUint16BE(); // width
        fHandle.readUint16BE();
        fHandle.readUint16BE(); // bpp
        fHandle.readUint16BE(); // height

        bool validPtr = false;
        // Handle variables only present in animation entries of size 30
        if (entrySize == 30) {
            validPtr = (fHandle.readUint32BE() != 0); // Read data pointer
            fHandle.readUint32BE(); // Discard mask pointer
        }

        foundFileIdx = fHandle.readSint16BE();
        int16 frameIndex = fHandle.readSint16BE(); // frame
        fHandle.read(name, 10);

        // Handle variables only present in animation entries of size 23
        if (entrySize == 23) {
            validPtr = (fHandle.readByte() != 0);
        }

        // Don't try to load invalid entries.
        if (foundFileIdx < 0 || !validPtr) {
            //resourceIndex++; // Jump over the invalid entry
            continue;
        }

        // Alright, the animation entry looks to be valid so let's start handling it...
        if (strcmp(currentPartName, name) != 0) {
            closePart();
            loadPart(name);
        }

        animName = g_cine->_partBuffer[foundFileIdx].partName;
        loadRelatedPalette(animName); // Is this for Future Wars only?
        loadResource(animName, resourceIndex, frameIndex);
    }

    loadPart(part);

    // Make sure we jump over all the animation entries
    fHandle.seek(fileStartPos + NUM_MAX_ANIMDATA * entrySize);
}
开发者ID:MathiasBartl,项目名称:scummvm,代码行数:68,代码来源:saveload.cpp

示例11: loadStream

bool Animation::loadStream(Common::SeekableReadStream &stream) {
	stream.skip(2); // skip not used x and y coord diff
	_loopCount = stream.readUint16LE();
	_phaseCount = stream.readUint16LE();
	stream.skip(2); // skip _frameCount here
	_baseX = stream.readUint16LE();
	_baseY = stream.readUint16LE();
	uint32 phaseTableOffset = stream.readUint32LE();
	uint32 tableOfFrameOffsets = stream.pos();

	stream.seek(phaseTableOffset);
	Phase tempPhase;
	_frameCount = 0;
	for (int phase = 0; phase < _phaseCount; phase++) {
		tempPhase._phaseOffsetX = stream.readSint16LE();
		tempPhase._phaseOffsetY = stream.readSint16LE();
		tempPhase._phaseToFrameIndex = stream.readUint16LE();
		if (tempPhase._phaseToFrameIndex > _frameCount) {
			_frameCount = tempPhase._phaseToFrameIndex;
		}
		_phaseList.push_back(tempPhase);
		stream.skip(2);
	}
	if (_phaseCount) {
		_frameCount++;
	}

	Frame tempFrame;
	for (int frame = 0; frame < _frameCount; frame++) {
		stream.seek(tableOfFrameOffsets + frame * 4);
		uint32 frameInfoOffset = stream.readUint32LE();
		stream.seek(frameInfoOffset);
		uint16 frameWidth = stream.readUint16LE();
		uint16 frameHeight = stream.readUint16LE();
		uint32 frameDataPos = stream.pos();
		uint32 frameDataOffset = stream.readUint32BE();

		tempFrame._surface = new Graphics::Surface();
		tempFrame._surface->create(frameWidth, frameHeight, Graphics::PixelFormat::createFormatCLUT8());
		if (frameDataOffset == MKTAG('m', 'a', 's', 'm')) {
			tempFrame._isCompressed = true;
			tempFrame._dataSize = stream.readUint32LE();
			tempFrame._compressedData = (byte *)malloc(tempFrame._dataSize);
			stream.read(tempFrame._compressedData, tempFrame._dataSize);
		} else {
			tempFrame._isCompressed = false;
			tempFrame._dataSize = 0;
			tempFrame._compressedData = nullptr;
			stream.seek(frameDataPos);
			for (uint16 i = 0; i < frameHeight; i++) {
				stream.read(tempFrame._surface->getBasePtr(0, i), frameWidth);
			}
		}
		_frameList.push_back(tempFrame);
	}

	return true;
}
开发者ID:AlbanBedel,项目名称:scummvm,代码行数:58,代码来源:animation.cpp

示例12: loadInventoryItemSpriteIndices

void GameModule::loadInventoryItemSpriteIndices(Common::SeekableReadStream &s) {
	debug(0, "GameModule::loadInventoryItemSpriteIndices()");

	s.seek(0x18C);
	uint32 offs = s.readUint32LE();
	s.seek(offs);
	for (int i = 0; i < kInventoryItemSpriteCount; ++i)
		_inventoryItemSpriteIndices[i] = s.readUint32LE();
}
开发者ID:86400,项目名称:scummvm,代码行数:9,代码来源:gamemodule.cpp

示例13: loadGuiSpriteIndices

void GameModule::loadGuiSpriteIndices(Common::SeekableReadStream &s) {
	debug(0, "GameModule::loadGuiSpriteIndices()");

	s.seek(0x188);
	uint32 offs = s.readUint32LE();
	s.seek(offs);
	for (int i = 0; i < kGuiSpriteCount; ++i)
		_guiSpriteIndices[i] = s.readUint32LE();
}
开发者ID:86400,项目名称:scummvm,代码行数:9,代码来源:gamemodule.cpp

示例14: loadDialogItemSpriteIndices

void GameModule::loadDialogItemSpriteIndices(Common::SeekableReadStream &s) {
	debug(0, "GameModule::loadDialogItemSpriteIndices()");

	s.seek(0x194);
	uint32 offs = s.readUint32LE();
	s.seek(offs);
	for (int i = 0; i < kDialogItemSpriteCount; ++i) {
		_dialogItemSpriteIndices[i] = s.readUint32LE();
	}
}
开发者ID:86400,项目名称:scummvm,代码行数:10,代码来源:gamemodule.cpp

示例15: loadWalkRects

void GameModule::loadWalkRects(Common::SeekableReadStream &s) {
	debug(0, "GameModule::loadWalkRects()");

	s.seek(0x150);
	_walkRectsCount = s.readUint32LE();
	uint32 offs = s.readUint32LE();
	_walkRects = new Common::Rect[_walkRectsCount];
	s.seek(offs);
	for (int i = 0; i < _walkRectsCount; ++i)
		_walkRects[i] = readRect(s);
}
开发者ID:86400,项目名称:scummvm,代码行数:11,代码来源:gamemodule.cpp


注:本文中的common::SeekableReadStream::seek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。