| 1329 | } |
| 1330 | |
| 1331 | void PersistenceManager::updateObject(SimObject* object, ParsedObject* parentObject) |
| 1332 | { |
| 1333 | // Create a default object of the same type |
| 1334 | ConsoleObject *defaultConObject = ConsoleObject::create(object->getClassName()); |
| 1335 | SimObject* defaultObject = dynamic_cast<SimObject*>(defaultConObject); |
| 1336 | |
| 1337 | // ***Really*** shouldn't happen |
| 1338 | if (!defaultObject) |
| 1339 | return; |
| 1340 | |
| 1341 | Vector<const char*> newLines; |
| 1342 | |
| 1343 | ParsedObject* parsedObject = findParsedObject(object, parentObject); |
| 1344 | |
| 1345 | // If we don't already have an association between the ParsedObject |
| 1346 | // and the SimObject then go ahead and create it |
| 1347 | if (parsedObject && parsedObject->simObject.isNull()) |
| 1348 | parsedObject->simObject = object; |
| 1349 | |
| 1350 | // Kill all fields on the remove list. |
| 1351 | |
| 1352 | for( U32 i = 0; i < mRemoveFields.size(); ++ i ) |
| 1353 | { |
| 1354 | RemoveField& field = mRemoveFields[ i ]; |
| 1355 | if( field.object != object ) |
| 1356 | continue; |
| 1357 | |
| 1358 | S32 propertyIndex = getPropertyIndex( parsedObject, field.fieldName, field.arrayPos ); |
| 1359 | if( propertyIndex != -1 ) |
| 1360 | removeField( parsedObject->properties[ propertyIndex ] ); |
| 1361 | } |
| 1362 | |
| 1363 | // Get our field list |
| 1364 | const AbstractClassRep::FieldList &list = object->getFieldList(); |
| 1365 | |
| 1366 | for(U32 i = 0; i < list.size(); i++) |
| 1367 | { |
| 1368 | const AbstractClassRep::Field* f = &list[i]; |
| 1369 | |
| 1370 | // Skip the special field types. |
| 1371 | if ( f->type >= AbstractClassRep::ARCFirstCustomField ) |
| 1372 | continue; |
| 1373 | |
| 1374 | for(U32 j = 0; S32(j) < f->elementCount; j++) |
| 1375 | { |
| 1376 | const char* value = getFieldValue(object, f->pFieldname, j); |
| 1377 | |
| 1378 | // Make sure we got a value |
| 1379 | if (!value) |
| 1380 | continue; |
| 1381 | |
| 1382 | // Let's see if this field is already in the file |
| 1383 | S32 propertyIndex = getPropertyIndex(parsedObject, f->pFieldname, j); |
| 1384 | |
| 1385 | if (propertyIndex > -1) |
| 1386 | { |
| 1387 | ParsedProperty& prop = parsedObject->properties[propertyIndex]; |
| 1388 |
nothing calls this directly
no test coverage detected