The International Simutrans Forum

 

Author Topic: Citycar speed increases every time the map is saved  (Read 344 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 247
Citycar speed increases every time the map is saved
« on: September 05, 2020, 01:46:05 PM »
At the end of private_car_t::rdwr (line 462) there is this piece of code:
Code: [Select]
// 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:
Code: [Select]
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.)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4869
  • Languages: EN, DE, AT
Re: Citycar speed increases every time the map is saved
« Reply #1 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Re: Citycar speed increases every time the map is saved
« Reply #2 on: September 27, 2020, 01:06:11 PM »
Lines deleted in r9258