summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-03-25 08:13:07 +0000
committerpeter1138 <peter1138@openttd.org>2007-03-25 08:13:07 +0000
commite74169364c92bb51d4ed4549fbd5cd3f44440952 (patch)
treed8af35e14ba602a5965636a5bf47c3a2c3c0bc8c /src
parent0a3719fb72de55f0535cc55a4aa2bfb52bedbd17 (diff)
downloadopenttd-e74169364c92bb51d4ed4549fbd5cd3f44440952.tar.xz
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 535e49387..1c853bb36 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -261,6 +261,20 @@ static StringID MapGRFStringID(uint32 grfid, StringID str)
return str;
}
+static uint8 MapDOSColour(uint8 colour)
+{
+ if (_use_dos_palette) return colour;
+
+ if (colour < 10) {
+ static uint8 dos_to_win_colour_map[] = { 0, 215, 216, 136, 88, 106, 32, 33, 40, 245 };
+ return dos_to_win_colour_map[colour];
+ }
+
+ if (colour >= 245 && colour < 254) return colour - 28;
+
+ return colour;
+}
+
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len);
@@ -1605,11 +1619,11 @@ static bool CargoChangeInfo(uint cid, int numinfo, int prop, byte **bufp, int le
break;
case 0x13: /* Colour for station rating bars */
- FOR_EACH_OBJECT cs[i].rating_colour = grf_load_byte(&buf);
+ FOR_EACH_OBJECT cs[i].rating_colour = MapDOSColour(grf_load_byte(&buf));
break;
case 0x14: /* Colour for cargo graph */
- FOR_EACH_OBJECT cs[i].legend_colour = grf_load_byte(&buf);
+ FOR_EACH_OBJECT cs[i].legend_colour = MapDOSColour(grf_load_byte(&buf));
break;
case 0x15: /* Freight status */