1 /**
2  * @file
3  * Contains definition of convoi_t class
4  */
5 
6 #ifndef simconvoi_h
7 #define simconvoi_h
8 
9 #include "simtypes.h"
10 #include "simunits.h"
11 #include "simcolor.h"
12 #include "linehandle_t.h"
13 
14 #include "ifc/sync_steppable.h"
15 
16 #include "dataobj/route.h"
17 #include "vehicle/overtaker.h"
18 #include "tpl/array_tpl.h"
19 #include "tpl/minivec_tpl.h"
20 
21 #include "convoihandle_t.h"
22 #include "halthandle_t.h"
23 
24 #define MAX_MONTHS               12 // Max history
25 
26 class weg_t;
27 class depot_t;
28 class karte_ptr_t;
29 class player_t;
30 class vehicle_t;
31 class vehicle_desc_t;
32 class schedule_t;
33 class cbuffer_t;
34 
35 /**
36  * Base class for all vehicle consists. Convoys can be referenced by handles, see halthandle_t.
37  *
38  * @author Hj. Malthaner
39  */
40 class convoi_t : public sync_steppable, public overtaker_t
41 {
42 public:
43 	enum {
44 		CONVOI_CAPACITY = 0,       // the amount of ware that could be transported, theoretically
45 		CONVOI_TRANSPORTED_GOODS,  // the amount of ware that has been transported
46 		CONVOI_REVENUE,            // the income this CONVOI generated
47 		CONVOI_OPERATIONS,         // the cost of operations this CONVOI generated
48 		CONVOI_PROFIT,             // total profit of this convoi
49 		CONVOI_DISTANCE,           // total distance traveled this month
50 		CONVOI_MAXSPEED,           // average max. possible speed
51 		CONVOI_WAYTOLL,
52 		MAX_CONVOI_COST            // Total number of cost items
53 	};
54 
55 	/* Constants
56 	 * @author prissi
57 	 */
58 	enum { default_vehicle_length=4};
59 
60 	enum states {INITIAL,
61 		EDIT_SCHEDULE,
62 		ROUTING_1,
63 		DUMMY4,
64 		DUMMY5,
65 		NO_ROUTE,
66 		DRIVING,
67 		LOADING,
68 		WAITING_FOR_CLEARANCE,
69 		WAITING_FOR_CLEARANCE_ONE_MONTH,
70 		CAN_START,
71 		CAN_START_ONE_MONTH,
72 		SELF_DESTRUCT,
73 		WAITING_FOR_CLEARANCE_TWO_MONTHS,
74 		CAN_START_TWO_MONTHS,
75 		LEAVING_DEPOT,
76 		ENTERING_DEPOT,
77 		MAX_STATES
78 	};
79 
80 private:
81 	/**
82 	* Route of this convoi - a sequence of coordinates. Actually
83 	* the path of the first vehicle
84 	* @author Hj. Malthaner
85 	*/
86 	route_t route;
87 
88 	/**
89 	* assigned line
90 	* @author hsiegeln
91 	*/
92 	linehandle_t line;
93 
94 	/**
95 	* holds id of line with pending update
96 	* -1 if no pending update
97 	* @author hsiegeln
98 	*/
99 	linehandle_t line_update_pending;
100 
101 	/**
102 	* Name of the convoi.
103 	* @see set_name
104 	* @author V. Meyer
105 	*/
106 	uint8 name_offset;
107 	char name_and_id[128];
108 
109 	/**
110 	* All vehicle-schedule pointers point here
111 	* @author Hj. Malthaner
112 	*/
113 	schedule_t *schedule;
114 
115 	koord3d schedule_target;
116 
117 	/**
118 	* loading_level was minimum_loading before. Actual percentage loaded for loadable vehicles (station length!).
119 	* needed as int, since used by the gui
120 	* @author Volker Meyer
121 	* @date  12.06.2003
122 	*/
123 	sint32 loading_level;
124 
125 	/**
126 	* At which loading level is the train allowed to start? 0 during driving.
127 	* needed as int, since used by the gui
128 	* @author Volker Meyer
129 	* @date  12.06.2003
130 	*/
131 	sint32 loading_limit;
132 
133 	/**
134 	* The vehicles of this convoi
135 	*
136 	* @author Hj. Malthaner
137 	*/
138 	array_tpl<vehicle_t*> fahr;
139 
140 	/*
141 	 * a list of all catg_index, which can be transported by this convoy.
142 	 */
143 	minivec_tpl<uint8> goods_catg_index;
144 
145 	/**
146 	* Convoi owner
147 	* @author Hj. Malthaner
148 	*/
149 	player_t *owner;
150 
151 	/**
152 	* Current map
153 	* @author Hj. Malthaner
154 	*/
155 	static karte_ptr_t welt;
156 
157 	/**
158 	* the convoi is being withdrawn from service
159 	* @author kierongreen
160 	*/
161 	bool withdraw;
162 
163 	/**
164 	* nothing will be loaded onto this convoi
165 	* @author kierongreen
166 	*/
167 	bool no_load;
168 
169 	/**
170 	* the convoi caches its freight info; it is only recalculation after loading or resorting
171 	* @author prissi
172 	*/
173 	bool freight_info_resort;
174 
175 	// true, if at least one vehicle of a convoi is obsolete
176 	bool has_obsolete;
177 
178 	// true, if there is at least one engine that requires catenary
179 	bool is_electric;
180 
181 	/**
182 	* the convoi caches its freight info; it is only recalculation after loading or resorting
183 	* @author prissi
184 	*/
185 	uint8 freight_info_order;
186 
187 	/**
188 	* Number of vehicles in this convoi.
189 	* @author Hj. Malthaner
190 	*/
191 	uint8 anz_vehikel;
192 
193 	/* Number of steps the current convoi did already
194 	 * (only needed for leaving/entering depot)
195 	 */
196 	sint16 steps_driven;
197 
198 	/*
199 	 * caches the running costs
200 	 */
201 	sint32 sum_running_costs;
202 
203 	/**
204 	* Overall performance.
205 	* Not stored, but calculated from individual parts
206 	* @author Hj. Malthaner
207 	*/
208 	uint32 sum_power;
209 
210 	/**
211 	* Overall performance with Gear.
212 	* Not stored, but calculated from individual parts
213 	* @author prissi
214 	*/
215 	sint32 sum_gear_and_power;
216 
217 	/* sum_weight: unloaded weight of all vehicles *
218 	* sum_gesamtweight: total weight of all vehicles *
219 	* Not stored, but calculated from individual weights
220 	* when loading/driving.
221 	* @author Hj. Malthaner, prissi
222 	*/
223 	sint64 sum_weight;
224 	sint64 sum_gesamtweight;
225 
226 	bool recalc_data_front;  ///< true, when front vehicle has to recalculate braking
227 	bool recalc_data;        ///< true, when convoy has to recalculate weights and speed limits
228 	bool recalc_speed_limit; ///< true, when convoy has to recalculate speed limits
229 
230 	sint64 sum_friction_weight;
231 	sint32 speed_limit;
232 
233 	/**
234 	* Lowest top speed of all vehicles. Doesn't get saved, but calculated
235 	* from the vehicles data
236 	* @author Hj. Malthaner
237 	*/
238 	sint32 min_top_speed;
239 
240 	/**
241 	 * this give the index of the next signal or the end of the route
242 	 * convois will slow down before it, if this is not a waypoint or the cannot pass
243 	 * The slowdown is done by the vehicle routines
244 	 * @author prissi
245 	 */
246 	uint16 next_stop_index;
247 
248 	/**
249 	 * this give the index until which the route has been reserved. It is used for
250 	 * restoring reservations after loading a game.
251 	 * @author prissi
252 	 */
253 	uint16 next_reservation_index;
254 
255 	/**
256 	 * The convoi is not processed every sync step for various actions
257 	 * (like waiting before signals, loading etc.) Such action will only
258 	 * continue after a waiting time larger than wait_lock
259 	 * @author Hanjs�rg Malthaner
260 	 */
261 	sint32 wait_lock;
262 
263 	/**
264 	 * Time when convoi arrived at the current stop
265 	 * Used to calculate when it should depart due to the 'month wait time'
266 	 */
267 	uint32 arrived_time;
268 
269 	/**
270 	* accumulated profit over a year
271 	* @author Hanjs�rg Malthaner
272 	*/
273 	sint64 jahresgewinn;
274 
275 	/* the odometer */
276 	sint64 total_distance_traveled;
277 
278 	uint32 distance_since_last_stop; // number of tiles entered since last stop
279 	uint32 sum_speed_limit; // sum of the speed limits encountered since the last stop
280 
281 	sint32 speedbonus_kmh; // speed used for speedbonus calculation in km/h
282 	sint32 maxspeed_average_count;	// just a simple count to average for statistics
283 
284 	// things for the world record
285 	sint32 max_record_speed; // current convois fastest speed ever
286 	koord record_pos;
287 
288 	// needed for speed control/calculation
289 	sint32 brake_speed_soll;    // brake target speed
290 	sint32 akt_speed_soll;    // target speed
291 	sint32 akt_speed;	        // current speed
292 	sint32 sp_soll;           // steps to go
293 	sint32 previous_delta_v;  // Stores the previous delta_v value; otherwise these digits are lost during calculation and vehicle do not accelerate
294 
295 	uint32 next_wolke;	// time to next smoke
296 
297 	states state;
298 
299 	ribi_t::ribi alte_richtung;
300 
301 	/**
302 	* Initialize all variables with default values.
303 	* Each constructor must call this method first!
304 	* @author Hj. Malthaner
305 	*/
306 	void init(player_t *player);
307 
308 	/**
309 	* Calculate route from Start to Target Coordinate
310 	* @author Hanjs�rg Malthaner
311 	*/
312 	bool drive_to();
313 
314 	/**
315 	* Setup vehicles for moving in same direction than before
316 	* if the direction is the same as before
317 	* @author Hanjs�rg Malthaner
318 	*/
319 	bool can_go_alte_richtung();
320 
321 	/**
322 	 * remove all track reservations (trains only)
323 	 */
324 	void unreserve_route();
325 
326 	// reserve route until next_reservation_index
327 	void reserve_route();
328 
329 	/**
330 	* Mark first and last vehicle.
331 	* @author Hanjs�rg Malthaner
332 	*/
333 	void set_erstes_letztes();
334 
335 	// returns the index of the vehikel at position length (16=1 tile)
336 	int get_vehicle_at_length(uint16);
337 
338 	/**
339 	* calculate income for last hop
340 	* only used for entering depot or recalculating routes when a schedule window is opened
341 	* @author Hj. Malthaner
342 	*/
343 	void calc_gewinn();
344 
345 	/**
346 	* Recalculates loading level and limit.
347 	* While driving loading_limit will be set to 0.
348 	* @author Volker Meyer
349 	* @date  20.06.2003
350 	*/
351 	void calc_loading();
352 
353 	/* Calculates (and sets) akt_speed
354 	 * needed for driving, entering and leaving a depot)
355 	 */
356 	void calc_acceleration(uint32 delta_t);
357 
358 	/*
359 	* struct holds new financial history for convoi
360 	* @author hsiegeln
361 	*/
362 	sint64 financial_history[MAX_MONTHS][MAX_CONVOI_COST];
363 
364 	/**
365 	* initialize the financial history
366 	* @author hsiegeln
367 	*/
368 	void init_financial_history();
369 
370 	/**
371 	* the koordinate of the home depot of this convoi
372 	* the last depot visited is considered being the home depot
373 	* @author hsiegeln
374 	*/
375 	koord3d home_depot;
376 
377 	/**
378 	* unset line -> remove cnv from line
379 	* @author hsiegeln
380 	*/
381 	void unset_line();
382 
383 	// matches two halts; if the pos is not identical, maybe the halt still is
384 	bool matches_halt( const koord3d pos1, const koord3d pos2 );
385 
386 	/**
387 	 * Register the convoy with the stops in the schedule
388 	 * @author Knightly
389 	 */
390 	void register_stops();
391 
392 	/**
393 	 * Unregister the convoy from the stops in the schedule
394 	 * @author Knightly
395 	 */
396 	void unregister_stops();
397 
398 	uint32 move_to(uint16 start_index);
399 
400 public:
401 	/**
402 	* Convoi haelt an Haltestelle und setzt quote fuer Fracht
403 	* @author Hj. Malthaner
404 	*/
405 	void hat_gehalten(halthandle_t halt);
406 
get_route()407 	const route_t* get_route() const { return &route; }
access_route()408 	route_t* access_route() { return &route; }
409 
get_schedule_target()410 	const koord3d get_schedule_target() const { return schedule_target; }
set_schedule_target(koord3d t)411 	void set_schedule_target( koord3d t ) { schedule_target = t; }
412 
413 	/**
414 	* get line
415 	* @author hsiegeln
416 	*/
get_line()417 	linehandle_t get_line() const {return line;}
418 
419 	/* true, if electrification needed for this convoi */
needs_electrification()420 	bool needs_electrification() const { return is_electric; }
421 
422 	/**
423 	* set line
424 	* @author hsiegeln
425 	*/
426 	void set_line(linehandle_t );
427 
428 	// updates a line schedule and tries to find the best next station to go
429 	void check_pending_updates();
430 
431 	// true if this is a waypoint
432 	bool is_waypoint( koord3d ) const;
433 
434 	/* changes the state of a convoi via tool_t; mandatory for networkmode!
435 	 * for list of commands and parameter see tool_t::tool_change_convoi_t
436 	 */
437 	void call_convoi_tool( const char function, const char *extra ) const;
438 
439 	/**
440 	 * set state: only use by tool_t::tool_change_convoi_t
441 	 */
set_state(uint16 new_state)442 	void set_state( uint16 new_state ) { assert(new_state<MAX_STATES); state = (states)new_state; }
443 
444 	/**
445 	* get state
446 	* @author hsiegeln
447 	*/
get_state()448 	int get_state() const { return state; }
449 
450 	/**
451 	* true if in waiting state (maybe also due to starting)
452 	* @author hsiegeln
453 	*/
is_waiting()454 	bool is_waiting() { return (state>=WAITING_FOR_CLEARANCE  &&  state<=CAN_START_TWO_MONTHS)  &&  state!=SELF_DESTRUCT; }
455 
456 	/**
457 	* reset state to no error message
458 	* @author prissi
459 	*/
reset_waiting()460 	void reset_waiting() { state=WAITING_FOR_CLEARANCE; }
461 
462 	/**
463 	* The handle for ourselves. In Anlehnung an 'this' aber mit
464 	* allen checks beim Zugriff.
465 	* @author Hanjs�rg Malthaner
466 	*/
467 	convoihandle_t self;
468 
469 	/**
470 	 * The profit in this year
471 	 * @author Hanjs�rg Malthaner
472 	 */
get_jahresgewinn()473 	const sint64 & get_jahresgewinn() const {return jahresgewinn;}
474 
get_total_distance_traveled()475 	const sint64 & get_total_distance_traveled() const { return total_distance_traveled; }
476 
477 	/**
478 	 * @return the total monthly fix cost for all vehicles in convoi
479 	 */
480 	sint32 get_fix_cost() const;
481 
482 	/**
483 	 * returns the total running cost for all vehicles in convoi
484 	 * @author hsiegeln
485 	 */
486 	sint32 get_running_cost() const;
487 
488 	/**
489 	 * returns the total new purchase cost for all vehicles in convoy
490 	 */
491 	sint64 get_purchase_cost() const;
492 
493 	/**
494 	* Constructor for loading from file,
495 	* @author Hj. Malthaner
496 	*/
497 	convoi_t(loadsave_t *file);
498 
499 	convoi_t(player_t* player);
500 
501 	virtual ~convoi_t();
502 
503 	/**
504 	* Load or save this convoi data
505 	* @author Hj. Malthaner
506 	*/
507 	void rdwr(loadsave_t *file);
508 
509 	/**
510 	 * method to load/save convoihandle_t
511 	 */
512 	static void rdwr_convoihandle_t(loadsave_t *file, convoihandle_t &cnv);
513 
514 	void finish_rd();
515 
516 	void rotate90( const sint16 y_size );
517 
518 	/**
519 	* Called if a vehicle enters a depot
520 	* @author Hanjs�rg Malthaner
521 	*/
522 	void betrete_depot(depot_t *dep);
523 
524 	/**
525 	* Return the internal name of the convois
526 	* @return Name of the convois
527 	* @author Hj. Malthaner
528 	*/
get_internal_name()529 	const char *get_internal_name() const {return name_and_id+name_offset;}
530 
531 	/**
532 	* Allows editing ...
533 	* @return Name of the Convois
534 	* @author Hj. Malthaner
535 	*/
access_internal_name()536 	char *access_internal_name() {return name_and_id+name_offset;}
537 
538 	/**
539 	* Return the name of the convois
540 	* @return Name of the convois
541 	* @author Hj. Malthaner
542 	*/
get_name()543 	const char *get_name() const {return name_and_id;}
544 
545 	/**
546 	* Sets the name. Copies name into this->name and translates it.
547 	* @author V. Meyer
548 	*/
549 	void set_name(const char *name, bool with_new_id = true);
550 
551 	/**
552 	 * Return the position of the convois.
553 	 * @return Position of the convois
554 	 * @author Hj. Malthaner
555 	 */
556 	koord3d get_pos() const;
557 
558 	/**
559 	 * @return current speed, this might be different from topspeed
560 	 *         actual currently set speed.
561 	 * @author Hj. Malthaner
562 	 */
get_akt_speed()563 	const sint32& get_akt_speed() const { return akt_speed; }
564 
565 	/**
566 	 * @return total power of this convoi
567 	 * @author Hj. Malthaner
568 	 */
get_sum_power()569 	const uint32 & get_sum_power() const {return sum_power;}
get_min_top_speed()570 	const sint32 & get_min_top_speed() const {return min_top_speed;}
get_speed_limit()571 	const sint32 & get_speed_limit() const {return speed_limit;}
572 
set_speed_limit(sint32 s)573 	void set_speed_limit(sint32 s) { speed_limit = s;}
574 
575 	/// @returns weight of the convoy's vehicles (excluding freight)
get_sum_weight()576 	const sint64 & get_sum_weight() const {return sum_weight;}
577 
578 	/// @returns weight of convoy including freight
get_sum_gesamtweight()579 	const sint64 & get_sum_gesamtweight() const {return sum_gesamtweight;}
580 
581 	/// changes sum_friction_weight, called when vehicle changed tile and friction changes as well.
update_friction_weight(sint64 delta_friction_weight)582 	void update_friction_weight(sint64 delta_friction_weight) { sum_friction_weight += delta_friction_weight; }
583 
584 	/// @returns theoretical max speed of a convoy with given @p total_power and @p total_weight
585 	static sint32 calc_max_speed(uint64 total_power, uint64 total_weight, sint32 speed_limit);
586 
587 	uint32 get_length() const;
588 
589 	/**
590 	 * @return length of convoi in the correct units for movement
591 	 * @author neroden
592 	 */
get_length_in_steps()593 	uint32 get_length_in_steps() const { return get_length() * VEHICLE_STEPS_PER_CARUNIT; }
594 
595 	/**
596 	 * Add the costs for travelling one tile
597 	 * @author Hj. Malthaner
598 	 */
599 	void add_running_cost( const weg_t *weg );
600 
601 	/**
602 	 * moving the vehicles of a convoi and acceleration/deceleration
603 	 * all other stuff => convoi_t::step()
604 	 * @author Hj. Malthaner
605 	 */
606 	sync_result sync_step(uint32 delta_t) OVERRIDE;
607 
608 	/**
609 	 * All things like route search or loading, that may take a little
610 	 * @author Hj. Malthaner
611 	 */
612 	void step();
613 
614 	/**
615 	* sets a new convoi in route
616 	* @author Hj. Malthaner
617 	*/
618 	void start();
619 
620 	void ziel_erreicht(); ///< Called, when the first vehicle reaches the target
621 
622 	/**
623 	* When a vehicle has detected a problem
624 	* force calculate a new route
625 	* @author Hanjs�rg Malthaner
626 	*/
627 	void suche_neue_route();
628 
629 	/**
630 	* Wait until vehicle 0 reports free route
631 	* will be called during a hop_check, if the road/track is blocked
632 	* @author Hj. Malthaner
633 	*/
634 	void warten_bis_weg_frei(sint32 restart_speed);
635 
636 	/**
637 	* @return Vehicle count
638 	* @author Hj. Malthaner
639 	*/
get_vehicle_count()640 	uint8 get_vehicle_count() const { return anz_vehikel; }
641 
642 	/**
643 	 * @return Vehicle at position i
644 	 */
get_vehikel(uint16 i)645 	vehicle_t* get_vehikel(uint16 i) const { return fahr[i]; }
646 
front()647 	vehicle_t* front() const { return fahr[0]; }
648 
back()649 	vehicle_t* back() const { return fahr[anz_vehikel - 1]; }
650 
651 	/**
652 	* Adds a vehicle at the start or end of the convoi.
653 	* @author Hj. Malthaner
654 	*/
655 	bool add_vehikel(vehicle_t *v, bool infront = false);
656 
657 	/**
658 	* Removes vehicles at position i
659 	* @author Hj. Malthaner
660 	*/
661 	vehicle_t * remove_vehikel_bei(unsigned short i);
662 
get_goods_catg_index()663 	const minivec_tpl<uint8> &get_goods_catg_index() const { return goods_catg_index; }
664 
665 	// recalculates the good transported by this convoy and (in case of changes) will start schedule recalculation
666 	void recalc_catg_index();
667 
668 	/**
669 	* Sets a schedule
670 	* @author Hj. Malthaner
671 	*/
672 	bool set_schedule(schedule_t *f);
673 
674 	/**
675 	* @return Current schedule
676 	* @author Hj. Malthaner
677 	*/
get_schedule()678 	schedule_t* get_schedule() const { return schedule; }
679 
680 	/**
681 	* Creates a new schedule if there isn't one already.
682 	* @return Current schedule
683 	* @author Hj. Malthaner
684 	*/
685 	schedule_t * create_schedule();
686 
687 	// remove wrong freight when schedule changes etc.
688 	void check_freight();
689 
690 	/**
691 	* @return Owner of this convoi
692 	* @author Hj. Malthaner
693 	*/
get_owner()694 	player_t * get_owner() const { return owner; }
695 
696 	/**
697 	* Opens an information window
698 	* @author Hj. Malthaner
699 	* @see simwin
700 	*/
701 	void open_info_window();
702 
703 	/**
704 	* @return a description string for the object, der z.B. in einem
705 	* Beobachtungsfenster angezeigt wird.
706 	* @author Hj. Malthaner
707 	* @see simwin
708 	*/
709 	void info(cbuffer_t & buf) const;
710 
711 	/**
712 	* @param buf the buffer to fill
713 	* @return Freight description text (buf)
714 	* @author Hj. Malthaner
715 	*/
716 	void get_freight_info(cbuffer_t & buf);
717 	void set_sortby(uint8 order);
get_sortby()718 	uint8 get_sortby() const { return freight_info_order; }
719 
720 	/**
721 	* Opens the schedule window
722 	* @author Hj. Malthaner
723 	* @see simwin
724 	*/
725 	void open_schedule_window( bool show );
726 
727 	/**
728 	* pruefe ob Beschraenkungen fuer alle Fahrzeuge erfuellt sind
729 	* @author Hj. Malthaner
730 	*/
731 	bool pruefe_alle();
732 
733 	/**
734 	* Control loading and unloading
735 	* V.Meyer: returns nothing
736 	* @author Hj. Malthaner
737 	*/
738 	void laden();
739 
740 	/**
741 	* Setup vehicles before starting to move
742 	* @author Hanjs�rg Malthaner
743 	*/
744 	void vorfahren();
745 
746 	/**
747 	* Calculate the total value of the convoi as the sum of all vehicle values.
748 	* @author Volker Meyer
749 	* @date  09.06.2003
750 	*/
751 	sint64 calc_restwert() const;
752 
753 	/**
754 	* Check if this convoi has entered a depot.
755 	* @author Volker Meyer
756 	* @date  09.06.2003
757 	*/
in_depot()758 	bool in_depot() const { return state == INITIAL; }
759 
760 	/**
761 	* loading_level was minimum_loading before. Actual percentage loaded of loadable
762 	* vehicles.
763 	* @author Volker Meyer
764 	* @date  12.06.2003
765 	*/
get_loading_level()766 	const sint32 &get_loading_level() const { return loading_level; }
767 
768 	/**
769 	* At which loading level is the train allowed to start? 0 during driving.
770 	* @author Volker Meyer
771 	* @date  12.06.2003
772 	*/
get_loading_limit()773 	const sint32 &get_loading_limit() const { return loading_limit; }
774 
775 	/**
776 	* Schedule convois for self destruction. Will be executed
777 	* upon next sync step
778 	* @author Hj. Malthaner
779 	*/
780 	void self_destruct();
781 
782 	/**
783 	* Helper method to remove convois from the map that cannot
784 	* removed normally (i.e. by sending to a depot) anymore.
785 	* This is a workaround for bugs in the game.
786 	* @author Hj. Malthaner
787 	* @date  12-Jul-03
788 	*/
789 	void destroy();
790 
791 	/**
792 	* Debug info to stderr
793 	* @author Hj. Malthaner
794 	* @date 04-Sep-03
795 	*/
796 	void dump() const;
797 
798 	/**
799 	* book a certain amount into the convois financial history
800 	* is called from vehicle during un/load
801 	* @author hsiegeln
802 	*/
803 	void book(sint64 amount, int cost_type);
804 
805 	/**
806 	* return a pointer to the financial history
807 	* @author hsiegeln
808 	*/
get_finance_history()809 	sint64* get_finance_history() { return *financial_history; }
810 
811 	/**
812 	* return a specified element from the financial history
813 	* @author hsiegeln
814 	*/
get_finance_history(int month,int cost_type)815 	sint64 get_finance_history(int month, int cost_type) const { return financial_history[month][cost_type]; }
816 	sint64 get_stat_converted(int month, int cost_type) const;
817 
818 	/**
819 	* only purpose currently is to roll financial history
820 	* @author hsiegeln
821 	*/
822 	void new_month();
823 
824 	/**
825 	 * Method for yearly action
826 	 * @author Hj. Malthaner
827 	 */
828 	void new_year();
829 
set_update_line(linehandle_t l)830 	void set_update_line(linehandle_t l) { line_update_pending = l; }
831 
set_home_depot(koord3d hd)832 	void set_home_depot(koord3d hd) { home_depot = hd; }
833 
get_home_depot()834 	koord3d get_home_depot() { return home_depot; }
835 
836 	/**
837 	 * Sends convoi to nearest depot.
838 	 * Has to be called synchronously on all clients in networkmode!
839 	 * @returns success message
840 	 */
841 	const char* send_to_depot(bool local);
842 
843 	/**
844 	 * this give the index of the next signal or the end of the route
845 	 * convois will slow down before it, if this is not a waypoint or the cannot pass
846 	 * The slowdown is done by the vehicle routines
847 	 * @author prissi
848 	 */
get_next_stop_index()849 	uint16 get_next_stop_index() const {return next_stop_index;}
850 	void set_next_stop_index(uint16 n);
851 
852 	/* including this route_index, the route was reserved the last time
853 	 * currently only used for tracks
854 	 */
get_next_reservation_index()855 	uint16 get_next_reservation_index() const {return next_reservation_index;}
856 	void set_next_reservation_index(uint16 n);
857 
858 	/* the current state of the convoi */
859 	PIXVAL get_status_color() const;
860 
861 	// returns tiles needed for this convoi
862 	uint16 get_tile_length() const;
863 
has_obsolete_vehicles()864 	bool has_obsolete_vehicles() const { return has_obsolete; }
865 
get_withdraw()866 	bool get_withdraw() const { return withdraw; }
867 
868 	void set_withdraw(bool new_withdraw);
869 
get_no_load()870 	bool get_no_load() const { return no_load; }
871 
set_no_load(bool new_no_load)872 	void set_no_load(bool new_no_load) { no_load = new_no_load; }
873 
must_recalc_data()874 	void must_recalc_data() { recalc_data = true; }
must_recalc_data_front()875 	void must_recalc_data_front() { recalc_data_front = true; }
must_recalc_speed_limit()876 	void must_recalc_speed_limit() { recalc_speed_limit = true; }
877 
878 	// calculates the speed used for the speedbonus base, and the max achievable speed at current power/weight for overtakers
879 	void calc_speedbonus_kmh();
880 	sint32 get_speedbonus_kmh() const;
881 
882 	// just a guess of the speed
883 	uint32 get_average_kmh() const;
884 
885 	// Overtaking for convois
886 	bool can_overtake(overtaker_t *other_overtaker, sint32 other_speed, sint16 steps_other) OVERRIDE;
887 };
888 
889 #endif
890