1 /* 2 * Copyright (c) 1997 - 2002 by Volker Meyer & Hansj�rg Malthaner 3 * 4 * This file is part of the Simutrans project under the artistic licence. 5 * 6 * node structure: 7 * 0 Name 8 * 1 Copyright 9 * 2 Image-list Background 10 * 3 Image-list Foreground 11 * 4 cursor(image 0) and icon (image 1) 12 *[ 5 Image-list Background - snow ] (if present) 13 *[ 6 Image-list Foreground - snow ] (if present) 14 *[ 7 (or 5 if no snow image) underground way ] (if present) 15 */ 16 17 #ifndef __TUNNEL_DESC_H 18 #define __TUNNEL_DESC_H 19 20 #include "../display/simimg.h" 21 #include "../simtypes.h" 22 #include "obj_base_desc.h" 23 #include "skin_desc.h" 24 #include "image_array.h" 25 #include "way_desc.h" 26 27 28 class tunnel_desc_t : public obj_desc_transport_infrastructure_t { 29 friend class tunnel_reader_t; 30 friend class tunnel_builder_t; // to convert the old tunnels to new ones 31 32 private: 33 static int slope_indices[81]; 34 35 /* number of seasons (0 = none, 1 = no snow/snow 36 */ 37 sint8 number_of_seasons; 38 39 /* has underground way image ? ( 0 = no, 1 = yes ) [way parameter] 40 */ 41 uint8 has_way; 42 43 /* Has broad portals? 44 */ 45 uint8 broad_portals; 46 47 public: get_background(slope_t::type slope,uint8 season,uint8 type)48 const image_t *get_background(slope_t::type slope, uint8 season, uint8 type ) const 49 { 50 const uint8 n = season && number_of_seasons == 1 ? 5 : 2; 51 return get_child<image_list_t>(n)->get_image(slope_indices[slope] + 4 * type); 52 } 53 get_background_id(slope_t::type slope,uint8 season,uint8 type)54 image_id get_background_id(slope_t::type slope, uint8 season, uint8 type ) const 55 { 56 const image_t *desc = get_background(slope, season, type ); 57 return desc != NULL ? desc->get_id() : IMG_EMPTY; 58 } 59 get_foreground(slope_t::type slope,uint8 season,uint8 type)60 const image_t *get_foreground(slope_t::type slope, uint8 season, uint8 type ) const 61 { 62 const uint8 n = season && number_of_seasons == 1 ? 6 : 3; 63 return get_child<image_list_t>(n)->get_image(slope_indices[slope] + 4 * type); 64 } 65 get_foreground_id(slope_t::type slope,uint8 season,uint8 type)66 image_id get_foreground_id(slope_t::type slope, uint8 season, uint8 type) const 67 { 68 const image_t *desc = get_foreground(slope, season, type ); 69 return desc != NULL ? desc->get_id() :IMG_EMPTY; 70 } 71 get_cursor()72 skin_desc_t const* get_cursor() const { return get_child<skin_desc_t>(4); } 73 74 waytype_t get_finance_waytype() const; 75 get_way_desc()76 const way_desc_t *get_way_desc() const 77 { 78 if(has_way) { 79 return get_child<way_desc_t>(5 + number_of_seasons * 2); 80 } 81 return NULL; 82 } 83 has_broad_portals()84 bool has_broad_portals() const { return (broad_portals != 0); }; 85 }; 86 87 #endif 88