lua: better typecasting for LuaInt and LuaUInt that doesnt throw overflow exceptions; and, render to a null image when the lua script manager Resume process hasnt begun (setting up a render target) but lua scripts run (due to loadstate, for example)

This commit is contained in:
zeromus 2013-12-30 16:36:15 +00:00
parent 213e02ffef
commit 436881beaf
2 changed files with 7 additions and 3 deletions

View File

@ -27,12 +27,12 @@ namespace BizHawk.Client.Common
protected static int LuaInt(object luaArg)
{
return Convert.ToInt32((double)luaArg);
return (int)(double)luaArg;
}
protected static uint LuaUInt(object luaArg)
{
return Convert.ToUInt32((double)luaArg);
return (uint)(double)luaArg;
}
/// <summary>

View File

@ -132,9 +132,13 @@ namespace BizHawk.Client.EmuHawk
return p;
}
Bitmap nullGraphicsBitmap = new Bitmap(1, 1);
private Graphics GetGraphics()
{
var g = luaSurface.GetGraphics();
Graphics g;
if (luaSurface == null)
g = Graphics.FromImage(nullGraphicsBitmap);
else g = luaSurface.GetGraphics();
int tx = Global.Emulator.CoreComm.ScreenLogicalOffsetX;
int ty = Global.Emulator.CoreComm.ScreenLogicalOffsetY;
if (tx != 0 || ty != 0)