本文整理汇总了C++中PropStream::GET_UINT16方法的典型用法代码示例。如果您正苦于以下问题:C++ PropStream::GET_UINT16方法的具体用法?C++ PropStream::GET_UINT16怎么用?C++ PropStream::GET_UINT16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropStream
的用法示例。
在下文中一共展示了PropStream::GET_UINT16方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readAttr
Attr_ReadValue Teleport::readAttr(AttrTypes_t attr, PropStream& propStream)
{
if(ATTR_TELE_DEST == attr){
TeleportDest tele_dest;
if( !propStream.GET_UINT16(tele_dest._x) ||
!propStream.GET_UINT16(tele_dest._y) ||
!propStream.GET_UINT8(tele_dest._z))
{
return ATTR_READ_ERROR;
}
setDestPos(Position(tele_dest._x, tele_dest._y, tele_dest._z));
return ATTR_READ_CONTINUE;
}
else
return Item::readAttr(attr, propStream);
}
示例2: loadMap
bool IOMapOTBM::loadMap(Map* map, const std::string& identifier)
{
int64_t start = OTSYS_TIME();
FileLoader f;
if(!f.openFile(identifier.c_str(), "OTBM", false, true)){
std::stringstream ss;
ss << "Could not open the file " << identifier << ".";
setLastErrorString(ss.str());
return false;
}
unsigned long type;
PropStream propStream;
NODE root = f.getChildNode((NODE)NULL, type);
if(!f.getProps(root, propStream)){
setLastErrorString("Could not read root property.");
return false;
}
OTBM_root_header root_header;
if( !propStream.GET_UINT32(root_header.version) ||
!propStream.GET_UINT16(root_header.width) ||
!propStream.GET_UINT16(root_header.height) ||
!propStream.GET_UINT32(root_header.majorVersionItems) ||
!propStream.GET_UINT32(root_header.minorVersionItems))
{
setLastErrorString("Could not read header.");
return false;
}
int header_version = root_header.version;
if(header_version <= 0){
//In otbm version 1 the count variable after splashes/fluidcontainers and stackables
//are saved as attributes instead, this solves alot of problems with items
//that is changed (stackable/charges/fluidcontainer/splash) during an update.
setLastErrorString("This map needs to be upgraded by using the latest map editor version to be able to load correctly.");
return false;
}
if(header_version > 2){
setLastErrorString("Unknown OTBM version detected, please update your server.");
return false;
}
if(root_header.majorVersionItems < 3){
setLastErrorString("This map needs to be upgraded by using the latest map editor version to be able to load correctly.");
return false;
}
if(root_header.majorVersionItems > (unsigned long)Items::dwMajorVersion){
setLastErrorString("The map was saved with a different items.otb version, an upgraded items.otb is required.");
return false;
}
// Prevent load maps saved with items.otb previous to
// version 800, because of the change to stackable of
// itemid 3965
if(root_header.minorVersionItems < CLIENT_VERSION_810){
setLastErrorString("This map needs to be updated.");
return false;
}
if(root_header.minorVersionItems > (unsigned long)Items::dwMinorVersion){
std::cout << "Warning: [OTBM loader] This map needs an updated items.otb." <<std::endl;
}
if(root_header.minorVersionItems == CLIENT_VERSION_854_BAD){
std::cout << "Warning: [OTBM loader] This map needs uses an incorrect version of items.otb." <<std::endl;
}
std::cout << "Map size: " << root_header.width << "x" << root_header.height << std::endl;
map->mapWidth = root_header.width;
map->mapHeight = root_header.height;
NODE nodeMap = f.getChildNode(root, type);
if(type != OTBM_MAP_DATA){
setLastErrorString("Could not read data node.");
return false;
}
if(!f.getProps(nodeMap, propStream)){
setLastErrorString("Could not read map data attributes.");
return false;
}
unsigned char attribute;
std::string mapDescription;
std::string tmp;
while(propStream.GET_UINT8(attribute)){
switch(attribute){
case OTBM_ATTR_DESCRIPTION:
if(!propStream.GET_STRING(mapDescription)){
setLastErrorString("Invalid description tag.");
return false;
}
std::cout << "Map description: " << mapDescription << std::endl;
//.........这里部分代码省略.........
示例3: readAttr
Attr_ReadValue Item::readAttr(const AttrTypes_t& attr, PropStream& propStream)
{
switch (attr)
{
case ATTR_COUNT:
{
uint8_t _count = 0;
if (!propStream.GET_UINT8(_count))
{
return ATTR_READ_ERROR;
}
setSubType(_count);
break;
}
case ATTR_ACTION_ID:
{
uint16_t _actionid = 0;
if (!propStream.GET_UINT16(_actionid))
{
return ATTR_READ_ERROR;
}
setActionId(_actionid);
break;
}
case ATTR_UNIQUE_ID:
{
uint16_t _uniqueid;
if (!propStream.GET_UINT16(_uniqueid))
{
return ATTR_READ_ERROR;
}
setUniqueId(_uniqueid);
break;
}
case ATTR_TEXT:
{
std::string _text;
if (!propStream.GET_STRING(_text))
{
return ATTR_READ_ERROR;
}
setText(_text);
break;
}
case ATTR_WRITTENDATE:
{
uint32_t _writtenDate;
if (!propStream.GET_UINT32(_writtenDate))
{
return ATTR_READ_ERROR;
}
setWrittenDate(_writtenDate);
break;
}
case ATTR_WRITTENBY:
{
std::string _writer;
if (!propStream.GET_STRING(_writer))
{
return ATTR_READ_ERROR;
}
setWriter(_writer);
break;
}
case ATTR_DESC:
{
std::string _text;
if (!propStream.GET_STRING(_text))
{
return ATTR_READ_ERROR;
}
setSpecialDescription(_text);
break;
}
case ATTR_RUNE_CHARGES:
{
uint8_t _charges = 1;
if (!propStream.GET_UINT8(_charges))
{
return ATTR_READ_ERROR;
}
setSubType(_charges);
break;
}
//.........这里部分代码省略.........