trafficlight.h

Go to the documentation of this file.
00001 /* $Id: trafficlight.h $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00018 static const uint8 _tlc_distance[5] = {
00019 0,  
00020 8,  
00021 24, 
00022 48, 
00023 80  
00024 };
00025 
00026 /* TileDiffs for the eight adjacent tiles. */
00027 static const TileIndexDiffC _tl_check_offsets[80] = {
00028   /* Tiles next to this tile (8 tiles). */
00029   {-1, -1},
00030   { 0, -1},
00031   { 1, -1},
00032   { 1,  0},
00033   { 1,  1},
00034   { 0,  1},
00035   {-1,  1},
00036   {-1,  0},
00037   /* Tiles two tiles from this tile (16 tile). */
00038   {-2, -2},
00039   {-1, -2},
00040   { 0, -2},
00041   { 1, -2},
00042   { 2, -2},
00043   { 2, -1},
00044   { 2,  0},
00045   { 2,  1},
00046   { 2,  2},
00047   { 1,  2},
00048   { 0,  2},
00049   {-1,  2},
00050   {-2,  2},
00051   {-2,  1},
00052   {-2,  0},
00053   {-2, -1},
00054   /* Tiles three tiles from this tiles (24 tiles). */
00055   {-3, -3},
00056   {-3, -2},
00057   {-3, -1},
00058   {-3,  0},
00059   {-3,  1},
00060   {-3,  2},
00061   {-3,  3},
00062   {-2,  3},
00063   {-1,  3},
00064   { 0,  3},
00065   { 1,  3},
00066   { 2,  3},
00067   { 3,  3},
00068   { 3,  2},
00069   { 3,  1},
00070   { 3,  0},
00071   { 3, -1},
00072   { 3, -2},
00073   { 3, -3},
00074   { 2, -3},
00075   { 1, -3},
00076   { 0, -3},
00077   {-1, -3},
00078   {-2, -3},
00079   /* Tiles three tiles away from this tile (32 tiles). */
00080   {-4, -4},
00081   {-3, -4},
00082   {-2, -4},
00083   {-1, -4},
00084   { 0, -4},
00085   { 1, -4},
00086   { 2, -4},
00087   { 3, -4},
00088   { 4, -4},
00089   { 4, -3},
00090   { 4, -2},
00091   { 4, -1},
00092   { 4,  0},
00093   { 4,  1},
00094   { 4,  2},
00095   { 4,  3},
00096   { 4,  4},
00097   { 3,  4},
00098   { 2,  4},
00099   { 1,  4},
00100   { 0,  4},
00101   {-1,  4},
00102   {-2,  4},
00103   {-3,  4},
00104   {-4,  4},
00105   {-4,  3},
00106   {-4,  2},
00107   {-4,  1},
00108   {-4,  0},
00109   {-4, -1},
00110   {-4, -2},
00111   {-4, -3}
00112 };
00113 
00117 static const Point _tl_offsets[2][4] = {
00118   {{15, 1}, {14, 15}, {1, 0}, {0, 14}},  // Left side driving.
00119   {{15, 14}, {1, 15}, {14, 0}, {0, 1}}   // Right side driving.
00120 };
00121 
00125 static const SpriteID _tls_to_sprites[7][4] = {
00126   {SPR_TL_SW_NONE,       SPR_TL_SE_NONE,       SPR_TL_NW_NONE,       SPR_TL_NE_NONE},
00127   {SPR_TL_SW_GREEN,      SPR_TL_SE_RED,        SPR_TL_NW_RED,        SPR_TL_NE_GREEN},
00128   {SPR_TL_SW_YELLOW,     SPR_TL_SE_RED,        SPR_TL_NW_RED,        SPR_TL_NE_YELLOW},
00129   {SPR_TL_SW_RED,        SPR_TL_SE_RED_YELLOW, SPR_TL_NW_RED_YELLOW, SPR_TL_NE_RED},
00130   {SPR_TL_SW_RED,        SPR_TL_SE_GREEN,      SPR_TL_NW_GREEN,      SPR_TL_NE_RED},
00131   {SPR_TL_SW_RED,        SPR_TL_SE_YELLOW,     SPR_TL_NW_YELLOW,     SPR_TL_NE_RED},
00132   {SPR_TL_SW_RED_YELLOW, SPR_TL_SE_RED,        SPR_TL_NW_RED,        SPR_TL_NE_RED_YELLOW},
00133 };