| 1866 | } |
| 1867 | |
| 1868 | void PersistenceManager::addRemoveField(SimObject* object, const char* fieldName) |
| 1869 | { |
| 1870 | // Check to see if this is an array variable |
| 1871 | U32 arrayPos = 0; |
| 1872 | const char* name = fieldName; |
| 1873 | |
| 1874 | if (dStrlen(fieldName) > 3 && fieldName[dStrlen(fieldName) - 1] == ']') |
| 1875 | { |
| 1876 | // The last character is a ']' which *should* mean |
| 1877 | // there is also a corresponding '[' |
| 1878 | const char* arrayPosStart = dStrrchr(fieldName, '['); |
| 1879 | |
| 1880 | if (!arrayPosStart) |
| 1881 | { |
| 1882 | Con::errorf("PersistenceManager::addRemoveField() - error parsing array position - \ |
| 1883 | was expecting a '[' character"); |
| 1884 | } |
| 1885 | else |
| 1886 | { |
| 1887 | // Parse the array position for the variable name |
| 1888 | dSscanf(arrayPosStart, "[%d]", &arrayPos); |
| 1889 | |
| 1890 | // Trim off the [<pos>] from the variable name |
| 1891 | char* variableName = dStrdup(fieldName); |
| 1892 | variableName[arrayPosStart - fieldName] = 0; |
| 1893 | |
| 1894 | // Set the variable name to our new shortened name |
| 1895 | name = StringTable->insert(variableName, true); |
| 1896 | |
| 1897 | // Cleanup our variableName buffer |
| 1898 | dFree( variableName ); |
| 1899 | } |
| 1900 | } |
| 1901 | |
| 1902 | // Make sure this field isn't already on the list |
| 1903 | if (!findRemoveField(object, name, arrayPos)) |
| 1904 | { |
| 1905 | mRemoveFields.increment(); |
| 1906 | |
| 1907 | RemoveField& field = mRemoveFields.last(); |
| 1908 | |
| 1909 | field.object = object; |
| 1910 | field.fieldName = StringTable->insert(name); |
| 1911 | field.arrayPos = arrayPos; |
| 1912 | } |
| 1913 | } |
| 1914 | |
| 1915 | bool PersistenceManager::isDirty(SimObject* object) |
| 1916 | { |