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


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

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


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

示例1: tokenize

void TwoDAFile::readRows2b(Common::SeekableReadStream &twoda) {
	/* And now read the cells. In binary 2DA files, each cell only
	 * stores a single 16-bit number, the offset into the data segment
	 * where the data for this cell can be found. Moreover, a single
	 * data offset can be used by several cells, deduplicating the
	 * cell data.
	 */

	size_t columnCount = _headers.size();
	size_t rowCount    = _rows.size();
	size_t cellCount   = columnCount * rowCount;

	uint32 *offsets = new uint32[cellCount];

	Common::StreamTokenizer tokenize(Common::StreamTokenizer::kRuleHeed);

	tokenize.addSeparator('\0');

	for (size_t i = 0; i < cellCount; i++)
		offsets[i] = twoda.readUint16LE();

	twoda.skip(2); // Size of the data segment in bytes

	size_t dataOffset = twoda.pos();

	for (size_t i = 0; i < rowCount; i++) {
		_rows[i] = new TwoDARow(*this);

		_rows[i]->_data.resize(columnCount);

		for (size_t j = 0; j < columnCount; j++) {
			size_t offset = dataOffset + offsets[i * columnCount + j];

			try {
				twoda.seek(offset);
			} catch (...) {
				delete[] offsets;
				throw;
			}

			_rows[i]->_data[j] = tokenize.getToken(twoda);
			if (_rows[i]->_data[j].empty())
				_rows[i]->_data[j] = "****";
		}
	}

	delete[] offsets;
}
开发者ID:TC01,项目名称:xoreos-tools,代码行数:48,代码来源:2dafile.cpp

示例2: loadFromStream

bool Mob::loadFromStream(Common::SeekableReadStream &stream) {
	int32 pos = stream.pos();

	uint16 visible = stream.readUint16LE();

	if (visible == 0xFFFF)
		return false;

	_visible = visible;
	_type = stream.readUint16LE();
	_rect.left = stream.readUint16LE();
	_rect.top = stream.readUint16LE();
	_rect.right = stream.readUint16LE();
	_rect.bottom = stream.readUint16LE();

	_mask = stream.readUint16LE();

	_examPosition.x = stream.readUint16LE();
	_examPosition.y = stream.readUint16LE();
	_examDirection = (Direction)stream.readUint16LE();

	_usePosition.x = stream.readByte();
	_usePosition.y = stream.readByte();
	_useDirection = (Direction)stream.readUint16LE();

	uint32 nameOffset = stream.readUint32LE();
	uint32 examTextOffset = stream.readUint32LE();

	byte c;
	stream.seek(nameOffset);
	_name.clear();
	while ((c = stream.readByte()))
		_name += c;

	stream.seek(examTextOffset);
	_examText.clear();
	c = stream.readByte();
	if (c) {
		_examText += c;
		do {
			c = stream.readByte();
			_examText += c;
		} while (c != 255);
	}
	stream.seek(pos + 32);

	return true;
}
开发者ID:86400,项目名称:scummvm,代码行数:48,代码来源:mob.cpp

示例3: isSave

