本文整理汇总了C++中PropStream::getByte方法的典型用法代码示例。如果您正苦于以下问题:C++ PropStream::getByte方法的具体用法?C++ PropStream::getByte怎么用?C++ PropStream::getByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropStream
的用法示例。
在下文中一共展示了PropStream::getByte方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unserialize
bool ItemAttribute::unserialize(PropStream& stream)
{
uint8_t type = 0;
stream.getByte(type);
switch(type)
{
case STRING:
{
std::string v;
if(!stream.getLongString(v))
return false;
set(v);
break;
}
case INTEGER:
{
uint32_t v;
if(!stream.getLong(v))
return false;
set(*reinterpret_cast<int32_t*>(&v));
break;
}
case FLOAT:
{
float v;
if(!stream.getFloat(v))
return false;
set(*reinterpret_cast<float*>(&v));
break;
}
case BOOLEAN:
{
uint8_t v;
if(!stream.getByte(v))
return false;
set(v != 0);
}
default:
break;
}
return true;
}
示例2: unserialize
bool Condition::unserialize(PropStream& propStream)
{
uint8_t attrType;
while(propStream.getByte(attrType) && attrType != CONDITIONATTR_END)
{
if(!unserializeProp((ConditionAttr_t)attrType, propStream))
return false;
}
return true;
}
示例3: readAttr
Attr_ReadValue Door::readAttr(AttrTypes_t attr, PropStream& propStream)
{
if(attr != ATTR_HOUSEDOORID)
return Item::readAttr(attr, propStream);
uint8_t _doorId = 0;
if(!propStream.getByte(_doorId))
return ATTR_READ_ERROR;
doorId = _doorId;
return ATTR_READ_CONTINUE;
}
示例4: unserializeAttr
bool Item::unserializeAttr(PropStream& propStream)
{
uint8_t attrType = ATTR_END;
while(propStream.getByte(attrType) && attrType != ATTR_END)
{
switch(readAttr((AttrTypes_t)attrType, propStream))
{
case ATTR_READ_ERROR:
return false;
case ATTR_READ_END:
return true;
default:
break;
}
}
return true;
}
示例5: loadContainer
bool IOMapSerialize::loadContainer(PropStream& propStream, Container* container)
{
while(container->serializationCount > 0)
{
if(!loadItem(propStream, container, false))
{
std::clog << "[Warning - IOMapSerialize::loadContainer] Unserialization error [0] for item in container " << container->getID() << std::endl;
return false;
}
container->serializationCount--;
}
uint8_t endAttr = ATTR_END;
propStream.getByte(endAttr);
if(endAttr == ATTR_END)
return true;
std::clog << "[Warning - IOMapSerialize::loadContainer] Unserialization error [1] for item in container " << container->getID() << std::endl;
return false;
}
示例6: loadMapBinaryTileBased
bool IOMapSerialize::loadMapBinaryTileBased(Map* map)
{
Database* db = Database::getInstance();
DBResult* result;
DBQuery query;
query << "SELECT `house_id`, `data` FROM `tile_store` WHERE `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID);
if(!(result = db->storeQuery(query.str())))
return false;
House* house = NULL;
do
{
int32_t houseId = result->getDataInt("house_id");
house = Houses::getInstance()->getHouse(houseId);
uint64_t attrSize = 0;
const char* attr = result->getDataStream("data", attrSize);
PropStream propStream;
propStream.init(attr, attrSize);
while(propStream.size())
{
uint16_t x = 0, y = 0;
uint8_t z = 0;
propStream.getShort(x);
propStream.getShort(y);
propStream.getByte(z);
uint32_t itemCount = 0;
propStream.getLong(itemCount);
Position pos(x, y, (int16_t)z);
if(house && house->hasPendingTransfer())
{
if(Player* player = g_game.getPlayerByGuidEx(house->getOwner()))
{
while(itemCount--)
loadItem(propStream, player->getInbox(), true);
if(player->isVirtual())
{
IOLoginData::getInstance()->savePlayer(player);
delete player;
}
}
}
else if(Tile* tile = map->getTile(pos))
{
while(itemCount--)
loadItem(propStream, tile, false);
}
else
{
std::clog << "[Error - IOMapSerialize::loadMapBinary] Unserialization of invalid tile"
<< " at position " << pos << std::endl;
break;
}
}
}
while(result->next());
result->free();
return true;
}
示例7: 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;
//.........这里部分代码省略.........
示例8: 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;
//.........这里部分代码省略.........