diff options
author | rubidium <rubidium@openttd.org> | 2011-02-04 15:40:35 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-02-04 15:40:35 +0000 |
commit | c85d350310d220885e07a5eed327110a4169f56b (patch) | |
tree | 2cc633d0b25bd501d2f8022856746a3be6f7c0c1 /src/train_cmd.cpp | |
parent | 46b3d114a828916226d66ec7536af9f62948759a (diff) | |
download | openttd-c85d350310d220885e07a5eed327110a4169f56b.tar.xz |
(svn r21960) -Change: show the length of vehicles in tiles, instead of half tiles in the depot
-Fix [FS#4461]: don't count the number of vehicles but the length of vehicles to (configurably) limit train length
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 58f19b6bf..139a7faa8 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -944,20 +944,21 @@ static CommandCost CheckTrainAttachment(Train *t) /* The maximum length for a train. For each part we decrease this by one * and if the result is negative the train is simply too long. */ - int allowed_len = _settings_game.vehicle.mammoth_trains ? 100 : 10; + int allowed_len = _settings_game.vehicle.max_train_length * TILE_SIZE - t->gcache.cached_veh_length; Train *head = t; Train *prev = t; /* Break the prev -> t link so it always holds within the loop. */ t = t->Next(); - allowed_len--; prev->SetNext(NULL); /* Make sure the cache is cleared. */ head->InvalidateNewGRFCache(); while (t != NULL) { + allowed_len -= t->gcache.cached_veh_length; + Train *next = t->Next(); /* Unlink the to-be-added piece; it is already unlinked from the previous @@ -966,8 +967,6 @@ static CommandCost CheckTrainAttachment(Train *t) /* Don't check callback for articulated or rear dual headed parts */ if (!t->IsArticulatedPart() && !t->IsRearDualheaded()) { - allowed_len--; // We do not count articulated parts and rear heads either. - /* Back up and clear the first_engine data to avoid using wagon override group */ EngineID first_engine = t->gcache.first_engine; t->gcache.first_engine = INVALID_ENGINE; @@ -1002,7 +1001,7 @@ static CommandCost CheckTrainAttachment(Train *t) t = next; } - if (allowed_len <= 0) return_cmd_error(STR_ERROR_TRAIN_TOO_LONG); + if (allowed_len < 0) return_cmd_error(STR_ERROR_TRAIN_TOO_LONG); return CommandCost(); } |