本文整理汇总了C++中PropStream::getStruct方法的典型用法代码示例。如果您正苦于以下问题:C++ PropStream::getStruct方法的具体用法?C++ PropStream::getStruct怎么用?C++ PropStream::getStruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropStream
的用法示例。
在下文中一共展示了PropStream::getStruct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMap
bool IOMap::loadMap(Map* map, const std::string& identifier)
{
FileLoader f;
if(!f.openFile(identifier.c_str(), false, true))
{
std::stringstream ss;
ss << "Could not open the file " << identifier << ".";
setLastErrorString(ss.str());
return false;
}
uint32_t type = 0;
NODE root = f.getChildNode((NODE)NULL, type);
PropStream propStream;
if(!f.getProps(root, propStream))
{
setLastErrorString("Could not read root property.");
return false;
}
OTBM_root_header* rootHeader;
if(!propStream.getStruct(rootHeader))
{
setLastErrorString("Could not read header.");
return false;
}
uint32_t headerVersion = rootHeader->version;
if(headerVersion <= 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(headerVersion > 3)
{
setLastErrorString("Unknown OTBM version detected.");
return false;
}
uint32_t headerMajorItems = rootHeader->majorVersionItems;
if(headerMajorItems < 3)
{
setLastErrorString("This map needs to be upgraded by using the latest map editor version to be able to load correctly.");
return false;
}
if(headerMajorItems > (uint32_t)Items::dwMajorVersion)
{
setLastErrorString("The map was saved with a different items.otb version, an upgraded items.otb is required.");
return false;
}
uint32_t headerMinorItems = rootHeader->minorVersionItems;
if(headerMinorItems < CLIENT_VERSION_810)
{
setLastErrorString("This map needs an updated items.otb.");
return false;
}
if(headerMinorItems > (uint32_t)Items::dwMinorVersion)
setLastErrorString("This map needs an updated items.otb.");
std::clog << "> Map size: " << rootHeader->width << "x" << rootHeader->height << "." << std::endl;
map->mapWidth = rootHeader->width;
map->mapHeight = rootHeader->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;
}
std::string tmp;
uint8_t attribute;
while(propStream.getByte(attribute))
{
switch(attribute)
{
case OTBM_ATTR_DESCRIPTION:
{
if(!propStream.getString(tmp))
{
setLastErrorString("Invalid description tag.");
return false;
}
map->descriptions.push_back(tmp);
break;
//.........这里部分代码省略.........
示例2: readAttr
//.........这里部分代码省略.........
return ATTR_READ_ERROR;
setAttribute("duration", duration);
break;
}
case ATTR_DECAYING_STATE:
{
uint8_t state;
if(!propStream.getByte(state))
return ATTR_READ_ERROR;
if((ItemDecayState_t)state != DECAYING_FALSE)
setAttribute("decaying", (int32_t)DECAYING_PENDING);
break;
}
//these should be handled through derived classes
//if these are called then something has changed in the items.otb since the map was saved
//just read the values
//Depot class
case ATTR_DEPOT_ID:
{
uint16_t depot;
if(!propStream.getShort(depot))
return ATTR_READ_ERROR;
break;
}
//Door class
case ATTR_HOUSEDOORID:
{
uint8_t door;
if(!propStream.getByte(door))
return ATTR_READ_ERROR;
break;
}
//Teleport class
case ATTR_TELE_DEST:
{
TeleportDest* dest;
if(!propStream.getStruct(dest))
return ATTR_READ_ERROR;
break;
}
//Bed class
case ATTR_SLEEPERGUID:
{
uint32_t sleeper;
if(!propStream.getLong(sleeper))
return ATTR_READ_ERROR;
break;
}
case ATTR_SLEEPSTART:
{
uint32_t sleepStart;
if(!propStream.getLong(sleepStart))
return ATTR_READ_ERROR;
break;
}
//Container class
case ATTR_CONTAINER_ITEMS:
{
uint32_t _count;
propStream.getLong(_count);
return ATTR_READ_ERROR;
}
//ItemAttributes class
case ATTR_ATTRIBUTE_MAP:
{
bool unique = hasIntegerAttribute("uid"), ret = unserializeMap(propStream);
if(!unique && hasIntegerAttribute("uid")) // unfortunately we have to do this
ScriptEnviroment::addUniqueThing(this);
// this attribute has a custom behavior as well
if(getDecaying() != DECAYING_FALSE)
setDecaying(DECAYING_PENDING);
if(ret)
break;
}
default:
return ATTR_READ_ERROR;
}
return ATTR_READ_CONTINUE;
}