diff options
| author | 2021-04-20 02:12:47 -0700 | |
|---|---|---|
| committer | 2021-04-20 02:12:47 -0700 | |
| commit | 8d047a8f0dcfb1bdaa4dcf87c001a30ebcc7cca8 (patch) | |
| tree | f0ca7134fd27aa3d9967195dd8946be542c749cc /src/emu/save.h | |
| parent | 7e33cb29e24b2ce9c4c3bf7b1d7b8784a93f3172 (diff) | |
Better handling of null/missing items. More consistent error handling. Reduced compression to default to speed up saves. Optimized simple binary saves as well. Device interfaces now have automatic containers. Fixed duplicate entry detection. Added logic to parse an item we're skipping. Added detection of missing/duplicate items from input JSON. Fixed timing for save/load.save-experiments
Diffstat (limited to 'src/emu/save.h')
| -rw-r--r-- | src/emu/save.h | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/emu/save.h b/src/emu/save.h index 61a5223a387..7d26c9382f3 100644 --- a/src/emu/save.h +++ b/src/emu/save.h @@ -144,6 +144,7 @@ public: save_registered_item &append(uintptr_t ptr_offset, save_type type, u32 native_size, char const *name, u32 count = 0); // find an item by name + save_registered_item *find(char const *name, u32 &index); save_registered_item *find(char const *name); // is this item replicatable (i.e., can we replicate it for all elements in an array?) @@ -285,11 +286,9 @@ public: template<typename T> std::enable_if_t<!std::is_array<T>::value, save_registrar> ®(std::unique_ptr<T> &data, char const *name) { - if (data.get() == nullptr) - throw emu_fatalerror("Passed null pointer to save state registration."); - save_registrar container(*this, &data, save_registered_item::TYPE_UNIQUE, sizeof(data), name, 0, data.get(), sizeof(T)); - container.reg(*data.get(), name); + if (data.get() != nullptr) + container.reg(*data.get(), name); return *this; } @@ -319,10 +318,6 @@ public: template<typename T> save_registrar ®(std::vector<T> &data, char const *name) { - // skip if no items - if (data.size() == 0) - return *this; - // create an outer container for the vector, then a regular array container within save_registrar container(*this, &data, save_registered_item::TYPE_VECTOR, sizeof(data), name, 0, &data[0], sizeof(T)); container.register_array(&data[0], save_registered_item::TYPE_VECTOR_ARRAY, name, data.size()); @@ -333,10 +328,6 @@ public: template<typename T> save_registrar ®(std::unique_ptr<T[]> &data, char const *name, std::size_t count) { - // skip if no items - if (count == 0) - return *this; - // create an outer container for the unique_ptr, then a regular array container within save_registrar container(*this, &data, save_registered_item::TYPE_UNIQUE, sizeof(data), name, 0, data.get(), sizeof(T)); container.register_array(&data[0], save_registered_item::TYPE_RAW_ARRAY, name, count); @@ -384,17 +375,14 @@ private: template<typename T> save_registrar ®ister_array(T *data, save_registered_item::save_type type, char const *name, std::size_t count) { - // skip 0-length items - if (count == 0) - return *this; - - // error on null pointer - if (data == nullptr) - throw emu_fatalerror("Passed null pointer to save state registration."); + // nullptr only allowed if the count is 0 + if (data == nullptr && count != 0) + throw emu_fatalerror("Save: registered pointer with a null pointer (%s.%s)", m_item.full_name().c_str(), name); // create a container and register the first item save_registrar container(*this, data, type, uintptr_t(&data[1]) - uintptr_t(&data[0]), name, count, &data[0], sizeof(T)); - container.reg(data[0], ""); + if (count != 0) + container.reg(data[0], ""); // if the first item was non-replicatable, register remaining items independently if (!container.m_item.subitems().front().is_replicatable(true)) |
