summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine.cpp
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2017-05-06 08:24:51 -0400
committer Vas Crabb <cuavas@users.noreply.github.com>2017-05-10 10:04:10 +1000
commitc5ef33acdc6e2bbf22e7975109b758c480e47d37 (patch)
tree98305977dc41ea52234b6db11eac2999586c7540 /src/emu/machine.cpp
parent36a43a078bce291a8382b760b773f3b66296d006 (diff)
Refactoring/cleanup to state load/save handling
- Changed running_machine::schedule_[load|save]() to take 'std::string &&' instead of 'const char *' - Changed running_machine::saveload_schedule to be 'enum class'
Diffstat (limited to 'src/emu/machine.cpp')
-rw-r--r--src/emu/machine.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp
index f674c3d003b..b8ef018c724 100644
--- a/src/emu/machine.cpp
+++ b/src/emu/machine.cpp
@@ -125,7 +125,7 @@ running_machine::running_machine(const machine_config &_config, machine_manager
m_ui_active(_config.options().ui_active()),
m_basename(_config.gamedrv().name),
m_sample_rate(_config.options().sample_rate()),
- m_saveload_schedule(SLS_NONE),
+ m_saveload_schedule(saveload_schedule::NONE),
m_saveload_schedule_time(attotime::zero),
m_saveload_searchpath(nullptr),
@@ -335,7 +335,7 @@ int running_machine::run(bool quiet)
soft_reset();
// handle initial load
- if (m_saveload_schedule != SLS_NONE)
+ if (m_saveload_schedule != saveload_schedule::NONE)
handle_saveload();
export_http_api();
@@ -344,7 +344,7 @@ int running_machine::run(bool quiet)
// run the CPUs until a reset or exit
m_hard_reset_pending = false;
- while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE)
+ while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != saveload_schedule::NONE)
{
g_profiler.start(PROFILER_EXTRA);
@@ -361,7 +361,7 @@ int running_machine::run(bool quiet)
m_video->frame_update();
// handle save/load
- if (m_saveload_schedule != SLS_NONE)
+ if (m_saveload_schedule != saveload_schedule::NONE)
handle_saveload();
g_profiler.stop();
@@ -571,7 +571,7 @@ std::string running_machine::get_statename(const char *option) const
// for state loading/saving
//-------------------------------------------------
-std::string running_machine::compose_saveload_filename(const char *filename, const char **searchpath)
+std::string running_machine::compose_saveload_filename(std::string &&filename, const char **searchpath)
{
std::string result;
@@ -581,7 +581,7 @@ std::string running_machine::compose_saveload_filename(const char *filename, con
// if so, this is easy
if (searchpath != nullptr)
*searchpath = nullptr;
- result = filename;
+ result = std::move(filename);
}
else
{
@@ -603,10 +603,10 @@ std::string running_machine::compose_saveload_filename(const char *filename, con
// for state loading/saving
//-------------------------------------------------
-void running_machine::set_saveload_filename(const char *filename)
+void running_machine::set_saveload_filename(std::string &&filename)
{
// compose the save/load filename and persist it
- m_saveload_pending_file = compose_saveload_filename(filename, &m_saveload_searchpath);
+ m_saveload_pending_file = compose_saveload_filename(std::move(filename), &m_saveload_searchpath);
}
@@ -615,13 +615,13 @@ void running_machine::set_saveload_filename(const char *filename)
// soon as possible
//-------------------------------------------------
-void running_machine::schedule_save(const char *filename)
+void running_machine::schedule_save(std::string &&filename)
{
// specify the filename to save or load
- set_saveload_filename(filename);
+ set_saveload_filename(std::move(filename));
// note the start time and set a timer for the next timeslice to actually schedule it
- m_saveload_schedule = SLS_SAVE;
+ m_saveload_schedule = saveload_schedule::SAVE;
m_saveload_schedule_time = this->time();
// we can't be paused since we need to clear out anonymous timers
@@ -639,7 +639,7 @@ void running_machine::immediate_save(const char *filename)
set_saveload_filename(filename);
// set up some parameters for handle_saveload()
- m_saveload_schedule = SLS_SAVE;
+ m_saveload_schedule = saveload_schedule::SAVE;
m_saveload_schedule_time = this->time();
// jump right into the save, anonymous timers can't hurt us!
@@ -652,13 +652,13 @@ void running_machine::immediate_save(const char *filename)
// soon as possible
//-------------------------------------------------
-void running_machine::schedule_load(const char *filename)
+void running_machine::schedule_load(std::string &&filename)
{
// specify the filename to save or load
- set_saveload_filename(filename);
+ set_saveload_filename(std::move(filename));
// note the start time and set a timer for the next timeslice to actually schedule it
- m_saveload_schedule = SLS_LOAD;
+ m_saveload_schedule = saveload_schedule::LOAD;
m_saveload_schedule_time = this->time();
// we can't be paused since we need to clear out anonymous timers
@@ -676,7 +676,7 @@ void running_machine::immediate_load(const char *filename)
set_saveload_filename(filename);
// set up some parameters for handle_saveload()
- m_saveload_schedule = SLS_LOAD;
+ m_saveload_schedule = saveload_schedule::LOAD;
m_saveload_schedule_time = this->time();
// jump right into the load, anonymous timers can't hurt us
@@ -860,7 +860,7 @@ void running_machine::handle_saveload()
// if no name, bail
if (!m_saveload_pending_file.empty())
{
- const char *const opname = (m_saveload_schedule == SLS_LOAD) ? "load" : "save";
+ const char *const opname = (m_saveload_schedule == saveload_schedule::LOAD) ? "load" : "save";
// if there are anonymous timers, we can't save just yet, and we can't load yet either
// because the timers might overwrite data we have loaded
@@ -874,17 +874,17 @@ void running_machine::handle_saveload()
}
else
{
- u32 const openflags = (m_saveload_schedule == SLS_LOAD) ? OPEN_FLAG_READ : (OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
+ u32 const openflags = (m_saveload_schedule == saveload_schedule::LOAD) ? OPEN_FLAG_READ : (OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
// open the file
emu_file file(m_saveload_searchpath, openflags);
auto const filerr = file.open(m_saveload_pending_file.c_str());
if (filerr == osd_file::error::NONE)
{
- const char *const opnamed = (m_saveload_schedule == SLS_LOAD) ? "loaded" : "saved";
+ const char *const opnamed = (m_saveload_schedule == saveload_schedule::LOAD) ? "loaded" : "saved";
// read/write the save state
- save_error saverr = (m_saveload_schedule == SLS_LOAD) ? m_save.read_file(file) : m_save.write_file(file);
+ save_error saverr = (m_saveload_schedule == saveload_schedule::LOAD) ? m_save.read_file(file) : m_save.write_file(file);
// handle the result
switch (saverr)
@@ -918,7 +918,7 @@ void running_machine::handle_saveload()
}
// close and perhaps delete the file
- if (saverr != STATERR_NONE && m_saveload_schedule == SLS_SAVE)
+ if (saverr != STATERR_NONE && m_saveload_schedule == saveload_schedule::SAVE)
file.remove_on_close();
}
else
@@ -929,7 +929,7 @@ void running_machine::handle_saveload()
// unschedule the operation
m_saveload_pending_file.clear();
m_saveload_searchpath = nullptr;
- m_saveload_schedule = SLS_NONE;
+ m_saveload_schedule = saveload_schedule::NONE;
}