OpenTTD
base_consist.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * 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.
4  * 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.
5  * 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/>.
6  */
7 
10 #include "stdafx.h"
11 #include "base_consist.h"
12 #include "vehicle_base.h"
13 #include "string_func.h"
14 
15 #include "safeguards.h"
16 
17 BaseConsist::~BaseConsist()
18 {
19  free(this->name);
20 }
21 
27 {
28  if (this == src) return;
29 
30  free(this->name);
31  this->name = src->name != nullptr ? stredup(src->name) : nullptr;
32 
35  this->timetable_start = src->timetable_start;
36 
38 
41 
47  }
49 }
Whether the vehicle has started running on the timetable yet.
Definition: vehicle_base.h:45
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
uint32 current_order_time
How many ticks have passed since this order started.
Definition: base_consist.h:21
int32 lateness_counter
How many ticks late (or early if negative) this vehicle is.
Definition: base_consist.h:22
uint16 service_interval
The interval for (automatic) servicing; either in days or %.
Definition: base_consist.h:25
Functions related to low-level strings.
Various front vehicle properties that are preserved when autoreplacing, using order-backup or switchi...
Definition: base_consist.h:17
Definition of base types and functions in a cross-platform compatible way.
void CopyConsistPropertiesFrom(const BaseConsist *src)
Copy properties of other BaseConsist.
A number of safeguards to prevent using unsafe methods.
Service interval is custom.
Definition: vehicle_base.h:50
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Definition: string.cpp:136
Whether the vehicle should fill in the timetable automatically.
Definition: vehicle_base.h:46
Properties for front vehicles/consists.
Date timetable_start
When the vehicle is supposed to start the timetable.
Definition: base_consist.h:23
char * name
Name of vehicle.
Definition: base_consist.h:18
Base class for all vehicles.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: depend.cpp:129
uint16 vehicle_flags
Used for gradual loading and other miscellaneous things (.
Definition: base_consist.h:30
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Whether non-destructive auto-fill should preserve waiting times.
Definition: vehicle_base.h:47
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
Definition: base_consist.h:28
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
Definition: base_consist.h:27
Service interval is percent.
Definition: vehicle_base.h:51