1 /* 2 * Copyright (c) 2006 by prissi 3 * 4 * This file is part of the Simutrans project under the artistic licence. 5 * 6 * Module description: 7 * signs on roads and other ways 8 */ 9 10 #ifndef __ROADSIGN_DESC_H 11 #define __ROADSIGN_DESC_H 12 13 #include "obj_base_desc.h" 14 #include "image_list.h" 15 #include "skin_desc.h" 16 #include "../dataobj/ribi.h" 17 #include "../simtypes.h" 18 #include "../network/checksum.h" 19 20 21 /* 22 * Author: 23 * prissi 24 * 25 * Description: 26 * Road signs 27 * 28 * Child nodes: 29 * 0 Name 30 * 1 Copyright 31 * 2 Image list 32 */ 33 class roadsign_desc_t : public obj_desc_transport_infrastructure_t { 34 friend class roadsign_reader_t; 35 36 private: 37 uint16 flags; 38 39 sint8 offset_left; // default 14 40 41 uint16 min_speed; // 0 = no min speed 42 43 public: 44 enum types { 45 NONE = 0, 46 ONE_WAY = 1U << 0, 47 CHOOSE_SIGN = 1U << 1, 48 PRIVATE_ROAD = 1U << 2, 49 SIGN_SIGNAL = 1U << 3, 50 SIGN_PRE_SIGNAL = 1U << 4, 51 ONLY_BACKIMAGE = 1U << 5, 52 SIGN_LONGBLOCK_SIGNAL = 1U << 6, 53 END_OF_CHOOSE_AREA = 1U << 7, 54 SIGN_PRIORITY_SIGNAL = 1U << 8 55 }; 56 get_image_id(ribi_t::dir dir)57 image_id get_image_id(ribi_t::dir dir) const 58 { 59 image_t const* const image = get_child<image_list_t>(2)->get_image(dir); 60 return image != NULL ? image->get_id() : IMG_EMPTY; 61 } 62 get_count()63 uint16 get_count() const { return get_child<image_list_t>(2)->get_count(); } 64 get_cursor()65 skin_desc_t const* get_cursor() const { return get_child<skin_desc_t>(3); } 66 get_min_speed()67 uint16 get_min_speed() const { return min_speed; } 68 is_single_way()69 bool is_single_way() const { return (flags & ONE_WAY) != 0; } 70 is_private_way()71 bool is_private_way() const { return (flags & PRIVATE_ROAD) != 0; } 72 73 // return true for a traffic light is_traffic_light()74 bool is_traffic_light() const { return (get_count() > 4); } 75 is_choose_sign()76 bool is_choose_sign() const { return (flags & CHOOSE_SIGN) != 0; } 77 78 // return true for signal is_simple_signal()79 bool is_simple_signal() const { return (flags & ( 80 SIGN_SIGNAL | 81 SIGN_PRE_SIGNAL | 82 SIGN_PRIORITY_SIGNAL | 83 SIGN_LONGBLOCK_SIGNAL | 84 CHOOSE_SIGN)) == SIGN_SIGNAL; } 85 86 // return true for presignal is_pre_signal()87 bool is_pre_signal() const { return (flags & SIGN_PRE_SIGNAL) != 0; } 88 89 // return true for priority signal is_priority_signal()90 bool is_priority_signal() const { return (flags & SIGN_PRIORITY_SIGNAL) != 0; } 91 92 // return true for single track section signal is_longblock_signal()93 bool is_longblock_signal() const { return (flags & SIGN_LONGBLOCK_SIGNAL) != 0; } 94 is_end_choose_signal()95 bool is_end_choose_signal() const { return (flags & END_OF_CHOOSE_AREA) != 0; } 96 is_signal_type()97 bool is_signal_type() const 98 { 99 return (flags&( 100 SIGN_SIGNAL | 101 SIGN_PRE_SIGNAL | 102 SIGN_PRIORITY_SIGNAL | 103 SIGN_LONGBLOCK_SIGNAL) 104 ) != 0; 105 } 106 get_flags()107 uint16 get_flags() const { return flags; } 108 get_offset_left()109 sint8 get_offset_left() const { return offset_left; } 110 calc_checksum(checksum_t * chk)111 void calc_checksum(checksum_t *chk) const 112 { 113 obj_desc_transport_infrastructure_t::calc_checksum(chk); 114 chk->input(flags); 115 chk->input(min_speed); 116 } 117 }; 118 119 ENUM_BITSET(roadsign_desc_t::types) 120 121 #endif 122