diff options
author | tron <tron@openttd.org> | 2005-12-29 12:42:59 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-12-29 12:42:59 +0000 |
commit | 246c126d250171bd69f66080dbc25fafef6a46d2 (patch) | |
tree | 471052da802f2cc20f631ca0291f7337c78cd45d | |
parent | 1ffc70079787954dda1182de89eca25f36837490 (diff) | |
download | openttd-246c126d250171bd69f66080dbc25fafef6a46d2.tar.xz |
(svn r3353) Simplify the automatic length adjustment algorithm for replacing trains: Use the length of the train before the replacement as reference length
-rw-r--r-- | lang/brazilian_portuguese.txt | 1 | ||||
-rw-r--r-- | lang/catalan.txt | 1 | ||||
-rw-r--r-- | lang/czech.txt | 1 | ||||
-rw-r--r-- | lang/danish.txt | 1 | ||||
-rw-r--r-- | lang/dutch.txt | 1 | ||||
-rw-r--r-- | lang/english.txt | 2 | ||||
-rw-r--r-- | lang/french.txt | 1 | ||||
-rw-r--r-- | lang/german.txt | 1 | ||||
-rw-r--r-- | lang/italian.txt | 1 | ||||
-rw-r--r-- | lang/norwegian.txt | 1 | ||||
-rw-r--r-- | lang/polish.txt | 1 | ||||
-rw-r--r-- | lang/portuguese.txt | 1 | ||||
-rw-r--r-- | lang/romanian.txt | 1 | ||||
-rw-r--r-- | lang/slovak.txt | 1 | ||||
-rw-r--r-- | lang/spanish.txt | 1 | ||||
-rw-r--r-- | lang/turkish.txt | 1 | ||||
-rw-r--r-- | openttd.c | 14 | ||||
-rw-r--r-- | order_cmd.c | 4 | ||||
-rw-r--r-- | station.h | 5 | ||||
-rw-r--r-- | station_cmd.c | 5 | ||||
-rw-r--r-- | train_cmd.c | 24 | ||||
-rw-r--r-- | vehicle.c | 24 | ||||
-rw-r--r-- | vehicle.h | 8 | ||||
-rw-r--r-- | vehicle_gui.c | 4 |
24 files changed, 22 insertions, 83 deletions
diff --git a/lang/brazilian_portuguese.txt b/lang/brazilian_portuguese.txt index aa0d8f641..aaedaf9e1 100644 --- a/lang/brazilian_portuguese.txt +++ b/lang/brazilian_portuguese.txt @@ -2759,7 +2759,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Seleccio STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Exibe o tipo de motor que substituirá o que está seleccionado à esquerda, se algum STR_REPLACE_HELP :{BLACK}Permite a substiuição de um tipo de motor por outro, quando comboios do tipo original entram num depósito STR_REPLACE_REMOVE_WAGON :{BLACK}Remoção de vagões: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Ativar essa opção fará com que a auto-reposição remova vagões dos trens, para que eles tenham o comprimento da menor estação em sua rota{}Ela removerá quantos vagões forem necessários, começando pelo da frente STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Lista de sinais - {COMMA} Sinais diff --git a/lang/catalan.txt b/lang/catalan.txt index 2bc66d86c..6d715da0f 100644 --- a/lang/catalan.txt +++ b/lang/catalan.txt @@ -2757,7 +2757,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Tria el STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Mosyta quin motor dels seleccionats a l'esquerra es reemplaça, si hi ha STR_REPLACE_HELP :{BLACK}Et permet reemplaçar un tipus de motor amb un altre, quan els trens del tipus original entrin a cotxeres STR_REPLACE_REMOVE_WAGON :{BLACK}Treure vagons: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Establint aixó a "On" farà que l'automodificació tregui vagons dels trens per evitar que excedeixi la seva llargària de la de l'estació més curta que es trobi a les seves ordres.{}Es treuràn tants vagons com es necessiti començant per davant STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Llista de senyals - {COMMA} Senyals diff --git a/lang/czech.txt b/lang/czech.txt index a5ce40faa..b4a1ea964 100644 --- a/lang/czech.txt +++ b/lang/czech.txt @@ -2812,7 +2812,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Vyber ty STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Tady je zobrazeno, za jakou lokomotivu se ta v levém seznamu vymenuje STR_REPLACE_HELP :{BLACK}Tato mo¸nost hry ti umoznuje vybrat typ lokomotivy, který nechá vymenit za jiný. To se bude automaticky provadet, kdy¸ lokomotiva zajede do depa. STR_REPLACE_REMOVE_WAGON :{BLACK}Odebírání vagonu: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Nastavením na "zapnuto" zacne funkce automatického vymenovani odstranovat vagony z vlaku, kdyby se neve¨ly do nejkrat¨í stanice ve svém jízdním radu.{}Bude od zacatku vlaku odstranovat tolik vagonu, kolik potrebuje. STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Seznam popisku - {COMMA} popis{P ek ky ku} diff --git a/lang/danish.txt b/lang/danish.txt index d36f87d3d..82e0ae433 100644 --- a/lang/danish.txt +++ b/lang/danish.txt @@ -2753,7 +2753,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Vælg den STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Viser hvilket køretøj at det valgte køretøj til venstre bliver udskiftet med, hvis det bliver udskiftet STR_REPLACE_HELP :{BLACK}Dette giver dig mulighed for at udskifte en køretøjstype med en anden, når et køretøj af den oprindelige type kører i depot STR_REPLACE_REMOVE_WAGON :{BLACK}Fjern vogn: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Ved at sætte dette til "Til" vil få autoreplace til at fjerne vogne fra tog for at få dem til at beholde deres længde hvis de overskrider længden af den korteste station i deres ordre{}Det vil fjerne så mange vogne som der er behov for, startende med de forreste STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Liste of skilte - {COMMA} Skilte diff --git a/lang/dutch.txt b/lang/dutch.txt index 76d53799a..ab527383f 100644 --- a/lang/dutch.txt +++ b/lang/dutch.txt @@ -2756,7 +2756,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Selectee STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Dit geeft weer waarmee de aan de linkerkant geselecteerde locomotief mee vervangen wordt STR_REPLACE_HELP :{BLACK}Deze optie stelt je in staat om een type locomotief te selecteren en die te vervangen door een andere. Dit zal automatisch gebeuren zodra de voertuigen een depot inrijden STR_REPLACE_REMOVE_WAGON :{BLACK}Wagons verwijderen: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Deze optie "Aan" zetten zorgt ervoor dat de autoreplace functie wagons van je trein afhaalt zodat ze in je korste station passen in hun orders lijst,{}waarbij wordt begonnen bij de eerste wagons STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Bordjes lijst - {COMMA} Bordjes diff --git a/lang/english.txt b/lang/english.txt index 682f22d3b..9691ffd6b 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -2759,7 +2759,7 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Choose t STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Displays which engine the left selected engine is being replaced with, if any STR_REPLACE_HELP :{BLACK}This allows you to replace one engine type with another type, when trains of the original type enter a depot STR_REPLACE_REMOVE_WAGON :{BLACK}Wagon removal: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Setting this to "On" will make autoreplace remove wagons from trains to make them keep their length if they exceed length of the shortest station in their orders.{}It will remove as many wagons as needed starting from the front +STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Make autoreplace keep the length of a train the same by removing wagons (starting at the front), if replacing the engine would make the train longer. STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Sign List - {COMMA} Sign{P "" s} diff --git a/lang/french.txt b/lang/french.txt index c9fd7982a..6e1987600 100644 --- a/lang/french.txt +++ b/lang/french.txt @@ -2760,7 +2760,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Choisir STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Ceci affiche par quelle locomotive celle qui est sélectionnée à gauche sera remplacée STR_REPLACE_HELP :{BLACK}Cette caractéristique permet de choisir un type de locomotive et de le remplacer par un autre. Ceci sera fait automatiquement quand le véhicule rentre dans un dépôt STR_REPLACE_REMOVE_WAGON :{BLACK}Retrait de wagon: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Activer ce paramètre permettra à l'autoremplacement de retirer des wagons d'un trains, ajustant ainsi sa longueur sur la plus courte station cédulée, advenant le cas d'une longueur excédentaire.{}Autant de wagons que requis seront retirés du train, en commencant par celui de tête. STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Liste des panneaux - {COMMA} panneau{P "" x} diff --git a/lang/german.txt b/lang/german.txt index e84b90fa6..85ef69170 100644 --- a/lang/german.txt +++ b/lang/german.txt @@ -2760,7 +2760,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Wähle ei STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Hier wird angezeigt, gegen welches Fahrzeug das auf der linken Seite gewählte ersetzt wird STR_REPLACE_HELP :{BLACK}Dieses Feature ermöglicht es, einen Fahrzeugtyp auszuwählen und ihn durch einen anderen ersetzen zu lassen. Dies geschieht automatisch, wenn das Fahrzeug regulär das Depot besucht. STR_REPLACE_REMOVE_WAGON :{BLACK}Waggon-Entfernung: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Diesen Schalter auf "An" schalten bewirkt das Entfernen von Waggons aus dem Zug, damit er nie länger wird als der kürzeste Bahnsteig im Fahrplan.{}Die Waggons werden am Anfang des Zuges entfernt, bis die Länge ausreichend ist. STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Schilderliste - {COMMA} Schild{P "" er} diff --git a/lang/italian.txt b/lang/italian.txt index f63fa5103..23dc38ab1 100644 --- a/lang/italian.txt +++ b/lang/italian.txt @@ -2758,7 +2758,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Selezion STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Mostra con quale locomotore verrà rimpiazzato il tipo selezionato a sinistra, se alcuno STR_REPLACE_HELP :{BLACK}Permette di rimpiazzare un locomotere con uno di un'altro tipo, quando il treno entra in un deposito STR_REPLACE_REMOVE_WAGON :{BLACK}Rimuovi vagoni: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Impostando "SI", quando viene eseguita la sostituzione automatica dei treni verranno rimossi i vagoni fino a raggiungere la lunghezza necessaria al treno per entrare nella stazione più corta presente nella lista ordini. I vagoni verranno rimossi partendo dalla testa del treno. STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Lista dei Cartelli - {COMMA} Cartelli diff --git a/lang/norwegian.txt b/lang/norwegian.txt index 5eb0bd25a..1e9ac4f8e 100644 --- a/lang/norwegian.txt +++ b/lang/norwegian.txt @@ -2754,7 +2754,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Velg jer STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Dette viser hvilket lokomotiv som overtar for det valgte lokomotivet på venstresiden STR_REPLACE_HELP :{BLACK}Dette verktøyet lar deg bytte ut en type lokomotiv med en annen. Dette blir gjort neste gang lokomotivet er innom et depot. STR_REPLACE_REMOVE_WAGON :{BLACK}Vognfjerning: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Ved å sette denne til "På" gjør du slik at auto-erstatt fjerner vogner fra tog slik at de beholder lengden hvis det er lenger enn den korteste stasjonen på ruten sin.{}Det vil fjerne så mange stasjoner som nødvending, og starter fra fronten jobber seg bakover STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Skiltliste - {COMMA} Skilt diff --git a/lang/polish.txt b/lang/polish.txt index 94a398bbd..c0b190dce 100644 --- a/lang/polish.txt +++ b/lang/polish.txt @@ -2759,7 +2759,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Wybierz STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Wyswietla typ pojazdu na jaki bedzie zastapiony pojazd zaznaczony po lewej stronie STR_REPLACE_HELP :{BLACK}Ta funkcja pozwala wybrac typ pojazdu i zastapic go innym. Bedzie sie to odbywac w momencie gdy pociag zjedzie do zajezdni STR_REPLACE_REMOVE_WAGON :{BLACK}Usuniecie pojazdu: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Ustawienie na "Wla" spowoduje ze tryb autowymiany usunie wagony z pociagu by utrzymac jego dlugosc jaka jest potrzebna do najkrotszej stacji w swoim rozkladzie.{}Usuniete beda wagony poczawszy od poczatku pociagu STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Lista tablic - {COMMA} Tablice diff --git a/lang/portuguese.txt b/lang/portuguese.txt index 11ef2e270..bf4a0cfce 100644 --- a/lang/portuguese.txt +++ b/lang/portuguese.txt @@ -2759,7 +2759,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Seleccio STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Exibe o tipo de motor que substituirá o que está seleccionado à esquerda, se algum STR_REPLACE_HELP :{BLACK}Permite a substiuição de um tipo de motor por outro, quando comboios do tipo original entram num depósito STR_REPLACE_REMOVE_WAGON :{BLACK}Remover vagões: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Ligar esta opção fará com que a funcionalidade de substituição automática remova vagões aos comboios, obrigando-os a manter o seu comprimento igual ao da menor estação presente nas ordens.{}Serão removidos tantos vagões quantos necessários, a começar pela frente. STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Lista de sinais - {COMMA} Sinais diff --git a/lang/romanian.txt b/lang/romanian.txt index a587b8c15..73a75df2e 100644 --- a/lang/romanian.txt +++ b/lang/romanian.txt @@ -2756,7 +2756,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Alege un STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Afiseaza cu ce model vor fi inlocuite vehiculele din stanga STR_REPLACE_HELP :{BLACK}Aceasta functie iti permite sa selectezi un model de vehicul si sa-l inlocuiesti cu altul. Schimbarea se va efectua automat la intrarea vehiculului intr-un depou. STR_REPLACE_REMOVE_WAGON :{BLACK}Retragere vagoane: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Prin comutarea acestui buton autoinlocuirea va sterge vagoane din componenta unui tren pentru a nu depasi marimea celei mai mici statii de pe traseu.{}Vor fi sterse toate vagoanele necesare incepand de la locomotiva STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Lista de semne - {COMMA} Semne diff --git a/lang/slovak.txt b/lang/slovak.txt index 2872516b6..55eb4db67 100644 --- a/lang/slovak.txt +++ b/lang/slovak.txt @@ -2758,7 +2758,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Vyber ty STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Tu sa zobrazuje, za ktoru lokomotiva sa lokomotiva v lavom zozname zamenuje STR_REPLACE_HELP :{BLACK}Umoznuje vybrat typ lokomotivy, ktory automaticky sa zameni za iny typ, ak vlaky s takouto lokomotivou sa zastavia v depe STR_REPLACE_REMOVE_WAGON :{BLACK}Odstranenie vagonu: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Pri nastaveni na "On" odstani vagony z vlakov, aby sa vosli do najkratsej stanice zo stanic v jeho prikazoch.{}Odstrani to pozadovany pocet vagonov, pocinajuc prvym STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Zoznam popisov - {COMMA} popisov diff --git a/lang/spanish.txt b/lang/spanish.txt index d14f49aa7..555c78253 100644 --- a/lang/spanish.txt +++ b/lang/spanish.txt @@ -2756,7 +2756,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Seleccio STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Muestra que locomotora será reemplazada STR_REPLACE_HELP :{BLACK}Esta función permite seleccionar un tipo de locomotora y reemplazarla por otra. El cambio se realizará cuando el vehículo llegue al depósito STR_REPLACE_REMOVE_WAGON :{BLACK}Quitar vagón: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Activar esta opción permite eliminar los vagones necesarios para que los trenes entren en las estaciones más cortas que estén marcadas en sus ordenes. Se eliminarán los vagones necesarios empezando por delante STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Lista de señales - {COMMA} Señales diff --git a/lang/turkish.txt b/lang/turkish.txt index ca0afccd6..ca0f969e8 100644 --- a/lang/turkish.txt +++ b/lang/turkish.txt @@ -2759,7 +2759,6 @@ STR_REPLACE_HELP_RAILTYPE :{BLACK}Lokomati STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Soldaki degistiriliyorsa neyle degistirildigini göster STR_REPLACE_HELP :{BLACK}Tren gara girdiginde seçilen türle degistirilir STR_REPLACE_REMOVE_WAGON :{BLACK}Vagon kaldirma: {ORANGE}{SKIP}{STRING} -STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Bu ayari "açik" yaparsaniz araçlari degistirme isleminde eger trenin talimatlarindaki duraklardan birine sigmayacak kadar uzuyorsa tren uzunlugu korunacaktir.{}Fazla vagonlar önden baslayarak satilacaktir STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_SIGN_LIST_CAPTION :{WHITE}Tabela Listesi - {COMMA} Tabela @@ -1263,21 +1263,13 @@ bool AfterLoadGame(uint version) } } - /* In version 16.1 of the savegame, trains became aware of station lengths - need to initialized to the invalid state - players needs to set renew_keep_length too */ + /* In version 16.1 of the savegame a player can decide if trains, which get + * replaced, shall keep their old length. In all prior versions, just default + * to false */ if (CheckSavegameVersionOldStyle(16, 1)) { - Vehicle *v; FOR_ALL_PLAYERS(p) { p->renew_keep_length = false; } - - FOR_ALL_VEHICLES(v) { - if (v->type == VEH_Train) { - v->u.rail.shortest_platform[0] = 255; - v->u.rail.shortest_platform[1] = 0; - } - } } /* In version 17, ground type is moved from m2 to m4 for depots and diff --git a/order_cmd.c b/order_cmd.c index 64c7878e0..43595e508 100644 --- a/order_cmd.c +++ b/order_cmd.c @@ -386,7 +386,6 @@ int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) } /* Update any possible open window of the vehicle */ InvalidateVehicleOrder(u); - if (u->type == VEH_Train) u->u.rail.shortest_platform[1] = 0; // we changed the orders so we invalidate the station length collector u = u->next_shared; } @@ -517,7 +516,6 @@ int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (v->current_order.type == OT_LOADING && HASBIT(v->current_order.flags, OFB_NON_STOP)) v->current_order.flags = 0; - if (v->type == VEH_Train) v->u.rail.shortest_platform[1] = 0; // we changed the orders so we invalidate the station length collector InvalidateVehicleOrder(v); } @@ -660,7 +658,6 @@ int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) InvalidateVehicleOrder(src); RebuildVehicleLists(); - if (dst->type == VEH_Train) dst->u.rail.shortest_platform[1] = 0; // we changed the orders so we invalidate the station length collector } } break; @@ -720,7 +717,6 @@ int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) InvalidateVehicleOrder(dst); RebuildVehicleLists(); - if (dst->type == VEH_Train) dst->u.rail.shortest_platform[1] = 0; // we changed the orders so we invalidate the station length collector } } break; @@ -248,11 +248,6 @@ static inline bool IsBuoyTile(TileIndex tile) return IsTileType(tile, MP_STATION) && _m[tile].m5 == 0x52; } -static inline bool TileBelongsToRailStation(const Station *st, TileIndex tile) -{ - return IsTileType(tile, MP_STATION) && _m[tile].m2 == st->index && _m[tile].m5 < 8; -} - /* Get's the direction the station exit points towards. Ie, returns 0 for a * station with the exit NE. */ static inline byte GetRoadStationDir(TileIndex tile) diff --git a/station_cmd.c b/station_cmd.c index 4eecdeff0..dcd8e961a 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -1065,6 +1065,11 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2) return cost; } +static bool TileBelongsToRailStation(const Station *st, TileIndex tile) +{ + return IsTileType(tile, MP_STATION) && _m[tile].m2 == st->index && _m[tile].m5 < 8; +} + static void MakeRailwayStationAreaSmaller(Station *st) { uint w = st->trainst_w; diff --git a/train_cmd.c b/train_cmd.c index f75dff5d7..dd7f19735 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -755,9 +755,6 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) SetFrontEngine(v); SetTrainEngine(v); - v->u.rail.shortest_platform[0] = 255; - v->u.rail.shortest_platform[1] = 0; - VehiclePositionChanged(v); if (rvi->flags & RVI_MULTIHEAD) { @@ -2427,27 +2424,6 @@ static bool ProcessTrainOrder(Vehicle *v) v->dest_tile = 0; - // store the station length if no shorter station was visited this order round - if (v->cur_order_index == 0) { - if (v->u.rail.shortest_platform[1] != 0 && v->u.rail.shortest_platform[1] != 255) { - // we went though a whole round of orders without interruptions, so we store the length of the shortest station - v->u.rail.shortest_platform[0] = v->u.rail.shortest_platform[1]; - } - // all platforms are shorter than 255, so now we can find the shortest in the next order round. They might have changed size - v->u.rail.shortest_platform[1] = 255; - } - - if (v->last_station_visited != INVALID_STATION) { - Station *st = GetStation(v->last_station_visited); - if (TileBelongsToRailStation(st, v->tile)) { - byte length = GetStationPlatforms(st, v->tile); - - if (length < v->u.rail.shortest_platform[1]) { - v->u.rail.shortest_platform[1] = length; - } - } - } - result = false; switch (order->type) { case OT_GOTO_STATION: @@ -1656,8 +1656,6 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags) if (GetNextVehicle(old_v) != NULL) { DoCommand(0, 0, (new_v->index << 16) | GetNextVehicle(old_v)->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); } - new_v->u.rail.shortest_platform[0] = old_v->u.rail.shortest_platform[0]; - new_v->u.rail.shortest_platform[1] = old_v->u.rail.shortest_platform[1]; } } /* We are done setting up the new vehicle. Now we move the cargo from the old one to the new one */ @@ -1701,7 +1699,10 @@ static void MaybeReplaceVehicle(Vehicle *v) byte flags = 0; int32 cost, temp_cost = 0; bool stopped = false; - bool train_fits_in_station = false; + + /* Remember the length in case we need to trim train later on + * If it's not a train, the value is unused */ + uint16 old_total_length = (v->type == VEH_Train) ? v->u.rail.cached_total_length : -1; _current_player = v->owner; @@ -1715,11 +1716,6 @@ static void MaybeReplaceVehicle(Vehicle *v) stopped = true; } - if (v->type == VEH_Train && v->u.rail.shortest_platform[0]*16 <= v->u.rail.cached_total_length && GetPlayer(v->owner)->renew_keep_length) { - // the train is not too long for the stations it visits. We should try to keep it that way if we change anything - train_fits_in_station = true; - } - for (;;) { cost = 0; w = v; @@ -1781,11 +1777,12 @@ static void MaybeReplaceVehicle(Vehicle *v) flags |= DC_EXEC; } - if (train_fits_in_station) { - // the train fitted in the stations it got in it's orders, so we should make sure that it still do + /* If setting is on to try not to exceed the old length of the train with the replacement */ + if (v->type == VEH_Train && p->renew_keep_length) { Vehicle *temp; w = v; - while (v->u.rail.shortest_platform[0]*16 < v->u.rail.cached_total_length) { + + while (v->u.rail.cached_total_length > old_total_length) { // the train is too long. We will remove cars one by one from the start of the train until it's short enough while (w != NULL && !(RailVehInfo(w->engine_type)->flags&RVI_WAGON) ) { w = GetNextVehicle(w); @@ -2094,8 +2091,9 @@ static const SaveLoad _train_desc[] = { SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleRail,pbs_status), SLE_UINT8, 2, 255), SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleRail,pbs_end_tile), SLE_UINT32, 2, 255), SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleRail,pbs_end_trackdir), SLE_UINT8, 2, 255), - SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleRail,shortest_platform[0]), SLE_UINT8, 2, 255), // added with 16.1, but was blank since 2 - SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleRail,shortest_platform[1]), SLE_UINT8, 2, 255), // added with 16.1, but was blank since 2 + + SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL, 2, 2, 255), + SLE_CONDREFX(offsetof(Vehicle,u)+offsetof(VehicleRail,other_multiheaded_part), REF_VEHICLE, 2, 255), // added with 17.1, but was blank since 2 // reserve extra space in savegame here. (currently 3 bytes) SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 3, 2, 255), @@ -78,14 +78,6 @@ typedef struct VehicleRail { TileIndex pbs_end_tile; Trackdir pbs_end_trackdir; - /** - * stuff to figure out how long a train should be. Used by autoreplace - * first byte holds the length of the shortest station. Updated each time order 0 is reached - * last byte is the shortest station reached this round though the orders. It can be invalidated by - * skip station and alike by setting it to 0. That way we will ensure that a complete loop is used to find the shortest station - */ - byte shortest_platform[2]; - // Link between the two ends of a multiheaded engine Vehicle *other_multiheaded_part; } VehicleRail; diff --git a/vehicle_gui.c b/vehicle_gui.c index fbfd7d698..c8e184c13 100644 --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -747,10 +747,10 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e) STR_019E_SHIP, STR_019D_AIRCRAFT }; - const Player *p = GetPlayer(_local_player); switch (e->event) { case WE_PAINT: { + const Player *p = GetPlayer(_local_player); int pos = w->vscroll.pos; EngineID selected_id[2] = { INVALID_ENGINE, INVALID_ENGINE }; int x = 1; @@ -934,7 +934,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e) break; } case 17: { /* toggle renew_keep_length */ - DoCommandP(0, 5, p->renew_keep_length ? 0 : 1, NULL, CMD_REPLACE_VEHICLE); + DoCommandP(0, 5, GetPlayer(_local_player)->renew_keep_length ? 0 : 1, NULL, CMD_REPLACE_VEHICLE); } break; case 4: { /* Start replacing */ EngineID veh_from = WP(w, replaceveh_d).sel_engine[0]; |