From ce1b55be039ae6c3b648d07bd5af0fd1980702f2 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 3 Mar 2018 02:07:08 +0100 Subject: [PATCH] graph.c: Pixel_figure is not a global var anymore --- src/brush.c | 2 +- src/factory.c | 4 ++-- src/graph.c | 8 +++++++- src/graph.h | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/brush.c b/src/brush.c index 0d6ead28..403ebc23 100644 --- a/src/brush.c +++ b/src/brush.c @@ -1244,7 +1244,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear) Brush_offset_X=start_x; Brush_offset_Y=start_y; - Pixel_figure=Pixel_figure_in_brush; + Set_Pixel_figure(Pixel_figure_in_brush); memset(Brush,Back_color,(long)Brush_width*Brush_height); Polyfill_general(vertices,points,xor_lut[Back_color]); diff --git a/src/factory.c b/src/factory.c index 1999c67f..71e0cecf 100644 --- a/src/factory.c +++ b/src/factory.c @@ -524,7 +524,7 @@ int L_DrawLine(lua_State* L) LUA_ARG_NUMBER(4, "drawline", y2, INT_MIN, INT_MAX); LUA_ARG_NUMBER(5, "drawline", c, INT_MIN, INT_MAX); - Pixel_figure = (void (*) (word,word,byte))Pixel_figure_no_screen; + Set_Pixel_figure((void (*) (word,word,byte))Pixel_figure_no_screen); Draw_line_general(x1, y1, x2, y2, c); return 0; @@ -598,7 +598,7 @@ int L_DrawCircle(lua_State* L) LUA_ARG_NUMBER(3, "drawcircle", r, INT_MIN, INT_MAX); LUA_ARG_NUMBER(4, "drawcircle", c, INT_MIN, INT_MAX); - Pixel_figure = (void (*) (word,word,byte))Pixel_figure_no_screen; + Set_Pixel_figure((void (*) (word,word,byte))Pixel_figure_no_screen); Circle_limit = r*r; Draw_empty_circle_general(x1, y1, r, c); diff --git a/src/graph.c b/src/graph.c index 017edfca..f858397c 100644 --- a/src/graph.c +++ b/src/graph.c @@ -57,7 +57,13 @@ #endif // Generic pixel-drawing function. -Func_pixel Pixel_figure; +static Func_pixel Pixel_figure; + +void Set_Pixel_figure(Func_pixel func) +{ + Pixel_figure = func; +} + typedef struct { diff --git a/src/graph.h b/src/graph.h index 901c3fa1..bac4285f 100644 --- a/src/graph.h +++ b/src/graph.h @@ -115,7 +115,7 @@ void Remap_spare(void); /// - ::Pixel_figure_preview_xor : On screen, XORing the color. /// - ::Pixel_figure_permanent : On screen and in the image. /// - ::Pixel_figure_clear_preview : On screen, reverting to the image's pixels. -extern Func_pixel Pixel_figure; +void Set_Pixel_figure(Func_pixel func); void Update_part_of_screen(short x, short y, short width, short height);