本文整理汇总了C++中PropStream类的典型用法代码示例。如果您正苦于以下问题:C++ PropStream类的具体用法?C++ PropStream怎么用?C++ PropStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PropStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unserializeProp
bool ConditionAttributes::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
switch(attr)
{
case CONDITIONATTR_SKILLS:
{
int32_t value = 0;
if(!propStream.GET_VALUE(value))
return false;
skills[currentSkill++] = value;
return true;
}
case CONDITIONATTR_STATS:
{
int32_t value = 0;
if(!propStream.GET_VALUE(value))
return false;
stats[currentStat++] = value;
return true;
}
default:
break;
}
return ConditionGeneric::unserializeProp(attr, propStream);
}
示例2: unserializeProp
bool Condition::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
switch (attr) {
case CONDITIONATTR_TYPE: {
int32_t value;
if (!propStream.GET_VALUE(value)) {
return false;
}
conditionType = (ConditionType_t)value;
return true;
}
case CONDITIONATTR_ID: {
int32_t value;
if (!propStream.GET_VALUE(value)) {
return false;
}
id = (ConditionId_t)value;
return true;
}
case CONDITIONATTR_TICKS: {
int32_t value;
if (!propStream.GET_VALUE(value)) {
return false;
}
ticks = value;
return true;
}
case CONDITIONATTR_ISBUFF: {
int8_t value;
if (!propStream.GET_VALUE(value)) {
return false;
}
isBuff = value != 0;
return true;
}
case CONDITIONATTR_SUBID: {
int32_t value;
if (!propStream.GET_VALUE(value)) {
return false;
}
subId = value;
return true;
}
case CONDITIONATTR_END:
return true;
default:
return false;
}
}
示例3: parseWaypoints
bool IOMap::parseWaypoints(OTB::Loader& loader, const OTB::Node& waypointsNode, Map& map)
{
PropStream propStream;
for (auto& node : waypointsNode.children) {
if (node.type != OTBM_WAYPOINT) {
setLastErrorString("Unknown waypoint node.");
return false;
}
if (!loader.getProps(node, propStream)) {
setLastErrorString("Could not read waypoint data.");
return false;
}
std::string name;
if (!propStream.readString(name)) {
setLastErrorString("Could not read waypoint name.");
return false;
}
OTBM_Destination_coords waypoint_coords;
if (!propStream.read(waypoint_coords)) {
setLastErrorString("Could not read waypoint coordinates.");
return false;
}
map.waypoints[name] = Position(waypoint_coords.x, waypoint_coords.y, waypoint_coords.z);
}
return true;
}
示例4: loadItems
void IOLoginData::loadItems(ItemMap& itemMap, DBResult* result)
{
do {
int32_t sid = result->getDataInt("sid");
int32_t pid = result->getDataInt("pid");
int32_t type = result->getDataInt("itemtype");
int32_t count = result->getDataInt("count");
unsigned long attrSize = 0;
const char* attr = result->getDataStream("attributes", attrSize);
PropStream propStream;
propStream.init(attr, attrSize);
Item* item = Item::CreateItem(type, count);
if (item) {
if (!item->unserializeAttr(propStream)) {
std::cout << "WARNING: Serialize error in IOLoginData::loadItems" << std::endl;
}
std::pair<Item*, int32_t> pair(item, pid);
itemMap[sid] = pair;
}
} while (result->next());
}
示例5: unserializeProp
bool ConditionSpeed::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
switch(attr)
{
case CONDITIONATTR_SPEEDDELTA:
{
int32_t value = 0;
if(!propStream.GET_VALUE(value))
return false;
speedDelta = value;
return true;
}
case CONDITIONATTR_FORMULA_MINA:
{
float value = 0;
if(!propStream.GET_VALUE(value))
return false;
mina = value;
return true;
}
case CONDITIONATTR_FORMULA_MINB:
{
float value = 0;
if(!propStream.GET_VALUE(value))
return false;
minb = value;
return true;
}
case CONDITIONATTR_FORMULA_MAXA:
{
float value = 0;
if(!propStream.GET_VALUE(value))
return false;
maxa = value;
return true;
}
case CONDITIONATTR_FORMULA_MAXB:
{
float value = 0;
if(!propStream.GET_VALUE(value))
return false;
maxb = value;
return true;
}
default:
break;
}
return ConditionOutfit::unserializeProp(attr, propStream);
}
示例6: unserializeProp
bool ConditionAttributes::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
if (attr == CONDITIONATTR_SKILLS) {
int32_t value = 0;
if (!propStream.GET_VALUE(value)) {
return false;
}
skills[currentSkill] = value;
++currentSkill;
return true;
} else if (attr == CONDITIONATTR_STATS) {
int32_t value = 0;
if (!propStream.GET_VALUE(value)) {
return false;
}
stats[currentStat] = value;
++currentStat;
return true;
}
return Condition::unserializeProp(attr, propStream);
}
示例7: unserializeProp
bool ConditionSoul::unserializeProp(const ConditionAttr_t& attr, PropStream& propStream)
{
if (attr == CONDITIONATTR_SOULGAIN)
{
uint32_t value = 0;
if (!propStream.GET_UINT32(value))
{
return false;
}
soulGain = value;
return true;
}
else if (attr == CONDITIONATTR_SOULTICKS)
{
uint32_t value = 0;
if (!propStream.GET_UINT32(value))
{
return false;
}
soulTicks = value;
return true;
}
return Condition::unserializeProp(attr, propStream);
}
示例8: getProps
bool FileLoader::getProps(const NODE node, PropStream& props)
{
size_t size;
if (const uint8_t* a = getProps(node, size)) {
props.init((char*)a, size);
return true;
}
props.init(nullptr, 0);
return false;
}
示例9: readAttr
Attr_ReadValue Teleport::readAttr(AttrTypes_t attr, PropStream& propStream)
{
if (ATTR_TELE_DEST == attr) {
if (!propStream.GET_USHORT(destPos.x) || !propStream.GET_USHORT(destPos.y) || !propStream.GET_UCHAR(destPos.z)) {
return ATTR_READ_ERROR;
}
return ATTR_READ_CONTINUE;
} else {
return Item::readAttr(attr, propStream);
}
}
示例10: getProps
bool FileLoader::getProps(const NODE node, PropStream& props)
{
size_t size;
if (const uint8_t* a = getProps(node, size)) {
props.init(reinterpret_cast<const char*>(a), size); // does not break strict aliasing
return true;
}
props.init(nullptr, 0);
return false;
}
示例11: OTSYS_TIME
bool IOMapSerialize::loadMap(Map* map)
{
int64_t start = OTSYS_TIME();
Database* db = Database::getInstance();
std::ostringstream query;
DBResult* result = db->storeQuery("SELECT `id` FROM `houses`");
if (!result) {
return true;
}
do {
query.str("");
query << "SELECT `data` FROM `tile_store` WHERE `house_id` = " << result->getDataInt("id");
DBResult* tileResult = db->storeQuery(query.str());
if (!tileResult) {
continue;
}
do {
unsigned long attrSize = 0;
const char* attr = tileResult->getDataStream("data", attrSize);
PropStream propStream;
propStream.init(attr, attrSize);
uint16_t x = 0, y = 0;
uint8_t z = 0;
propStream.GET_USHORT(x);
propStream.GET_USHORT(y);
propStream.GET_UCHAR(z);
if (x == 0 || y == 0) {
continue;
}
Tile* tile = map->getTile(x, y, z);
if (!tile) {
continue;
}
uint32_t item_count = 0;
propStream.GET_ULONG(item_count);
while (item_count--) {
loadItem(propStream, tile);
}
} while (tileResult->next());
db->freeResult(tileResult);
} while (result->next());
db->freeResult(result);
std::cout << "> Loaded house items in: " << (OTSYS_TIME() - start) / (1000.) << " s" << std::endl;
return true;
}
示例12: unserializeProp
bool ConditionDamage::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
switch(attr)
{
case CONDITIONATTR_DELAYED:
{
bool value = false;
if(!propStream.getType(value))
return false;
delayed = value;
return true;
}
case CONDITIONATTR_PERIODDAMAGE:
{
int32_t value = 0;
if(!propStream.getType(value))
return false;
periodDamage = value;
return true;
}
case CONDITIONATTR_OWNER:
{
uint32_t value = 0;
if(!propStream.getType(value))
return false;
owner = value;
return true;
}
case CONDITIONATTR_INTERVALDATA:
{
IntervalInfo damageInfo;
if(!propStream.getType(damageInfo))
return false;
damageList.push_back(damageInfo);
if(getTicks() != -1)
setTicks(getTicks() + damageInfo.interval);
return true;
}
default:
break;
}
return Condition::unserializeProp(attr, propStream);
}
示例13: getProps
bool FileLoader::getProps(const NODE node, PropStream &props)
{
unsigned long size;
const unsigned char* a = getProps(node, size);
if(!a){
props.init(NULL, 0);
return false;
}
else{
props.init((char*)a, size);
return true;
}
}
示例14: parseMapDataAttributes
bool IOMap::parseMapDataAttributes(OTB::Loader& loader, const OTB::Node& mapNode, Map& map, const std::string& fileName)
{
PropStream propStream;
if (!loader.getProps(mapNode, propStream)) {
setLastErrorString("Could not read map data attributes.");
return false;
}
std::string mapDescription;
std::string tmp;
uint8_t attribute;
while (propStream.read<uint8_t>(attribute)) {
switch (attribute) {
case OTBM_ATTR_DESCRIPTION:
if (!propStream.readString(mapDescription)) {
setLastErrorString("Invalid description tag.");
return false;
}
break;
case OTBM_ATTR_EXT_SPAWN_FILE:
if (!propStream.readString(tmp)) {
setLastErrorString("Invalid spawn tag.");
return false;
}
map.spawnfile = fileName.substr(0, fileName.rfind('/') + 1);
map.spawnfile += tmp;
break;
case OTBM_ATTR_EXT_HOUSE_FILE:
if (!propStream.readString(tmp)) {
setLastErrorString("Invalid house tag.");
return false;
}
map.housefile = fileName.substr(0, fileName.rfind('/') + 1);
map.housefile += tmp;
break;
default:
setLastErrorString("Unknown header node.");
return false;
}
}
return true;
}
示例15: unserializeProp
bool ConditionDamage::unserializeProp(ConditionAttr_t attr, PropStream& propStream)
{
if (attr == CONDITIONATTR_DELAYED) {
uint8_t value;
if (!propStream.read<uint8_t>(value)) {
return false;
}
delayed = (value != 0);
return true;
} else if (attr == CONDITIONATTR_PERIODDAMAGE) {
return propStream.read<int32_t>(periodDamage);
} else if (attr == CONDITIONATTR_OWNER) {
return propStream.skip(4);
} else if (attr == CONDITIONATTR_INTERVALDATA) {
IntervalInfo damageInfo;
if (!propStream.read<IntervalInfo>(damageInfo)) {
return false;
}
damageList.push_back(damageInfo);
if (ticks != -1) {
setTicks(ticks + damageInfo.interval);
}
return true;
}
return Condition::unserializeProp(attr, propStream);
}