FS#4044 - autoreplace doesn't work when at the vehicle limit

Attached to Project: OpenTTD
Opened by Zdeněk Sojka (SmatZ) - Tuesday, 17 August 2010, 22:40 GMT
Last edited by Remko Bijker (Rubidium) - Friday, 20 August 2010, 17:35 GMT
Type Bug
Category Vehicles → Autoreplace
Status Closed
Assigned To No-one
Operating System All
Severity High
Priority Normal
Reported Version 1.0.3
Due in Version 1.0.4
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


It's not possible to autoreplace train in this savegame. this savegame causes crash when train 237 enters depot and wagon removal is enabled

openttd: /home/smatz/openttd/rev/src/autoreplace_cmd.cpp:692: CommandCost CmdAutoreplaceVehicle(TileIndex, DoCommandFlag, uint32, uint32, const char*): Assertion `ret.Succeeded() && ret.GetCost() == cost.GetCost()' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff4da4165 in raise () from /lib/
(gdb) bt
#0 0x00007ffff4da4165 in raise () from /lib/
#1 0x00007ffff4da5580 in abort () from /lib/
#2 0x00007ffff4d9d201 in __assert_fail () from /lib/
#3 0x00000000005100d0 in CmdAutoreplaceVehicle (tile=<value optimized out>, flags=DC_EXEC, p1=<value optimized out>, p2=<value optimized out>, text=<value optimized out>) at /home/smatz/openttd/rev/src/autoreplace_cmd.cpp:692
#4 0x000000000052cc73 in DoCommand (tile=0, p1=5041, p2=0, flags=DC_EXEC, cmd=<value optimized out>, text=0x0) at /home/smatz/openttd/rev/src/command.cpp:446
#5 0x0000000000761c5c in CallVehicleTicks () at /home/smatz/openttd/rev/src/vehicle.cpp:816
This task depends upon

Closed by  Remko Bijker (Rubidium)
Friday, 20 August 2010, 17:35 GMT
Reason for closing:  Fixed
Additional comments about closing:  In r20582
Comment by Zdeněk Sojka (SmatZ) - Tuesday, 17 August 2010, 22:44 GMT
The crash happens in 1.0 as well, but the not being able to autoreplace problem doesn't happen in 1.0 (it seems). Those problems might be unrelated.
Comment by Zdeněk Sojka (SmatZ) - Tuesday, 17 August 2010, 22:57 GMT
Press the Autoreplace button to crash. "Works" in both 1.0 and trunk.
Comment by Zdeněk Sojka (SmatZ) - Wednesday, 18 August 2010, 08:11 GMT
Actually it is a server killer, but only when built with asserts enabled (which doesn't happen in release builds). It crashes when max_trains==1 as well, so it is easily triggerable.