bool SaveContainer::isSave(Common::SeekableReadStream &stream) {
	// Remember the stream's position to seek back to
	uint32 startPos = stream.pos();

	SaveHeader header;

	header.setType(kID);
	header.setVersion(kVersion);

	bool result = header.verifyReadSize(stream);

	// Seek back
	stream.seek(startPos);

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

示例4: loadBmpArr

void TopMenu::loadBmpArr(Common::SeekableReadStream &in) {
	_arraySize = in.readUint16BE();

	delete _arrayBmp;
	_arrayBmp = new Graphics::Surface *[_arraySize * 2];
	for (int i = 0; i < _arraySize; i++) {
		uint16 bmpSize = in.readUint16BE();
		uint32 filPos = in.pos();
		Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize);

		Graphics::BitmapDecoder bitmapDecoder;
		if (!bitmapDecoder.loadStream(stream))
			error("TopMenu::loadBmpArr(): Could not load bitmap");

		const Graphics::Surface *bitmapSrc = bitmapDecoder.getSurface();
		if (bitmapSrc->format.bytesPerPixel == 1)
			error("TopMenu::loadBmpArr(): Unhandled paletted image");

		_arrayBmp[i * 2] = bitmapSrc->convertTo(g_system->getOverlayFormat());
		_arrayBmp[i * 2 + 1] = new Graphics::Surface();
		_arrayBmp[i * 2 + 1]->create(_arrayBmp[i * 2]->w * 2, _arrayBmp[i * 2]->h * 2, g_system->getOverlayFormat());
		byte *src = (byte *)_arrayBmp[i * 2]->getPixels();
		byte *dst = (byte *)_arrayBmp[i * 2 + 1]->getPixels();

		for (int j = 0; j < _arrayBmp[i * 2]->h; j++) {
			src = (byte *)_arrayBmp[i * 2]->getBasePtr(0, j);
			dst = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2);
			for (int k = _arrayBmp[i * 2]->w; k > 0; k--) {
				for (int m = _arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) {
					*dst++ = *src++;
				}
				src -= _arrayBmp[i * 2]->format.bytesPerPixel;

				for (int m = _arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) {
					*dst++ = *src++;
				}
			}
			src = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2);
			dst = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2 + 1);
			for (int k = _arrayBmp[i * 2 + 1]->pitch; k > 0; k--) {
				*dst++ = *src++;
			}
		}

		in.seek(filPos + bmpSize);
	}
}
开发者ID:MaddTheSane,项目名称:scummvm,代码行数:47,代码来源:dialogs.cpp

示例5: matchRMAPToCard

uint16 MohawkEngine_Riven::matchRMAPToCard(uint32 rmapCode) {
	uint16 index = 0;
	Common::SeekableReadStream *rmapStream = getResource(ID_RMAP, 1);

	for (uint16 i = 1; rmapStream->pos() < rmapStream->size(); i++) {
		uint32 code = rmapStream->readUint32BE();
		if (code == rmapCode)
			index = i;
	}

	delete rmapStream;

	if (!index)
		error ("Could not match RMAP code %08x", rmapCode);

	return index - 1;
}
开发者ID:AlbanBedel,项目名称:scummvm,代码行数:17,代码来源:riven.cpp

示例6: readStringFixed

Common::UString GFF4Struct::getString(Common::SeekableReadStream &data, Common::Encoding encoding) const {
	/* When the string is encoded in UTF-8, then length field specifies the length in bytes.
	 * Otherwise, it's the length in characters. */
	const size_t lengthMult = encoding == Common::kEncodingUTF8 ? 1 : Common::getBytesPerCodepoint(encoding);

	const size_t offset = data.pos();

	const uint32 length = data.readUint32LE();
	const size_t size   = length * lengthMult;

	try {
		return readStringFixed(data, encoding, size);
	} catch (...) {
	}

	return Common::UString::format("GFF4: Invalid string encoding (0x%08X)", (uint) offset);
}
开发者ID:Glyth,项目名称:xoreos,代码行数:17,代码来源:gff4file.cpp

示例7: SeekableSubReadStream

Common::SeekableReadStream *GFF4Struct::getData(uint32 field) const {
	const Field *f;
	Common::SeekableReadStream *data = getField(field, f);
	if (!data)
		return 0;

	const uint32 count = getListCount(*data, *f);
	const uint32 size  = getFieldSize(f->type);

	if ((size == 0) || (count == 0))
		return 0;

	const uint32 dataBegin = data->pos();
	const uint32 dataEnd   = data->pos() + (count * size);

	return new Common::SeekableSubReadStream(data, dataBegin, dataEnd);
}
开发者ID:Glyth,项目名称:xoreos,代码行数:17,代码来源:gff4file.cpp

示例8: load

