Update readme.md
[openttd-joker.git] / src / base_consist.cpp
blobd6e4b4eaf71937029ec33a81ba71b719e7adedb0
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file base_consist.cpp Properties for front vehicles/consists. */
12 #include "stdafx.h"
13 #include "base_consist.h"
14 #include "vehicle_base.h"
15 #include "string_func.h"
17 #include "safeguards.h"
19 BaseConsist::~BaseConsist()
21 free(this->name);
24 /**
25 * Copy properties of other BaseConsist.
26 * @param src Source for copying
28 void BaseConsist::CopyConsistPropertiesFrom(const BaseConsist *src)
30 if (this == src) return;
32 free(this->name);
33 this->name = src->name != nullptr ? stredup(src->name) : nullptr;
35 this->current_order_time = src->current_order_time;
36 this->current_loading_time = src->current_loading_time;
37 this->lateness_counter = src->lateness_counter;
38 this->timetable_start = src->timetable_start;
40 this->service_interval = src->service_interval;
42 this->cur_real_order_index = src->cur_real_order_index;
43 this->cur_implicit_order_index = src->cur_implicit_order_index;
44 this->cur_timetable_order_index = src->cur_timetable_order_index;
46 if (HasBit(src->vehicle_flags, VF_TIMETABLE_STARTED)) SetBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
47 if (HasBit(src->vehicle_flags, VF_AUTOMATE_TIMETABLE)) SetBit(this->vehicle_flags, VF_AUTOMATE_TIMETABLE);
48 if (HasBit(src->vehicle_flags, VF_AUTOMATE_PRES_WAIT_TIME)) SetBit(this->vehicle_flags, VF_AUTOMATE_PRES_WAIT_TIME);
49 if (HasBit(src->vehicle_flags, VF_SERVINT_IS_PERCENT) != HasBit(this->vehicle_flags, VF_SERVINT_IS_PERCENT)) {
50 ToggleBit(this->vehicle_flags, VF_SERVINT_IS_PERCENT);
52 if (HasBit(src->vehicle_flags, VF_SERVINT_IS_CUSTOM)) SetBit(this->vehicle_flags, VF_SERVINT_IS_CUSTOM);