The International Simutrans Forum

 

Author Topic: Fix for wrong insertion order during loading  (Read 288 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 269
Fix for wrong insertion order during loading
« on: October 04, 2020, 10:13:58 AM »
This patch fixes 2 small bugs during loading:
  • When loading freight for a vehicle, the freight needs to be appended to the freight list instead of prepended, since freight is saved from front to back.
  • When loading objects in objlist_t::rdwr, the objects need to be appended to the objlist since we already save them in the correct order. (objlist_t::add does not obey this requirement.)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10829
  • Languages: De,EN,JP
Re: Fix for wrong insertion order during loading
« Reply #1 on: October 04, 2020, 11:56:44 AM »
objlist::add makes sure the objects are in the right order even when loading ancient savegames. However, one can save quite some time by just appending them, that is true.

The thing with freight was done to save time because appending to a list takes much longer than inserting. For that reason, stations (where order is more critical) are vector since a long time. I agree that vehicels should keep the order. In the worst case of a big ships this are 900 packets, which is a lot but not very much of a slowdown, since typical even a900 passenger ship has less than 100 packets.

One could also thing of making them a vector, especially considering the overhead of 64 pointer per ware and the better caching when going through them. On the other hand, most convoi vehicles have 1-5 packets in them.

So I incorporated this in r9270