void ImageFile::load(Common::SeekableReadStream &stream, bool skipPalette, bool animImages) {
	loadPalette(stream);

	int streamSize = stream.size();
	while (stream.pos() < streamSize) {
		ImageFrame frame;
		frame._width = stream.readUint16LE() + 1;
		frame._height = stream.readUint16LE() + 1;
		frame._paletteBase = stream.readByte();

		if (animImages) {
			// Animation cutscene image files use a 16-bit x offset
			frame._offset.x = stream.readUint16LE();
			frame._rleEncoded = (frame._offset.x & 0xff) == 1;
			frame._offset.y = stream.readByte();
		} else {
			// Standard image files have a separate byte for the RLE flag, and an 8-bit X offset
			frame._rleEncoded = stream.readByte() == 1;
			frame._offset.x = stream.readByte();
			frame._offset.y = stream.readByte();
		}

		frame._rleEncoded = !skipPalette && frame._rleEncoded;

		if (frame._paletteBase) {
			// Nibble packed frame data
			frame._size = (frame._width * frame._height) / 2;
		} else if (frame._rleEncoded) {
			// This size includes the header size, which we subtract
			frame._size = stream.readUint16LE() - 11;
			frame._rleMarker = stream.readByte();
		} else {
			// Uncompressed data
			frame._size = frame._width * frame._height;
		}

		// Load data for frame and decompress it
		byte *data = new byte[frame._size + 4];
		stream.read(data, frame._size);
		Common::fill(data + frame._size, data + frame._size + 4, 0);
		frame.decompressFrame(data, IS_ROSE_TATTOO);
		delete[] data;

		push_back(frame);
	}
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:46,代码来源:image_file.cpp

示例9: dumpStream

bool dumpStream(Common::SeekableReadStream &stream, const Common::UString &fileName) {
	Common::DumpFile file;
	if (!file.open(fileName))
		return false;

	uint32 pos = stream.pos();

	stream.seek(0);

	file.writeStream(stream);
	file.flush();

	bool error = file.err();

	stream.seek(pos);
	file.close();

	return !error;
}
开发者ID:DeejStar,项目名称:xoreos,代码行数:19,代码来源:util.cpp

示例10: parseNextBlockTag

bool CUP_Player::parseNextBlockTag(Common::SeekableReadStream &dataStream) {
	uint32 tag = dataStream.readUint32BE();
	uint32 size = dataStream.readUint32BE() - 8;
	uint32 next = dataStream.pos() + size;
	debug(1, "New block tag %s %d dataSize %d", tag2str(tag), size, _dataSize);
	switch (tag) {
	case MKTAG('F','R','A','M'):
		handleFRAM(dataStream, size);
		break;
	case MKTAG('L','Z','S','S'):
		if (handleLZSS(dataStream, size) && _outLzssBufSize != 0) {
			Common::MemoryReadStream memoryStream(_outLzssBufData, _outLzssBufSize);
			parseNextBlockTag(memoryStream);
		}
		break;
	case MKTAG('R','A','T','E'):
		handleRATE(dataStream, size);
		break;
	case MKTAG('R','G','B','S'):
		handleRGBS(dataStream, size);
		break;
	case MKTAG('S','N','D','E'):
		handleSNDE(dataStream, size);
		break;
	case MKTAG('T','O','I','L'):
		handleTOIL(dataStream, size);
		break;
	case MKTAG('S','R','L','E'):
		handleSRLE(dataStream, size);
		break;
	case MKTAG('B','L','O','K'):
		_dataSize -= size + 8;
		return false;
	case MKTAG('W','R','L','E'):
		// this is never triggered
	default:
		warning("Unhandled tag %s", tag2str(tag));
		break;
	}
	dataStream.seek(next);
	return true;
}
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:42,代码来源:cup_player_he.cpp

示例11: loadFromStream

bool PScr::loadFromStream(Common::SeekableReadStream &stream) {
	int32 pos = stream.pos();
	uint16 file = stream.readUint16LE();
	if (file == 0xFFFF) {
		return false;
	}
	_x = stream.readUint16LE();
	_y = stream.readUint16LE();
	_step = stream.readUint16LE();

	const Common::String pscrStreamName = Common::String::format("PS%02d", file);
	Common::SeekableReadStream *pscrStream = SearchMan.createReadStreamForMember(pscrStreamName);
	if (pscrStream != nullptr) {
		loadSurface(*pscrStream);
	}
	delete pscrStream;
	stream.seek(pos + 12); // size of PScrList struct

	return true;
}
开发者ID:86400,项目名称:scummvm,代码行数:20,代码来源:pscr.cpp

示例12: readHeader

void PLTFile::readHeader(Common::SeekableReadStream &plt) {
	AuroraBase::readHeader(plt);

	if (_id != kPLTID)
		throw Common::Exception("Not a PLT file");
	if (_version != kVersion1)
		throw Common::Exception("Unsupported PLT file version %08X", _version);

	uint32 layers = plt.readUint32LE();
	if (layers > kLayerMAX)
		throw Common::Exception("Too many layers (%d)", layers);

	plt.skip(4); // Unknown

	_width  = plt.readUint32LE();
	_height = plt.readUint32LE();

	if ((plt.size() - plt.pos()) < (int32) (2 * _width * _height))
		throw Common::Exception("Not enough data");
}
开发者ID:mcajend,项目名称:xoreos,代码行数:20,代码来源:pltfile.cpp

示例13: identifyGFF

static GFFVersion identifyGFF(Common::SeekableReadStream &input, bool allowNWNPremium) {
	uint32 id = 0xFFFFFFFF, version = 0xFFFFFFFF;

	try {
		size_t pos = input.pos();

		id      = input.readUint32BE();
		version = input.readUint32BE();

		input.seek(pos);

	} catch (...) {
		throw;
	}

	GFFVersion gffVersion;
	if        ((version == kVersion32) || (version == kVersion33)) {
		gffVersion      = kGFFVersion3;
		allowNWNPremium = false;
	} else if ((version == kVersion40) || (version == kVersion41)) {
		gffVersion      = kGFFVersion4;
		allowNWNPremium = false;
	} else if (allowNWNPremium && (FROM_BE_32(id) >= 0x30) && (FROM_BE_32(id) <= 0x12F)) {
		gffVersion      = kGFFVersion3;
	} else
		throw Common::Exception("Invalid GFF %s, %s",
		                        Common::debugTag(id).c_str(), Common::debugTag(version).c_str());

	size_t foundType = 0xFFFFFFFF;
	for (size_t i = 0; i < ARRAYSIZE(kGFFTypes); i++) {
		if (kGFFTypes[i] == id) {
			foundType = i;
			break;
		}
	}

	if ((foundType == 0xFFFFFFFF) && !allowNWNPremium)
		warning("Unknown GFF type %s", Common::debugTag(id).c_str());

	return gffVersion;
}
开发者ID:TC01,项目名称:xoreos-tools,代码行数:41,代码来源:gffdumper.cpp

示例14: decodeTRLE

static void decodeTRLE(uint8 *dst, int dstPitch, Common::Rect &dstRect, Common::SeekableReadStream &dataStream) {
	dst += dstRect.top * dstPitch + dstRect.left;
	int h = dstRect.bottom - dstRect.top + 1;
	int w = dstRect.right - dstRect.left + 1;
	while (h--) {
		int lineSize = dataStream.readUint16LE();
		int nextLineOffset = dataStream.pos() + lineSize;
		uint8 *dstNextLine = dst + dstPitch;
		if (lineSize != 0) {
			uint8 *dstEnd = dst + w;
			while (dst < dstEnd) {
				int code = dataStream.readByte();
				if (code & 1) { // skip
					code >>= 1;
					dst += code;
				} else if (code & 2) { // set
					code = (code >> 2) + 1;
					const int sz = MIN<int>(code, dstEnd - dst);
					memset(dst, dataStream.readByte(), sz);
					dst += sz;
				} else { // copy
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:21,代码来源:cup_player_he.cpp

示例15: parseInstruction

bool parseInstruction(Common::SeekableReadStream &ncs, Instruction &instr) {
	instr.address = ncs.pos();

	try {
		instr.opcode = (Opcode)          ncs.readByte();
		instr.type   = (InstructionType) ncs.readByte();
	} catch (...) {
		if (ncs.eos())
			return false;

		throw;
	}

	if (((size_t)instr.opcode >= ARRAYSIZE(kParseFunc)) || !kParseFunc[(size_t)instr.opcode])
		throw Common::Exception("Invalid opcode 0x%02X", (uint8)instr.opcode);

	const ParseFunc func = kParseFunc[(size_t)instr.opcode];
	(*func)(instr, ncs);

	return true;
}
开发者ID:asr1,项目名称:xoreos-tools,代码行数:21,代码来源:instruction.cpp


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