(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
This commit is contained in:
bjarni
2005-11-18 23:41:03 +00:00
parent 65d9eb07a9
commit 16e65960b9
17 changed files with 615 additions and 243 deletions

View File

@@ -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