Skip to content

Commit

Permalink
emu/save.cpp: Made illegal save state registrations always fatal.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuavas committed Feb 22, 2024
1 parent 53082b4 commit 9cf425b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 27 deletions.
4 changes: 0 additions & 4 deletions src/emu/machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,10 +890,6 @@ void running_machine::handle_saveload()
// handle the result
switch (saverr)
{
case STATERR_ILLEGAL_REGISTRATIONS:
popmessage("Error: Unable to %s state %s %s due to illegal registrations. See error.log for details.", opname, preposname, m_saveload_pending_file);
break;

case STATERR_INVALID_HEADER:
popmessage("Error: Unable to %s state %s %s due to an invalid header. Make sure the save state is correct for this system.", opname, preposname, m_saveload_pending_file);
break;
Expand Down
22 changes: 1 addition & 21 deletions src/emu/save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ enum
save_manager::save_manager(running_machine &machine)
: m_machine(machine)
, m_reg_allowed(true)
, m_illegal_regs(0)
{
m_rewind = std::make_unique<rewinder>(*this);
}
Expand Down Expand Up @@ -187,9 +186,7 @@ void save_manager::save_memory(device_t *device, const char *module, const char
if (!m_reg_allowed)
{
machine().logerror("Attempt to register save state entry after state registration is closed!\nModule %s tag %s name %s\n", module, tag, name);
if (machine().system().flags & machine_flags::SUPPORTS_SAVE)
fatalerror("Attempt to register save state entry after state registration is closed!\nModule %s tag %s name %s\n", module, tag, name);
m_illegal_regs++;
fatalerror("Attempt to register save state entry after state registration is closed!\nModule %s tag %s name %s\n", module, tag, name);
return;
}

Expand Down Expand Up @@ -408,10 +405,6 @@ save_error save_manager::read_buffer(const void *buf, size_t size)
template <typename T, typename U, typename V, typename W>
inline save_error save_manager::do_write(T check_space, U write_block, V start_header, W start_data)
{
// if we have illegal registrations, return an error
if (m_illegal_regs > 0)
return STATERR_ILLEGAL_REGISTRATIONS;

// check for sufficient space
size_t total_size = HEADER_SIZE;
for (const auto &entry : m_entry_list)
Expand Down Expand Up @@ -455,10 +448,6 @@ inline save_error save_manager::do_write(T check_space, U write_block, V start_h
template <typename T, typename U, typename V, typename W>
inline save_error save_manager::do_read(T check_length, U read_block, V start_header, W start_data)
{
// if we have illegal registrations, return an error
if (m_illegal_regs > 0)
return STATERR_ILLEGAL_REGISTRATIONS;

// check for sufficient space
size_t total_size = HEADER_SIZE;
for (const auto &entry : m_entry_list)
Expand Down Expand Up @@ -663,10 +652,6 @@ save_error ram_state::load()
// initialize
m_data.seekg(0);

// if we have illegal registrations, return an error
if (m_save.m_illegal_regs > 0)
return STATERR_ILLEGAL_REGISTRATIONS;

// get the save manager to load state
return m_save.read_stream(m_data);
}
Expand Down Expand Up @@ -916,11 +901,6 @@ void rewinder::report_error(save_error error, rewind_operation operation)
switch (error)
{
// internal saveload failures
case STATERR_ILLEGAL_REGISTRATIONS:
m_save.machine().logerror("Rewind error: Unable to %s state due to illegal registrations.", opname);
m_save.machine().popmessage("Rewind error occured. See error.log for details.");
break;

case STATERR_INVALID_HEADER:
m_save.machine().logerror("Rewind error: Unable to %s state due to an invalid header. "
"Make sure the save state is correct for this machine.\n", opname);
Expand Down
2 changes: 0 additions & 2 deletions src/emu/save.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ enum save_error
{
STATERR_NONE,
STATERR_NOT_FOUND,
STATERR_ILLEGAL_REGISTRATIONS,
STATERR_INVALID_HEADER,
STATERR_READ_ERROR,
STATERR_WRITE_ERROR,
Expand Down Expand Up @@ -334,7 +333,6 @@ class save_manager
running_machine & m_machine; // reference to our machine
std::unique_ptr<rewinder> m_rewind; // rewinder
bool m_reg_allowed; // are registrations allowed?
s32 m_illegal_regs; // number of illegal registrations

std::vector<std::unique_ptr<state_entry>> m_entry_list; // list of registered entries
std::vector<std::unique_ptr<ram_state>> m_ramstate_list; // list of ram states
Expand Down

0 comments on commit 9cf425b

Please sign in to comment.