summaryrefslogtreecommitdiff
path: root/vehicle_gui.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-11-18 23:41:03 +0000
committerbjarni <bjarni@openttd.org>2005-11-18 23:41:03 +0000
commit22a46798378768271af6b90cd41327155a909dd2 (patch)
tree3dd0d12983f0eaa08af460475f1f8b0a2c961d75 /vehicle_gui.c
parent40ec9bb1235a2231f0c883baaae73e106c67f1cf (diff)
downloadopenttd-22a46798378768271af6b90cd41327155a909dd2.tar.xz
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
This means that any user attempt to remove a rear engine will tell the user to move the front engine instead This fixes the assert when moving multiheaded engines (introduced in r3144) Note: to make old savegames use this feature, some engines might be turned around in order to link engines in pairs -Codechange: train subtype is now a bitmask This allows fast access to info like if it is a wagon or engine and if it is in front and so on Note: savegame version bump
Diffstat (limited to 'vehicle_gui.c')
-rw-r--r--vehicle_gui.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c
index f5f9fe5f4..21ea66c32 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -18,6 +18,7 @@
#include "variables.h"
#include "vehicle_gui.h"
#include "viewport.h"
+#include "train.h"
Sorting _sorting;
@@ -105,7 +106,7 @@ void ResortVehicleLists(void)
void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID station)
{
- uint subtype = (type != VEH_Aircraft) ? TS_Front_Engine : 2;
+ uint subtype = (type != VEH_Aircraft) ? Train_Front : 2;
uint n = 0;
uint i;
@@ -122,7 +123,9 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
if (station != INVALID_STATION) {
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
- if (v->type == type && v->subtype <= subtype) {
+ if (v->type == type && (
+ (type == VEH_Train && IsFrontEngine(v)) ||
+ (type != VEH_Train && v->subtype <= subtype))) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
@@ -138,7 +141,9 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
} else {
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
- if (v->type == type && v->subtype <= subtype && v->owner == owner) {
+ if (v->type == type && v->owner == owner && (
+ (type == VEH_Train && IsFrontEngine(v)) ||
+ (type != VEH_Train && v->subtype <= subtype))) {
_vehicle_sort[n].index = v->index;
_vehicle_sort[n].owner = v->owner;
++n;