| 348 | } |
| 349 | |
| 350 | PersistentDataItem Persistence::getByKey(int entity_id, const std::string &key, bool *added) { |
| 351 | if (!is_good_entity_id(entity_id) || key.empty() || !Core::getInstance().isWorldLoaded()) |
| 352 | return PersistentDataItem(); |
| 353 | |
| 354 | CoreSuspender suspend; |
| 355 | |
| 356 | bool found = store.contains(entity_id) && store[entity_id].contains(key); |
| 357 | if (added) |
| 358 | *added = !found; |
| 359 | if (found) |
| 360 | return PersistentDataItem(store[entity_id].find(key)->second); |
| 361 | if (!added) |
| 362 | return PersistentDataItem(); |
| 363 | return addItem(entity_id, key); |
| 364 | } |
| 365 | |
| 366 | bool Persistence::deleteItem(const PersistentDataItem &item) { |
| 367 | if (!item.isValid()) |
nothing calls this directly
no test coverage detected