int InputIges::readIntFields(istrstream*& data_line, int nof_fields, int* buffer) { //NOTE: we read data-lines until necessary number of //data fields is read from the file int counter; for(counter = 0; counter < nof_fields; counter++) { getDataField(data_line, dataFieldBuffer); buffer[counter] = atol(dataFieldBuffer); } return counter; }
bool SimObject::writeObject(Stream *stream) { stream->writeString(getName() ? getName() : ""); // Static fields AbstractClassRep *rep = getClassRep(); AbstractClassRep::FieldList &fieldList = rep->mFieldList; AbstractClassRep::FieldList::iterator itr; U32 savePos = stream->getPosition(); U32 numFields = fieldList.size(); stream->write(numFields); for(itr = fieldList.begin();itr != fieldList.end();itr++) { if( itr->type >= AbstractClassRep::ARCFirstCustomField ) { numFields--; continue; } const char *field = getDataField(itr->pFieldname, NULL); if(field == NULL) field = ""; stream->writeString(itr->pFieldname); stream->writeString(field); } // Dynamic Fields if(mCanSaveFieldDictionary) { SimFieldDictionary * fieldDictionary = getFieldDictionary(); for(SimFieldDictionaryIterator ditr(fieldDictionary); *ditr; ++ditr) { SimFieldDictionary::Entry * entry = (*ditr); stream->writeString(entry->slotName); stream->writeString(entry->value); numFields++; } } // Overwrite the number of fields with the correct value U32 savePos2 = stream->getPosition(); stream->setPosition(savePos); stream->write(numFields); stream->setPosition(savePos2); return true; }
// Method reads one point from input-string *s*. bool InputIges::readPoint(istrstream*& data_line, Point3& p) { for(int i = 0; i < 3; i++) { getDataField(data_line, dataFieldBuffer); p[i] = atof(dataFieldBuffer); p[i] *= model->unit.conv[i]; } return true; }
const UTF8 *Settings::value(const UTF8 *settingName, const UTF8 *defaultValue) { String name; buildGroupString(name, settingName); StringTableEntry nameEntry = StringTable->insert(name.c_str()); name += "_default"; StringTableEntry defaultNameEntry = StringTable->insert(name.c_str()); // we do this setModStaticFields call to make sure our get/set calls // don't grab a regular field, don't want to stomp anything setModStaticFields(false); const UTF8 *value = getDataField(nameEntry, NULL); const UTF8 *storedDefaultValue = getDataField(defaultNameEntry, NULL); setModStaticFields(true); if(dStrcmp(value, "") != 0) return value; else if(dStrcmp(storedDefaultValue, "") != 0) return storedDefaultValue; else return defaultValue; }
bool SFXEmitter::onAdd() { if( !Parent::onAdd() ) return false; if( isServerObject() ) { // Validate the data we'll be passing across // the network to the client. mDescription.validate(); // Read an old 'profile' field for backwards-compatibility. if( !mTrack ) { static const char* sProfile = StringTable->insert( "profile" ); const char* profileName = getDataField( sProfile, NULL ); if( profileName && profileName[ 0 ] ) { if( !Sim::findObject( profileName, mTrack ) ) Con::errorf( "SFXEmitter::onAdd - No SFXTrack '%s' in SFXEmitter '%i' (%s)", profileName, getId(), getName() ); else { // Remove the old 'profile' field. setDataField( sProfile, NULL, "" ); } } } // Convert a legacy 'channel' field, if we have one. static const char* sChannel = StringTable->insert( "channel" ); const char* channelValue = getDataField( sChannel, NULL ); if( channelValue && channelValue[ 0 ] ) { const char* group = Con::evaluatef( "return sfxOldChannelToGroup( %s );", channelValue ); SFXSource* sourceGroup; if( !Sim::findObject( group, sourceGroup ) ) Con::errorf( "SFXEmitter::onAdd - could not resolve channel '%s' to SFXSource", channelValue ); else { static const char* sSourceGroup = StringTable->insert( "sourceGroup" ); setDataField( sSourceGroup, NULL, sourceGroup->getIdString() ); // Remove the old 'channel' field. setDataField( sChannel, NULL, "" ); } } } else { _update(); // Do we need to start playback? if( mPlayOnAdd && mSource ) mSource->play(); } // Setup the bounds. mObjScale.set( mDescription.mMaxDistance, mDescription.mMaxDistance, mDescription.mMaxDistance ); resetWorldBox(); addToScene(); return true; }