本文整理汇总了C++中PropStream::GET_STRING方法的典型用法代码示例。如果您正苦于以下问题:C++ PropStream::GET_STRING方法的具体用法?C++ PropStream::GET_STRING怎么用?C++ PropStream::GET_STRING使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropStream
的用法示例。
在下文中一共展示了PropStream::GET_STRING方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unserializeAttributeMap
bool ItemAttributes::unserializeAttributeMap(PropStream& stream)
{
uint16_t n;
if(stream.GET_USHORT(n)){
createAttributes();
std::string key;
ItemAttribute attrib;
while(n--){
if(!stream.GET_STRING(key))
return false;
if(!attrib.unserialize(stream))
return false;
(*attributes)[key] = attrib;
}
}
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.GET_STRUCT(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 > 2)
{
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::cout << "> 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.GET_UCHAR(attribute))
{
switch(attribute)
{
case OTBM_ATTR_DESCRIPTION:
{
if(!propStream.GET_STRING(tmp))
{
setLastErrorString("Invalid description tag.");
return false;
}
map->descriptions.push_back(tmp);
break;
//.........这里部分代码省略.........
示例3: loadMap
bool IOMap::loadMap(Map* map, const std::string& identifier)
{
int64_t start = OTSYS_TIME();
FileLoader f;
if (!f.openFile(identifier.c_str(), "OTBM", false, true)) {
std::ostringstream ss;
ss << "Could not open the file " << identifier << '.';
setLastErrorString(ss.str());
return false;
}
uint32_t type;
PropStream propStream;
NODE root = f.getChildNode((NODE)nullptr, type);
if (!f.getProps(root, propStream)) {
setLastErrorString("Could not read root property.");
return false;
}
OTBM_root_header* root_header;
if (!propStream.GET_STRUCT(root_header)) {
setLastErrorString("Could not read header.");
return false;
}
uint32_t headerVersion = root_header->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 need to be upgraded by using the latest map editor version to be able to load correctly.");
return false;
}
if (headerVersion > 2) {
setLastErrorString("Unknown OTBM version detected.");
return false;
}
if (root_header->majorVersionItems < 3) {
setLastErrorString("This map need to be upgraded by using the latest map editor version to be able to load correctly.");
return false;
}
if (root_header->majorVersionItems > (uint32_t)Items::dwMajorVersion) {
setLastErrorString("The map was saved with a different items.otb version, an upgraded items.otb is required.");
return false;
}
if (root_header->minorVersionItems < CLIENT_VERSION_810) {
setLastErrorString("This map needs to be updated.");
return false;
}
if (root_header->minorVersionItems > (uint32_t)Items::dwMinorVersion) {
std::cout << "[Warning - IOMap::loadMap] This map needs an updated items.otb." << std::endl;
}
std::cout << "> Map size: " << root_header->width << "x" << root_header->height << '.' << std::endl;
map->mapWidth = root_header->width;
map->mapHeight = root_header->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;
}
unsigned char attribute;
std::string mapDescription;
std::string tmp;
while (propStream.GET_UCHAR(attribute)) {
switch (attribute) {
case OTBM_ATTR_DESCRIPTION:
if (!propStream.GET_STRING(mapDescription)) {
setLastErrorString("Invalid description tag.");
return false;
}
break;
case OTBM_ATTR_EXT_SPAWN_FILE:
if (!propStream.GET_STRING(tmp)) {
setLastErrorString("Invalid spawn tag.");
return false;
//.........这里部分代码省略.........
示例4: loadMap
bool IOMapOTBM::loadMap(Map* map, const std::string& identifier)
{
int64_t start = OTSYS_TIME();
FileLoader f;
if(!f.openFile(identifier.c_str(), "OTBM", false, true)){
std::stringstream ss;
ss << "Could not open the file " << identifier << ".";
setLastErrorString(ss.str());
return false;
}
unsigned long type;
PropStream propStream;
NODE root = f.getChildNode((NODE)NULL, type);
if(!f.getProps(root, propStream)){
setLastErrorString("Could not read root property.");
return false;
}
OTBM_root_header root_header;
if( !propStream.GET_UINT32(root_header.version) ||
!propStream.GET_UINT16(root_header.width) ||
!propStream.GET_UINT16(root_header.height) ||
!propStream.GET_UINT32(root_header.majorVersionItems) ||
!propStream.GET_UINT32(root_header.minorVersionItems))
{
setLastErrorString("Could not read header.");
return false;
}
int header_version = root_header.version;
if(header_version <= 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(header_version > 2){
setLastErrorString("Unknown OTBM version detected, please update your server.");
return false;
}
if(root_header.majorVersionItems < 3){
setLastErrorString("This map needs to be upgraded by using the latest map editor version to be able to load correctly.");
return false;
}
if(root_header.majorVersionItems > (unsigned long)Items::dwMajorVersion){
setLastErrorString("The map was saved with a different items.otb version, an upgraded items.otb is required.");
return false;
}
// Prevent load maps saved with items.otb previous to
// version 800, because of the change to stackable of
// itemid 3965
if(root_header.minorVersionItems < CLIENT_VERSION_810){
setLastErrorString("This map needs to be updated.");
return false;
}
if(root_header.minorVersionItems > (unsigned long)Items::dwMinorVersion){
std::cout << "Warning: [OTBM loader] This map needs an updated items.otb." <<std::endl;
}
if(root_header.minorVersionItems == CLIENT_VERSION_854_BAD){
std::cout << "Warning: [OTBM loader] This map needs uses an incorrect version of items.otb." <<std::endl;
}
std::cout << "Map size: " << root_header.width << "x" << root_header.height << std::endl;
map->mapWidth = root_header.width;
map->mapHeight = root_header.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;
}
unsigned char attribute;
std::string mapDescription;
std::string tmp;
while(propStream.GET_UINT8(attribute)){
switch(attribute){
case OTBM_ATTR_DESCRIPTION:
if(!propStream.GET_STRING(mapDescription)){
setLastErrorString("Invalid description tag.");
return false;
}
std::cout << "Map description: " << mapDescription << std::endl;
//.........这里部分代码省略.........
示例5: readAttr
Attr_ReadValue Item::readAttr(AttrTypes_t attr, PropStream& propStream)
{
switch (attr) {
case ATTR_COUNT: {
uint8_t _count = 0;
if (!propStream.GET_UCHAR(_count)) {
return ATTR_READ_ERROR;
}
setSubType(_count);
break;
}
case ATTR_ACTION_ID: {
uint16_t _actionid = 0;
if (!propStream.GET_USHORT(_actionid)) {
return ATTR_READ_ERROR;
}
setActionId(_actionid);
break;
}
case ATTR_UNIQUE_ID: {
uint16_t _uniqueid;
if (!propStream.GET_USHORT(_uniqueid)) {
return ATTR_READ_ERROR;
}
setUniqueId(_uniqueid);
break;
}
case ATTR_TEXT: {
std::string _text;
if (!propStream.GET_STRING(_text)) {
return ATTR_READ_ERROR;
}
setText(_text);
break;
}
case ATTR_WRITTENDATE: {
uint32_t _writtenDate;
if (!propStream.GET_ULONG(_writtenDate)) {
return ATTR_READ_ERROR;
}
setDate(_writtenDate);
break;
}
case ATTR_WRITTENBY: {
std::string _writer;
if (!propStream.GET_STRING(_writer)) {
return ATTR_READ_ERROR;
}
setWriter(_writer);
break;
}
case ATTR_DESC: {
std::string _text;
if (!propStream.GET_STRING(_text)) {
return ATTR_READ_ERROR;
}
setSpecialDescription(_text);
break;
}
case ATTR_RUNE_CHARGES: {
uint8_t _charges = 1;
if (!propStream.GET_UCHAR(_charges)) {
return ATTR_READ_ERROR;
}
setSubType(_charges);
break;
}
case ATTR_CHARGES: {
uint16_t _charges = 1;
if (!propStream.GET_USHORT(_charges)) {
return ATTR_READ_ERROR;
}
setSubType(_charges);
break;
//.........这里部分代码省略.........
示例6: readAttr
bool Item::readAttr(AttrTypes_t attr, PropStream& propStream)
{
switch(attr){
case ATTR_COUNT:
{
unsigned char _count = 0;
if(!propStream.GET_UCHAR(_count)){
return false;
}
setItemCountOrSubtype(_count);
break;
}
case ATTR_ACTION_ID:
{
unsigned short _actionid = 0;
if(!propStream.GET_USHORT(_actionid)){
return false;
}
setActionId(_actionid);
break;
}
case ATTR_UNIQUE_ID:
{
unsigned short _uniqueid;
if(!propStream.GET_USHORT(_uniqueid)){
return false;
}
setUniqueId(_uniqueid);
break;
}
case ATTR_TEXT:
{
std::string _text;
if(!propStream.GET_STRING(_text)){
return false;
}
setText(_text);
break;
}
case ATTR_DESC:
{
std::string _text;
if(!propStream.GET_STRING(_text)){
return false;
}
setSpecialDescription(_text);
break;
}
case ATTR_RUNE_CHARGES:
{
unsigned char _charges = 1;
if(!propStream.GET_UCHAR(_charges)){
return false;
}
setItemCountOrSubtype(_charges);
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:
{
unsigned short _depotId;
if(!propStream.GET_USHORT(_depotId)){
return false;
}
return true;
}
//Door class
case ATTR_HOUSEDOORID:
{
unsigned char _doorId;
if(!propStream.GET_UCHAR(_doorId)){
return false;
}
return true;
}
//Teleport class
case ATTR_TELE_DEST:
{
TeleportDest* tele_dest;
if(!propStream.GET_STRUCT(tele_dest)){
//.........这里部分代码省略.........
示例7: unserialize
//.........这里部分代码省略.........
case ConditionEffect::MOD_SKILL:
{
if(revision != 1){
return false;
}
uint32_t value;
if(!propStream.GET_VALUE(value)){
return false;
}
ConditionEffect::ModSkill mod;
mod.type = SkillType::fromInteger(value);
if(!propStream.GET_VALUE(mod.percent)){
return false;
}
if(!propStream.GET_VALUE(mod.value)){
return false;
}
if(!propStream.GET_VALUE(mod.delta)){
return false;
}
data = mod;
break;
}
case ConditionEffect::SHAPESHIFT:
{
if(revision != 1){
return false;
}
ConditionEffect::ModShapeShift mod;
if(!propStream.GET_VALUE(mod.lookType)){
return false;
}
if(!propStream.GET_VALUE(mod.lookTypeEx)){
return false;
}
if(!propStream.GET_VALUE(mod.lookHead)){
return false;
}
if(!propStream.GET_VALUE(mod.lookBody)){
return false;
}
if(!propStream.GET_VALUE(mod.lookLegs)){
return false;
}
if(!propStream.GET_VALUE(mod.lookFeet)){
return false;
}
if(!propStream.GET_VALUE(mod.lookAddons)){
return false;
}
data = mod;
break;
}
case ConditionEffect::LIGHT:
{
if(revision != 1){
return false;
}
ConditionEffect::ModLight mod;
if(!propStream.GET_VALUE(mod.level)){
return false;
}
if(!propStream.GET_VALUE(mod.color)){
return false;
}
data = mod;
break;
}
case ConditionEffect::DISPEL:
{
if(revision != 1){
return false;
}
ConditionEffect::ModDispel mod;
if(!propStream.GET_STRING(mod.name)){
return false;
}
data = mod;
break;
}
case ConditionEffect::SCRIPT:
{
if(revision != 1){
return false;
}
ConditionEffect::ModScript mod;
if(!propStream.GET_STRING(mod.name)){
return false;
}
data = mod;
break;
}
default: return false;
}
return true;
}