diff --git a/src/osgPlugins/ive/IveVersion.h b/src/osgPlugins/ive/IveVersion.h index 264f99735..92db3b255 100644 --- a/src/osgPlugins/ive/IveVersion.h +++ b/src/osgPlugins/ive/IveVersion.h @@ -26,8 +26,9 @@ #define VERSION_0015 15 #define VERSION_0016 16 #define VERSION_0017 17 +#define VERSION_0018 18 -#define VERSION VERSION_0017 +#define VERSION VERSION_0018 /* The BYTE_SEX tag is used to check the endian of the IVE file being read in. The IVE format diff --git a/src/osgPlugins/ive/Text.cpp b/src/osgPlugins/ive/Text.cpp index 8e482686a..cebed1174 100644 --- a/src/osgPlugins/ive/Text.cpp +++ b/src/osgPlugins/ive/Text.cpp @@ -102,17 +102,17 @@ void Text::write(DataOutputStream* out){ else { // do it the hardway...output each character as an int - osg::ref_ptr strarr = new osg::UByteArray(textstring.size()); + osg::ref_ptr strarr = new osg::UIntArray(textstring.size()); for(itr=textstring.begin(); itr!=textstring.end(); ++itr) { - strarr->push_back((char)(*itr)); + strarr->push_back((*itr)); } out->writeBool(false); - out->writeUByteArray(strarr.get()); + out->writeUIntArray(strarr.get()); } } @@ -168,16 +168,29 @@ void Text::read(DataInputStream* in){ setText(in->readString()); else { - std::string textstr; - - osg::ref_ptr arr = in->readUByteArray(); - - for(unsigned int i = 0; i < arr->getNumElements(); i++) + if ( in->getVersion() >= VERSION_0018 ) { - textstr += (char) arr->at(i); - } + osgText::String textstr; + osg::ref_ptr arr = in->readUIntArray(); + for(unsigned int i = 0; i < arr->getNumElements(); i++) + { + textstr.push_back( arr->at(i) ); + } - setText(textstr); + setText(textstr); + } + else + { + // buggy original path, should have used a UIntArray originally, now fixed above. + std::string textstr; + osg::ref_ptr arr = in->readUByteArray(); + for(unsigned int i = 0; i < arr->getNumElements(); i++) + { + textstr += (char) arr->at(i); + } + + setText(textstr); + } } }