From 22a46798378768271af6b90cd41327155a909dd2 Mon Sep 17 00:00:00 2001 From: bjarni Date: Fri, 18 Nov 2005 23:41:03 +0000 Subject: (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 --- economy.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'economy.c') diff --git a/economy.c b/economy.c index 04aa5ad05..d595d13f4 100644 --- a/economy.c +++ b/economy.c @@ -26,6 +26,7 @@ #include "variables.h" #include "vehicle_gui.h" #include "ai/ai.h" +#include "train.h" // Score info const ScoreInfo _score_info[] = { @@ -129,7 +130,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update) FOR_ALL_VEHICLES(v) { if (v->owner != owner) continue; - if ((v->type == VEH_Train && v->subtype == TS_Front_Engine) || + if ((v->type == VEH_Train && IsFrontEngine(v)) || v->type == VEH_Road || (v->type == VEH_Aircraft && v->subtype<=2) || v->type == VEH_Ship) { @@ -313,7 +314,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player) if (v->owner == new_player) { switch (v->type) { case VEH_Train: - if (v->subtype == TS_Front_Engine) num_train++; + if (IsFrontEngine(v)) num_train++; break; case VEH_Road: num_road++; @@ -338,7 +339,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player) DeleteVehicle(v); } else { v->owner = new_player; - if (v->type == VEH_Train && v->subtype == TS_Front_Engine) + if (v->type == VEH_Train && IsFrontEngine(v)) v->unitnumber = ++num_train; else if (v->type == VEH_Road) v->unitnumber = ++num_road; @@ -1289,7 +1290,7 @@ static bool LoadWait(const Vehicle *v, const Vehicle *u) { } FOR_ALL_VEHICLES(x) { - if ((x->type != VEH_Train || x->subtype == TS_Front_Engine) && // for all locs + if ((x->type != VEH_Train || IsFrontEngine(x)) && // for all locs u->last_station_visited == x->last_station_visited && // at the same station !(x->vehstatus & VS_STOPPED) && // not stopped x->current_order.type == OT_LOADING && // loading -- cgit v1.2.3-54-g00ecf