本文整理汇总了C++中PropStream::getString方法的典型用法代码示例。如果您正苦于以下问题:C++ PropStream::getString方法的具体用法?C++ PropStream::getString怎么用?C++ PropStream::getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropStream
的用法示例。
在下文中一共展示了PropStream::getString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unserializeMap
bool ItemAttributes::unserializeMap(PropStream& stream)
{
uint16_t n;
if(!stream.getShort(n))
return true;
createAttributes();
while(n--)
{
std::string key;
if(!stream.getString(key))
return false;
ItemAttribute attr;
if(!attr.unserialize(stream))
return false;
(*attributes)[key] = attr;
}
return true;
}
示例2: 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;
//.........这里部分代码省略.........
示例3: readAttr
Attr_ReadValue Item::readAttr(AttrTypes_t attr, PropStream& propStream)
{
switch(attr)
{
case ATTR_COUNT:
{
uint8_t _count;
if(!propStream.getByte(_count))
return ATTR_READ_ERROR;
setSubType((uint16_t)_count);
break;
}
case ATTR_ACTION_ID:
{
uint16_t aid;
if(!propStream.getShort(aid))
return ATTR_READ_ERROR;
setAttribute("aid", aid);
break;
}
case ATTR_UNIQUE_ID:
{
uint16_t uid;
if(!propStream.getShort(uid))
return ATTR_READ_ERROR;
setUniqueId(uid);
break;
}
case ATTR_NAME:
{
std::string name;
if(!propStream.getString(name))
return ATTR_READ_ERROR;
setAttribute("name", name);
break;
}
case ATTR_PLURALNAME:
{
std::string name;
if(!propStream.getString(name))
return ATTR_READ_ERROR;
setAttribute("pluralname", name);
break;
}
case ATTR_ARTICLE:
{
std::string article;
if(!propStream.getString(article))
return ATTR_READ_ERROR;
setAttribute("article", article);
break;
}
case ATTR_ATTACK:
{
int32_t attack;
if(!propStream.getLong((uint32_t&)attack))
return ATTR_READ_ERROR;
setAttribute("attack", attack);
break;
}
case ATTR_EXTRAATTACK:
{
int32_t attack;
if(!propStream.getLong((uint32_t&)attack))
return ATTR_READ_ERROR;
setAttribute("extraattack", attack);
break;
}
case ATTR_DEFENSE:
{
int32_t defense;
if(!propStream.getLong((uint32_t&)defense))
return ATTR_READ_ERROR;
setAttribute("defense", defense);
break;
}
case ATTR_EXTRADEFENSE:
{
int32_t defense;
if(!propStream.getLong((uint32_t&)defense))
return ATTR_READ_ERROR;
//.........这里部分代码省略.........