# HG changeset patch # User signde # Date 1095149595 0 # Node ID f4894a2cdfe8931b3b1940a2f74afa9aeff25038 # Parent e6e62a5e7f521373b024c95f87a14d572608a1e3 (svn r243) -Fix: [1022689] When destroying a part of a train with a 2 side engine the second engine was also deleted [Celestar] diff -r e6e62a5e7f52 -r f4894a2cdfe8 train_cmd.c --- a/train_cmd.c Tue Sep 14 01:21:07 2004 +0000 +++ b/train_cmd.c Tue Sep 14 08:13:15 2004 +0000 @@ -773,7 +773,17 @@ first = v; if (first->subtype != 0) { first = GetFirstVehicleInChain(first); - last = NULL; + last = GetLastVehicleInChain(first); + //now if: + // 1) we delete a whole a chain, and + // 2) the first and the last vehicle of that train are of the same type, and + // 3) the first and the last vehicle of the chain are not identical, and + // 4) and of "engine" type (i.e. not a carriage) + // then let the last vehicle live + if ( (p2 == 1) && ( last->engine_type == first->engine_type ) && (last != first) && (first->subtype == 0) ) + last = GetPrevVehicleInChain(last); + else + last = NULL; } else { if (p2 != 1) { // sell last part of multiheaded? @@ -825,7 +835,7 @@ tmp = v; v = v->next; DeleteVehicle(tmp); - if (v == NULL || p2 != 1) break; + if (v == last || p2 != 1) break; } // delete last vehicle of multiheaded train? @@ -844,7 +854,7 @@ cost = 0; for(;;) { cost -= v->value; - if ((v=v->next) == NULL || p2 != 1) break; + if ((v=v->next) == last || p2 != 1) break; } if (last) cost -= last->value; }