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


Python Buffer.readUnsignedInt方法代码示例

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


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

示例1: Monsters

# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import readUnsignedInt [as 别名]
class Monsters(object):
	def __init__(self, path):
		self.b = Buffer()

		with open(path, 'r') as f:
			self.b.addInfos(f.read())

		c = self.b.readUTF(3)
		if(cmp(c, "D2O") != 0):
			print("D2O error: {}".format(c))
			raise Exception()

		self._indexes = dict()

		self.b.setCursor(self.b.readUnsignedInt());

		nbValues = self.b.readInt() / 8;
		for i in range(0, nbValues):
			key = self.b.readInt();
			val = self.b.readInt();

			self._indexes[key] = val;

		'''
		int nbClasses = MonsterDecode::_stream->readInt();
		printf("nbclass = %d\n", nbClasses);
		for(int i = 0; i < nbClasses; i++){
			int id = MonsterDecode::_stream->readInt();
			std::string lastName = MonsterDecode::_stream->readUTF();
			std::string firstName = MonsterDecode::_stream->readUTF();
			cout << "(" << id << ") " << firstName << "." << lastName << endl;
			int nbFields = MonsterDecode::_stream->readInt();
			for(int j = 0; j < nbFields; j++){
				std::string fieldName = MonsterDecode::_stream->readUTF();
				int fieldType = MonsterDecode::_stream->readInt();
				cout << "\t" << fieldName << ", type : " << fieldType << endl;

			}
		}

		return 0'''

	def getObj(self, arg1):
		mstr = Monster()

		pos = self._indexes[arg1];

		self.b.setCursor(pos);

		if(self.b.readInt() != 3):
			print("!= 2 ?");
			return None;

		mstr._id = self.b.readInt()
		mstr._nameId = self.b.readInt() # readI18n
		mstr._gfxId = self.b.readInt()
		mstr._race = self.b.readInt()
		mstr._grade = 0 # self.b.readInt()

		return mstr;

	def hasObj(arg1):
		return self._indexes[arg1]
开发者ID:alucas,项目名称:dsniff,代码行数:65,代码来源:monster.py


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