From fa15037a4292151440c2628847ad208d7b4559d3 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Fri, 29 Jan 2010 02:20:45 +0000 Subject: [PATCH] Lua: GetBrushBackupPixel now works (Had forgotten to make initial copy :-/ ) git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1289 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- factory.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/factory.c b/factory.c index 63b96623..f780618f 100644 --- a/factory.c +++ b/factory.c @@ -375,27 +375,31 @@ void Button_Brush_Factory(void) Brush_backup_width = Brush_width; Brush_backup_height = Brush_height; - if (Brush == NULL) + if (Brush_backup == NULL) { Verbose_error_message("Out of memory!"); } - else if (luaL_loadfile(L,scriptdir) != 0) - { - message = lua_tostring(L, 1); - if(message) - Verbose_error_message(message); - else - Warning_message("Unknown error loading script!"); + else + { + memcpy(Brush_backup, Brush, ((long)Brush_height)*Brush_width); + + if (luaL_loadfile(L,scriptdir) != 0) + { + message = lua_tostring(L, 1); + if(message) + Verbose_error_message(message); + else + Warning_message("Unknown error loading script!"); + } + else if (lua_pcall(L, 0, 0, 0) != 0) + { + message = lua_tostring(L, 1); + if(message) + Verbose_error_message(message); + else + Warning_message("Unknown error running script!"); + } } - else if (lua_pcall(L, 0, 0, 0) != 0) - { - message = lua_tostring(L, 1); - if(message) - Verbose_error_message(message); - else - Warning_message("Unknown error running script!"); - } - // Cleanup free(Brush_backup); Brush_backup=NULL;