- LoadState through Lua isn't counted for movie RerecordCount.
 - Added movie.setrerecordcount and movie.getrerecordcount for people who really want to count their bot loadstates.
This commit is contained in:
scepheo 2014-10-20 20:31:31 +00:00
parent d0aee55059
commit 28f21e1775
2 changed files with 35 additions and 2 deletions

View File

@ -70,6 +70,15 @@ namespace BizHawk.Client.Common
return Global.MovieSession.ReadOnly; return Global.MovieSession.ReadOnly;
} }
[LuaMethodAttributes(
"getrerecordcount",
"Gets the rerecord count of the current movie."
)]
public static ulong GetRerecordCount()
{
return Global.MovieSession.Movie.Rerecords;
}
[LuaMethodAttributes( [LuaMethodAttributes(
"getrerecordcounting", "getrerecordcounting",
"Returns whether or not the current movie is incrementing rerecords on loadstate" "Returns whether or not the current movie is incrementing rerecords on loadstate"
@ -123,11 +132,11 @@ namespace BizHawk.Client.Common
[LuaMethodAttributes( [LuaMethodAttributes(
"rerecordcount", "rerecordcount",
"Returns the current rerecord count for the loaded movie" "[Deprecated] Alias of getrerecordcount"
)] )]
public static string RerecordCount() public static string RerecordCount()
{ {
return Global.MovieSession.Movie.Rerecords.ToString(); return GetRerecordCount().ToString();
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -139,6 +148,22 @@ namespace BizHawk.Client.Common
Global.MovieSession.ReadOnly = readOnly; Global.MovieSession.ReadOnly = readOnly;
} }
[LuaMethodAttributes(
"setrerecordcount",
"Sets the rerecord count of the current movie."
)]
public static void SetRerecordCount(double count)
{
// Lua numbers are always double, integer precision holds up
// to 53 bits, so throw an error if it's bigger than that.
const double precisionLimit = 9007199254740992d;
if (count > precisionLimit)
throw new Exception("Rerecord count exceeds Lua integer precision.");
Global.MovieSession.Movie.Rerecords = (ulong)count;
}
[LuaMethodAttributes( [LuaMethodAttributes(
"setrerecordcounting", "setrerecordcounting",
"Sets whether or not the current movie will increment the rerecord counter on loadstate" "Sets whether or not the current movie will increment the rerecord counter on loadstate"

View File

@ -2448,6 +2448,12 @@ namespace BizHawk.Client.EmuHawk
public void LoadState(string path, string userFriendlyStateName, bool fromLua = false) // Move to client.common public void LoadState(string path, string userFriendlyStateName, bool fromLua = false) // Move to client.common
{ {
// If from lua, disable counting rerecords
bool wasCountingRerecords = Global.MovieSession.Movie.IsCountingRerecords;
if (fromLua)
Global.MovieSession.Movie.IsCountingRerecords = false;
GlobalWin.DisplayManager.NeedsToPaint = true; GlobalWin.DisplayManager.NeedsToPaint = true;
if (SavestateManager.LoadStateFile(path, userFriendlyStateName)) if (SavestateManager.LoadStateFile(path, userFriendlyStateName))
@ -2469,6 +2475,8 @@ namespace BizHawk.Client.EmuHawk
{ {
GlobalWin.OSD.AddMessage("Loadstate error!"); GlobalWin.OSD.AddMessage("Loadstate error!");
} }
Global.MovieSession.Movie.IsCountingRerecords = wasCountingRerecords;
} }
public void LoadQuickSave(string quickSlotName, bool fromLua = false) public void LoadQuickSave(string quickSlotName, bool fromLua = false)