OpenTTD
base_consist.cpp
Go to the documentation of this file.
1 /* $Id: base_consist.cpp 27280 2015-05-11 16:40:06Z frosch $ */
2 
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  */
9 
12 #include "stdafx.h"
13 #include "base_consist.h"
14 #include "vehicle_base.h"
15 #include "string_func.h"
16 
17 #include "safeguards.h"
18 
19 BaseConsist::~BaseConsist()
20 {
21  free(this->name);
22 }
23 
29 {
30  if (this == src) return;
31 
32  free(this->name);
33  this->name = src->name != NULL ? stredup(src->name) : NULL;
34 
37  this->timetable_start = src->timetable_start;
38 
40 
43 
49  }
51 }
Whether the vehicle has started running on the timetable yet.
Definition: vehicle_base.h:47
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:23
int32 lateness_counter
How many ticks late (or early if negative) this vehicle is.
Definition: base_consist.h:24
uint16 service_interval
The interval for (automatic) servicing; either in days or %.
Definition: base_consist.h:27
Functions related to low-level strings.
Various front vehicle properties that are preserved when autoreplacing, using order-backup or switchi...
Definition: base_consist.h:19
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:52
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Definition: string.cpp:126
Whether the vehicle should fill in the timetable automatically.
Definition: vehicle_base.h:48
Properties for front vehicles/consists.
Date timetable_start
When the vehicle is supposed to start the timetable.
Definition: base_consist.h:25
char * name
Name of vehicle.
Definition: base_consist.h:20
Base class for all vehicles.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: depend.cpp:114
uint16 vehicle_flags
Used for gradual loading and other miscellaneous things (.
Definition: base_consist.h:32
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:49
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
Definition: base_consist.h:30
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
Definition: base_consist.h:29
Service interval is percent.
Definition: vehicle_base.h:53