int File::GetInt(const char *key, int defaultValue) { CAT_DEBUG_ENFORCE(key); // Add this path to the hash table SanitizedKey san_key(key); KeyAdapter key_input(san_key); LineItem *item = _table.Lookup(key_input); if (item) return item->GetValueInt(); // If default value is not undefined, #if !defined(CAT_RAGDOLL_STORE_EMPTY) if (defaultValue != 0) #endif { // Create a new item for this key item = _table.Create(key_input); if (item) { // Push onto the new list CAT_FSLL_PUSH_FRONT(_newest, item, _sort_next); item->_enlisted = true; SanitizeKeyStringCase(key, item->CaseKey()); item->SetValueInt(defaultValue); } } return defaultValue; }
void File::SetInt(const char *key, int value, RWLock *lock) { CAT_DEBUG_ENFORCE(key && lock); lock->WriteLock(); // Add this path to the hash table SanitizedKey san_key(key); KeyAdapter key_input(san_key); LineItem *item = _table.Lookup(key_input); if (!item) { #if !defined(CAT_RAGDOLL_STORE_EMPTY) if (value != 0) #endif { // Create a new item for this key item = _table.Create(key_input); if (item) { // Push onto the new list CAT_FSLL_PUSH_FRONT(_newest, item, _sort_next); item->_enlisted = true; SanitizeKeyStringCase(key, item->CaseKey()); item->SetValueInt(value); } } } else { // If item is not listed yet, if (!item->_enlisted) { CAT_FSLL_PUSH_FRONT(_modded, item, _sort_next); item->_enlisted = true; } item->SetValueInt(value); } lock->WriteUnlock(); }