| 2018 | } |
| 2019 | |
| 2020 | bool PersistenceManager::saveDirtyObject(SimObject* object) |
| 2021 | { |
| 2022 | // find our object passed in |
| 2023 | for (U32 i = 0; i < mDirtyObjects.size(); i++) |
| 2024 | { |
| 2025 | const DirtyObject& dirtyObject = mDirtyObjects[i]; |
| 2026 | |
| 2027 | if (dirtyObject.isNull()) |
| 2028 | continue; |
| 2029 | |
| 2030 | if (dirtyObject.getObject() == object) |
| 2031 | { |
| 2032 | // Open our new file and parse it |
| 2033 | bool success = parseFile(dirtyObject.fileName); |
| 2034 | |
| 2035 | if (!success) |
| 2036 | { |
| 2037 | const char *name = object->getName(); |
| 2038 | if (name) |
| 2039 | { |
| 2040 | Con::errorf("PersistenceManager::saveDirtyObject(): Unable to open %s to save %s %s (%d)", |
| 2041 | dirtyObject.fileName, object->getClassName(), name, object->getId()); |
| 2042 | } |
| 2043 | else |
| 2044 | { |
| 2045 | Con::errorf("PersistenceManager::saveDirtyObject(): Unable to open %s to save %s (%d)", |
| 2046 | dirtyObject.fileName, object->getClassName(), object->getId()); |
| 2047 | } |
| 2048 | |
| 2049 | return false; |
| 2050 | } |
| 2051 | |
| 2052 | // if the file exists then lets update and save |
| 2053 | if(mCurrentFile) |
| 2054 | { |
| 2055 | updateObject(object); |
| 2056 | saveDirtyFile(); |
| 2057 | } |
| 2058 | |
| 2059 | break; |
| 2060 | } |
| 2061 | } |
| 2062 | |
| 2063 | // remove this object from the dirty list |
| 2064 | removeDirty(object); |
| 2065 | |
| 2066 | return true; |
| 2067 | } |
| 2068 | |
| 2069 | void PersistenceManager::removeObjectFromFile(SimObject* object, const char* fileName) |
| 2070 | { |
no test coverage detected