(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
authordominik
Tue, 14 Dec 2004 20:54:01 +0000
changeset 657 40a9032b454b
parent 656 01540e6c0fed
child 658 ed6a0ea93a6c
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
gfx.c
gfx.h
viewport.c
--- a/gfx.c	Tue Dec 14 20:27:00 2004 +0000
+++ b/gfx.c	Tue Dec 14 20:54:01 2004 +0000
@@ -492,7 +492,7 @@
 
 		if (color != 0xFF) {
 switch_color:;
-			if (real_color & 0x100) {
+			if (real_color & IS_PALETTE_COLOR) {
 				_string_colorremap[1] = color;
 				_string_colorremap[2] = 215;
 			} else {
@@ -1976,5 +1976,5 @@
 	//  of the player
 	if (player == OWNER_SPECTATOR || player == OWNER_SPECTATOR - 1)
 			return 1;
-	return (_color_list[_player_colors[player]].window_color_1b) | 0x100;
+	return (_color_list[_player_colors[player]].window_color_1b) | IS_PALETTE_COLOR;
 }
--- a/gfx.h	Tue Dec 14 20:27:00 2004 +0000
+++ b/gfx.h	Tue Dec 14 20:54:01 2004 +0000
@@ -111,4 +111,9 @@
 extern byte _palettes[4][256 * 3];
 VARDEF byte _cur_palette[768];
 
+
+typedef enum StringColorFlags {
+	IS_PALETTE_COLOR = 0x100, // color value is already a real palette color index, not an index of a StringColor
+} StringColorFlags;
+
 #endif
--- a/viewport.c	Tue Dec 14 20:27:00 2004 +0000
+++ b/viewport.c	Tue Dec 14 20:54:01 2004 +0000
@@ -1111,20 +1111,9 @@
 		SetDParam(0, ss->params[0]);
 		SetDParam(1, ss->params[1]);
 		if (_display_opt & DO_TRANS_BUILDINGS && ss->width != 0) {
-			/* This is such a frustrating mess - I need to convert
-			 * from real color codes to string color codes and guess
-			 * what, they are completely different. --pasky */
-			static const byte ci2sci[17] = {
-				/*  0 */ 16, /*  1 */  0, /*  2 */  5,
-				/*  3X*/  2, /*  4 */  8, /*  5 */  3,
-				/*  6X*/ 14, /*  7 */  7, /*  8 */  9,
-				/*  9 */ 13, /* 10 */ 10, /* 11 */ 15,
-				/* 12 */  4, /* 13 */  6, /* 14 */ 11,
-				/* 15 */  1, /* 16 */ 12
-			};
-			byte color = ci2sci[ss->color + 1];
-
-			DrawString(ss->x >> zoom, (ss->y >> zoom) - (ss->width&0x8000?2:0), ss->string, color);
+			/* Real colors need the IS_PALETTE_COLOR flag, otherwise colors from _string_colormap are assumed. */
+			DrawString(ss->x >> zoom, (ss->y >> zoom) - (ss->width&0x8000?2:0), ss->string, 
+			           (_color_list[ss->color].window_color_bgb | IS_PALETTE_COLOR));
 		} else {
 			DrawString(ss->x >> zoom, (ss->y >> zoom) - (ss->width&0x8000?2:0), ss->string, 16);
 		}