It's certain that the colors in terrain.txt can't correspond to the colors in terrain.bmp. In the bottom of terrain.txt, there are 2 entries for plains (color indexes 0 and 2), 5 for mountains (4,7,9,10,11), and 3 for coastal desert (13, 14, 15). But in the top, only 1 actual color is defined for each terrain type. Additionally, some terrain types in the top of the file (pti, inland ocean, woods, impassable mountains, marsh) don't appear in the color index list at all. So correspondence is literally impossible. The colors in the terrain definitions are probably a left-over from older games, not actually used anymore, or at least not used for this purpose.