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 7 #ifndef __CROSSING_DESC_H 8 #define __CROSSING_DESC_H 9 10 #include "obj_base_desc.h" 11 #include "image.h" 12 #include "image_list.h" 13 #include "../simtypes.h" 14 #include "../network/checksum.h" 15 16 17 class checksum_t; 18 19 /* 20 * Author: 21 * Volker Meyer 22 * 23 * Child nodes: 24 * 0 Name 25 * 1 Copyright 26 * 2 Image-list 27 */ 28 class crossing_desc_t : public obj_desc_timelined_t { 29 friend class crossing_reader_t; 30 31 private: 32 waytype_t waytype1; 33 waytype_t waytype2; 34 35 sint8 sound; 36 37 uint32 closed_animation_time; 38 uint32 open_animation_time; 39 40 sint32 topspeed1; // the topspeed depeds strongly on the crossing ... 41 sint32 topspeed2; 42 43 public: 44 /* the imagelists are: 45 * open_ns 46 * open_ew 47 * front_open_ns 48 * front_open_ew 49 * closed_ns 50 * .... 51 * =>ns=0 NorthSouth ns=1, East-West 52 */ get_background(uint8 ns,bool open,uint16 phase)53 const image_t *get_background(uint8 ns, bool open, uint16 phase) const 54 { 55 if(open) { 56 return get_child<image_list_t>(2 + ns)->get_image(phase); 57 } 58 else { 59 image_list_t const* const imglist = get_child<image_list_t>(6 + ns); 60 return imglist ? imglist->get_image(phase) : NULL; 61 } 62 } 63 get_foreground(uint8 ns,bool open,uint16 phase)64 const image_t *get_foreground(uint8 ns, bool open, uint16 phase) const 65 { 66 uint8 const n = ns + (open ? 4 : 8); 67 image_list_t const* const imglist = get_child<image_list_t>(n); 68 return imglist ? imglist->get_image(phase) : 0; 69 } 70 get_waytype(int i)71 waytype_t get_waytype(int i) const { return i==0? waytype1 : waytype2; } get_maxspeed(int i)72 sint32 get_maxspeed(int i) const { return i==0 ? topspeed1 : topspeed2; } get_phases(bool open,bool front)73 uint16 get_phases(bool open, bool front) const { return get_child<image_list_t>(6 - 4 * open + 2 * front)->get_count(); } get_animation_time(bool open)74 uint32 get_animation_time(bool open) const { return open ? open_animation_time : closed_animation_time; } 75 get_sound()76 sint8 get_sound() const { return sound; } 77 calc_checksum(checksum_t * chk)78 void calc_checksum(checksum_t *chk) const 79 { 80 chk->input(waytype1); 81 chk->input(waytype2); 82 chk->input(closed_animation_time); 83 chk->input(open_animation_time); 84 chk->input(topspeed1); 85 chk->input(topspeed2); 86 chk->input(intro_date); 87 chk->input(retire_date); 88 } 89 }; 90 91 #endif 92