shithub: cflood

Download patch

ref: 5e50d459126b42fa6538da84fcea65ac7250d083
parent: 4dd39471d23d01c82e86d3347decfa9448ca7fa6
author: Sigrid Solveig Haflínudóttir <248148+ftrvxmtrx@users.noreply.github.com>
date: Tue Dec 18 20:51:41 EST 2012

games/cflood: set color{a,b} once

--- a/games/cflood.c
+++ b/games/cflood.c
@@ -50,7 +50,6 @@
 	nil
 };
 
-static int inv;
 static int size;
 static int sid;
 static int state;
@@ -59,6 +58,7 @@
 static uchar *cells;
 static Image *colors[NumColors];
 static Rectangle buttons[NumColors];
+static Image *colora, *colorb;
 
 static void
 floodneighbours(uchar color, int x, int y);
@@ -72,14 +72,8 @@
 	Rectangle r;
 	char s[64];
 	Font *f;
-	Image *colora, *colorb;
 
 	sp.x = sp.y = 0;
-	colora = colorb = display->black;
-	if(inv)
-		colorb = display->white;
-	else
-		colora = display->white;
 
 	/* clear the old caption */
 	draw(screen, Rect(p.x, p.y, p.x+strsize.x, p.y+strsize.y), colora, nil, ZP);
@@ -251,7 +245,7 @@
 
 void main(int argc, char** argv)
 {
-	int key, p, i, oldbuttons, sidmax;
+	int key, p, i, oldbuttons, sidmax, inv;
 	Event e;
 	Mouse m;
 	Menu menu;
@@ -285,6 +279,9 @@
 	r = Rect(0, 0, 1, 1);
 	for(i = 0; i < NumColors; i++)
 		colors[i] = allocimage(display, r, CMAP8, 1, srccolors[i]);
+
+	colora = inv ? display->black : display->white;
+	colorb = inv ? display->white : display->black;
 
 	einit(Emouse);
 	menu.item = mstr;