The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: ceeac on September 05, 2020, 01:46:05 PM

Title: Citycar speed increases every time the map is saved
Post by: ceeac on September 05, 2020, 01:46:05 PM
At the end of private_car_t::rdwr (line 462) there is this piece of code:

// do not start with zero speed!
current_speed ++;

This increases the speed of all private cars, even when saving the game while paused. It is therefore possible to make private cars "teleport" to the beginning of the next tile by pausing the game, saving it a large number of times, then un-pausing again :)

Is the code actually required? If yes, the code should probably be changed to something like this:

if (file->is_loading()) {
current_speed = max(current_speed, 1);
}


Fixing this bug will also make sure that save files are byte-equal when saving the game twice in a row while paused (That is how I found the bug in the first place.)
Title: Re: Citycar speed increases every time the map is saved
Post by: Dwachs on September 05, 2020, 05:07:58 PM
Funny! These particular lines are at least 14 years old.

I think these two lines can be deleted. If speed is zero, it will be corrected in sync_step.
Title: Re: Citycar speed increases every time the map is saved
Post by: prissi on September 27, 2020, 01:06:11 PM
Lines deleted in r9258