本文整理汇总了C++中PropStream::getLong方法的典型用法代码示例。如果您正苦于以下问题:C++ PropStream::getLong方法的具体用法?C++ PropStream::getLong怎么用?C++ PropStream::getLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropStream
的用法示例。
在下文中一共展示了PropStream::getLong方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readAttr
Attr_ReadValue BedItem::readAttr(AttrTypes_t attr, PropStream& propStream)
{
switch(attr)
{
case ATTR_SLEEPERGUID:
{
uint32_t _sleeper;
if(!propStream.getLong(_sleeper))
return ATTR_READ_ERROR;
if(_sleeper)
{
std::string name;
if(IOLoginData::getInstance()->getNameByGuid(_sleeper, name))
{
setSpecialDescription(name + " is sleeping there.");
Beds::getInstance()->setBedSleeper(this, _sleeper);
}
}
sleeper = _sleeper;
return ATTR_READ_CONTINUE;
}
case ATTR_SLEEPSTART:
{
uint32_t sleepStart;
if(!propStream.getLong(sleepStart))
return ATTR_READ_ERROR;
setAttribute("sleepstart", (int32_t)sleepStart);
return ATTR_READ_CONTINUE;
}
default:
break;
}
return Item::readAttr(attr, propStream);
}
示例2: 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;
}
示例3: readAttr
Attr_ReadValue Container::readAttr(AttrTypes_t attr, PropStream& propStream)
{
switch(attr)
{
case ATTR_CONTAINER_ITEMS:
{
uint32_t count;
if(!propStream.getLong(count))
return ATTR_READ_ERROR;
serializationCount = count;
return ATTR_READ_END;
}
default:
break;
}
return Item::readAttr(attr, propStream);
}
示例4: 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;
}
示例5: loadMap
//.........这里部分代码省略.........
NODE nodeTile = f.getChildNode(nodeMapData, type);
while(nodeTile != NO_NODE)
{
if(f.getError() != ERROR_NONE)
{
setLastErrorString("Could not read node data.");
return false;
}
if(type == OTBM_TILE || type == OTBM_HOUSETILE)
{
if(!f.getProps(nodeTile, propStream))
{
setLastErrorString("Could not read node data.");
return false;
}
OTBM_Tile_coords* tileCoord;
if(!propStream.getStruct(tileCoord))
{
setLastErrorString("Could not read tile position.");
return false;
}
Tile* tile = NULL;
Item* ground = NULL;
uint32_t tileflags = 0;
uint16_t px = base_x + tileCoord->_x, py = base_y + tileCoord->_y, pz = base_z;
House* house = NULL;
if(type == OTBM_HOUSETILE)
{
uint32_t _houseid;
if(!propStream.getLong(_houseid))
{
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] Could not read house id.";
setLastErrorString(ss.str());
return false;
}
house = Houses::getInstance()->getHouse(_houseid, true);
if(!house)
{
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] Could not create house id: " << _houseid;
setLastErrorString(ss.str());
return false;
}
tile = new HouseTile(px, py, pz, house);
house->addTile(static_cast<HouseTile*>(tile));
}
//read tile attributes
uint8_t attribute;
while(propStream.getByte(attribute))
{
switch(attribute)
{
case OTBM_ATTR_TILE_FLAGS:
{
uint32_t flags;
if(!propStream.getLong(flags))
示例6: 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;
//.........这里部分代码省略.........