News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Fix for wrong insertion order during loading

Started by ceeac, October 04, 2020, 10:13:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ceeac

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.)

prissi

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